mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-23 19:19:50 +00:00
Optimize loading performance of mode-line.
This commit is contained in:
parent
1adcc1f9a9
commit
079762c85b
1 changed files with 36 additions and 41 deletions
|
@ -96,8 +96,6 @@ Given ~/Projects/FOSS/emacs/lisp/comint.el
|
||||||
(defvar anzu--state)
|
(defvar anzu--state)
|
||||||
(defvar anzu--total-matched)
|
(defvar anzu--total-matched)
|
||||||
(defvar anzu-cons-mode-line-p)
|
(defvar anzu-cons-mode-line-p)
|
||||||
(defvar anzu-minimum-input-length)
|
|
||||||
(defvar anzu-search-threshold)
|
|
||||||
(defvar evil-ex-active-highlights-alist)
|
(defvar evil-ex-active-highlights-alist)
|
||||||
(defvar evil-ex-argument)
|
(defvar evil-ex-argument)
|
||||||
(defvar evil-ex-range)
|
(defvar evil-ex-range)
|
||||||
|
@ -235,39 +233,36 @@ active.")
|
||||||
((error "%s is not a valid segment" seg))))
|
((error "%s is not a valid segment" seg))))
|
||||||
(nreverse forms)))
|
(nreverse forms)))
|
||||||
|
|
||||||
(defmacro doom-modeline-def-modeline (name lhs &optional rhs)
|
(defun doom-modeline-def-modeline (name lhs &optional rhs)
|
||||||
"Defines a modeline format and byte-compiles it.
|
"Defines a modeline format and byte-compiles it.
|
||||||
|
|
||||||
NAME is a symbol to identify it (used by `doom-modeline' for retrieval).
|
NAME is a symbol to identify it (used by `doom-modeline' for retrieval).
|
||||||
LHS and RHS are lists of symbols of modeline segments defined with
|
LHS and RHS are lists of symbols of modeline segments defined with
|
||||||
`doom-modeline-def-segment'.
|
`doom-modeline-def-segment'.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
(doom-modeline-def-modeline minimal
|
(doom-modeline-def-modeline 'minimal
|
||||||
(bar matches \" \" buffer-info)
|
'(bar matches \" \" buffer-info)
|
||||||
(media-info major-mode))
|
'(media-info major-mode))
|
||||||
(doom-modeline-set-modeline 'minimal t)"
|
(doom-modeline-set-modeline 'minimal t)"
|
||||||
(let ((sym (intern (format "doom-modeline-format--%s" name)))
|
(let ((sym (intern (format "doom-modeline-format--%s" name)))
|
||||||
(lhs-forms (doom-modeline--prepare-segments lhs))
|
(lhs-forms (doom-modeline--prepare-segments lhs))
|
||||||
(rhs-forms (doom-modeline--prepare-segments rhs)))
|
(rhs-forms (doom-modeline--prepare-segments rhs)))
|
||||||
`(progn
|
(defalias sym
|
||||||
(fset ',sym
|
(lambda ()
|
||||||
(lambda ()
|
(let ((lhs (eval `(list ,@lhs-forms) t))
|
||||||
,(concat "Modeline:\n"
|
(rhs (eval `(list ,@rhs-forms) t)))
|
||||||
(format " %s\n %s"
|
(let ((rhs-str (format-mode-line rhs)))
|
||||||
(prin1-to-string lhs)
|
(list lhs
|
||||||
(prin1-to-string rhs)))
|
(propertize
|
||||||
(let ((lhs (list ,@lhs-forms))
|
" " 'display
|
||||||
(rhs (list ,@rhs-forms)))
|
`((space :align-to (- (+ right right-fringe right-margin)
|
||||||
(let ((rhs-str (format-mode-line rhs)))
|
,(+ 1 (string-width rhs-str))))))
|
||||||
(list lhs
|
rhs-str))))
|
||||||
(propertize
|
(concat "Modeline:\n"
|
||||||
" " 'display
|
(format " %s\n %s"
|
||||||
`((space :align-to (- (+ right right-fringe right-margin)
|
(prin1-to-string lhs)
|
||||||
,(+ 1 (string-width rhs-str))))))
|
(prin1-to-string rhs))))))
|
||||||
rhs-str)))))
|
|
||||||
,(unless (bound-and-true-p byte-compile-current-file)
|
|
||||||
`(let (byte-compile-warnings)
|
|
||||||
(byte-compile #',sym))))))
|
|
||||||
|
|
||||||
(defun doom-modeline (key)
|
(defun doom-modeline (key)
|
||||||
"Return a mode-line configuration associated with KEY (a symbol).
|
"Return a mode-line configuration associated with KEY (a symbol).
|
||||||
|
@ -408,7 +403,7 @@ If STRICT-P, return nil if no project was found, otherwise return
|
||||||
(when (display-graphic-p)
|
(when (display-graphic-p)
|
||||||
(apply 'all-the-icons-material args)))
|
(apply 'all-the-icons-material args)))
|
||||||
|
|
||||||
(defsubst doom-modeline--active ()
|
(defun doom-modeline--active ()
|
||||||
"Whether is an active window."
|
"Whether is an active window."
|
||||||
(eq (selected-window) doom-modeline-current-window))
|
(eq (selected-window) doom-modeline-current-window))
|
||||||
|
|
||||||
|
@ -1021,25 +1016,25 @@ See `mode-line-percent-position'.")
|
||||||
;; Mode lines
|
;; Mode lines
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(doom-modeline-def-modeline main
|
(doom-modeline-def-modeline 'main
|
||||||
(workspace-number window-number bar evil-state matches " " buffer-info buffer-position " " selection-info)
|
' (workspace-number window-number bar evil-state matches " " buffer-info buffer-position " " selection-info)
|
||||||
(global buffer-encoding major-mode process vcs flycheck))
|
'(global buffer-encoding major-mode process vcs flycheck))
|
||||||
|
|
||||||
(doom-modeline-def-modeline minimal
|
(doom-modeline-def-modeline 'minimal
|
||||||
(bar matches " " buffer-info)
|
'(bar matches " " buffer-info)
|
||||||
(media-info major-mode))
|
'(media-info major-mode))
|
||||||
|
|
||||||
(doom-modeline-def-modeline special
|
(doom-modeline-def-modeline 'special
|
||||||
(window-number bar evil-state matches " " buffer-info-simple buffer-position " " selection-info)
|
'(window-number bar evil-state matches " " buffer-info-simple buffer-position " " selection-info)
|
||||||
(global buffer-encoding major-mode process flycheck))
|
'(global buffer-encoding major-mode process flycheck))
|
||||||
|
|
||||||
(doom-modeline-def-modeline project
|
(doom-modeline-def-modeline 'project
|
||||||
(window-number bar buffer-default-directory)
|
'(window-number bar buffer-default-directory)
|
||||||
(global major-mode))
|
'(global major-mode))
|
||||||
|
|
||||||
(doom-modeline-def-modeline media
|
(doom-modeline-def-modeline 'media
|
||||||
(window-number bar " %b ")
|
'(window-number bar " %b ")
|
||||||
(global media-info major-mode))
|
'(global media-info major-mode))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Hooks
|
;; Hooks
|
||||||
|
|
Loading…
Reference in a new issue