I am trying mu4u for Gmail and an Exchange account.

;;; Mail directory shortcuts
  (setq mu4e-maildir-shortcuts
        '(("/Gmail/INBOX" . ?g)
          ("/Exchange/INBOX" . ?a)))

;;; Bookmarks
  (setq mu4e-bookmarks
        `(("flag:unread AND NOT flag:trashed AND NOT (maildir:/[Gmail].Trash OR maildir:/Trash)" "Unread messages" ?u)
          ("date:today..now" "Today's messages" ?t)
          ("date:7d..now" "Last 7 days" ?w)
          ("mime:image/*" "Messages with images" ?p)
          (,(mapconcat 'identity
                        (lambda (maildir)
                          (concat "maildir:" (car maildir)))
                        mu4e-maildir-shortcuts) " OR ")
           "All inboxes" ?i)))


On mu4e main view, hitting bu brings me unread email from all over places including Trash folders.

How do I change it so that I don't see messages that are trashed in Trash folders or marked spam?


You can skip specific maildir from indexing for search, using .noindex file.

from mu-index(1):

If there is a file called .noindex in a directory, the contents of that directory and all of its subdirectories will be ignored. This can be useful to exclude certain directories from the indexing process, for example direc‐ tories with spam-messages.

ex. $ touch ~/Maildir/Gmail/[Gmail].Trash/.noindex && mu index

  • Then you can't even see them when you jump to their maildirs in mu4e. So you lose the ability to check Spam for wrongly filed emails.
    – RichieHH
    Jan 21 '21 at 16:06

If your query is not returning the results you expect, try expanding it out. Sometimes there are bugs with features like parentheses. That is, instead of:

flag:unread AND NOT (maildir:/Trash OR maildir:/[Gmail].Trash)


flag:unread AND NOT maildir:/Trash AND NOT maildir:/[Gmail].Trash

Also note that if you are trying these at the command line with mu-find, you should escape or quote the parts with special characters, like parentheses or brackets, but don't quote the whole query:

$ mu find flag:unread AND NOT \( maildir:/Trash OR "maildir:/[Gmail].Trash" \)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.