If you have queries that you use often, you may want to store them as bookmarks. Bookmark searches are available in the main view (see Main view), header view (see Headers view), and message view (see Message view), using (by default) the key b (M-x mu4e-search-bookmark), or B (M-x mu4e-search-bookmark-edit) which lets you edit the bookmark first.
mu4e provides a number of default bookmarks. Their definition is instructive:
(defvar mu4e-bookmarks `( ,(make-mu4e-bookmark :name "Unread messages" :query "flag:unread AND NOT flag:trashed" :key ?u) ,(make-mu4e-bookmark :name "Today's messages" :query "date:today..now" :key ?t) ,(make-mu4e-bookmark :name "Last 7 days" :query "date:7d..now" :key ?w) ,(make-mu4e-bookmark :name "Messages with images" :query "mime:image/*" :key ?p)) "A list of pre-defined queries. Each query is represented by a mu4e-bookmark structure with parameters :name with the name of the bookmark, :query with the query expression (a query string or an s-expression that evaluates to query string) and a :key, which is the shortcut-key for the query. An older form of bookmark, a 3-item list with (QUERY DESCRIPTION KEY) is still recognized as well, for backward-compatibility.")
You can replace these or add your own items, by putting in your configuration (~/.emacs) something like:
(add-to-list 'mu4e-bookmarks (make-mu4e-bookmark :name "Big messages" :query "size:5M..500M" :key ?b))
This prepends your bookmark to the list, and assigns the key b to it. If
you want to append your bookmark, you can use
t as the third argument to
In the various mu4e views, pressing b lists all the bookmarks 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 bb.
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 most a week old in your inbox:
(add-to-list 'mu4e-bookmarks (make-mu4e-bookmark :name "Inbox messages in the last 7 days" :query (concat "maildir:/inbox AND date:" (format-time-string "%Y%m%d" (subtract-time (current-time) (days-to-time 7)))) :key ?w) t)
There is also M-x mu4e-headers-search-bookmark-edit (key B), which lets you edit the bookmarked query before invoking it. This can be useful if you have many similar queries, but need to change some parameter. For example, you could have a bookmark ‘"date:today..now AND "’31, which limits any result to today’s messages.
Not a valid search query by itself