mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-27 11:09:52 +00:00
Minor fix.
This commit is contained in:
parent
747f060cdf
commit
998cfe1bd4
1 changed files with 81 additions and 77 deletions
|
@ -104,7 +104,7 @@ then it detaches itself."
|
|||
(defvar doom-modeline-fn-alist ())
|
||||
(defvar doom-modeline-var-alist ()))
|
||||
|
||||
(defmacro doom-modeline-def-segment! (name &rest body)
|
||||
(defmacro doom-modeline-def-segment (name &rest body)
|
||||
"Defines a modeline segment and byte compiles it."
|
||||
(declare (indent defun) (doc-string 2))
|
||||
(let ((sym (intern (format "doom-modeline-segment--%s" name)))
|
||||
|
@ -125,6 +125,7 @@ then it detaches itself."
|
|||
(byte-compile #',sym))))))))
|
||||
|
||||
(defsubst doom-modeline--prepare-segments (segments)
|
||||
"Prepare mode-line `SEGMENTS'."
|
||||
(let (forms it)
|
||||
(dolist (seg segments)
|
||||
(cond ((stringp seg)
|
||||
|
@ -138,15 +139,16 @@ then it detaches itself."
|
|||
((error "%s is not a valid segment" seg))))
|
||||
(nreverse forms)))
|
||||
|
||||
(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!'.
|
||||
(defmacro doom-modeline-def (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'.
|
||||
Example:
|
||||
(doom-modeline-def-modeline! minimal
|
||||
(doom-modeline-def minimal
|
||||
(bar matches \" \" buffer-info)
|
||||
(media-info major-mode))
|
||||
(doom-set-modeline 'minimal t)"
|
||||
(doom-modeline-set 'minimal t)"
|
||||
(let ((sym (intern (format "doom-modeline-format--%s" name)))
|
||||
(lhs-forms (doom-modeline--prepare-segments lhs))
|
||||
(rhs-forms (doom-modeline--prepare-segments rhs)))
|
||||
|
@ -171,14 +173,16 @@ Example:
|
|||
(byte-compile #',sym))))))
|
||||
|
||||
(defun doom-modeline (key)
|
||||
"Return 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 (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."
|
||||
(when-let ((modeline (doom-modeline key)))
|
||||
"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 (m (doom-modeline key))
|
||||
(setf (if default
|
||||
(default-value 'mode-line-format)
|
||||
(buffer-local-value 'mode-line-format (current-buffer)))
|
||||
|
@ -516,7 +520,7 @@ Example:
|
|||
;; buffer information
|
||||
;;
|
||||
|
||||
(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
|
||||
buffer where knowing the current project directory is important."
|
||||
(let ((face (if (doom-modeline--active) 'doom-modeline-buffer-path)))
|
||||
|
@ -530,7 +534,7 @@ buffer where knowing the current project directory is important."
|
|||
'face face))))
|
||||
|
||||
;;
|
||||
(doom-modeline-def-segment! buffer-info
|
||||
(doom-modeline-def-segment buffer-info
|
||||
"Combined information about the current buffer, including the current working
|
||||
directory, the file name, and its state (modified, read-only or non-existent)."
|
||||
(concat (cond (buffer-read-only
|
||||
|
@ -562,7 +566,7 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
|||
(doom-modeline-buffer-file-name)
|
||||
"%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."
|
||||
(propertize
|
||||
"%b"
|
||||
|
@ -571,7 +575,7 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
|||
((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."
|
||||
(concat (pcase (coding-system-eol-type buffer-file-coding-system)
|
||||
(0 "LF ")
|
||||
|
@ -587,7 +591,7 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
|||
;; major-mode
|
||||
;;
|
||||
|
||||
(doom-modeline-def-segment! major-mode
|
||||
(doom-modeline-def-segment major-mode
|
||||
"The major mode, including process, environment and text-scale info."
|
||||
(propertize
|
||||
(concat (format-mode-line mode-name)
|
||||
|
@ -644,7 +648,7 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
|||
(add-hook 'after-save-hook #'doom-modeline--update-vcs)
|
||||
(add-hook 'find-file-hook #'doom-modeline--update-vcs t)
|
||||
|
||||
(doom-modeline-def-segment! vcs
|
||||
(doom-modeline-def-segment vcs
|
||||
"Displays the current branch, colored based on its state."
|
||||
doom-modeline--vcs)
|
||||
|
||||
|
@ -688,7 +692,7 @@ Uses `all-the-icons-material' to fetch the icon."
|
|||
(`errored (doom-modeline-icon "sim_card_alert" "Error" 'doom-modeline-urgent))
|
||||
(`interrupted (doom-modeline-icon "pause" "Interrupted" 'font-lock-doc-face)))))
|
||||
|
||||
(doom-modeline-def-segment! flycheck
|
||||
(doom-modeline-def-segment flycheck
|
||||
"Displays color-coded flycheck error status in the current buffer with pretty
|
||||
icons."
|
||||
doom-modeline--flycheck)
|
||||
|
@ -706,7 +710,7 @@ icons."
|
|||
"If non-nil, a word count will be added to the selection-info modeline
|
||||
segment.")
|
||||
|
||||
(doom-modeline-def-segment! selection-info
|
||||
(doom-modeline-def-segment selection-info
|
||||
"Information about the current selection, such as how many characters and
|
||||
lines are selected, or the NxM dimensions of a block selection."
|
||||
(when (and mark-active (doom-modeline--active))
|
||||
|
@ -804,7 +808,7 @@ lines are selected, or the NxM dimensions of a block selection."
|
|||
length))
|
||||
'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
|
||||
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."
|
||||
|
@ -819,7 +823,7 @@ with `evil-ex-substitute', and/or 4. The number of active `iedit' regions."
|
|||
;; media-info
|
||||
;;
|
||||
|
||||
(doom-modeline-def-segment! media-info
|
||||
(doom-modeline-def-segment media-info
|
||||
"Metadata regarding the current file, such as dimensions for images."
|
||||
;; TODO Include other information
|
||||
(cond ((eq major-mode 'image-mode)
|
||||
|
@ -833,7 +837,7 @@ with `evil-ex-substitute', and/or 4. The number of active `iedit' regions."
|
|||
|
||||
(defvar doom-modeline--bar-active nil)
|
||||
(defvar doom-modeline--bar-inactive nil)
|
||||
(doom-modeline-def-segment! bar
|
||||
(doom-modeline-def-segment bar
|
||||
"The bar regulates the height of the mode-line in GUI Emacs.
|
||||
Returns \"\" to not break --no-window-system."
|
||||
(if (display-graphic-p)
|
||||
|
@ -863,7 +867,7 @@ Returns \"\" to not break --no-window-system."
|
|||
(advice-add #'window-numbering-install-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)
|
||||
(propertize (format " %s " (window-numbering-get-number-string))
|
||||
'face (if (doom-modeline--active)
|
||||
|
@ -876,7 +880,7 @@ Returns \"\" to not break --no-window-system."
|
|||
;;
|
||||
|
||||
(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
|
||||
enabled."
|
||||
(if (and (bound-and-true-p eyebrowse-mode)
|
||||
|
@ -893,23 +897,23 @@ enabled."
|
|||
;; Mode lines
|
||||
;;
|
||||
|
||||
(doom-modeline-def-modeline! main
|
||||
(doom-modeline-def main
|
||||
(workspace-number bar matches " " buffer-info " %l:%c %p " selection-info)
|
||||
(buffer-encoding major-mode vcs flycheck))
|
||||
|
||||
(doom-modeline-def-modeline! minimal
|
||||
(doom-modeline-def minimal
|
||||
(bar matches " " buffer-info)
|
||||
(media-info major-mode))
|
||||
|
||||
(doom-modeline-def-modeline! special
|
||||
(doom-modeline-def special
|
||||
(bar matches " " buffer-info-simple " %l:%c %p " selection-info)
|
||||
(buffer-encoding major-mode flycheck))
|
||||
|
||||
(doom-modeline-def-modeline! project
|
||||
(doom-modeline-def project
|
||||
(bar buffer-default-directory)
|
||||
(major-mode))
|
||||
|
||||
(doom-modeline-def-modeline! media
|
||||
(doom-modeline-def media
|
||||
(bar " %b ")
|
||||
(media-info major-mode))
|
||||
|
||||
|
|
Loading…
Reference in a new issue