mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-23 19:19:50 +00:00
Fix warnings.
This commit is contained in:
parent
29e92d589c
commit
7498b4879e
1 changed files with 259 additions and 257 deletions
144
doom-modeline.el
144
doom-modeline.el
|
@ -141,7 +141,7 @@ Body forms can access the hook's arguments through the let-bound variable
|
||||||
`(progn ,@(nreverse forms)))))
|
`(progn ,@(nreverse forms)))))
|
||||||
|
|
||||||
(defmacro doom-modeline-def-segment! (name &rest forms)
|
(defmacro doom-modeline-def-segment! (name &rest forms)
|
||||||
"Defines a modeline segment and byte compiles it."
|
"Define a modeline segment and byte compiles it."
|
||||||
(declare (indent defun) (doc-string 2))
|
(declare (indent defun) (doc-string 2))
|
||||||
(let ((sym (intern (format "doom-modeline-segment--%s" name))))
|
(let ((sym (intern (format "doom-modeline-segment--%s" name))))
|
||||||
`(progn
|
`(progn
|
||||||
|
@ -158,9 +158,10 @@ Body forms can access the hook's arguments through the let-bound variable
|
||||||
collect (list (intern (format "doom-modeline-segment--%s" (symbol-name seg))))))
|
collect (list (intern (format "doom-modeline-segment--%s" (symbol-name seg))))))
|
||||||
|
|
||||||
(defmacro doom-modeline-def-modeline! (name lhs &optional rhs)
|
(defmacro doom-modeline-def-modeline! (name lhs &optional rhs)
|
||||||
"Defines a modeline format and byte-compiles it. NAME is a symbol to identify
|
"Define a modeline format and byte-compiles it.
|
||||||
it (used by `doom-modeline' for retrieval). LHS and RHS are lists of symbols of
|
NAME is a symbol to identify it (used by `doom-modeline' for retrieval).
|
||||||
modeline segments defined with `doom-modeline-def-segment!'.
|
LHS and RHS are lists of symbols of modeline segments defined
|
||||||
|
with `doom-modeline-def-segment!'.
|
||||||
Example:
|
Example:
|
||||||
(doom-modeline-def-modeline! minimal
|
(doom-modeline-def-modeline! minimal
|
||||||
(bar matches \" \" buffer-info)
|
(bar matches \" \" buffer-info)
|
||||||
|
@ -185,15 +186,15 @@ Example:
|
||||||
(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
|
"Return a mode-line configuration associated with KEY (a symbol).
|
||||||
error if it doesn't exist."
|
Throws an error if it doesn't exist."
|
||||||
(let ((fn (intern (format "doom-modeline-format--%s" key))))
|
(let ((fn (intern (format "doom-modeline-format--%s" key))))
|
||||||
(when (functionp fn)
|
(when (functionp fn)
|
||||||
`(:eval (,fn)))))
|
`(:eval (,fn)))))
|
||||||
|
|
||||||
(defun doom-modeline-set-modeline (key &optional default)
|
(defun doom-modeline-set-modeline (key &optional default)
|
||||||
"Set the modeline format. Does nothing if the modeline KEY doesn't exist. If
|
"Set the modeline format. Does nothing if the modeline KEY doesn't exist.
|
||||||
DEFAULT is non-nil, set the default mode-line for all buffers."
|
If DEFAULT is non-nil, set the default mode-line for all buffers."
|
||||||
(-when-let* ((modeline (doom-modeline key)))
|
(-when-let* ((modeline (doom-modeline key)))
|
||||||
(setf (if default
|
(setf (if default
|
||||||
(default-value 'mode-line-format)
|
(default-value 'mode-line-format)
|
||||||
|
@ -207,76 +208,15 @@ If STRICT-P, return nil if no project was found, otherwise return
|
||||||
(let (projectile-require-project-root)
|
(let (projectile-require-project-root)
|
||||||
(projectile-project-root)))
|
(projectile-project-root)))
|
||||||
|
|
||||||
;;
|
|
||||||
;; modeline configs
|
|
||||||
;;
|
|
||||||
|
|
||||||
(defun doom-modeline-eldoc (text)
|
|
||||||
(concat (when (display-graphic-p)
|
|
||||||
(doom-modeline--make-xpm
|
|
||||||
(face-background 'doom-modeline-eldoc-bar nil t)
|
|
||||||
doom-modeline-height
|
|
||||||
doom-modeline-bar-width))
|
|
||||||
text))
|
|
||||||
|
|
||||||
;; Show eldoc in the mode-line with `eval-expression'
|
|
||||||
(defun doom-modeline--show-eldoc (input)
|
|
||||||
"Display string STR in the mode-line next to minibuffer."
|
|
||||||
(with-current-buffer (eldoc-current-buffer)
|
|
||||||
(let* ((str (and (stringp input) input))
|
|
||||||
(mode-line-format (or (and str (or (doom-modeline-eldoc str) str))
|
|
||||||
mode-line-format))
|
|
||||||
mode-line-in-non-selected-windows)
|
|
||||||
(force-mode-line-update)
|
|
||||||
(sit-for eldoc-show-in-mode-line-delay))))
|
|
||||||
(setq eldoc-in-minibuffer-show-fn #'doom-modeline--show-eldoc)
|
|
||||||
|
|
||||||
(eldoc-in-minibuffer-mode +1)
|
|
||||||
|
|
||||||
|
|
||||||
;; anzu and evil-anzu expose current/total state that can be displayed in the
|
|
||||||
;; mode-line.
|
|
||||||
(when (featurep 'evil-anzu)
|
|
||||||
(doom-modeline-add-transient-hook! #'evil-ex-start-search (require 'evil-anzu))
|
|
||||||
|
|
||||||
(setq anzu-cons-mode-line-p nil
|
|
||||||
anzu-minimum-input-length 1
|
|
||||||
anzu-search-threshold 250)
|
|
||||||
|
|
||||||
;; Avoid anzu conflicts across buffers
|
|
||||||
(mapc #'make-variable-buffer-local
|
|
||||||
'(anzu--total-matched anzu--current-position anzu--state
|
|
||||||
anzu--cached-count anzu--cached-positions anzu--last-command
|
|
||||||
anzu--last-isearch-string anzu--overflow-p))
|
|
||||||
|
|
||||||
;; Ensure anzu state is cleared when searches & iedit are done
|
|
||||||
(add-hook 'isearch-mode-end-hook #'anzu--reset-status t)
|
|
||||||
(add-hook '+evil-esc-hook #'anzu--reset-status t)
|
|
||||||
(add-hook 'iedit-mode-end-hook #'anzu--reset-status))
|
|
||||||
|
|
||||||
|
|
||||||
;; Keep `doom-modeline-current-window' up-to-date
|
|
||||||
(defvar doom-modeline-current-window (frame-selected-window))
|
|
||||||
(defun doom-modeline-set-selected-window (&rest _)
|
|
||||||
"Set `doom-modeline-current-window' appropriately."
|
|
||||||
(-when-let* ((win (frame-selected-window)))
|
|
||||||
(unless (minibuffer-window-active-p win)
|
|
||||||
(setq doom-modeline-current-window win))))
|
|
||||||
|
|
||||||
(add-hook 'window-configuration-change-hook #'doom-modeline-set-selected-window)
|
|
||||||
(add-hook 'focus-in-hook #'doom-modeline-set-selected-window)
|
|
||||||
(advice-add #'handle-switch-frame :after #'doom-modeline-set-selected-window)
|
|
||||||
(advice-add #'select-window :after #'doom-modeline-set-selected-window)
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Variables
|
;; Variables
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(defvar doom-modeline-height 29
|
(defvar doom-modeline-height 29
|
||||||
"How tall the mode-line should be (only respected in GUI emacs).")
|
"How tall the mode-line should be (only respected in GUI).")
|
||||||
|
|
||||||
(defvar doom-modeline-bar-width 3
|
(defvar doom-modeline-bar-width 3
|
||||||
"How wide the mode-line bar should be (only respected in GUI emacs).")
|
"How wide the mode-line bar should be (only respected in GUI).")
|
||||||
|
|
||||||
(defvar doom-modeline-vspc
|
(defvar doom-modeline-vspc
|
||||||
(propertize " " 'face 'variable-pitch)
|
(propertize " " 'face 'variable-pitch)
|
||||||
|
@ -379,6 +319,68 @@ active."
|
||||||
"The face used for brackets around the project."
|
"The face used for brackets around the project."
|
||||||
:group 'doom-modeline)
|
:group 'doom-modeline)
|
||||||
|
|
||||||
|
;;
|
||||||
|
;; modeline configs
|
||||||
|
;;
|
||||||
|
|
||||||
|
(defun doom-modeline-eldoc (text)
|
||||||
|
(concat (when (display-graphic-p)
|
||||||
|
(doom-modeline--make-xpm
|
||||||
|
(face-background 'doom-modeline-eldoc-bar nil t)
|
||||||
|
doom-modeline-height
|
||||||
|
doom-modeline-bar-width))
|
||||||
|
text))
|
||||||
|
|
||||||
|
;; Show eldoc in the mode-line with `eval-expression'
|
||||||
|
(defun doom-modeline--show-eldoc (input)
|
||||||
|
"Display string STR in the mode-line next to minibuffer."
|
||||||
|
(with-current-buffer (eldoc-current-buffer)
|
||||||
|
(let* ((str (and (stringp input) input))
|
||||||
|
(mode-line-format (or (and str (or (doom-modeline-eldoc str) str))
|
||||||
|
mode-line-format))
|
||||||
|
mode-line-in-non-selected-windows)
|
||||||
|
(force-mode-line-update)
|
||||||
|
(sit-for eldoc-show-in-mode-line-delay))))
|
||||||
|
(setq eldoc-in-minibuffer-show-fn #'doom-modeline--show-eldoc)
|
||||||
|
|
||||||
|
(eldoc-in-minibuffer-mode +1)
|
||||||
|
|
||||||
|
|
||||||
|
;; anzu and evil-anzu expose current/total state that can be displayed in the
|
||||||
|
;; mode-line.
|
||||||
|
(when (featurep 'evil-anzu)
|
||||||
|
(doom-modeline-add-transient-hook! #'evil-ex-start-search (require 'evil-anzu))
|
||||||
|
|
||||||
|
(setq anzu-cons-mode-line-p nil
|
||||||
|
anzu-minimum-input-length 1
|
||||||
|
anzu-search-threshold 250)
|
||||||
|
|
||||||
|
;; Avoid anzu conflicts across buffers
|
||||||
|
(mapc #'make-variable-buffer-local
|
||||||
|
'(anzu--total-matched anzu--current-position anzu--state
|
||||||
|
anzu--cached-count anzu--cached-positions anzu--last-command
|
||||||
|
anzu--last-isearch-string anzu--overflow-p))
|
||||||
|
|
||||||
|
;; Ensure anzu state is cleared when searches & iedit are done
|
||||||
|
(add-hook 'isearch-mode-end-hook #'anzu--reset-status t)
|
||||||
|
;; (add-hook '+evil-esc-hook #'anzu--reset-status t)
|
||||||
|
(add-hook 'iedit-mode-end-hook #'anzu--reset-status))
|
||||||
|
|
||||||
|
|
||||||
|
;; Keep `doom-modeline-current-window' up-to-date
|
||||||
|
(defvar doom-modeline-current-window (frame-selected-window))
|
||||||
|
(defun doom-modeline-set-selected-window (&rest _)
|
||||||
|
"Set `doom-modeline-current-window' appropriately."
|
||||||
|
(-when-let* ((win (frame-selected-window)))
|
||||||
|
(unless (minibuffer-window-active-p win)
|
||||||
|
(setq doom-modeline-current-window win))))
|
||||||
|
|
||||||
|
(add-hook 'window-configuration-change-hook #'doom-modeline-set-selected-window)
|
||||||
|
(add-hook 'focus-in-hook #'doom-modeline-set-selected-window)
|
||||||
|
(advice-add #'handle-switch-frame :after #'doom-modeline-set-selected-window)
|
||||||
|
(advice-add #'select-window :after #'doom-modeline-set-selected-window)
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Bootstrap
|
;; Bootstrap
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in a new issue