From b4ca140005dec52532e5b93a59ceef08d63abfe8 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Thu, 23 Feb 2023 21:38:57 +0800 Subject: mail: Add the option of only running hooks without updating * mail.el (durand-mail-update): Now if we run the update command with the argument of `0', then it only runs the hook `durand-mail-update-hook`, which currently contains only the function `notmuch-poll`. This allows the user to index mails without fetching mails, which is useful since the timer that fetches mails in the background does not index mails, intentionally. --- mail.el | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/mail.el b/mail.el index ed2dd00..57d680f 100644 --- a/mail.el +++ b/mail.el @@ -290,19 +290,34 @@ PROCESS is finished." (defun durand-mail-update (&optional foreground-p) "Update mails. If FOREGROUND-P is non-nil, also display the progress in a -separate buffer." - (interactive (list t)) - (make-process - :name "durand-mail-update" - :command durand-mail-update-command - :filter (cond (foreground-p #'durand-mail-update-filter)) - :sentinel (cond (foreground-p #'durand-mail-update-sentinel)) - :buffer (cond - (foreground-p - (let ((buffer - (get-buffer-create durand-mail-update-buffer))) - (buffer-disable-undo buffer) - buffer))))) +separate buffer. + +If FOREGROUND-P is `0', do not fetch mails, but just run +`durand-mail-update-hook.'" + (interactive + (list + (let ((arg current-prefix-arg)) + (cond + ((and (numberp arg) + (= arg 0)) + 0) + ((null arg)))))) + (cond + ((and (numberp foreground-p) + (= foreground-p 0)) + (message "hi") + (run-hooks 'durand-mail-update-hook)) + ((make-process + :name "durand-mail-update" + :command durand-mail-update-command + :filter (cond (foreground-p #'durand-mail-update-filter)) + :sentinel (cond (foreground-p #'durand-mail-update-sentinel)) + :buffer (cond + (foreground-p + (let ((buffer + (get-buffer-create durand-mail-update-buffer))) + (buffer-disable-undo buffer) + buffer))))))) (defvar durand-mail-update-timer nil "A timer to automatically update mail in the background.") -- cgit v1.2.3-18-g5258