summaryrefslogtreecommitdiff
path: root/modeline.el
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2021-01-19 15:07:57 +0800
committerJSDurand <mmemmew@gmail.com>2021-01-19 15:07:57 +0800
commit4d28d444af32ddf4af5900786473fadacc43e4b1 (patch)
tree1b39232dcbda85cbdad85d64c3e0cb536da267a6 /modeline.el
parent82d3a1fcc5c36a48b2a404536f89e1d80c48d999 (diff)
QoL changes.
* bongo.el: Use header-line now. Try to improve the tick. * dired-conf.el: Require dired-x. * elisp.el: Hide Eldoc on the mode line. * text-conf.el (assq): Hide auto-fill-mode on the mode line. * modeline.el (modeline-format-left): Display minor modes information. (modeline-minor-modes-name-len-max): Max length of displayed minor modes. (modeline-format-minor-modes): Display minor modes information. (durand-mouse-minor-mode-menu): Make the default minor mode menu work with my custom mode line. * rime-conf.el ("emacs-rime"): Bind a key to set the input method to rime in the minibuffer, so that I can use this input method to search the buffer, for example.
Diffstat (limited to 'modeline.el')
-rw-r--r--modeline.el68
1 files changed, 65 insertions, 3 deletions
diff --git a/modeline.el b/modeline.el
index 62e4781..46d9080 100644
--- a/modeline.el
+++ b/modeline.el
@@ -36,7 +36,9 @@
(modeline-spc)
(modeline-format-position)
(modeline-spc)
- (modeline-format-buffer-size)))
+ (modeline-format-buffer-size)
+ (modeline-spc)
+ (modeline-format-minor-modes)))
;;;###autoload
(defun modeline-format-right ()
@@ -360,14 +362,74 @@ W is the width, H is the height of the bar."
(format-mode-line
(file-size-human-readable (string-to-number (format-mode-line "%i")))
(cond
- ((modeline-active-window-p)
- 'mode-line)
+ ((modeline-active-window-p) 'mode-line)
(t 'mode-line-inactive)))
nil
"Buffer size\nmouse-1: Display Line and Column Mode Menu"
mode-line-column-line-number-mode-map))
;;;###autoload
+(defvar modeline-minor-modes-name-len-max 150
+ "The maximal length for the display of minor modes in the mode line.")
+
+;;;###autoload
+(defun modeline-format-minor-modes ()
+ "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)))))
+ (cond
+ ((<= (length orig) modeline-minor-modes-name-len-max)
+ orig)
+ ((concat
+ (substring orig 0 (- modeline-minor-modes-name-len-max
+ 3))
+ "..."))))
+ nil
+ "Minor mode
+mouse-1: Display minor mode menu
+mouse-2: Show help for minor mode
+mouse-3: Toggle minor modes"
+ mode-line-minor-mode-keymap))
+
+;;; NOTE: The minor mode menu does not work with my custom mode line.
+
+;;;###autoload
+(defun durand-mouse-minor-mode-menu (event)
+ "Show minor-mode menu for EVENT on minor modes area of the mode line.
+Modified for my custom mode line."
+ (interactive "@e")
+ (let* ((string-obj (nth 4 (car (cdr event))))
+ (str (car string-obj))
+ (str-pos (cdr string-obj))
+ invalid indicator)
+ (cond
+ ((string= str "") (setq invalid t))
+ ((= (aref str str-pos) 32) (setq str-pos (1+ str-pos))))
+ (cond
+ (invalid)
+ ((= (aref str str-pos) 32))
+ (t
+ (let* ((orig str-pos)
+ (start str-pos)
+ (end str-pos))
+ (while (and (>= start 0)
+ (/= (aref str start) 32))
+ (setq start (1- start)))
+ (while (and (< end (length str))
+ (/= (aref str end) 32))
+ (setq end (1+ end)))
+ (setq indicator (substring-no-properties str (1+ start) end))
+ (minor-mode-menu-from-indicator indicator))))))
+
+(advice-add 'mouse-minor-mode-menu :override #'durand-mouse-minor-mode-menu)
+
+;;;###autoload
(defvar modeline-buffer-name-len-max 50
"The maximal length of the name of the buffer to be displayed in the mode line.")