mu4e-headers: switch buffer to search results

..except for 'background searches', such as the one after re-indexing.

Fixes #2545.
This commit is contained in:
Dirk-Jan C. Binnema 2023-10-07 08:14:35 +03:00
parent fcd89039eb
commit c021433519
1 changed files with 12 additions and 6 deletions

View File

@ -783,6 +783,11 @@ present, don't do anything."
(defconst mu4e~no-matches "No matching messages found")
(defconst mu4e~end-of-results "End of search results")
(defvar mu4e--search-background nil
"Is this a background search?
If so, do not attempt to switch buffers. This variable is to be let-bound
to t before \"automatic\" searches.")
(defun mu4e--search-execute (expr ignore-history)
"Search for query EXPR.
@ -810,7 +815,7 @@ true, do *not* update the query history stack."
;; when the buffer is already visible, select it; otherwise,
;; switch to it.
(unless (get-buffer-window buf 0)
(unless (get-buffer-window buf (if mu4e--search-background 0 nil))
(mu4e-display-buffer buf t))
(run-hook-with-args 'mu4e-search-hook expr)
(mu4e~headers-clear mu4e~search-message)
@ -1090,7 +1095,8 @@ no user-interaction ongoing."
;; 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)))
(mu4e-search-rerun))))
(let ((mu4e--search-background t))
(mu4e-search-rerun)))))
(defcustom mu4e-headers-eldoc-format "“%s” from %f on %d"
"Format for the `eldoc' string for the current message in the headers buffer.