Add input method to the modeline

This commit is contained in:
Case Duckworth 2022-02-28 09:40:07 -06:00
parent b454114819
commit b0346f6283
2 changed files with 26 additions and 0 deletions

View File

@ -1919,6 +1919,7 @@ See also `crux-reopen-as-root-mode'."
+modeline-reading-mode
+modeline-narrowed)
",")
+modeline-input-method
,(+modeline-concat
'(+modeline-region
+modeline-line-column

View File

@ -301,5 +301,30 @@ See `line-number-mode', `column-number-mode', `file-percentage-mode'"
(force-mode-line-update)))))
'mouse-face 'mode-line-highlight))))
(defun +modeline-input-method (&optional spacer)
"Display which input method is active."
(when current-input-method
(concat (or spacer +modeline-default-spacer)
(propertize current-input-method-title
'help-echo (format
(concat "Current input method: %s\n"
"mouse-1: Describe current input method\n"
"mouse-3: Toggle input method")
current-input-method)
'local-map (purecopy
(let ((map (make-sparse-keymap)))
(define-key map [mode-line mouse-1]
(lambda (e)
(interactive "e")
(with-selected-window (posn-window (event-start e))
(describe-current-input-method))))
(define-key map [mode-line mouse-3]
(lambda (e)
(interactive "e")
(with-selected-window (posn-window (event-start e))
(toggle-input-method nil :interactive))))
map))
'mouse-face 'mode-line-highlight))))
(provide '+modeline)
;;; +modeline.el ends here