mu4e: implement mu4e-quit-hook

As seen on r/emacs.
This commit is contained in:
Dirk-Jan C. Binnema
2025-10-11 22:19:12 +03:00
committed by Seth Ladygo
parent 20d18cb7ee
commit 7526777c7d
3 changed files with 17 additions and 4 deletions

View File

@ -309,6 +309,9 @@
and connect to the SCM REPL with ~M-x mu4e-mu-scm-repl~ after restart (see
their docstrings for details)
- 1.12.14: add ~mu4e-quit-hook~, a hook is just before quitting mu4e. See its
docstring for details.
*** scm
- 1.12.12: add new guile/scheme binding in ~scm/~. These are to replace the

View File

@ -45,12 +45,22 @@
(require 'mu4e-notification)
(require 'mu4e-server) ;; communication with backend
(when mu4e-speedbar-support
(require 'mu4e-speedbar)) ;; support for speedbar
(when mu4e-org-support
(require 'mu4e-org)) ;; support for org-mode links
(defcustom mu4e-quit-hook nil
"Hook run just before quitting mu4e.
This hook runs just before mu4e performs its own cleanup.
Note that it only fires when mu4e actually terminates; i.e.,
`mu4e-quit' _without_ the \"bury-only\" parameter."
:type 'hook
:package-version '(mu4e . "1.12.14")
:group 'mu4e)
;; We can't properly use compose buffers that are revived using
;; desktop-save-mode; so let's turn that off.
(with-eval-after-load 'desktop
@ -171,6 +181,7 @@ invoke FUNC (if available) afterwards."
(defun mu4e--stop ()
"Stop mu4e."
(run-hooks 'mu4e-quit-hook)
(when mu4e--update-timer
(cancel-timer mu4e--update-timer)
(setq mu4e--update-timer nil))

View File

@ -909,8 +909,7 @@ 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 @code{mu4e}-session@footnote{@t{mu4e-quit}; or with a @t{C-u}
prefix argument, it merely buries the buffer}
@item Finally, @t{[q]uit mu4e} quits your @code{mu4e}-session@footnote{@t{mu4e-quit}; or with a @t{C-u} prefix argument, it merely buries the buffer. A hook @code{mu4e-quit-hook} is available as well}
@end itemize
@node Headers view
@ -4359,7 +4358,7 @@ usually because one of the following reasons:
changes in @code{mu4e} are not immediately visible in the command-line @command{mu},
since it can take a while before changes are committed to disk (for performance
reasons). Note that quitting @code{mu4e} or invoking @t{mu4e-update-mail-and-index}
and @t{mu4e-update-index} trigger committing to disk as a side-effect.
and @t{mu4e-update-index} have the side-effect of committing changed data to disk.
@item different options:
@code{mu4e} defaults to having @t{mu4e-headers-include-related}, and
@t{mu4e-headers-results-limit} set to 500. However, the command-line @command{mu