Reduce complexity and optimize performance for header-line
This commit is contained in:
parent
a1feb86eb8
commit
3d8a82fcb4
1 changed files with 19 additions and 10 deletions
|
@ -23,23 +23,32 @@
|
|||
|
||||
(add-hook 'after-make-frame-functions 'center-frame)
|
||||
|
||||
(defvar my-cached-vc-info "")
|
||||
(defun my-vc-info ()
|
||||
(setq my-cached-vc-info (when vc-mode
|
||||
(concat (substring vc-mode 5)
|
||||
" ["
|
||||
(substring (vc-working-revision (buffer-file-name)) 0 8)
|
||||
"] "))))
|
||||
|
||||
(defvar my-cached-project-name "")
|
||||
(defun my-project-name ()
|
||||
(setq my-cached-project-name (file-name-base (directory-file-name (project-root (project-current))))))
|
||||
|
||||
(add-hook 'after-save-hook 'my-vc-info)
|
||||
(add-hook 'after-save-hook 'my-project-name)
|
||||
|
||||
(setq-default header-line-format
|
||||
(list "%b %*%n %l:%c %p "
|
||||
'(:eval mode-name)
|
||||
'(:eval (format-mode-line minor-mode-alist))
|
||||
" "
|
||||
'(:eval (when vc-mode
|
||||
(concat (substring vc-mode 5)
|
||||
" ["
|
||||
(substring (vc-working-revision (buffer-file-name)) 0 8)
|
||||
"] ")))
|
||||
'(:eval mode-name) " "
|
||||
'(:eval my-cached-vc-info)
|
||||
'(:eval (if mode-line-process (concat ":" mode-line-process) ""))
|
||||
'(:eval (file-name-directory buffer-file-name))
|
||||
"-%-"))
|
||||
|
||||
(setq-default mode-line-format
|
||||
(list ""
|
||||
'(:eval (when-let ((project (project-current)))
|
||||
(concat (file-name-base (directory-file-name (project-root project))) " ")))
|
||||
'(:eval my-cached-project-name) " "
|
||||
global-mode-string
|
||||
'(:eval (concat system-name " " user-login-name))
|
||||
" "
|
||||
|
|
Loading…
Add table
Reference in a new issue