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
516
doom-modeline.el
516
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
|
||||||
;;
|
;;
|
||||||
|
@ -526,88 +528,88 @@ Example:
|
||||||
|
|
||||||
|
|
||||||
(doom-modeline-def-segment! buffer-default-directory
|
(doom-modeline-def-segment! buffer-default-directory
|
||||||
"Displays `default-directory'. This is for special buffers like the scratch
|
"Displays `default-directory'. This is for special buffers like the scratch
|
||||||
buffer where knowing the current project directory is important."
|
buffer where knowing the current project directory is important."
|
||||||
(let ((face (if (doom-modeline--active) 'doom-modeline-buffer-path)))
|
(let ((face (if (doom-modeline--active) 'doom-modeline-buffer-path)))
|
||||||
(concat (if (display-graphic-p) " ")
|
(concat (if (display-graphic-p) " ")
|
||||||
(doom-modeline-maybe-icon-octicon
|
(doom-modeline-maybe-icon-octicon
|
||||||
"file-directory"
|
"file-directory"
|
||||||
:face face
|
:face face
|
||||||
:v-adjust -0.05
|
:v-adjust -0.05
|
||||||
:height 1.25)
|
:height 1.25)
|
||||||
(propertize (concat " " (abbreviate-file-name default-directory))
|
(propertize (concat " " (abbreviate-file-name default-directory))
|
||||||
'face face))))
|
'face face))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
(doom-modeline-def-segment! buffer-info
|
(doom-modeline-def-segment! buffer-info
|
||||||
"Combined information about the current buffer, including the current working
|
"Combined information about the current buffer, including the current working
|
||||||
directory, the file name, and its state (modified, read-only or non-existent)."
|
directory, the file name, and its state (modified, read-only or non-existent)."
|
||||||
(concat
|
(concat
|
||||||
(cond (buffer-read-only
|
(cond (buffer-read-only
|
||||||
(concat (doom-modeline-maybe-icon-octicon
|
(concat (doom-modeline-maybe-icon-octicon
|
||||||
"lock"
|
"lock"
|
||||||
:face 'doom-modeline-warning
|
:face 'doom-modeline-warning
|
||||||
:v-adjust -0.05)
|
:v-adjust -0.05)
|
||||||
" "))
|
" "))
|
||||||
((buffer-modified-p)
|
((buffer-modified-p)
|
||||||
(concat (doom-modeline-maybe-icon-faicon
|
(concat (doom-modeline-maybe-icon-faicon
|
||||||
"floppy-o"
|
"floppy-o"
|
||||||
:face 'doom-modeline-buffer-modified
|
:face 'doom-modeline-buffer-modified
|
||||||
:v-adjust -0.0575)
|
:v-adjust -0.0575)
|
||||||
" "))
|
" "))
|
||||||
((and buffer-file-name
|
((and buffer-file-name
|
||||||
(not (file-exists-p buffer-file-name)))
|
(not (file-exists-p buffer-file-name)))
|
||||||
(concat (doom-modeline-maybe-icon-octicon
|
(concat (doom-modeline-maybe-icon-octicon
|
||||||
"circle-slash"
|
"circle-slash"
|
||||||
:face 'doom-modeline-urgent
|
:face 'doom-modeline-urgent
|
||||||
:v-adjust -0.05)
|
:v-adjust -0.05)
|
||||||
" "))
|
" "))
|
||||||
((buffer-narrowed-p)
|
((buffer-narrowed-p)
|
||||||
(concat (doom-modeline-maybe-icon-octicon
|
(concat (doom-modeline-maybe-icon-octicon
|
||||||
"fold"
|
"fold"
|
||||||
:face 'doom-modeline-warning
|
:face 'doom-modeline-warning
|
||||||
:v-adjust -0.05)
|
:v-adjust -0.05)
|
||||||
" ")))
|
" ")))
|
||||||
(if buffer-file-name
|
(if buffer-file-name
|
||||||
(doom-modeline-buffer-file-name)
|
(doom-modeline-buffer-file-name)
|
||||||
"%b")))
|
"%b")))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
(doom-modeline-def-segment! buffer-info-simple
|
(doom-modeline-def-segment! buffer-info-simple
|
||||||
"Display only the current buffer's name, but with fontification."
|
"Display only the current buffer's name, but with fontification."
|
||||||
(propertize
|
(propertize
|
||||||
"%b"
|
"%b"
|
||||||
'face (cond ((and buffer-file-name (buffer-modified-p))
|
'face (cond ((and buffer-file-name (buffer-modified-p))
|
||||||
'doom-modeline-buffer-modified)
|
'doom-modeline-buffer-modified)
|
||||||
((doom-modeline--active) 'doom-modeline-buffer-file))))
|
((doom-modeline--active) 'doom-modeline-buffer-file))))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
(doom-modeline-def-segment! buffer-encoding
|
(doom-modeline-def-segment! buffer-encoding
|
||||||
"Displays the encoding and eol style of the buffer the same way Atom does."
|
"Displays the encoding and eol style of the buffer the same way Atom does."
|
||||||
(concat (pcase (coding-system-eol-type buffer-file-coding-system)
|
(concat (pcase (coding-system-eol-type buffer-file-coding-system)
|
||||||
(0 "LF ")
|
(0 "LF ")
|
||||||
(1 "CRLF ")
|
(1 "CRLF ")
|
||||||
(2 "CR "))
|
(2 "CR "))
|
||||||
(let ((sys (coding-system-plist buffer-file-coding-system)))
|
(let ((sys (coding-system-plist buffer-file-coding-system)))
|
||||||
(cond ((memq (plist-get sys :category) '(coding-category-undecided coding-category-utf-8))
|
(cond ((memq (plist-get sys :category) '(coding-category-undecided coding-category-utf-8))
|
||||||
"UTF-8")
|
"UTF-8")
|
||||||
(t (upcase (symbol-name (plist-get sys :name))))))
|
(t (upcase (symbol-name (plist-get sys :name))))))
|
||||||
" "))
|
" "))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
(doom-modeline-def-segment! major-mode
|
(doom-modeline-def-segment! major-mode
|
||||||
"The major mode, including process, environment and text-scale info."
|
"The major mode, including process, environment and text-scale info."
|
||||||
(propertize
|
(propertize
|
||||||
(concat (format-mode-line mode-name)
|
(concat (format-mode-line mode-name)
|
||||||
(when (stringp mode-line-process)
|
(when (stringp mode-line-process)
|
||||||
mode-line-process)
|
mode-line-process)
|
||||||
(when doom-modeline-env-version
|
(when doom-modeline-env-version
|
||||||
(concat " " doom-modeline-env-version))
|
(concat " " doom-modeline-env-version))
|
||||||
(and (featurep 'face-remap)
|
(and (featurep 'face-remap)
|
||||||
(/= text-scale-mode-amount 0)
|
(/= text-scale-mode-amount 0)
|
||||||
(format " (%+d)" text-scale-mode-amount)))
|
(format " (%+d)" text-scale-mode-amount)))
|
||||||
'face (if (doom-modeline--active) 'doom-modeline-buffer-major-mode)))
|
'face (if (doom-modeline--active) 'doom-modeline-buffer-major-mode)))
|
||||||
|
|
||||||
|
|
||||||
(defun doom-modeline-maybe-icon-octicon (&rest args)
|
(defun doom-modeline-maybe-icon-octicon (&rest args)
|
||||||
|
@ -624,39 +626,39 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
||||||
|
|
||||||
;;
|
;;
|
||||||
(doom-modeline-def-segment! vcs
|
(doom-modeline-def-segment! vcs
|
||||||
"Displays the current branch, colored based on its state."
|
"Displays the current branch, colored based on its state."
|
||||||
(when (and vc-mode buffer-file-name)
|
(when (and vc-mode buffer-file-name)
|
||||||
(let* ((backend (vc-backend buffer-file-name))
|
(let* ((backend (vc-backend buffer-file-name))
|
||||||
(state (vc-state buffer-file-name backend)))
|
(state (vc-state buffer-file-name backend)))
|
||||||
(let ((face 'mode-line-inactive)
|
(let ((face 'mode-line-inactive)
|
||||||
(active (doom-modeline--active))
|
(active (doom-modeline--active))
|
||||||
(all-the-icons-default-adjust -0.1))
|
(all-the-icons-default-adjust -0.1))
|
||||||
(concat (if (display-graphic-p) " ")
|
(concat (if (display-graphic-p) " ")
|
||||||
(cond ((memq state '(edited added))
|
(cond ((memq state '(edited added))
|
||||||
(if active (setq face 'doom-modeline-info))
|
(if active (setq face 'doom-modeline-info))
|
||||||
(doom-modeline-maybe-icon-octicon
|
(doom-modeline-maybe-icon-octicon
|
||||||
"git-compare"
|
"git-compare"
|
||||||
:face face
|
:face face
|
||||||
:v-adjust -0.05))
|
:v-adjust -0.05))
|
||||||
((eq state 'needs-merge)
|
((eq state 'needs-merge)
|
||||||
(if active (setq face 'doom-modeline-info))
|
(if active (setq face 'doom-modeline-info))
|
||||||
(doom-modeline-maybe-icon-octicon "git-merge" :face face))
|
(doom-modeline-maybe-icon-octicon "git-merge" :face face))
|
||||||
((eq state 'needs-update)
|
((eq state 'needs-update)
|
||||||
(if active (setq face 'doom-modeline-warning))
|
(if active (setq face 'doom-modeline-warning))
|
||||||
(doom-modeline-maybe-icon-octicon "arrow-down" :face face))
|
(doom-modeline-maybe-icon-octicon "arrow-down" :face face))
|
||||||
((memq state '(removed conflict unregistered))
|
((memq state '(removed conflict unregistered))
|
||||||
(if active (setq face 'doom-modeline-urgent))
|
(if active (setq face 'doom-modeline-urgent))
|
||||||
(doom-modeline-maybe-icon-octicon "alert" :face face))
|
(doom-modeline-maybe-icon-octicon "alert" :face face))
|
||||||
(t
|
(t
|
||||||
(if active (setq face 'font-lock-doc-face))
|
(if active (setq face 'font-lock-doc-face))
|
||||||
(doom-modeline-maybe-icon-octicon
|
(doom-modeline-maybe-icon-octicon
|
||||||
"git-branch"
|
"git-branch"
|
||||||
:face face
|
:face face
|
||||||
:v-adjust -0.05)))
|
:v-adjust -0.05)))
|
||||||
" "
|
" "
|
||||||
(propertize (substring vc-mode (+ (if (eq backend 'Hg) 2 3) 2))
|
(propertize (substring vc-mode (+ (if (eq backend 'Hg) 2 3) 2))
|
||||||
'face (if active face))
|
'face (if active face))
|
||||||
" ")))))
|
" ")))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
@ -673,22 +675,22 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
||||||
(if vc-mode " " " ")))
|
(if vc-mode " " " ")))
|
||||||
|
|
||||||
(doom-modeline-def-segment! flycheck
|
(doom-modeline-def-segment! flycheck
|
||||||
"Displays color-coded flycheck error status in the current buffer with pretty
|
"Displays color-coded flycheck error status in the current buffer with pretty
|
||||||
icons."
|
icons."
|
||||||
(when (boundp 'flycheck-last-status-change)
|
(when (boundp 'flycheck-last-status-change)
|
||||||
(pcase flycheck-last-status-change
|
(pcase flycheck-last-status-change
|
||||||
(`finished (if flycheck-current-errors
|
(`finished (if flycheck-current-errors
|
||||||
(let-alist (flycheck-count-errors flycheck-current-errors)
|
(let-alist (flycheck-count-errors flycheck-current-errors)
|
||||||
(let ((sum (+ (or .error 0) (or .warning 0))))
|
(let ((sum (+ (or .error 0) (or .warning 0))))
|
||||||
(doom-modeline-icon "do_not_disturb_alt"
|
(doom-modeline-icon "do_not_disturb_alt"
|
||||||
(number-to-string sum)
|
(number-to-string sum)
|
||||||
(if .error 'doom-modeline-urgent 'doom-modeline-warning)
|
(if .error 'doom-modeline-urgent 'doom-modeline-warning)
|
||||||
-0.25)))
|
-0.25)))
|
||||||
(doom-modeline-icon "check" nil 'doom-modeline-info)))
|
(doom-modeline-icon "check" nil 'doom-modeline-info)))
|
||||||
(`running (doom-modeline-icon "access_time" nil 'font-lock-doc-face -0.25))
|
(`running (doom-modeline-icon "access_time" nil 'font-lock-doc-face -0.25))
|
||||||
(`no-checker (doom-modeline-icon "sim_card_alert" "-" 'font-lock-doc-face))
|
(`no-checker (doom-modeline-icon "sim_card_alert" "-" 'font-lock-doc-face))
|
||||||
(`errored (doom-modeline-icon "sim_card_alert" "Error" 'doom-modeline-urgent))
|
(`errored (doom-modeline-icon "sim_card_alert" "Error" 'doom-modeline-urgent))
|
||||||
(`interrupted (doom-modeline-icon "pause" "Interrupted" 'font-lock-doc-face)))))
|
(`interrupted (doom-modeline-icon "pause" "Interrupted" 'font-lock-doc-face)))))
|
||||||
;; ('interrupted (doom-modeline-icon "x" "Interrupted" 'font-lock-doc-face)))))
|
;; ('interrupted (doom-modeline-icon "x" "Interrupted" 'font-lock-doc-face)))))
|
||||||
|
|
||||||
|
|
||||||
|
@ -698,25 +700,25 @@ icons."
|
||||||
(current-column)))
|
(current-column)))
|
||||||
|
|
||||||
(doom-modeline-def-segment! selection-info
|
(doom-modeline-def-segment! selection-info
|
||||||
"Information about the current selection, such as how many characters and
|
"Information about the current selection, such as how many characters and
|
||||||
lines are selected, or the NxM dimensions of a block selection."
|
lines are selected, or the NxM dimensions of a block selection."
|
||||||
(when (and (doom-modeline--active) (or mark-active (eq evil-state 'visual)))
|
(when (and (doom-modeline--active) (or mark-active (eq evil-state 'visual)))
|
||||||
(let ((reg-beg (region-beginning))
|
(let ((reg-beg (region-beginning))
|
||||||
(reg-end (region-end)))
|
(reg-end (region-end)))
|
||||||
(propertize
|
(propertize
|
||||||
(let ((lines (count-lines reg-beg (min (1+ reg-end) (point-max)))))
|
(let ((lines (count-lines reg-beg (min (1+ reg-end) (point-max)))))
|
||||||
(cond ((or (bound-and-true-p rectangle-mark-mode)
|
(cond ((or (bound-and-true-p rectangle-mark-mode)
|
||||||
(eq 'block evil-visual-selection))
|
(eq 'block evil-visual-selection))
|
||||||
(let ((cols (abs (- (doom-modeline-column reg-end)
|
(let ((cols (abs (- (doom-modeline-column reg-end)
|
||||||
(doom-modeline-column reg-beg)))))
|
(doom-modeline-column reg-beg)))))
|
||||||
(format "%dx%dB" lines cols)))
|
(format "%dx%dB" lines cols)))
|
||||||
((eq 'line evil-visual-selection)
|
((eq 'line evil-visual-selection)
|
||||||
(format "%dL" lines))
|
(format "%dL" lines))
|
||||||
((> lines 1)
|
((> lines 1)
|
||||||
(format "%dC %dL" (- (1+ reg-end) reg-beg) lines))
|
(format "%dC %dL" (- (1+ reg-end) reg-beg) lines))
|
||||||
(t
|
(t
|
||||||
(format "%dC" (- (1+ reg-end) reg-beg)))))
|
(format "%dC" (- (1+ reg-end) reg-beg)))))
|
||||||
'face 'doom-modeline-highlight))))
|
'face 'doom-modeline-highlight))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
@ -792,36 +794,36 @@ lines are selected, or the NxM dimensions of a block selection."
|
||||||
'face (if (doom-modeline--active) 'doom-modeline-panel))))
|
'face (if (doom-modeline--active) 'doom-modeline-panel))))
|
||||||
|
|
||||||
(doom-modeline-def-segment! matches
|
(doom-modeline-def-segment! matches
|
||||||
"Displays: 1. the currently recording macro, 2. A current/total for the
|
"Displays: 1. the currently recording macro, 2. A current/total for the
|
||||||
current search term (with anzu), 3. The number of substitutions being conducted
|
current search term (with anzu), 3. The number of substitutions being conducted
|
||||||
with `evil-ex-substitute', and/or 4. The number of active `iedit' regions."
|
with `evil-ex-substitute', and/or 4. The number of active `iedit' regions."
|
||||||
(let ((meta (concat (doom-modeline--macro-recording)
|
(let ((meta (concat (doom-modeline--macro-recording)
|
||||||
(doom-modeline--anzu)
|
(doom-modeline--anzu)
|
||||||
(doom-modeline--evil-substitute)
|
(doom-modeline--evil-substitute)
|
||||||
(doom-modeline--iedit))))
|
(doom-modeline--iedit))))
|
||||||
(or (and (not (equal meta "")) meta)
|
(or (and (not (equal meta "")) meta)
|
||||||
(if buffer-file-name " %I "))))
|
(if buffer-file-name " %I "))))
|
||||||
|
|
||||||
;; TODO Include other information
|
;; TODO Include other information
|
||||||
(doom-modeline-def-segment! media-info
|
(doom-modeline-def-segment! media-info
|
||||||
"Metadata regarding the current file, such as dimensions for images."
|
"Metadata regarding the current file, such as dimensions for images."
|
||||||
(cond ((eq major-mode 'image-mode)
|
(cond ((eq major-mode 'image-mode)
|
||||||
(cl-destructuring-bind (width . height)
|
(cl-destructuring-bind (width . height)
|
||||||
(image-size (image-get-display-property) :pixels)
|
(image-size (image-get-display-property) :pixels)
|
||||||
(format " %dx%d " width height)))))
|
(format " %dx%d " width height)))))
|
||||||
|
|
||||||
(doom-modeline-def-segment! bar
|
(doom-modeline-def-segment! bar
|
||||||
"The bar regulates the height of the mode-line in GUI Emacs.
|
"The bar regulates the height of the mode-line in GUI Emacs.
|
||||||
Returns \"\" to not break --no-window-system."
|
Returns \"\" to not break --no-window-system."
|
||||||
(if (display-graphic-p)
|
(if (display-graphic-p)
|
||||||
(doom-modeline--make-xpm
|
(doom-modeline--make-xpm
|
||||||
(face-background (if (doom-modeline--active)
|
(face-background (if (doom-modeline--active)
|
||||||
'doom-modeline-bar
|
'doom-modeline-bar
|
||||||
'doom-modeline-inactive-bar)
|
'doom-modeline-inactive-bar)
|
||||||
nil t)
|
nil t)
|
||||||
doom-modeline-height
|
doom-modeline-height
|
||||||
doom-modeline-bar-width)
|
doom-modeline-bar-width)
|
||||||
""))
|
""))
|
||||||
|
|
||||||
(defun doom-modeline-eyebrowse-number ()
|
(defun doom-modeline-eyebrowse-number ()
|
||||||
(when (and (bound-and-true-p eyebrowse-mode)
|
(when (and (bound-and-true-p eyebrowse-mode)
|
||||||
|
@ -841,47 +843,47 @@ Returns \"\" to not break --no-window-system."
|
||||||
(cadr minibuffer-edges)))))
|
(cadr minibuffer-edges)))))
|
||||||
|
|
||||||
(doom-modeline-def-segment! persp-number
|
(doom-modeline-def-segment! persp-number
|
||||||
"The persp number."
|
"The persp number."
|
||||||
(when (featurep 'persp-mode)
|
(when (featurep 'persp-mode)
|
||||||
(when (doom-modeline-window-bottom-left-p)
|
(when (doom-modeline-window-bottom-left-p)
|
||||||
(-when-let* ((persp (get-current-persp)))
|
(-when-let* ((persp (get-current-persp)))
|
||||||
(propertize
|
(propertize
|
||||||
(concat
|
(concat
|
||||||
(number-to-string
|
(number-to-string
|
||||||
(+ 1
|
(+ 1
|
||||||
(cl-position
|
(cl-position
|
||||||
(persp-name persp)
|
(persp-name persp)
|
||||||
(persp-names-current-frame-fast-ordered))))
|
(persp-names-current-frame-fast-ordered))))
|
||||||
"."
|
"."
|
||||||
(or (doom-modeline-eyebrowse-number) "1")
|
(or (doom-modeline-eyebrowse-number) "1")
|
||||||
" ")
|
" ")
|
||||||
'face 'doom-modeline-persp)))))
|
'face 'doom-modeline-persp)))))
|
||||||
|
|
||||||
|
|
||||||
(advice-add #'window-numbering-install-mode-line :override #'ignore)
|
(advice-add #'window-numbering-install-mode-line :override #'ignore)
|
||||||
(advice-add #'window-numbering-clear-mode-line :override #'ignore)
|
(advice-add #'window-numbering-clear-mode-line :override #'ignore)
|
||||||
|
|
||||||
(doom-modeline-def-segment! window-number
|
(doom-modeline-def-segment! window-number
|
||||||
(if (bound-and-true-p window-numbering-mode)
|
(if (bound-and-true-p window-numbering-mode)
|
||||||
(propertize (format " %s " (window-numbering-get-number-string))
|
(propertize (format " %s " (window-numbering-get-number-string))
|
||||||
'face (if (doom-modeline--active)
|
'face (if (doom-modeline--active)
|
||||||
'doom-modeline-bar
|
'doom-modeline-bar
|
||||||
'doom-modeline-inactive-bar))
|
'doom-modeline-inactive-bar))
|
||||||
""))
|
""))
|
||||||
|
|
||||||
(declare-function eyebrowse--get 'eyebrowse)
|
(declare-function eyebrowse--get 'eyebrowse)
|
||||||
(doom-modeline-def-segment! workspace-number
|
(doom-modeline-def-segment! workspace-number
|
||||||
"The current workspace name or number. Requires `eyebrowse-mode' to be
|
"The current workspace name or number. Requires `eyebrowse-mode' to be
|
||||||
enabled."
|
enabled."
|
||||||
(if (and (bound-and-true-p eyebrowse-mode)
|
(if (and (bound-and-true-p eyebrowse-mode)
|
||||||
(< 1 (length (eyebrowse--get 'window-configs))))
|
(< 1 (length (eyebrowse--get 'window-configs))))
|
||||||
(let* ((num (eyebrowse--get 'current-slot))
|
(let* ((num (eyebrowse--get 'current-slot))
|
||||||
(tag (when num (nth 2 (assoc num (eyebrowse--get 'window-configs)))))
|
(tag (when num (nth 2 (assoc num (eyebrowse--get 'window-configs)))))
|
||||||
(str (if (and tag (< 0 (length tag)))
|
(str (if (and tag (< 0 (length tag)))
|
||||||
tag
|
tag
|
||||||
(when num (int-to-string num)))))
|
(when num (int-to-string num)))))
|
||||||
(propertize (format "%s " str) 'face 'doom-modeline-eyebrowse))
|
(propertize (format "%s " str) 'face 'doom-modeline-eyebrowse))
|
||||||
""))
|
""))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Mode lines
|
;; Mode lines
|
||||||
|
|
Loading…
Reference in a new issue