Skip to content

Commit

Permalink
mu4e: fix mu4e~headers-maybe-auto-update
Browse files Browse the repository at this point in the history
The check for # of marked message was flawed since mu4e-mark-marks-num
should we called from the headers buffer (and wasn't, necessarily).

Fixes #2779.
  • Loading branch information
djcb committed Oct 29, 2024
1 parent 7e6ab29 commit ae29b2d
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions mu4e/mu4e-headers.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)))))

Expand Down

0 comments on commit ae29b2d

Please sign in to comment.