mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-23 19:19:50 +00:00
Revert performance optimization for buffer info.
Because the buffer info will be updated in many scenarios and no need to handle all cases in hooks or advices. But Keep showing buffer name if it doesn't equal the file name.
This commit is contained in:
parent
f336f37efa
commit
9701be775c
1 changed files with 16 additions and 29 deletions
|
@ -609,33 +609,20 @@ buffer where knowing the current project directory is important."
|
||||||
'face face))))
|
'face face))))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
(defvar-local doom-modeline-buffer-file-name
|
(defun doom-modeline-update-buffer-file-name ()
|
||||||
(propertize "%b" 'face 'doom-modeline-buffer-file))
|
"Update buffer file name in mode-line.
|
||||||
(defun doom-modeline-update-buffer-file-name (&rest _)
|
|
||||||
"Propertized variable `buffer-file-name' based on `doom-modeline-buffer-file-name-style'."
|
|
||||||
(setq doom-modeline-buffer-file-name
|
|
||||||
;; Show buffer name if it doesn't equal the file name.
|
|
||||||
;; NOTE: Format: "buffer-file-name[buffer-name]".
|
|
||||||
;; Except the same buffer names in different directories.
|
|
||||||
(when-let ((file-name (doom-modeline-buffer-file-name))
|
|
||||||
(buffer-name (buffer-name))
|
|
||||||
(buffer-file-name buffer-file-name))
|
|
||||||
(if (string-equal
|
|
||||||
(file-name-nondirectory buffer-file-name)
|
|
||||||
(replace-regexp-in-string "<.+>$" "" buffer-name))
|
|
||||||
file-name
|
|
||||||
(format "%s[%s]" file-name buffer-name)))))
|
|
||||||
(add-hook 'find-file-hook #'doom-modeline-update-buffer-file-name)
|
|
||||||
(add-hook 'after-revert-hook #'doom-modeline-update-buffer-file-name)
|
|
||||||
(add-hook 'after-save-hook #'doom-modeline-update-buffer-file-name)
|
|
||||||
(advice-add #'rename-buffer :after #'doom-modeline-update-buffer-file-name)
|
|
||||||
|
|
||||||
(when (>= emacs-major-version 26)
|
Show buffer name if it doesn't equal the file name.
|
||||||
(add-variable-watcher
|
Format: \"buffer-file-name[buffer-name]\".
|
||||||
'doom-modeline-buffer-file-name-style
|
Except the same buffer names in different directories."
|
||||||
(lambda (_sym _val op _where)
|
(when-let ((file-name (doom-modeline-buffer-file-name))
|
||||||
(when (eq op 'set)
|
(buffer-name (buffer-name))
|
||||||
(doom-modeline-update-buffer-file-name)))))
|
(buffer-file-name buffer-file-name))
|
||||||
|
(if (string-equal
|
||||||
|
(file-name-nondirectory buffer-file-name)
|
||||||
|
(replace-regexp-in-string "<.+>$" "" buffer-name))
|
||||||
|
file-name
|
||||||
|
(format "%s[%s]" file-name buffer-name))))
|
||||||
|
|
||||||
(doom-modeline-def-segment buffer-info
|
(doom-modeline-def-segment buffer-info
|
||||||
"Combined information about the current buffer, including the current working
|
"Combined information about the current buffer, including the current working
|
||||||
|
@ -668,9 +655,9 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
||||||
:face 'doom-modeline-warning
|
:face 'doom-modeline-warning
|
||||||
:v-adjust -0.05)
|
:v-adjust -0.05)
|
||||||
" "))))
|
" "))))
|
||||||
(if (and active buffer-file-name)
|
(if buffer-file-name
|
||||||
doom-modeline-buffer-file-name
|
(doom-modeline-update-buffer-file-name)
|
||||||
(propertize "%b" 'face (if active 'doom-modeline-buffer-file))))))
|
"%b"))))
|
||||||
|
|
||||||
(doom-modeline-def-segment buffer-info-simple
|
(doom-modeline-def-segment buffer-info-simple
|
||||||
"Display only the current buffer's name, but with fontification."
|
"Display only the current buffer's name, but with fontification."
|
||||||
|
|
Loading…
Reference in a new issue