mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-23 19:19:50 +00:00
[Feature] timemachine mode-line for git-timemachine-mode.
This commit is contained in:
parent
3167beda51
commit
46338a560d
2 changed files with 77 additions and 39 deletions
|
@ -371,48 +371,53 @@ mouse-1: Previous buffer\nmouse-3: Next buffer"
|
|||
(if buffer-file-name
|
||||
(doom-modeline-update-buffer-file-name))))))))
|
||||
|
||||
(defsubst doom-modeline--buffer-mode-icon ()
|
||||
"The icon of the current major mode."
|
||||
(when (and doom-modeline-icon doom-modeline-major-mode-icon)
|
||||
(when-let ((icon (or doom-modeline--buffer-file-icon
|
||||
(doom-modeline-update-buffer-file-icon))))
|
||||
(when icon
|
||||
(concat
|
||||
(if (doom-modeline--active)
|
||||
icon
|
||||
(propertize icon 'face `(:inherit
|
||||
,(let* ((props (get-text-property 0 'face icon)))
|
||||
(if doom-modeline-major-mode-color-icon
|
||||
props (remove :inherit props)))
|
||||
:inherit
|
||||
mode-line-inactive)))
|
||||
(doom-modeline-vspc))))))
|
||||
|
||||
(defsubst doom-modeline--buffer-state-icon ()
|
||||
"The icon of the current buffer state."
|
||||
(when-let ((icon (or doom-modeline--buffer-file-state-icon
|
||||
(doom-modeline-update-buffer-file-state-icon))))
|
||||
(when icon
|
||||
(concat
|
||||
(if (doom-modeline--active)
|
||||
icon
|
||||
(propertize icon 'face `(:inherit
|
||||
,(get-text-property 0 'face icon)
|
||||
:inherit
|
||||
mode-line-inactive)))
|
||||
(doom-modeline-vspc)))))
|
||||
|
||||
(defsubst doom-modeline--buffer-name ()
|
||||
"The current buffer name."
|
||||
(when-let ((name (or doom-modeline--buffer-file-name
|
||||
(doom-modeline-update-buffer-file-name))))
|
||||
(if (doom-modeline--active)
|
||||
name
|
||||
(propertize name 'face 'mode-line-inactive))))
|
||||
|
||||
(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)."
|
||||
(let ((active (doom-modeline--active)))
|
||||
(concat
|
||||
(doom-modeline-whitespace)
|
||||
|
||||
;; major mode icon
|
||||
(when (and doom-modeline-icon doom-modeline-major-mode-icon)
|
||||
(when-let ((icon (or doom-modeline--buffer-file-icon
|
||||
(doom-modeline-update-buffer-file-icon))))
|
||||
(when icon
|
||||
(concat
|
||||
(if active
|
||||
icon
|
||||
(propertize icon 'face `(:inherit
|
||||
,(let* ((props (get-text-property 0 'face icon)))
|
||||
(if doom-modeline-major-mode-color-icon
|
||||
props (remove :inherit props)))
|
||||
:inherit
|
||||
mode-line-inactive)))
|
||||
(doom-modeline-vspc)))))
|
||||
|
||||
;; state icon
|
||||
(when-let ((icon (or doom-modeline--buffer-file-state-icon
|
||||
(doom-modeline-update-buffer-file-state-icon))))
|
||||
(when icon
|
||||
(concat
|
||||
(if active
|
||||
icon
|
||||
(propertize icon 'face `(:inherit
|
||||
,(get-text-property 0 'face icon)
|
||||
:inherit
|
||||
mode-line-inactive)))
|
||||
(doom-modeline-vspc))))
|
||||
|
||||
;; buffer file name
|
||||
(when-let ((name (or doom-modeline--buffer-file-name
|
||||
(doom-modeline-update-buffer-file-name))))
|
||||
(if active
|
||||
name
|
||||
(propertize name 'face 'mode-line-inactive))))))
|
||||
(concat
|
||||
(doom-modeline-whitespace)
|
||||
(doom-modeline--buffer-mode-icon)
|
||||
(doom-modeline--buffer-state-icon)
|
||||
(doom-modeline--buffer-name)))
|
||||
|
||||
(doom-modeline-def-segment buffer-info-simple
|
||||
"Display only the current buffer's name, but with fontification."
|
||||
|
@ -2238,6 +2243,29 @@ The cdr can also be a function that returns a name to use.")
|
|||
(eq 1 (cdr (assq 'follow doom-modeline--helm-current-source))))
|
||||
"HF"))
|
||||
|
||||
;;
|
||||
;; git timemachine
|
||||
;;
|
||||
|
||||
(doom-modeline-def-segment git-timemachine
|
||||
(let ((active (doom-modeline--active)))
|
||||
(concat
|
||||
(doom-modeline-whitespace)
|
||||
|
||||
(doom-modeline--buffer-mode-icon)
|
||||
|
||||
;; snapshot icon
|
||||
(doom-modeline-buffer-file-state-icon
|
||||
"camera_alt"
|
||||
"%1*"
|
||||
(if active 'doom-modeline-warning 'mode-line-inactive))
|
||||
(doom-modeline-vspc)
|
||||
|
||||
;; buffer name
|
||||
(propertize "%b" 'face (if active
|
||||
'doom-modeline-buffer-file
|
||||
'mode-line-inactive)))))
|
||||
|
||||
(provide 'doom-modeline-segments)
|
||||
|
||||
;;; doom-modeline-segments.el ends here
|
||||
|
|
|
@ -121,6 +121,9 @@
|
|||
'(bar helm-buffer-id helm-number helm-follow helm-prefix-argument)
|
||||
'(helm-help))
|
||||
|
||||
(doom-modeline-def-modeline 'timemachine
|
||||
'(bar window-number matches git-timemachine buffer-position parrot selection-info)
|
||||
'(misc-info fancy-battery mu4e github debug minor-modes indent-info buffer-encoding major-mode))
|
||||
|
||||
;;
|
||||
;; Interfaces
|
||||
|
@ -178,6 +181,11 @@ If DEFAULT is non-nil, set the default mode-line for all buffers."
|
|||
"Set helm mode-line."
|
||||
(doom-modeline-set-modeline 'helm))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom-modeline-set-timemachine-modeline (&rest _)
|
||||
"Set timemachine mode-line."
|
||||
(doom-modeline-set-modeline 'timemachine))
|
||||
|
||||
|
||||
;;
|
||||
;; Mode
|
||||
|
@ -210,6 +218,7 @@ If DEFAULT is non-nil, set the default mode-line for all buffers."
|
|||
(add-hook 'image-mode-hook #'doom-modeline-set-media-modeline)
|
||||
(add-hook 'circe-mode-hook #'doom-modeline-set-special-modeline)
|
||||
(add-hook 'pdf-view-mode-hook #'doom-modeline-set-pdf-modeline)
|
||||
(add-hook 'git-timemachine-mode-hook #'doom-modeline-set-timemachine-modeline)
|
||||
(add-hook 'paradox-menu-mode-hook #'doom-modeline-set-package-modeline)
|
||||
;; Add advice
|
||||
(advice-add #'helm-display-mode-line :override #'doom-modeline-set-helm-modeline))
|
||||
|
@ -224,6 +233,7 @@ If DEFAULT is non-nil, set the default mode-line for all buffers."
|
|||
(remove-hook 'image-mode-hook #'doom-modeline-set-media-modeline)
|
||||
(remove-hook 'circe-mode-hook #'doom-modeline-set-special-modeline)
|
||||
(remove-hook 'pdf-view-mode-hook #'doom-modeline-set-pdf-modeline)
|
||||
(remove-hook 'git-timemachine-mode-hook #'doom-modeline-set-timemachine-modeline)
|
||||
(remove-hook 'paradox-menu-mode-hook #'doom-modeline-set-package-modeline)
|
||||
;; Remove advices
|
||||
(advice-remove #'helm-display-mode-line #'doom-modeline-set-helm-modeline))))
|
||||
|
|
Loading…
Reference in a new issue