summaryrefslogtreecommitdiff
path: root/modeline.el
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2021-01-09 14:22:00 +0800
committerJSDurand <mmemmew@gmail.com>2021-01-09 14:22:00 +0800
commitdc206ebe9397d656971ba7fc3a092009ef4e797a (patch)
treed963873011122fdf0eafeba89afd487115994bc5 /modeline.el
parenta2f7f2bf9077ba8acfc550575b9e21aa9ffe7bae (diff)
temporary state
Diffstat (limited to 'modeline.el')
-rw-r--r--modeline.el129
1 files changed, 88 insertions, 41 deletions
diff --git a/modeline.el b/modeline.el
index 3fce55c..7da967e 100644
--- a/modeline.el
+++ b/modeline.el
@@ -8,7 +8,7 @@
(left-len (length left))
(right-len (length right))
(middle (propertize " " 'display
- (make-string (- (window-width)
+ (make-string (- (window-total-width)
left-len
right-len)
32))))
@@ -17,6 +17,15 @@
(setq-default mode-line-format '("%e" (:eval (modeline-format-main))))
;;;###autoload
+(defun modeline-format-dashboard ()
+ "The mode line format for the dashboard."
+ (concat
+ (modeline-format-bar)
+ (modeline-spc)
+ (modeline-format-directory)))
+
+
+;;;###autoload
(defun modeline-format-left ()
"The left mode line format."
(concat
@@ -131,6 +140,20 @@ MAP is the local keymap of the text."
;;; Various sections of the mode line
;;;###autoload
+(defun modeline-format-directory ()
+ "Display the default directory on the mode line."
+ (modeline-propertize
+ (propertize
+ default-directory
+ 'face (cond ((modeline-active-window-p) 'mode-line)
+ (t 'mode-line-inactive)))
+ nil "The current directory\nmouse-1: Open that directory"
+ (let ((map '(keymap)))
+ (define-key map (vector 'mode-line 'down-mouse-1)
+ (lambda () (interactive) (dired default-directory)))
+ map)))
+
+;;;###autoload
(defun modeline-spc ()
"A space with the appropriate face."
(format-mode-line " "
@@ -285,20 +308,42 @@ W is the width, H is the height of the bar."
;;;###autoload
(defun modeline-format-position ()
"The position of the cursor to be displayed in the mode line."
- (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)))))
- (cond
- ((modeline-active-window-p) 'mode-line)
- (t 'mode-line-inactive)))
- nil
- "Buffer position\nmouse-1: Display Line and Column Mode Menu"
- mode-line-column-line-number-mode-map))
+ (cond
+ ((derived-mode-p 'pdf-view-mode)
+ (modeline-propertize
+ (propertize
+ (let ((current (pdf-view-current-page))
+ (total (pdf-info-number-of-pages)))
+ (concat
+ "P."
+ (number-to-string current)
+ "/"
+ (number-to-string total)))
+ 'face (cond
+ ((modeline-active-window-p) 'mode-line)
+ (t 'mode-line-inactive)))
+ nil "Current page / Total pages"))
+ (t
+ (modeline-propertize
+ (propertize
+ (let* ((lc (format-mode-line "%l:%C "))
+ (percent (format-mode-line "%p")))
+ (concat
+ lc
+ (cond
+ ((eq (aref percent 0) 32)
+ (concat (substring percent 1) "%"))
+ ((memq (aref percent 0) (number-sequence 48 57))
+ (concat percent "%"))
+ ((> (length percent) 3)
+ (substring percent 0 3))
+ (t percent))))
+ 'face (cond
+ ((modeline-active-window-p) 'mode-line)
+ (t 'mode-line-inactive)))
+ nil
+ "Buffer position\nmouse-1: Display Line and Column Mode Menu"
+ mode-line-column-line-number-mode-map))))
;;;###autoload
(defun modeline-format-buffer-size ()
@@ -329,36 +374,39 @@ W is the width, H is the height of the bar."
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)))))
- (cond
- ((> (length orig) modeline-buffer-name-len-max)
- (concat
- (substring orig 0 (- modeline-buffer-name-len-max 3))
- "..."))
- (t orig)))
+ (let* ((face (cond ((modeline-active-window-p) 'mode-line-buffer-id)
+ (t 'mode-line-inactive)))
+ (orig (format-mode-line "%b" face)))
+ (concat
+ (format-mode-line "%[" face)
+ (cond
+ ((> (length orig) modeline-buffer-name-len-max)
+ (concat
+ (substring orig 0 (- modeline-buffer-name-len-max 3))
+ "..."))
+ (t orig))
+ (format-mode-line "%]" face)))
nil
(concat (buffer-file-name)
- "\n"
- "mouse-1: ibuffer")
+ "\n"
+ "mouse-1: ibuffer")
mode-line-buffer-identification-keymap))
;;;###autoload
(defun modeline-format-major-mode ()
"The major mode to display in the mode line."
(declare (pure t) (side-effect-free t))
- (modeline-propertize
- (format-mode-line
- "%m"
- (cond ((modeline-active-window-p)
- '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))
+ (concat
+ (modeline-propertize
+ (format-mode-line
+ "%m"
+ (cond ((modeline-active-window-p)
+ '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)
+ (modeline-spc)))
;;;###autoload
(defvar-local modeline-vcs-str ""
@@ -420,16 +468,15 @@ This will be displayed in the mode line."
;;;###autoload
(defun modeline-format-vc-mode ()
"Display version control system information on the mode line."
- (declare (pure t) (side-effect-free t))
+ (declare (pure t) (side-effect-free 'error-free))
(cond
((and (stringp modeline-vcs-str)
(not (string= modeline-vcs-str "")))
(concat
- (modeline-spc)
+ ;; (modeline-spc)
(modeline-propertize
(cond
- ((modeline-active-window-p)
- modeline-vcs-str)
+ ((modeline-active-window-p) modeline-vcs-str)
(t (propertize modeline-vcs-str 'face 'mode-line-inactive)))
nil
(get-text-property 1 'help-echo vc-mode)