mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-27 11:09:52 +00:00
Merge from develop branch.
This commit is contained in:
parent
c2ad2a27f3
commit
84e9a43bd1
1 changed files with 115 additions and 182 deletions
297
doom-modeline.el
297
doom-modeline.el
|
@ -72,76 +72,7 @@
|
||||||
|
|
||||||
(defvar doom-modeline--transient-counter 0))
|
(defvar doom-modeline--transient-counter 0))
|
||||||
|
|
||||||
(defmacro doom-modeline-add-transient-hook! (hook &rest forms)
|
(defmacro doom-modeline-def-segment (name &rest forms)
|
||||||
"Attache transient FORMS to a HOOK.
|
|
||||||
HOOK can be a quoted hook or a sharp-quoted function (which will be advised).
|
|
||||||
These forms will be evaluated once when that function/hook is first invoked,
|
|
||||||
then it detaches itself."
|
|
||||||
(declare (indent 1))
|
|
||||||
(let ((append (eq (car forms) :after))
|
|
||||||
(fn (intern (format "doom-transient-hook-%s" (cl-incf doom-modeline--transient-counter)))))
|
|
||||||
`(when ,hook
|
|
||||||
(fset ',fn
|
|
||||||
(lambda (&rest _)
|
|
||||||
,@forms
|
|
||||||
(cond ((functionp ,hook) (advice-remove ,hook #',fn))
|
|
||||||
((symbolp ,hook) (remove-hook ,hook #',fn)))
|
|
||||||
(unintern ',fn nil)))
|
|
||||||
(cond ((functionp ,hook)
|
|
||||||
(advice-add ,hook ,(if append :after :before) #',fn))
|
|
||||||
((symbolp ,hook)
|
|
||||||
(add-hook ,hook #',fn ,append))))))
|
|
||||||
|
|
||||||
(defmacro doom-modeline-add-hook! (&rest args)
|
|
||||||
"A convenience macro for `add-hook'.
|
|
||||||
Takes, in order:
|
|
||||||
1. Optional properties :local and/or :append, which will make the hook
|
|
||||||
buffer-local or append to the list of hooks (respectively),
|
|
||||||
2. The hooks: either an unquoted major mode, an unquoted list of major-modes,
|
|
||||||
a quoted hook variable or a quoted list of hook variables. If unquoted, the
|
|
||||||
hooks will be resolved by appending -hook to each symbol.
|
|
||||||
3. A function, list of functions, or body forms to be wrapped in a lambda.
|
|
||||||
Examples:
|
|
||||||
(doom-modeline-add-hook! 'some-mode-hook 'enable-something)
|
|
||||||
(doom-modeline-add-hook! some-mode '(enable-something and-another))
|
|
||||||
(doom-modeline-add-hook! '(one-mode-hook second-mode-hook) 'enable-something)
|
|
||||||
(doom-modeline-add-hook! (one-mode second-mode) 'enable-something)
|
|
||||||
(doom-modeline-add-hook! :append (one-mode second-mode) 'enable-something)
|
|
||||||
(doom-modeline-add-hook! :local (one-mode second-mode) 'enable-something)
|
|
||||||
(doom-modeline-add-hook! (one-mode second-mode) (setq v 5) (setq a 2))
|
|
||||||
(doom-modeline-add-hook! :append :local (one-mode second-mode) (setq v 5) (setq a 2))
|
|
||||||
Body forms can access the hook's arguments through the let-bound variable
|
|
||||||
`ARGS'."
|
|
||||||
(declare (indent defun) (debug t))
|
|
||||||
(let ((hook-fn 'add-hook)
|
|
||||||
append-p local-p)
|
|
||||||
(while (keywordp (car args))
|
|
||||||
(pcase (pop args)
|
|
||||||
(:append (setq append-p t))
|
|
||||||
(:local (setq local-p t))
|
|
||||||
(:remove (setq hook-fn 'remove-hook))))
|
|
||||||
(let ((hooks (doom-modeline--resolve-hooks (pop args)))
|
|
||||||
(funcs
|
|
||||||
(let ((val (car args)))
|
|
||||||
(if (memq (car-safe val) '(quote function))
|
|
||||||
(if (cdr-safe (cadr val))
|
|
||||||
(cadr val)
|
|
||||||
(list (cadr val)))
|
|
||||||
(list args))))
|
|
||||||
forms)
|
|
||||||
(dolist (fn funcs)
|
|
||||||
(setq fn (if (symbolp fn)
|
|
||||||
`(function ,fn)
|
|
||||||
`(lambda (&rest _) ,@args)))
|
|
||||||
(dolist (hook hooks)
|
|
||||||
(push (cond ((eq hook-fn 'remove-hook)
|
|
||||||
`(remove-hook ',hook ,fn ,local-p))
|
|
||||||
(t
|
|
||||||
`(add-hook ',hook ,fn ,append-p ,local-p)))
|
|
||||||
forms)))
|
|
||||||
`(progn ,@(nreverse forms)))))
|
|
||||||
|
|
||||||
(defmacro doom-modeline-def-segment! (name &rest forms)
|
|
||||||
"Define a modeline segment NAME by FORMS and byte compiles it."
|
"Define a modeline segment NAME by FORMS 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))))
|
||||||
|
@ -159,16 +90,16 @@ Body forms can access the hook's arguments through the let-bound variable
|
||||||
else
|
else
|
||||||
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 (name lhs &optional rhs)
|
||||||
"Define a modeline format and byte-compiles it.
|
"Define a modeline format and byte-compiles it.
|
||||||
NAME is a symbol to identify it (used by `doom-modeline' for retrieval).
|
NAME is a symbol to identify it (used by `doom-modeline' for retrieval).
|
||||||
LHS and RHS are lists of symbols of modeline segments defined
|
LHS and RHS are lists of symbols of modeline segments defined
|
||||||
with `doom-modeline-def-segment!'.
|
with `doom-modeline-def-segment'.
|
||||||
Example:
|
Example:
|
||||||
(doom-modeline-def-modeline! minimal
|
(doom-modeline-def minimal
|
||||||
(bar matches \" \" buffer-info)
|
(bar matches \" \" buffer-info)
|
||||||
(media-info major-mode))
|
(media-info major-mode))
|
||||||
(doom-modeline-set-modeline 'minimal t)"
|
(doom-modeline-set 'minimal t)"
|
||||||
(let ((sym (intern (format "doom-modeline-format--%s" name)))
|
(let ((sym (intern (format "doom-modeline-format--%s" name)))
|
||||||
(lhs-forms (doom-modeline--prepare-segments lhs))
|
(lhs-forms (doom-modeline--prepare-segments lhs))
|
||||||
(rhs-forms (doom-modeline--prepare-segments rhs)))
|
(rhs-forms (doom-modeline--prepare-segments rhs)))
|
||||||
|
@ -194,7 +125,7 @@ Throws an error if it doesn't exist."
|
||||||
(when (functionp fn)
|
(when (functionp fn)
|
||||||
`(:eval (,fn)))))
|
`(:eval (,fn)))))
|
||||||
|
|
||||||
(defun doom-modeline-set-modeline (key &optional default)
|
(defun doom-modeline-set (key &optional default)
|
||||||
"Set the modeline format. Does nothing if the modeline KEY doesn't exist.
|
"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."
|
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)))
|
||||||
|
@ -221,8 +152,8 @@ If STRICT-P, return nil if no project was found, otherwise return
|
||||||
"How wide the mode-line bar should be (only respected in GUI).")
|
"How wide the mode-line bar should be (only respected in GUI).")
|
||||||
|
|
||||||
(defvar doom-modeline-vspc
|
(defvar doom-modeline-vspc
|
||||||
"Text style with icons in mode-line."
|
(propertize " " 'face 'variable-pitch)
|
||||||
(propertize " " 'face 'variable-pitch))
|
"Text style with icons in mode-line.")
|
||||||
|
|
||||||
(defvar doom-modeline-buffer-file-name-style 'truncate-upto-project
|
(defvar doom-modeline-buffer-file-name-style 'truncate-upto-project
|
||||||
"Determines the style used by `doom-modeline-buffer-file-name'.
|
"Determines the style used by `doom-modeline-buffer-file-name'.
|
||||||
|
@ -351,23 +282,20 @@ active."
|
||||||
|
|
||||||
;; anzu and evil-anzu expose current/total state that can be displayed in the
|
;; anzu and evil-anzu expose current/total state that can be displayed in the
|
||||||
;; mode-line.
|
;; mode-line.
|
||||||
(when (featurep 'evil-anzu)
|
(setq anzu-cons-mode-line-p nil
|
||||||
(doom-modeline-add-transient-hook! #'evil-ex-start-search (require 'evil-anzu))
|
anzu-minimum-input-length 1
|
||||||
|
anzu-search-threshold 250)
|
||||||
|
|
||||||
(setq anzu-cons-mode-line-p nil
|
;; Avoid anzu conflicts across buffers
|
||||||
anzu-minimum-input-length 1
|
(mapc #'make-variable-buffer-local
|
||||||
anzu-search-threshold 250)
|
'(anzu--total-matched anzu--current-position anzu--state
|
||||||
|
anzu--cached-count anzu--cached-positions anzu--last-command
|
||||||
|
anzu--last-isearch-string anzu--overflow-p))
|
||||||
|
|
||||||
;; Avoid anzu conflicts across buffers
|
;; Ensure anzu state is cleared when searches & iedit are done
|
||||||
(mapc #'make-variable-buffer-local
|
(add-hook 'isearch-mode-end-hook #'anzu--reset-status t)
|
||||||
'(anzu--total-matched anzu--current-position anzu--state
|
;; (add-hook '+evil-esc-hook #'anzu--reset-status t)
|
||||||
anzu--cached-count anzu--cached-positions anzu--last-command
|
(add-hook 'iedit-mode-end-hook #'anzu--reset-status)
|
||||||
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
|
;; Keep `doom-modeline-current-window' up-to-date
|
||||||
|
@ -391,7 +319,8 @@ active."
|
||||||
;; Show version string for multi-version managers like rvm, rbenv, pyenv, etc.
|
;; Show version string for multi-version managers like rvm, rbenv, pyenv, etc.
|
||||||
(defvar-local doom-modeline-env-version nil)
|
(defvar-local doom-modeline-env-version nil)
|
||||||
(defvar-local doom-modeline-env-command nil)
|
(defvar-local doom-modeline-env-command nil)
|
||||||
(doom-modeline-add-hook! '(focus-in-hook find-file-hook) #'doom-modeline-update-env)
|
(add-hook 'focus-in-hook #'doom-modeline-update-env)
|
||||||
|
(add-hook 'find-file-hook #'doom-modeline-update-env)
|
||||||
(defun doom-modeline-update-env ()
|
(defun doom-modeline-update-env ()
|
||||||
"Update environment for mode-line."
|
"Update environment for mode-line."
|
||||||
(when doom-modeline-env-command
|
(when doom-modeline-env-command
|
||||||
|
@ -404,8 +333,12 @@ active."
|
||||||
;; Only support python and ruby for now
|
;; Only support python and ruby for now
|
||||||
|
|
||||||
;; TODO torgeir
|
;; TODO torgeir
|
||||||
(doom-modeline-add-hook! 'python-mode-hook (setq doom-modeline-env-command "python --version 2>&1 | cut -d' ' -f2"))
|
(add-hook 'python-mode-hook
|
||||||
(doom-modeline-add-hook! 'ruby-mode-hook (setq doom-modeline-env-command "ruby --version 2>&1 | cut -d' ' -f2"))
|
(lambda ()
|
||||||
|
(setq doom-modeline-env-command "python --version 2>&1 | cut -d' ' -f2")))
|
||||||
|
(add-hook 'ruby-mode-hook
|
||||||
|
(lambda ()
|
||||||
|
(setq doom-modeline-env-command "ruby --version 2>&1 | cut -d' ' -f2")))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Modeline helpers
|
;; Modeline helpers
|
||||||
|
@ -532,7 +465,7 @@ 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)))
|
||||||
|
@ -547,7 +480,7 @@ buffer where knowing the current project directory is important."
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
(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
|
||||||
|
@ -581,16 +514,16 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
||||||
"%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 ")
|
||||||
|
@ -603,7 +536,7 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
||||||
" "))
|
" "))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
(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)
|
||||||
|
@ -633,7 +566,7 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
||||||
(apply 'all-the-icons-material args)))
|
(apply 'all-the-icons-material args)))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
(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))
|
||||||
|
@ -681,23 +614,23 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
||||||
(propertize text 'face face))
|
(propertize text 'face face))
|
||||||
(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)))))
|
||||||
|
|
||||||
|
|
||||||
|
@ -707,7 +640,7 @@ icons."
|
||||||
(save-excursion (goto-char pos)
|
(save-excursion (goto-char pos)
|
||||||
(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)))
|
||||||
|
@ -802,37 +735,37 @@ Require `anzu', also `evil-anzu' if using `evil-mode'
|
||||||
length))
|
length))
|
||||||
'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 ()
|
||||||
"The eyebrowse number."
|
"The eyebrowse number."
|
||||||
|
@ -853,7 +786,7 @@ Returns \"\" to not break --no-window-system."
|
||||||
(eq (nth 3 edges)
|
(eq (nth 3 edges)
|
||||||
(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)
|
||||||
|
@ -874,7 +807,7 @@ Returns \"\" to not break --no-window-system."
|
||||||
(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)
|
||||||
|
@ -883,42 +816,42 @@ Returns \"\" to not break --no-window-system."
|
||||||
""))
|
""))
|
||||||
|
|
||||||
(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
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(doom-modeline-def-modeline! main
|
(doom-modeline-def main
|
||||||
(workspace-number bar matches " " buffer-info " %l:%c %p " selection-info)
|
(workspace-number bar matches " " buffer-info " %l:%c %p " selection-info)
|
||||||
(buffer-encoding major-mode vcs flycheck))
|
(buffer-encoding major-mode vcs flycheck))
|
||||||
|
|
||||||
(doom-modeline-def-modeline! minimal
|
(doom-modeline-def minimal
|
||||||
(bar matches " " buffer-info)
|
(bar matches " " buffer-info)
|
||||||
(media-info major-mode))
|
(media-info major-mode))
|
||||||
|
|
||||||
(doom-modeline-def-modeline! special
|
(doom-modeline-def special
|
||||||
(bar matches " " buffer-info-simple " %l:%c %p " selection-info)
|
(bar matches " " buffer-info-simple " %l:%c %p " selection-info)
|
||||||
(buffer-encoding major-mode flycheck))
|
(buffer-encoding major-mode flycheck))
|
||||||
|
|
||||||
(doom-modeline-def-modeline! project
|
(doom-modeline-def project
|
||||||
(bar buffer-default-directory)
|
(bar buffer-default-directory)
|
||||||
(major-mode))
|
(major-mode))
|
||||||
|
|
||||||
(doom-modeline-def-modeline! media
|
(doom-modeline-def media
|
||||||
(bar " %b ")
|
(bar " %b ")
|
||||||
(media-info major-mode))
|
(media-info major-mode))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Bootstrap
|
;; Bootstrap
|
||||||
|
@ -927,22 +860,22 @@ enabled."
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom-modeline-init ()
|
(defun doom-modeline-init ()
|
||||||
"Set the default modeline."
|
"Set the default modeline."
|
||||||
(doom-modeline-set-modeline 'main t)
|
(doom-modeline-set 'main t)
|
||||||
|
|
||||||
;; This scratch and messages buffer is already created and doesn't get a
|
;; This scratch and messages buffer is already created and doesn't get a
|
||||||
;; modeline.
|
;; modeline.
|
||||||
(with-current-buffer "*Messages*"
|
(with-current-buffer "*Messages*"
|
||||||
(doom-modeline-set-modeline 'main))
|
(doom-modeline-set 'main))
|
||||||
(with-current-buffer "*scratch*"
|
(with-current-buffer "*scratch*"
|
||||||
(doom-modeline-set-modeline 'main)))
|
(doom-modeline-set 'main)))
|
||||||
|
|
||||||
(defun doom-modeline-set-special-modeline ()
|
(defun doom-modeline-set-special-modeline ()
|
||||||
"Set the special modeline."
|
"Set the special modeline."
|
||||||
(doom-modeline-set-modeline 'special))
|
(doom-modeline-set 'special))
|
||||||
|
|
||||||
(defun doom-modeline-set-media-modeline ()
|
(defun doom-modeline-set-media-modeline ()
|
||||||
"Set the media modeline."
|
"Set the media modeline."
|
||||||
(doom-modeline-set-modeline 'media))
|
(doom-modeline-set 'media))
|
||||||
|
|
||||||
(add-hook 'image-mode-hook #'doom-modeline-set-media-modeline)
|
(add-hook 'image-mode-hook #'doom-modeline-set-media-modeline)
|
||||||
(add-hook 'org-src-mode-hook #'doom-modeline-set-special-modeline)
|
(add-hook 'org-src-mode-hook #'doom-modeline-set-special-modeline)
|
||||||
|
|
Loading…
Reference in a new issue