mirror of https://github.com/djcb/mu.git
mu4e: implement mu4e-search-query
Pick a query using completing-read with a new command mu4e-search-query. Update docs.
This commit is contained in:
parent
40a73c70f2
commit
d5129052df
18
NEWS.org
18
NEWS.org
|
@ -45,6 +45,10 @@
|
||||||
|
|
||||||
*** mu4e
|
*** mu4e
|
||||||
|
|
||||||
|
- New command ~mu4e-search-query~ (bound to =c=) which lets you pick a query
|
||||||
|
(from bookmark / maildir shortcuts) with completion in main / headers /
|
||||||
|
view buffers.
|
||||||
|
|
||||||
- improved support for dealing with attachments and other MIME-parts in the
|
- improved support for dealing with attachments and other MIME-parts in the
|
||||||
message view; they gained completions support with annotations in the
|
message view; they gained completions support with annotations in the
|
||||||
minibuffer
|
minibuffer
|
||||||
|
@ -65,14 +69,14 @@
|
||||||
for some (selected) mailing-list archives.
|
for some (selected) mailing-list archives.
|
||||||
|
|
||||||
- ~mu4e-quit~ now takes a prefix argument which, if provided, causes it to
|
- ~mu4e-quit~ now takes a prefix argument which, if provided, causes it to
|
||||||
bury he mu main buffer, rather than quitting mu. ~mu4e~ will now just switch
|
bury the mu main buffer, rather than quitting mu. ~mu4e~ will now just
|
||||||
the mu4e buffer if it exists (otherwise it starts ~mu4e~).
|
switch the mu4e buffer if it exists (otherwise it starts ~mu4e~).
|
||||||
|
|
||||||
- ~mu4e~ benefits from the mentioned speed-ups in querying, and adds some of
|
- ~mu4e~ queries are much snappier now. ~mu4e~ benefits from the mentioned
|
||||||
its own - e.g., for showing 500 messages (debug build), we went from 642ms
|
speed-ups in querying, and adds some of its own - e.g., for showing 500
|
||||||
to 247ms. Note, the optimizations are experimental, and for now you can
|
messages (debug build), we went from 642ms to 247ms. Note, the
|
||||||
turn them off by setting =mu4e-mu-allow-temp-file= to =nil= (and restart
|
optimizations are experimental, and for now you can turn them off by
|
||||||
~mu4e~); and reporting.
|
setting =mu4e-mu-allow-temp-file= to =nil= (and restart ~mu4e~); and reporting.
|
||||||
|
|
||||||
- after retrieving mail (~mu4e-update-mail-and-index~), save the output of the
|
- after retrieving mail (~mu4e-update-mail-and-index~), save the output of the
|
||||||
retrieval command in a buffer =*mu4e-last-update*=, = which can be useful
|
retrieval command in a buffer =*mu4e-last-update*=, = which can be useful
|
||||||
|
|
|
@ -315,7 +315,8 @@ Otherwise, do nothing."
|
||||||
(mu4e--main-items 'maildirs max-length)
|
(mu4e--main-items 'maildirs max-length)
|
||||||
"\n"
|
"\n"
|
||||||
(propertize " Misc\n\n" 'face 'mu4e-title-face)
|
(propertize " Misc\n\n" 'face 'mu4e-title-face)
|
||||||
|
(mu4e--main-action "\t* [@]Choose query\n"
|
||||||
|
#'mu4e-search-query nil "c")
|
||||||
(mu4e--main-action "\t* [@]Switch context\n"
|
(mu4e--main-action "\t* [@]Switch context\n"
|
||||||
#'mu4e-context-switch nil ";")
|
#'mu4e-context-switch nil ";")
|
||||||
(mu4e--main-action "\t* [@]Update email & database\n"
|
(mu4e--main-action "\t* [@]Update email & database\n"
|
||||||
|
|
|
@ -80,7 +80,7 @@ the latest query-items.")
|
||||||
(unless (stringp query)
|
(unless (stringp query)
|
||||||
(mu4e-warn "Could not get query string from %s" bm))
|
(mu4e-warn "Could not get query string from %s" bm))
|
||||||
;; apparently, non-UTF8 queries exist, i.e.,
|
;; apparently, non-UTF8 queries exist, i.e.,
|
||||||
;; with maild dir names.
|
;; with maildir names.
|
||||||
(decode-coding-string query 'utf-8 t))))
|
(decode-coding-string query 'utf-8 t))))
|
||||||
|
|
||||||
(defun mu4e--query-items-pick-favorite (items)
|
(defun mu4e--query-items-pick-favorite (items)
|
||||||
|
|
|
@ -217,7 +217,7 @@ the search."
|
||||||
(mu4e--query-items-refresh 'reset-baseline))
|
(mu4e--query-items-refresh 'reset-baseline))
|
||||||
|
|
||||||
(run-hook-with-args 'mu4e-search-bookmark-hook expr)
|
(run-hook-with-args 'mu4e-search-bookmark-hook expr)
|
||||||
(mu4e-search expr (when edit "Edit bookmark: ") edit)))
|
(mu4e-search expr (when edit "Edit query: ") edit)))
|
||||||
|
|
||||||
(defun mu4e-search-bookmark-edit ()
|
(defun mu4e-search-bookmark-edit ()
|
||||||
"Edit an existing bookmark before executing it."
|
"Edit an existing bookmark before executing it."
|
||||||
|
@ -547,6 +547,36 @@ the mode-line.")
|
||||||
'help-echo (format "mu4e query:\n\t%s" mu4e--search-last-query))
|
'help-echo (format "mu4e query:\n\t%s" mu4e--search-last-query))
|
||||||
"]")))
|
"]")))
|
||||||
|
|
||||||
|
(defun mu4e-search-query (&optional edit)
|
||||||
|
"Select a search query through `completing-read'.
|
||||||
|
|
||||||
|
If prefix-argument EDIT is non-nil, allow for editing the chosen
|
||||||
|
query before submitting it."
|
||||||
|
(interactive "P")
|
||||||
|
(let* ((candidates (seq-map (lambda (item)
|
||||||
|
(cons (plist-get item :name) item))
|
||||||
|
(mu4e-query-items)))
|
||||||
|
(longest-name
|
||||||
|
(seq-max (seq-map (lambda (c) (length (car c))) candidates)))
|
||||||
|
(longest-query
|
||||||
|
(seq-max (seq-map (lambda (c) (length (plist-get (cdr c) :query)))
|
||||||
|
candidates)))
|
||||||
|
|
||||||
|
(annotation-func
|
||||||
|
(lambda (candidate)
|
||||||
|
(let* ((item (cdr-safe (assoc candidate candidates)))
|
||||||
|
(name (propertize (or (plist-get item :name) "")
|
||||||
|
'face 'mu4e-header-key-face))
|
||||||
|
(query (propertize (or (plist-get item :query) "")
|
||||||
|
'face 'mu4e-header-value-face)))
|
||||||
|
(concat
|
||||||
|
" "
|
||||||
|
(make-string (- longest-name (length name)) ?\s)
|
||||||
|
query))))
|
||||||
|
(completion-extra-properties
|
||||||
|
`(:annotation-function ,annotation-func)))
|
||||||
|
(mu4e-search-bookmark (completing-read "Query: " candidates) edit)))
|
||||||
|
|
||||||
(define-minor-mode mu4e-search-minor-mode
|
(define-minor-mode mu4e-search-minor-mode
|
||||||
"Mode for searching for messages."
|
"Mode for searching for messages."
|
||||||
:global nil
|
:global nil
|
||||||
|
@ -569,6 +599,8 @@ the mode-line.")
|
||||||
(define-key map "b" #'mu4e-search-bookmark)
|
(define-key map "b" #'mu4e-search-bookmark)
|
||||||
(define-key map "B" #'mu4e-search-bookmark-edit)
|
(define-key map "B" #'mu4e-search-bookmark-edit)
|
||||||
|
|
||||||
|
(define-key map "c" #'mu4e-search-query)
|
||||||
|
|
||||||
(define-key map "j" #'mu4e-search-maildir)
|
(define-key map "j" #'mu4e-search-maildir)
|
||||||
map))
|
map))
|
||||||
|
|
||||||
|
@ -580,6 +612,8 @@ the mode-line.")
|
||||||
:help "Show messages matching some bookmark query"]
|
:help "Show messages matching some bookmark query"]
|
||||||
["Search maildir" mu4e-search-maildir
|
["Search maildir" mu4e-search-maildir
|
||||||
:help "Show messages in some maildir"]
|
:help "Show messages in some maildir"]
|
||||||
|
["Choose query" mu4e-search-query
|
||||||
|
:help "Show messages for some query"]
|
||||||
["Previous query" mu4e-search-prev
|
["Previous query" mu4e-search-prev
|
||||||
:help "Run previous query"]
|
:help "Run previous query"]
|
||||||
["Next query" mu4e-search-next
|
["Next query" mu4e-search-next
|
||||||
|
|
|
@ -987,6 +987,7 @@ S edit last query
|
||||||
/ narrow the search
|
/ narrow the search
|
||||||
b search bookmark
|
b search bookmark
|
||||||
B edit bookmark before search
|
B edit bookmark before search
|
||||||
|
c search query with completion
|
||||||
j jump to maildir
|
j jump to maildir
|
||||||
M-left,\ previous query
|
M-left,\ previous query
|
||||||
M-right next query
|
M-right next query
|
||||||
|
@ -1362,6 +1363,7 @@ S edit last query
|
||||||
/ narrow the search
|
/ narrow the search
|
||||||
b search bookmark
|
b search bookmark
|
||||||
B edit bookmark before search
|
B edit bookmark before search
|
||||||
|
c search query with completion
|
||||||
j jump to maildir
|
j jump to maildir
|
||||||
|
|
||||||
O change sort order
|
O change sort order
|
||||||
|
|
Loading…
Reference in New Issue