From f21945a5afa22e051d3888b8dcacb2b27900403f Mon Sep 17 00:00:00 2001 From: JSDurand Date: Thu, 24 Dec 2020 16:27:22 +0800 Subject: More progess --- modeline.el | 144 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 72 insertions(+), 72 deletions(-) (limited to 'modeline.el') diff --git a/modeline.el b/modeline.el index 54bee5c..3fce55c 100644 --- a/modeline.el +++ b/modeline.el @@ -92,9 +92,9 @@ MAP is the local keymap of the text." "Refresh the focus state of the mode line." (setq modeline-active-window nil) (mapc (lambda (frame) - (cond ((eq (frame-focus-state frame) t) - (setq modeline-active-window (modeline-get-active-window frame))))) - (frame-list))) + (cond ((eq (frame-focus-state frame) t) + (setq modeline-active-window (modeline-get-active-window frame))))) + (frame-list))) (add-hook 'window-configuration-change-hook #'modeline-set-active-window) (add-hook 'buffer-list-update-hook #'modeline-set-active-window) @@ -134,9 +134,9 @@ MAP is the local keymap of the text." (defun modeline-spc () "A space with the appropriate face." (format-mode-line " " - (cond ((modeline-active-window-p) - 'mode-line) - (t 'mode-line-inactive)))) + (cond ((modeline-active-window-p) + 'mode-line) + (t 'mode-line-inactive)))) ;;;###autoload (defvar modeline-bar-width 3 @@ -226,8 +226,8 @@ W is the width, H is the height of the bar." data ",\n") "\n};") 'xpm t :ascent 'center)))) - modeline-bar-img-inactive - (propertize + modeline-bar-img-inactive + (propertize " " 'display (let ((data (make-list modeline-bar-height (make-list modeline-bar-width 97))) @@ -254,7 +254,7 @@ W is the width, H is the height of the bar." ((and (display-graphic-p) (image-type-available-p 'xpm)) (cond ((modeline-active-window-p) modeline-bar-img) - (t modeline-bar-img-inactive))))) + (t modeline-bar-img-inactive))))) ;;;###autoload (defun modeline-format-buffer-status () @@ -264,23 +264,23 @@ W is the width, H is the height of the bar." ;; modified or not (cond ((and buffer-file-name (buffer-modified-p)) (format-mode-line "M" (cond - (active-p - 'doom-modeline-buffer-modified) - (t 'mode-line-inactive))))) + (active-p + 'doom-modeline-buffer-modified) + (t 'mode-line-inactive))))) ;; read-only? (cond (buffer-read-only (format-mode-line "R" (cond - (active-p - 'doom-modeline-urgent) - (t 'mode-line-inactive))))) + (active-p + 'doom-modeline-urgent) + (t 'mode-line-inactive))))) ;; narrow? (cond ((buffer-narrowed-p) (format-mode-line "N" (cond - (active-p - 'doom-modeline-warning) - (t 'mode-line-inactive)))))))) + (active-p + 'doom-modeline-warning) + (t 'mode-line-inactive)))))))) ;;;###autoload (defun modeline-format-position () @@ -288,11 +288,11 @@ W is the width, H is the height of the bar." (modeline-propertize (format-mode-line (concat "%l:%C " - (let ((orig (format-mode-line "%p"))) - (cond - ((memq (aref orig 0) (number-sequence 48 57)) - (concat orig "%%%")) - (t (substring orig 0 3))))) + (let ((orig (format-mode-line "%p"))) + (cond + ((memq (aref orig 0) (number-sequence 48 57)) + (concat orig "%%%")) + (t (substring orig 0 3))))) (cond ((modeline-active-window-p) 'mode-line) (t 'mode-line-inactive))) @@ -321,7 +321,7 @@ W is the width, H is the height of the bar." (let ((map (make-sparse-keymap))) (define-key map [mode-line mouse-1] #'ibuffer) (setq mode-line-buffer-identification-keymap - map)) + map)) ;;;###autoload (defun modeline-format-buffer-name () @@ -330,20 +330,20 @@ This will be displayed in the mode line." (declare (pure t) (side-effect-free t)) (modeline-propertize (let ((orig - (format-mode-line - "%b" (cond ((modeline-active-window-p) - 'mode-line-buffer-id) - (t 'mode-line-inactive))))) + (format-mode-line + "%b" (cond ((modeline-active-window-p) + 'mode-line-buffer-id) + (t 'mode-line-inactive))))) (cond ((> (length orig) modeline-buffer-name-len-max) (concat - (substring orig 0 (- modeline-buffer-name-len-max 3)) - "...")) + (substring orig 0 (- modeline-buffer-name-len-max 3)) + "...")) (t orig))) nil (concat (buffer-file-name) - "\n" - "mouse-1: ibuffer") + "\n" + "mouse-1: ibuffer") mode-line-buffer-identification-keymap)) ;;;###autoload @@ -354,14 +354,14 @@ This will be displayed in the mode line." (format-mode-line "%m" (cond ((modeline-active-window-p) - 'doom-modeline-buffer-major-mode) - (t 'mode-line-inactive))) + 'doom-modeline-buffer-major-mode) + (t 'mode-line-inactive))) nil "Major mode\nmouse-1: Display major mode menu\nmouse-2: Show help for major mode\nmouse-3: Toggle minor modes" mode-line-major-mode-keymap)) ;;;###autoload -(defvar modeline-vcs-str "" +(defvar-local modeline-vcs-str "" "Display the version control system information on the mode line.") ;;;###autoload (defvar modeline-vcs-length-max 12 @@ -376,41 +376,41 @@ This will be displayed in the mode line." (cond ((and vc-mode bfn) (let* ((backend (vc-backend bfn)) - (state (vc-state bfn backend)) - (indicator (cond - ((memq state '(added edited)) - (format-mode-line - "* " 'doom-modeline-info)) - ((eq state 'needs-merge) - (format-mode-line - "? " 'doom-modeline-info)) - ((eq state 'needs-update) - (format-mode-line - "! " 'doom-modeline-warning)) - ((memq state '(removed conflict unregistered)) - (format-mode-line - "! " 'doom-modeline-urgent)) - (t (format-mode-line - "@ " 'doom-modeline-info)))) - (str (cond (vc-display-status - (substring vc-mode (+ (cond ((eq backend 'Hg) 2) - (t 3)) - 2))) - (t "")))) - (concat - indicator - (propertize - (cond - ((> (length str) modeline-vcs-length-max) - (concat (substring str 0 (- modeline-vcs-length-max 3)) - "...")) - (t str)) - 'face (cond - ((eq state 'needs-update) - 'doom-modeline-warning) - ((memq state '(removed conflict unregistered)) - 'doom-modeline-urgent) - (t 'doom-modeline-info)))))) + (state (vc-state bfn backend)) + (indicator (cond + ((memq state '(added edited)) + (format-mode-line + "* " 'doom-modeline-info)) + ((eq state 'needs-merge) + (format-mode-line + "? " 'doom-modeline-info)) + ((eq state 'needs-update) + (format-mode-line + "! " 'doom-modeline-warning)) + ((memq state '(removed conflict unregistered)) + (format-mode-line + "! " 'doom-modeline-urgent)) + (t (format-mode-line + "@ " 'doom-modeline-info)))) + (str (cond (vc-display-status + (substring vc-mode (+ (cond ((eq backend 'Hg) 2) + (t 3)) + 2))) + (t "")))) + (concat + indicator + (propertize + (cond + ((> (length str) modeline-vcs-length-max) + (concat (substring str 0 (- modeline-vcs-length-max 3)) + "...")) + (t str)) + 'face (cond + ((eq state 'needs-update) + 'doom-modeline-warning) + ((memq state '(removed conflict unregistered)) + 'doom-modeline-urgent) + (t 'doom-modeline-info)))))) (t ""))))) (add-hook 'find-file-hook #'modeline-update-vcs-str) @@ -423,13 +423,13 @@ This will be displayed in the mode line." (declare (pure t) (side-effect-free t)) (cond ((and (stringp modeline-vcs-str) - (not (string= modeline-vcs-str ""))) + (not (string= modeline-vcs-str ""))) (concat (modeline-spc) (modeline-propertize (cond ((modeline-active-window-p) - modeline-vcs-str) + modeline-vcs-str) (t (propertize modeline-vcs-str 'face 'mode-line-inactive))) nil (get-text-property 1 'help-echo vc-mode) -- cgit v1.2.3-18-g5258