summaryrefslogtreecommitdiff
path: root/modeline.el
diff options
context:
space:
mode:
Diffstat (limited to 'modeline.el')
-rw-r--r--modeline.el72
1 files changed, 43 insertions, 29 deletions
diff --git a/modeline.el b/modeline.el
index 212db07..12893ea 100644
--- a/modeline.el
+++ b/modeline.el
@@ -8,10 +8,12 @@
(left-len (length left))
(right-len (length right))
(middle (propertize " " 'display
- (make-string (- (window-total-width)
- left-len
- right-len)
- 32))))
+ (make-string
+ (max (- (window-total-width)
+ left-len
+ right-len)
+ 0)
+ 32))))
(concat left middle right)))
(setq-default mode-line-format '("%e" (:eval (modeline-format-main))))
@@ -22,7 +24,9 @@
(concat
;; (modeline-format-bar)
(modeline-spc)
- (modeline-format-directory)))
+ (modeline-format-directory)
+ (modeline-spc)
+ (modeline-format-minor-modes)))
;;;###autoload
(defun modeline-format-left ()
@@ -56,11 +60,14 @@
MOUSE-FACE is used when the mouse is over the text.
HELP-ECHO is the additional information displayed when the mouse is over the text.
MAP is the local keymap of the text."
- (let ((mouse-face (or mouse-face 'mode-line-highlight)))
- `(propertize ,str
- 'mouse-face ',mouse-face
- 'help-echo ,help-echo
- 'local-map ,map)))
+ (let ((mouse-face (or mouse-face 'mode-line-highlight))
+ (help-echo-form (cond (help-echo (list (quote 'help-echo) help-echo))))
+ (map-form (cond (map (list (quote 'local-map) map)))))
+ (append
+ `(propertize ,str
+ 'mouse-face ',mouse-face)
+ help-echo-form
+ map-form)))
;;; Determination of the active mode-line
@@ -377,12 +384,16 @@ W is the width, H is the height of the bar."
"Display some minor modes information."
(declare (pure t) (side-effect-free t))
(modeline-propertize
- (let ((orig
- (format-mode-line
- minor-mode-alist
- (cond
- ((modeline-active-window-p) 'mode-line)
- ('mode-line-inactive)))))
+ (let* ((raw
+ (format-mode-line
+ minor-mode-alist
+ (cond
+ ((modeline-active-window-p) 'mode-line)
+ ('mode-line-inactive))))
+ (orig (cond
+ ((and (not (string= raw ""))
+ (= (aref raw 0) 32)) (substring raw 1))
+ (raw))))
(cond
((<= (length orig) modeline-minor-modes-name-len-max)
orig)
@@ -446,13 +457,15 @@ This will be displayed in the mode line."
(modeline-propertize
(let* ((face (cond ((modeline-active-window-p) 'mode-line-buffer-id)
(t 'mode-line-inactive)))
+ (name-max (min modeline-buffer-name-len-max
+ (floor (window-width) 2)))
(orig (format-mode-line "%b" face)))
(concat
(format-mode-line "%[" face)
(cond
- ((> (length orig) modeline-buffer-name-len-max)
+ ((> (length orig) name-max)
(concat
- (substring orig 0 (- modeline-buffer-name-len-max 3))
+ (substring orig 0 (max (- name-max 3) 1))
"..."))
(t orig))
(format-mode-line "%]" face)))
@@ -466,17 +479,18 @@ This will be displayed in the mode line."
(defun modeline-format-major-mode ()
"The major mode to display in the mode line."
(declare (pure t) (side-effect-free t))
- (concat
- (modeline-propertize
- (format-mode-line
- '("%m" global-mode-string)
- (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)))
+ (let ((face (cond ((modeline-active-window-p) 'doom-modeline-buffer-major-mode)
+ ('mode-line-inactive))))
+ (concat
+ (modeline-propertize
+ (format-mode-line '("%m") face)
+ 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)
+ (modeline-propertize
+ (format-mode-line global-mode-string face))
+ (modeline-spc))))
;;;###autoload
(defvar-local modeline-vcs-str ""