The notmuch-poll
command, bound to G
in notmuch-common-keymap
,
polls synchronously, which makes it useless,
so we write my-notmuch-poll
that is asynchronous:
(with-eval-after-load 'notmuch (defun my-notmuch-poll () "Run `notmuch new' asynchronously and refresh relevant buffers." (interactive) (let ((buffer "*Notmuch new*")) ;; Call `notmuch new' asynchronously. (let ((process (notmuch-start-notmuch "notmuch-new" buffer (lambda (process event) (when (eq (process-status process) 'exit) (when (get-buffer buffer) (kill-buffer buffer)) (notmuch-refresh-all-buffers) (message "Polling mail... done"))) "new"))) ;; HACK The `internal-default-process-filter' does not auto-scroll. (set-process-filter process (lambda (process output) (when (buffer-live-p (process-buffer process)) (with-current-buffer (process-buffer process) (insert output) (let ((win (get-buffer-window))) (when (window-live-p win) (set-window-point win (point-max)))))))) ;; Show progress. (let ((display-buffer-alist `((,(regexp-quote buffer) (display-buffer-in-side-window) (window-height . 8))))) (display-buffer buffer))))))
(with-eval-after-load 'notmuch (keymap-set notmuch-common-keymap "G" #'my-notmuch-poll))