Fix warnings.

This commit is contained in:
Vincent Zhang 2018-06-15 12:18:01 +08:00
parent 29e92d589c
commit 7498b4879e

View file

@ -141,7 +141,7 @@ Body forms can access the hook's arguments through the let-bound variable
`(progn ,@(nreverse 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))
(let ((sym (intern (format "doom-modeline-segment--%s" name))))
`(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))))))
(defmacro doom-modeline-def-modeline! (name lhs &optional rhs)
"Defines a modeline format and byte-compiles it. 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 `doom-modeline-def-segment!'.
"Define a modeline format and byte-compiles it.
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 `doom-modeline-def-segment!'.
Example:
(doom-modeline-def-modeline! minimal
(bar matches \" \" buffer-info)
@ -185,15 +186,15 @@ Example:
(byte-compile #',sym))))))
(defun doom-modeline (key)
"Returns a mode-line configuration associated with KEY (a symbol). Throws an
error if it doesn't exist."
"Return a mode-line configuration associated with KEY (a symbol).
Throws an error if it doesn't exist."
(let ((fn (intern (format "doom-modeline-format--%s" key))))
(when (functionp fn)
`(:eval (,fn)))))
(defun doom-modeline-set-modeline (key &optional default)
"Set the modeline format. Does nothing if the modeline KEY doesn't exist. If
DEFAULT is non-nil, set the default mode-line for all buffers."
"Set the modeline format. Does nothing if the modeline KEY doesn't exist.
If DEFAULT is non-nil, set the default mode-line for all buffers."
(-when-let* ((modeline (doom-modeline key)))
(setf (if default
(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)
(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
;;
(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
"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
(propertize " " 'face 'variable-pitch)
@ -379,6 +319,68 @@ active."
"The face used for brackets around the project."
: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
;;