mu4e: add prefix arg to mu4e-quit

Remove mu4e-main-quit-or-bury and simply update mu4e-quit
to take a prefix which, if non-nil, make mu4e-quit
bury the buffer rather than quite mu4e.

Also make the mu4e check for an existing mu4e buffer, and if found,
switch to it rather start mu4e.
This commit is contained in:
Dirk-Jan C. Binnema 2023-08-07 19:13:11 +03:00
parent 843c086b2c
commit 31bb84182b
4 changed files with 30 additions and 27 deletions

View File

@ -64,8 +64,9 @@
- also, there are now actions ('a' in view/header) to get to online archives
for some (selected) mailing-list archives.
- In the main-view, by default ~q~ is now bound to ~mu4e-main-quit-or-bury~,
which calls either ~mu4e-quit~ or, with prefix argument, ~bury-buffer~.
- ~mu4e-quit~ now takes a prefix argument which, if provided, causes it to
bury he mu main buffer, rather than quitting mu. ~mu4e~ will now just switch
the mu4e buffer if it exists (otherwise it starts ~mu4e~).
- ~mu4e~ benefits from the mentioned speed-ups in querying, and adds some of
its own - e.g., for showing 500 messages (debug build), we went from 642ms

View File

@ -110,17 +110,10 @@ the personal addresses."
(current-time-string baseline-t)
"Never"))))
(defun mu4e-main-quit-or-bury (&optional bury)
"Quit mu4e, or, with prefix-argument, bury the buffer."
(interactive "P")
(if bury
(bury-buffer)
(mu4e-quit)))
(defvar mu4e-main-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "q" #'mu4e-main-quit-or-bury)
(define-key map "q" #'mu4e-quit)
(define-key map "C" #'mu4e-compose-new)
(define-key map "m" #'mu4e--main-toggle-mail-sending-mode)
@ -335,7 +328,7 @@ Otherwise, do nothing."
(mu4e--main-action "\t* [@]News\n" #'mu4e-news nil "N")
(mu4e--main-action "\t* [@]About mu4e\n" #'mu4e-about nil "A")
(mu4e--main-action "\t* [@]Help\n" #'mu4e-display-manual nil "H")
(mu4e--main-action "\t* [@]quit\n" #'mu4e-main-quit-or-bury nil "q")
(mu4e--main-action "\t* [@]quit\n" #'mu4e-quit nil "q")
"\n"
(propertize " Info\n\n" 'face 'mu4e-title-face)
(mu4e--key-val "last updated"

View File

@ -61,18 +61,26 @@
Then, show the main window, unless BACKGROUND (prefix-argument)
is non-nil."
(interactive "P")
;; start mu4e, then show the main view
(mu4e--init-handlers)
(mu4e--start
(unless background #'mu4e--main-view)))
(if (and (not background) (buffer-live-p mu4e-main-buffer-name))
;; already running.
(switch-to-buffer mu4e-main-buffer-name)
;; start mu4e, then show the main view
(mu4e--init-handlers)
(mu4e--start
(unless background #'mu4e--main-view))))
(defun mu4e-quit()
"Quit the mu4e session."
(interactive)
(if mu4e-confirm-quit
(when (y-or-n-p (mu4e-format "Are you sure you want to quit?"))
(mu4e--stop))
(mu4e--stop)))
(defun mu4e-quit(&optional bury)
"Quit the mu4e session or bury the buffer.
If prefix-argument BURY is non-nil, merely bury the buffer.
Otherwise, completely quit mu4e, including automatic updating."
(interactive "P")
(if bury
(bury-buffer)
(if mu4e-confirm-quit
(when (y-or-n-p (mu4e-format "Are you sure you want to quit?"))
(mu4e--stop))
(mu4e--stop))))
;;; Internals

View File

@ -858,16 +858,17 @@ visible only if you have actually set up mail-queuing. @ref{Queuing
mail}
@item @t{[A]bout mu4e} provides general information about the program
@item @t{[H]elp} shows help information for this view
@item Finally, @t{[q]uit mu4e} quits your @t{mu4e}-session
@item Finally, @t{[q]uit mu4e} quits your @t{mu4e}-session@footnote{@t{mu4e-quit}; or with a @t{C-u}
prefix argument, it merely buries the buffer}
@end itemize
@node Headers view
@chapter The headers view
The headers view shows the results of a query. The header-line shows
the names of the fields. Below that, there is a line with those
fields, for each matching message, followed by a footer line. The
major-mode for the headers view is @code{mu4e-headers-mode}.
The headers view shows the results of a query. The header-line shows the names
of the fields. Below that, there is a line with those fields, for each matching
message, followed by a footer line. The major-mode for the headers view is
@code{mu4e-headers-mode}.
@menu
* Overview: HV Overview. What is the Header View