mu4e: Update single-window mode

Update mu4e~headers-quit-buffer and mu4e~main-menu.

mu4e~headers-quit-buffer in single-window mode now kills current buffer
instead of quitting mu4e.

mu4e~main-menu is updated to redisplay the main menu on context switch
or unknown keybinding, display errors in commands better, and to handle
C-g and ESC keys.

Thanks to Joost Kremers for the suggestions.
This commit is contained in:
Vladimir Sedach
2017-06-12 18:55:51 -07:00
committed by djcb
parent afb47e7ef6
commit 6017ac46ce
2 changed files with 26 additions and 19 deletions

View File

@ -1722,7 +1722,7 @@ other windows."
(interactive) (interactive)
(if (eq mu4e-split-view 'single-window) (if (eq mu4e-split-view 'single-window)
(progn (mu4e-mark-handle-when-leaving) (progn (mu4e-mark-handle-when-leaving)
(mu4e-quit)) (kill-buffer))
(unless (eq major-mode 'mu4e-headers-mode) (unless (eq major-mode 'mu4e-headers-mode)
(mu4e-error "Must be in mu4e-headers-mode (%S)" major-mode)) (mu4e-error "Must be in mu4e-headers-mode (%S)" major-mode))
(mu4e-mark-handle-when-leaving) (mu4e-mark-handle-when-leaving)

View File

@ -226,24 +226,31 @@ clicked."
(defun mu4e~main-menu () (defun mu4e~main-menu ()
"mu4e main view in the minibuffer." "mu4e main view in the minibuffer."
(interactive) (interactive)
(let ((mu4e-hide-index-messages t)) (let ((key
(call-interactively (read-key
(lookup-key (mu4e-format
mu4e-main-mode-map "%s"
(string (concat
(read-key (mu4e~main-action-str "[j]ump " 'mu4e-jump-to-maildir)
(mu4e-format (mu4e~main-action-str "[s]earch " 'mu4e-search)
"%s" (mu4e~main-action-str "[C]ompose " 'mu4e-compose-new)
(concat (mu4e~main-action-str "[b]ookmarks " 'mu4e-headers-search-bookmark)
(mu4e~main-action-str "[j]ump " 'mu4e-jump-to-maildir) (mu4e~main-action-str "[;]Switch context " 'mu4e-context-switch)
(mu4e~main-action-str "[s]earch " 'mu4e-search) (mu4e~main-action-str "[U]pdate " 'mu4e-update-mail-and-index)
(mu4e~main-action-str "[C]ompose " 'mu4e-compose-new) (mu4e~main-action-str "[N]ews " 'mu4e-news)
(mu4e~main-action-str "[b]ookmarks " 'mu4e-headers-search-bookmark) (mu4e~main-action-str "[A]bout " 'mu4e-about)
(mu4e~main-action-str "[;]Switch context " 'mu4e-context-switch) (mu4e~main-action-str "[H]elp " 'mu4e-display-manual))))))
(mu4e~main-action-str "[U]pdate " 'mu4e-update-mail-and-index) (unless (member key '(?\C-g ?\C-\[))
(mu4e~main-action-str "[N]ews " 'mu4e-news) (let ((mu4e-command (lookup-key mu4e-main-mode-map (string key) t)))
(mu4e~main-action-str "[A]bout " 'mu4e-about) (if mu4e-command
(mu4e~main-action-str "[H]elp " 'mu4e-display-manual))))))))) (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))))))
;; (progn ;; (progn
;; (define-key mu4e-compose-mode-map (kbd "C-c m") 'mu4e~main-toggle-mail-sending-mode) ;; (define-key mu4e-compose-mode-map (kbd "C-c m") 'mu4e~main-toggle-mail-sending-mode)