mu4e: show actual keybindings in main-view

Let the main-screen show a representation of the *actual* keybindings
rather than assuming the defaults.

For that to work, we need to invoke mu4e-main-mode earlier; add a new
hook mu4e-main-mode-rendered-hook which is invoked after rendering is
complete.

Add a few helpers for this to mu4e-helpers.
This commit is contained in:
Dirk-Jan C. Binnema
2023-02-11 11:59:07 +02:00
parent 5df98d57cb
commit 6559f0f86e
2 changed files with 101 additions and 75 deletions

View File

@ -471,5 +471,22 @@ COMPONENTS."
(mapconcat (lambda (part) (if (stringp part) part ""))
(cons directory components) "/")))
(defun mu4e-string-replace (from-string to-string in-string)
"Replace FROM-STRING with TO-STRING in IN-STRING each time it occurs.
Mu4e version of emacs 28's string-replace."
(replace-regexp-in-string (regexp-quote from-string)
to-string in-string nil 'literal))
(defun mu4e-key-description (cmd)
"Get the textual form of current binding to interactive function CMD.
If it is unbound, return nil. If there are multiple bindings,
return the shortest."
;; not a perfect heuristic: e.g. '<up>' is longer that 'C-p'
(car-safe
(seq-sort (lambda (b1 b2)
(< (length b1) (length b2)))
(seq-map #'key-description
(where-is-internal cmd)))))
(provide 'mu4e-helpers)
;;; mu4e-helpers.el ends here