mirror of https://github.com/djcb/mu.git
mu4e: allow lisp expressions for bookmarks
based on an idea by davidcsterratt
This commit is contained in:
parent
707051827d
commit
823d80f075
|
@ -375,14 +375,19 @@ and offer to create it if it does not exist yet."
|
|||
(defun mu4e-get-bookmark-query (kar)
|
||||
"Get the corresponding bookmarked query for shortcut character
|
||||
KAR, or raise an error if none is found."
|
||||
(let ((chosen-bm
|
||||
(find-if
|
||||
(lambda (bm)
|
||||
(= kar (nth 2 bm)))
|
||||
mu4e-bookmarks)))
|
||||
(if chosen-bm
|
||||
(nth 0 chosen-bm)
|
||||
(mu4e-warn "Unknown shortcut '%c'" kar))))
|
||||
(let* ((chosen-bm
|
||||
(or (find-if
|
||||
(lambda (bm)
|
||||
(= kar (nth 2 bm)))
|
||||
mu4e-bookmarks)
|
||||
(mu4e-warn "Unknown shortcut '%c'" kar)))
|
||||
(expr (nth 0 chosen-bm))
|
||||
(query (eval expr)))
|
||||
(if (stringp query)
|
||||
query
|
||||
(mu4e-warn "Expression must evaluate to query string ('%S')" expr))))
|
||||
|
||||
|
||||
|
||||
|
||||
;;; converting flags->string and vice-versa ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
|
|
@ -1862,6 +1862,23 @@ defined in the echo area, with the shortcut key highlighted. So, to invoke the
|
|||
bookmark we just defined (to get the list of "Big Messages"), all you need to
|
||||
type is @kbd{bb}.
|
||||
|
||||
@subsection Lisp expressions as bookmarks
|
||||
|
||||
Instead of using strings, it is also possible to use Lisp expressions as
|
||||
bookmarks. The only requirement is that they evaluate to a query string.
|
||||
|
||||
For example, to get all the messages that are at least a week old in
|
||||
your inbox:
|
||||
|
||||
@lisp
|
||||
(add-to-list 'mu4e-bookmarks '(
|
||||
(concat "maildir:/inbox date:.."
|
||||
(format-time-string "%Y%m%d"
|
||||
(subtract-time (current-time) (days-to-time 7))))
|
||||
"Messages older than a week" ?O) t)
|
||||
@end lisp
|
||||
|
||||
|
||||
@subsection Editing bookmarks before searching
|
||||
|
||||
There is also @kbd{M-x mu4e-headers-search-bookmark-edit} (key @key{B}), which
|
||||
|
|
Loading…
Reference in New Issue