Merge pull request #1921 from tsdh/make-jump-maildir-query-editable-with-prefix-arg

mu4e-jump-to-maildir: offer editing the query when a prefix arg is given
This commit is contained in:
Dirk-Jan C. Binnema 2021-02-12 00:53:07 +02:00 committed by GitHub
commit bf5c93aab6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 14 deletions

View File

@ -1542,7 +1542,16 @@ or `past'."
(pop mu4e~headers-query-future)))) (pop mu4e~headers-query-future))))
;;; Interactive functions ;;; Reading queries with completion
(defun mu4e-read-query (prompt &optional initial-input)
"Read a search query with completion using PROMPT and INITIAL-INPUT."
(minibuffer-with-setup-hook
(lambda ()
(setq-local completion-at-point-functions
#'mu4e--search-query-competion-at-point)
(use-local-map mu4e-minibuffer-search-query-map))
(read-string prompt initial-input 'mu4e~headers-search-hist)))
(defvar mu4e~headers-search-hist nil (defvar mu4e~headers-search-hist nil
"History list of searches.") "History list of searches.")
@ -1584,6 +1593,9 @@ or `past'."
map) map)
"The keymap when reading a search query.") "The keymap when reading a search query.")
;;; Interactive functions
(defun mu4e-headers-search (&optional expr prompt edit (defun mu4e-headers-search (&optional expr prompt edit
ignore-history msgid show) ignore-history msgid show)
"Search in the mu database for EXPR, and switch to the output "Search in the mu database for EXPR, and switch to the output
@ -1602,13 +1614,7 @@ searching. If SHOW is non-nil, show the message with MSGID."
(expr (expr
(if edit (if edit
(read-string prompt expr) (read-string prompt expr)
(or expr (or expr (mu4e-read-query prompt)))))
(minibuffer-with-setup-hook
(lambda ()
(setq-local completion-at-point-functions
#'mu4e--search-query-competion-at-point)
(use-local-map mu4e-minibuffer-search-query-map))
(read-string prompt nil 'mu4e~headers-search-hist))))))
(mu4e-mark-handle-when-leaving) (mu4e-mark-handle-when-leaving)
(mu4e~headers-search-execute expr ignore-history) (mu4e~headers-search-execute expr ignore-history)
(setq mu4e~headers-msgid-target msgid (setq mu4e~headers-msgid-target msgid
@ -1882,15 +1888,19 @@ untrashed)."
(interactive) (interactive)
(mu4e~headers-prev-or-next-unread nil)) (mu4e~headers-prev-or-next-unread nil))
(defun mu4e~headers-jump-to-maildir (maildir) (defun mu4e~headers-jump-to-maildir (maildir &optional edit)
"Show the messages in maildir (user is prompted to ask what "Show the messages in maildir.
maildir)." The user is prompted to ask what maildir. If prefix arg EDIT is
given, offer to edit the search query before executing it."
(interactive (interactive
(let ((maildir (mu4e-ask-maildir "Jump to maildir: "))) (let ((maildir (mu4e-ask-maildir "Jump to maildir: ")))
(list maildir))) (list maildir current-prefix-arg)))
(when maildir (when maildir
(setq query (format "maildir:\"%s\"" maildir))
(when edit
(setq query (mu4e-read-query "Refine query: " query)))
(mu4e-mark-handle-when-leaving) (mu4e-mark-handle-when-leaving)
(mu4e-headers-search (format "maildir:\"%s\"" maildir)))) (mu4e-headers-search query)))
(defun mu4e-headers-split-view-grow (&optional n) (defun mu4e-headers-split-view-grow (&optional n)
"In split-view, grow the headers window. "In split-view, grow the headers window.

View File

@ -2157,7 +2157,8 @@ with the difference being that the target is always a maildir --- maildir
queries provide a `traditional' folder-like interface to a search-based e-mail queries provide a `traditional' folder-like interface to a search-based e-mail
client. By default, maildir searches are available in the @ref{Main view}, client. By default, maildir searches are available in the @ref{Main view},
@ref{Headers view}, and @ref{Message view}, with the key @key{j} @ref{Headers view}, and @ref{Message view}, with the key @key{j}
(@code{mu4e-jump-to-maildir}). (@code{mu4e-jump-to-maildir}). If a prefix argument is given, the maildir
query can be refined before execution.
@subsection Setting up maildir shortcuts @subsection Setting up maildir shortcuts