mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-23 19:19:50 +00:00
Format codes.
This commit is contained in:
parent
03c00e84ab
commit
97f3e709fb
1 changed files with 186 additions and 186 deletions
372
doom-modeline.el
372
doom-modeline.el
|
@ -528,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)
|
||||||
|
@ -626,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))
|
||||||
" ")))))
|
" ")))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
@ -675,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)))))
|
||||||
|
|
||||||
|
|
||||||
|
@ -700,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))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
@ -794,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)
|
||||||
|
@ -843,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