mu4e-main: rewrite mu4e--main-menu

The old one had bit-rotted quite a bit.

Fixes #2296.
This commit is contained in:
Dirk-Jan C. Binnema 2022-07-07 00:52:32 +03:00
parent 2433cf7b89
commit 39d7096bba
1 changed files with 17 additions and 28 deletions

View File

@ -275,6 +275,7 @@ When REFRESH is non nil refresh infos from server."
(mu4e--main-redraw-buffer)))) (mu4e--main-redraw-buffer))))
(defun mu4e--main-redraw-buffer () (defun mu4e--main-redraw-buffer ()
"Redraw the main buffer."
(with-current-buffer mu4e-main-buffer-name (with-current-buffer mu4e-main-buffer-name
(let ((inhibit-read-only t) (let ((inhibit-read-only t)
(pos (point)) (pos (point))
@ -403,34 +404,22 @@ When REFRESH is non nil refresh infos from server."
(revert-buffer)))) (revert-buffer))))
(defun mu4e--main-menu () (defun mu4e--main-menu ()
"The mu4e main menu." "The mu4e main menu in the mini-buffer."
(interactive) (let ((func (mu4e-read-option
(let ((key "Do: "
(read-key '(("jump" . mu4e~headers-jump-to-maildir)
(mu4e-format ("search" . mu4e-search)
"%s" ("Compose" . mu4e-compose-new)
(concat ("bookmarks" . mu4e-headers-search-bookmark)
(mu4e--main-action-str "[j]ump " 'mu4e-jump-to-maildir) (";Switch context" . mu4e-context-switch)
(mu4e--main-action-str "[s]earch " 'mu4e-search) ("Update" . mu4e-update-mail-and-index)
(mu4e--main-action-str "[C]ompose " 'mu4e-compose-new) ("News" . mu4e-news)
(mu4e--main-action-str "[b]ookmarks " 'mu4e-headers-search-bookmark) ("About" . mu4e-about)
(mu4e--main-action-str "[;]Switch context " 'mu4e-context-switch) ("Help " . mu4e-display-manual)))))
(mu4e--main-action-str "[U]pdate " 'mu4e-update-mail-and-index) (call-interactively func)
(mu4e--main-action-str "[N]ews " 'mu4e-news) (when (eq func 'mu4e-context-switch)
(mu4e--main-action-str "[A]bout " 'mu4e-about) (sit-for 1)
(mu4e--main-action-str "[H]elp " 'mu4e-display-manual)))))) (mu4e--main-menu))))
(unless (member key '(?\C-g ?\C-\[))
(let ((mu4e-command (lookup-key mu4e-main-mode-map (string key) t)))
(if mu4e-command
(condition-case err
(let ((mu4e-hide-index-messages t))
(call-interactively mu4e-command))
(error (when (cadr err) (message (cadr err)))))
(message (mu4e-format "key %s not bound to a command" (string key))))
(when (or (not mu4e-command) (eq mu4e-command 'mu4e-context-switch))
(sit-for 1)
(mu4e--main-menu))))))
;;; _
(provide 'mu4e-main) (provide 'mu4e-main)
;;; mu4e-main.el ends here ;;; mu4e-main.el ends here