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