From 7ce5e477f320708230fa897c662ccafb1319633a Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Fri, 10 May 2019 01:53:14 +0800 Subject: [PATCH] [Feature] Info mode-line. --- doom-modeline-segments.el | 35 ++++++++++++++++++++++++++++++++++- doom-modeline.el | 35 +++++++++++++++++++++++------------ 2 files changed, 57 insertions(+), 13 deletions(-) diff --git a/doom-modeline-segments.el b/doom-modeline-segments.el index b18a301..9c4e8d7 100644 --- a/doom-modeline-segments.el +++ b/doom-modeline-segments.el @@ -39,6 +39,9 @@ ;; Externals ;; +(defvar Info-current-file) +(defvar Info-current-node) +(defvar Info-mode-line-node-keymap) (defvar anzu--cached-count) (defvar anzu--current-position) (defvar anzu--overflow-p) @@ -1517,6 +1520,36 @@ mouse-3: Describe current input method") 'local-map mode-line-input-method-map)) +;; +;; Info +;; + +(doom-modeline-def-segment info + "The segment for `Info-mode'." + (let ((active (doom-modeline--active))) + (concat + " (" + ;; topic + (propertize (if (stringp Info-current-file) + (replace-regexp-in-string + "%" "%%" + (file-name-sans-extension + (file-name-nondirectory Info-current-file))) + (format "*%S*" Info-current-file)) + 'face (if active 'doom-modeline-info 'mode-line-inactive)) + ") " + ;; node + (if Info-current-node + (propertize (replace-regexp-in-string + "%" "%%" Info-current-node) + 'face (if active 'doom-modeline-buffer-path 'mode-line-inactive) + 'help-echo + "mouse-1: scroll forward, mouse-3: scroll back" + 'mouse-face 'mode-line-highlight + 'local-map Info-mode-line-node-keymap) + "")))) + + ;; ;; LSP ;; @@ -2065,7 +2098,7 @@ we don't want to remove that so we just return the original." (when (and doom-modeline-icon doom-modeline-major-mode-icon) (concat " " - (let ((icon (doom-modeline-icon-for-mode 'paradox-menu-mode))) + (let ((icon (doom-modeline-icon-for-mode 'paradox-menu-mode :v-adjust -0.15))) (propertize icon 'face `(:inherit ,(let ((props (get-text-property 0 'face icon))) (if doom-modeline-major-mode-color-icon diff --git a/doom-modeline.el b/doom-modeline.el index 51877a0..4f88e3e 100644 --- a/doom-modeline.el +++ b/doom-modeline.el @@ -98,6 +98,14 @@ '(bar window-number " " buffer-default-directory) '(misc-info fancy-battery mu4e github debug " " major-mode process)) +(doom-modeline-def-modeline 'package + '(bar window-number package) + '(misc-info " " major-mode process)) + +(doom-modeline-def-modeline 'info + '(bar window-number buffer-info info buffer-position parrot selection-info) + '(misc-info buffer-encoding major-mode)) + (doom-modeline-def-modeline 'media '(bar window-number buffer-size buffer-info) '(misc-info media-info major-mode process vcs)) @@ -106,10 +114,6 @@ '(bar window-number buffer-size buffer-info pdf-pages) '(misc-info " " major-mode process vcs)) -(doom-modeline-def-modeline 'package - '(bar window-number package) - '(misc-info " " major-mode process)) - ;; ;; Interfaces @@ -137,26 +141,31 @@ If DEFAULT is non-nil, set the default mode-line for all buffers." "Set sepcial mode-line." (doom-modeline-set-modeline 'special)) -;;;###autoload -(defun doom-modeline-set-media-modeline () - "Set media mode-line." - (doom-modeline-set-modeline 'media)) - ;;;###autoload (defun doom-modeline-set-project-modeline () "Set project mode-line." (doom-modeline-set-modeline 'project)) ;;;###autoload -(defun doom-modeline-set-pdf-modeline () - "Set pdf mode-line." - (doom-modeline-set-modeline 'pdf)) +(defun doom-modeline-set-info-modeline () + "Set Info mode-line." + (doom-modeline-set-modeline 'info)) ;;;###autoload (defun doom-modeline-set-package-modeline () "Set package mode-line." (doom-modeline-set-modeline 'package)) +;;;###autoload +(defun doom-modeline-set-media-modeline () + "Set media mode-line." + (doom-modeline-set-modeline 'media)) + +;;;###autoload +(defun doom-modeline-set-pdf-modeline () + "Set pdf mode-line." + (doom-modeline-set-modeline 'pdf)) + ;; ;; Mode @@ -181,6 +190,7 @@ If DEFAULT is non-nil, set the default mode-line for all buffers." (with-current-buffer bname (doom-modeline-set-main-modeline)))) ;; Add hooks + (add-hook 'Info-mode-hook #'doom-modeline-set-info-modeline) (add-hook 'magit-mode-hook #'doom-modeline-set-project-modeline) (add-hook 'dashboard-mode-hook #'doom-modeline-set-project-modeline) (add-hook 'image-mode-hook #'doom-modeline-set-media-modeline) @@ -191,6 +201,7 @@ If DEFAULT is non-nil, set the default mode-line for all buffers." ;; Restore mode-line (setq-default mode-line-format doom-modeline--default-mode-line) ;; Remove hooks + (remove-hook 'Info-mode-hook #'doom-modeline-set-info-modeline) (remove-hook 'magit-mode-hook #'doom-modeline-set-project-modeline) (remove-hook 'dashboard-mode-hook #'doom-modeline-set-project-modeline) (remove-hook 'image-mode-hook #'doom-modeline-set-media-modeline)