Fix incorrectly rendered icons in modeline #773

And possibly fix bytecomp warnings about unused lexical variables.
This commit is contained in:
Henrik Lissner 2018-07-30 23:00:35 +02:00
parent c2d5b64790
commit 1211c2c7f7
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -1,7 +1,5 @@
;;; ui/doom-modeline/config.el -*- lexical-binding: t; -*- ;;; ui/doom-modeline/config.el -*- lexical-binding: t; -*-
;; ;;
;; Modeline library ;; Modeline library
;; ;;
@ -36,7 +34,7 @@
(push seg forms)) (push seg forms))
((symbolp seg) ((symbolp seg)
(cond ((setq it (cdr (assq seg doom--modeline-fn-alist))) (cond ((setq it (cdr (assq seg doom--modeline-fn-alist)))
(push (list :eval (list it)) forms)) (push (list it) forms))
((setq it (cdr (assq seg doom--modeline-var-alist))) ((setq it (cdr (assq seg doom--modeline-var-alist)))
(push it forms)) (push it forms))
((error "%s is not a defined segment" seg)))) ((error "%s is not a defined segment" seg))))
@ -58,20 +56,21 @@ Example:
(rhs-forms (doom--prepare-modeline-segments rhs))) (rhs-forms (doom--prepare-modeline-segments rhs)))
(defalias sym (defalias sym
(lambda () (lambda ()
(let ((rhs-str (format-mode-line rhs-forms))) (let ((lhs (eval `(list ,@lhs-forms) t))
(list lhs-forms (rhs (eval `(list ,@rhs-forms) t)))
(let ((rhs-str (format-mode-line rhs)))
(list lhs
(propertize (propertize
" " 'display " " 'display
`((space :align-to (- (+ right right-fringe right-margin) `((space :align-to (- (+ right right-fringe right-margin)
,(+ 1 (string-width rhs-str)))))) ,(+ 1 (string-width rhs-str))))))
rhs-str))) rhs-str))))
(concat "Modeline:\n" (concat "Modeline:\n"
(format " %s\n %s" (format " %s\n %s"
(prin1-to-string lhs) (prin1-to-string lhs)
(prin1-to-string rhs)))) (prin1-to-string rhs))))
(unless (bound-and-true-p byte-compile-current-file)
(let (byte-compile-warnings) (let (byte-compile-warnings)
(byte-compile sym))))) (byte-compile sym))))
(defun doom-modeline (key) (defun doom-modeline (key)
"Returns a mode-line configuration associated with KEY (a symbol). Throws an "Returns a mode-line configuration associated with KEY (a symbol). Throws an
@ -265,7 +264,7 @@ file-name => comint.el")
;; Modeline helpers ;; Modeline helpers
;; ;;
(defsubst active () (defun active ()
(eq (selected-window) +doom-modeline-current-window)) (eq (selected-window) +doom-modeline-current-window))
(defun +doom-modeline--make-xpm (face width height) (defun +doom-modeline--make-xpm (face width height)