* mu4e: add hooks mu4e-headers-found-hook and mu4e-update-pre-hook, document them.

This commit is contained in:
djcb 2013-10-13 21:44:47 +03:00
parent c36030a086
commit 92158cfdd4
4 changed files with 36 additions and 12 deletions

View File

@ -209,6 +209,11 @@ PREDICATE-FUNC as PARAM. This is useful for getting user-input.")
(defvar mu4e-headers-full-search nil (defvar mu4e-headers-full-search nil
"Whether to show all results. "Whether to show all results.
If this is nil show results up to `mu4e-search-results-limit')") If this is nil show results up to `mu4e-search-results-limit')")
(defvar mu4e-headers-found-hook nil
"Hook run just *after* all of the headers for the last search
query have been received and are displayed.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -477,6 +482,9 @@ if provided, or at the end of the buffer otherwise."
(defconst mu4e~no-matches (purecopy "No matching messages found")) (defconst mu4e~no-matches (purecopy "No matching messages found"))
(defconst mu4e~end-of-results (purecopy "End of search results")) (defconst mu4e~end-of-results (purecopy "End of search results"))
(defun mu4e~headers-found-handler (count) (defun mu4e~headers-found-handler (count)
"Create a one line description of the number of headers found "Create a one line description of the number of headers found
after the end of the search results." after the end of the search results."
@ -491,9 +499,11 @@ after the end of the search results."
(insert (propertize str 'face 'mu4e-system-face 'intangible t)) (insert (propertize str 'face 'mu4e-system-face 'intangible t))
(unless (= 0 count) (unless (= 0 count)
(mu4e-message "Found %d matching message%s" (mu4e-message "Found %d matching message%s"
count (if (= 1 count) "" "s")) count (if (= 1 count) "" "s"))))
;; highlight the first message ;; highlight the first message
(mu4e~headers-highlight (mu4e~headers-docid-at-point (point-min))))))))) (mu4e~headers-highlight (mu4e~headers-docid-at-point (point-min)))
;; run-hooks
(run-hooks 'mu4e-headers-found-hook)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@ -804,6 +804,7 @@ The messages are inserted into the process buffer."
run-in-background is non-nil (or called with prefix-argument), run run-in-background is non-nil (or called with prefix-argument), run
in the background; otherwise, pop up a window." in the background; otherwise, pop up a window."
(interactive "P") (interactive "P")
(run-hooks 'mu4e-update-pre-hook)
(unless mu4e-get-mail-command (unless mu4e-get-mail-command
(mu4e-error "`mu4e-get-mail-command' is not defined")) (mu4e-error "`mu4e-get-mail-command' is not defined"))
(let* ((process-connection-type t) (let* ((process-connection-type t)
@ -827,7 +828,7 @@ in the background; otherwise, pop up a window."
(buf (process-buffer proc)) (buf (process-buffer proc))
(visible-window (get-buffer-window buf 'visible))) (visible-window (get-buffer-window buf 'visible)))
(message nil) (message nil)
;; there may be an error, give the user up to 5 seconds to check ;; there may be an erro, give the user up to 5 seconds to check
(when maybe-error (sit-for 5)) (when maybe-error (sit-for 5))
(mu4e-update-index) (mu4e-update-index)
(when (and (buffer-live-p buf) visible-window) (when (and (buffer-live-p buf) visible-window)

View File

@ -78,6 +78,11 @@ mu4e."
:group 'mu4e :group 'mu4e
:safe 'integerp) :safe 'integerp)
(defvar mu4e-update-pre-hook nil
"Hook run just *before* the mail-retrieval / database updating process starts.
You can use this hook for example to `mu4e-get-mail-command' with
some specific setting.")
(defvar mu4e-hide-index-messages nil (defvar mu4e-hide-index-messages nil
"If non-nil, mu4e does not show the \"Indexing...\" messages, or "If non-nil, mu4e does not show the \"Indexing...\" messages, or
any messages relating to updated contacts.") any messages relating to updated contacts.")

View File

@ -477,6 +477,11 @@ A simple setup could look something like:
mu4e-update-interval 300) ;; update every 5 minutes mu4e-update-interval 300) ;; update every 5 minutes
@end lisp @end lisp
A hook @code{mu4e-update-pre-hook} is available which is run right before
starting the process, which you can for example to influence
@code{mu4e-get-mail-command} based on the the current situation (location,
time of day, ...).
It is possible to get notifications when the indexing process does any updates It is possible to get notifications when the indexing process does any updates
- for example when receiving new mail. See @code{mu4e-index-updated-hook} and - for example when receiving new mail. See @code{mu4e-index-updated-hook} and
some tips on its usage in the @ref{FAQ}. some tips on its usage in the @ref{FAQ}.
@ -764,6 +769,9 @@ Jamie Zawinski's mail threading algorithm,
found during the indexing process, and if there is no current found during the indexing process, and if there is no current
user-interaction. If you do not want such automatic updates, set user-interaction. If you do not want such automatic updates, set
@code{mu4e-headers-auto-update} to @code{nil}. @code{mu4e-headers-auto-update} to @code{nil}.
@item There is a hook-function @code{mu4e-headers-found-hook} available which
is invoked just after @t{mu4e} has completed showing the messages in the
headers-view.
@end itemize @end itemize
@node Keybindings @node Keybindings