ui/doom-modeline: minor refactor
This commit is contained in:
parent
6b453962d7
commit
d01deb5545
1 changed files with 39 additions and 14 deletions
|
@ -42,6 +42,10 @@
|
|||
(add-hook 'doom-escape-hook #'anzu--reset-status t)
|
||||
(add-hook 'iedit-mode-end-hook #'anzu--reset-status))
|
||||
|
||||
;; fish-style modeline
|
||||
(def-package! shrink-path
|
||||
:commands (shrink-path-prompt shrink-path-file-mixed))
|
||||
|
||||
|
||||
;; Keep `+doom-modeline-current-window' up-to-date
|
||||
(defvar +doom-modeline-current-window (frame-selected-window))
|
||||
|
@ -56,10 +60,6 @@
|
|||
(advice-add #'handle-switch-frame :after #'+doom-modeline|set-selected-window)
|
||||
(advice-add #'select-window :after #'+doom-modeline|set-selected-window)
|
||||
|
||||
;; fish-style modeline
|
||||
(def-package! shrink-path
|
||||
:commands (shrink-path-prompt shrink-path-file-mixed))
|
||||
|
||||
|
||||
;;
|
||||
;; Variables
|
||||
|
@ -288,7 +288,7 @@ Example:
|
|||
|
||||
|
||||
;;
|
||||
;; Segments
|
||||
;; buffer information
|
||||
;;
|
||||
|
||||
(def-modeline-segment! buffer-default-directory
|
||||
|
@ -304,7 +304,6 @@ buffer where knowing the current project directory is important."
|
|||
(propertize (concat " " (abbreviate-file-name default-directory))
|
||||
'face face))))
|
||||
|
||||
;;
|
||||
(def-modeline-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)."
|
||||
|
@ -337,7 +336,6 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
|||
(+doom-modeline-buffer-file-name)
|
||||
"%b")))
|
||||
|
||||
;;
|
||||
(def-modeline-segment! buffer-info-simple
|
||||
"Display only the current buffer's name, but with fontification."
|
||||
(propertize
|
||||
|
@ -346,7 +344,6 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
|||
'doom-modeline-buffer-modified)
|
||||
((active) 'doom-modeline-buffer-file))))
|
||||
|
||||
;;
|
||||
(def-modeline-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)
|
||||
|
@ -359,7 +356,11 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
|||
(t (upcase (symbol-name (plist-get sys :name))))))
|
||||
" "))
|
||||
|
||||
|
||||
;;
|
||||
;; major-mode
|
||||
;;
|
||||
|
||||
(def-modeline-segment! major-mode
|
||||
"The major mode, including process, environment and text-scale info."
|
||||
(propertize
|
||||
|
@ -371,7 +372,11 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
|||
(format " (%+d)" text-scale-mode-amount)))
|
||||
'face (if (active) 'doom-modeline-buffer-major-mode)))
|
||||
|
||||
|
||||
;;
|
||||
;; vcs
|
||||
;;
|
||||
|
||||
(def-modeline-segment! vcs
|
||||
"Displays the current branch, colored based on its state."
|
||||
(when (and vc-mode buffer-file-name)
|
||||
|
@ -407,7 +412,11 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
|||
'face (if active face))
|
||||
" ")))))
|
||||
|
||||
|
||||
;;
|
||||
;; flycheck
|
||||
;;
|
||||
|
||||
(defun +doom-ml-icon (icon &optional text face voffset)
|
||||
"Displays an octicon ICON with FACE, followed by TEXT. Uses
|
||||
`all-the-icons-octicon' to fetch the icon."
|
||||
|
@ -416,8 +425,7 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
|||
(concat
|
||||
(all-the-icons-material icon :face face :height 1.1 :v-adjust (or voffset -0.2))
|
||||
(if text +doom-modeline-vspc)))
|
||||
(when text
|
||||
(propertize text 'face face))
|
||||
(if text (propertize text 'face face))
|
||||
(if vc-mode " " " ")))
|
||||
|
||||
(defvar-local +doom-modeline--flycheck nil)
|
||||
|
@ -443,7 +451,11 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
|||
icons."
|
||||
+doom-modeline--flycheck)
|
||||
|
||||
|
||||
;;
|
||||
;; selection-info
|
||||
;;
|
||||
|
||||
(defsubst doom-column (pos)
|
||||
(save-excursion (goto-char pos)
|
||||
(current-column)))
|
||||
|
@ -480,6 +492,9 @@ lines are selected, or the NxM dimensions of a block selection."
|
|||
|
||||
|
||||
;;
|
||||
;; matches (anzu, evil-substitute, iedit, macro)
|
||||
;;
|
||||
|
||||
(defun +doom-modeline--macro-recording ()
|
||||
"Display current Emacs or evil macro being recorded."
|
||||
(when (and (active) (or defining-kbd-macro executing-kbd-macro))
|
||||
|
@ -561,14 +576,24 @@ with `evil-ex-substitute', and/or 4. The number of active `iedit' regions."
|
|||
(or (and (not (equal meta "")) meta)
|
||||
(if buffer-file-name " %I "))))
|
||||
|
||||
;; TODO Include other information
|
||||
|
||||
;;
|
||||
;; media-info
|
||||
;;
|
||||
|
||||
(def-modeline-segment! media-info
|
||||
"Metadata regarding the current file, such as dimensions for images."
|
||||
;; TODO Include other information
|
||||
(cond ((eq major-mode 'image-mode)
|
||||
(cl-destructuring-bind (width . height)
|
||||
(image-size (image-get-display-property) :pixels)
|
||||
(format " %dx%d " width height)))))
|
||||
|
||||
|
||||
;;
|
||||
;; bar
|
||||
;;
|
||||
|
||||
(defvar +doom-modeline--bar-active nil)
|
||||
(defvar +doom-modeline--bar-inactive nil)
|
||||
(def-modeline-segment! bar
|
||||
|
@ -612,7 +637,7 @@ Returns \"\" to not break --no-window-system."
|
|||
|
||||
(defun +doom-modeline|init ()
|
||||
;; Create bars
|
||||
(setq +doom-modeline--bar-active (+doom-modeline--make-xpm 'doom-modeline-bar)
|
||||
(setq +doom-modeline--bar-active (+doom-modeline--make-xpm 'doom-modeline-bar)
|
||||
+doom-modeline--bar-inactive (+doom-modeline--make-xpm 'doom-modeline-inactive-bar))
|
||||
|
||||
;; These buffers are already created and don't get modelines. For the love of
|
||||
|
@ -641,5 +666,5 @@ Returns \"\" to not break --no-window-system."
|
|||
(add-hook 'doom-scratch-buffer-hook #'+doom-modeline|set-special-modeline)
|
||||
(add-hook '+doom-dashboard-mode-hook #'+doom-modeline|set-project-modeline)
|
||||
|
||||
(add-hook 'image-mode-hook #'+doom-modeline|set-media-modeline)
|
||||
(add-hook 'circe-mode-hook #'+doom-modeline|set-special-modeline)
|
||||
(add-hook 'image-mode-hook #'+doom-modeline|set-media-modeline)
|
||||
(add-hook 'circe-mode-hook #'+doom-modeline|set-special-modeline)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue