Add mouse-over info to modeline segments

Also extracts indentation style info from +modeline-encoding into new
+modeline-indent-style segment.
This commit is contained in:
Henrik Lissner 2018-10-03 02:33:18 -04:00
parent 702e0a6159
commit f20cfd21c2
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -439,10 +439,13 @@ Meant for `+modeline-buffer-path-function'."
:on-hooks (find-file-hook after-save-hook after-revert-hook) :on-hooks (find-file-hook after-save-hook after-revert-hook)
:init (propertize "%b" 'face 'doom-modeline-buffer-file) :init (propertize "%b" 'face 'doom-modeline-buffer-file)
:faces t :faces t
(+modeline-build-path (buffer-file-name (buffer-base-buffer)))) (let ((file-path (buffer-file-name (buffer-base-buffer))))
(propertize (+modeline-build-path file-path)
'help-echo file-path)))
(def-modeline-segment! +modeline-buffer-directory (def-modeline-segment! +modeline-buffer-directory
(let ((face (if (active) 'doom-modeline-buffer-path))) (let ((face (if (active) 'doom-modeline-buffer-path)))
(propertize
(concat (if (display-graphic-p) " ") (concat (if (display-graphic-p) " ")
(all-the-icons-octicon (all-the-icons-octicon
"file-directory" "file-directory"
@ -451,7 +454,8 @@ Meant for `+modeline-buffer-path-function'."
:height 1.25) :height 1.25)
" " " "
(propertize (abbreviate-file-name default-directory) (propertize (abbreviate-file-name default-directory)
'face face)))) 'face face))
'help-echo default-directory)))
(def-modeline-segment! +modeline-vcs (def-modeline-segment! +modeline-vcs
:on-set (vc-mode) :on-set (vc-mode)
@ -486,25 +490,36 @@ Meant for `+modeline-buffer-path-function'."
(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)))))))
(def-modeline-segment! +modeline-indent-style
:on-hooks (after-revert-hook after-save-hook find-file-hook)
:on-set (indent-tabs-mode tab-width)
(propertize (format "%s%d "
(if indent-tabs-mode "" "")
tab-width)
'help-echo
(format "Indentation: %d %s wide"
tab-width
(if indent-tabs-mode "tabs" "spaces"))))
(def-modeline-segment! +modeline-encoding (def-modeline-segment! +modeline-encoding
:on-hooks (after-revert-hook after-save-hook find-file-hook) :on-hooks (after-revert-hook after-save-hook find-file-hook)
:on-set (buffer-file-coding-system indent-tabs-mode tab-width) :on-set (buffer-file-coding-system)
(format "%s%d %s %s" (concat (pcase (coding-system-eol-type buffer-file-coding-system)
(if indent-tabs-mode "" "") (0 (propertize "LF" 'help-echo "EOL convention: \\n (Unix)"))
tab-width (1 (propertize "CRLF" 'help-echo "EOL convention: \\r\\n (Windows, Symbian OS, etc)"))
(pcase (coding-system-eol-type buffer-file-coding-system) (2 (propertize "CR" 'help-echo "EOL convention: \\r (pre-OSX MacOS)")))
(0 "LF") " "
(1 "CRLF")
(2 "CR"))
(let* ((sys (coding-system-plist buffer-file-coding-system)) (let* ((sys (coding-system-plist buffer-file-coding-system))
(category (plist-get sys :category))) (category (plist-get sys :category)))
(propertize
(cond ((eq category 'coding-category-undecided) (cond ((eq category 'coding-category-undecided)
"") "")
((or (eq category 'coding-category-utf-8) ((or (eq category 'coding-category-utf-8)
(eq (plist-get sys :name) 'prefer-utf-8)) (eq (plist-get sys :name) 'prefer-utf-8))
"UTF-8 ") "UTF-8 ")
((concat (upcase (symbol-name (plist-get sys :name))) ((concat (upcase (symbol-name (plist-get sys :name)))
" ")))))) " ")))
'help-echo (plist-get (coding-system-plist buffer-file-coding-system) :docstring)))))
(def-modeline-segment! +modeline-major-mode (def-modeline-segment! +modeline-major-mode
(propertize (format-mode-line mode-name) (propertize (format-mode-line mode-name)
@ -680,6 +695,7 @@ icons."
+modeline-buffer-id +modeline-buffer-id
" %2l:%c %p ") " %2l:%c %p ")
`(mode-line-misc-info `(mode-line-misc-info
+modeline-indent-style
+modeline-encoding +modeline-encoding
+modeline-major-mode " " +modeline-major-mode " "
(vc-mode (" " +modeline-vcs " ")) (vc-mode (" " +modeline-vcs " "))