diff --git a/mu4e/mu4e-headers.el b/mu4e/mu4e-headers.el index 691277f9..c214ce89 100644 --- a/mu4e/mu4e-headers.el +++ b/mu4e/mu4e-headers.el @@ -1093,19 +1093,23 @@ true, do *not* update the query history stack." (defun mu4e~headers-maybe-auto-update () "Update the current headers buffer after indexing changes. + Furthermore, `mu4e-headers-auto-update' is non-nil and there is -no user-interaction ongoing." - (when (and mu4e-headers-auto-update ;; must be set - mu4e-index-update-status - (not (mu4e-get-view-buffer)) ;; not when viewing a message - (not (zerop (plist-get mu4e-index-update-status :updated))) - ;; NOTE: `mu4e-mark-marks-num' can return nil. Is that intended? - (zerop (or (mu4e-mark-marks-num) 0)) ;; non active marks - (not (active-minibuffer-window))) ;; no user input only - ;; rerun search if there's a live window with search results; - ;; otherwise we'd trigger a headers view from out of nowhere. - (when (and (buffer-live-p (mu4e-get-headers-buffer)) - (window-live-p (get-buffer-window (mu4e-get-headers-buffer) t))) +no user-interaction ongoing. + +We only update headers when quite a few conditions are true -- +see the code." + (when-let* ((hdrsbuf (mu4e-get-headers-buffer))) + (when (and mu4e-headers-auto-update ;; must be set + mu4e-index-update-status + (not (mu4e-get-view-buffer)) ;; not when viewing a message + (not (zerop (plist-get mu4e-index-update-status :updated))) + (buffer-live-p hdrsbuf) + (window-live-p (get-buffer-window hdrsbuf t)) + ;; don't disturb marks. + (zerop (or (with-current-buffer hdrsbuf (mu4e-mark-marks-num)) 0)) + (not (active-minibuffer-window))) ;; no user input only + ;; when all that is true, rerun the current query. (let ((mu4e--search-background t)) (mu4e-search-rerun)))))