]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: fix `notmuch-*-filter-by-tag' query strings
authorKristoffer Balintona <krisbalintona@gmail.com>
Thu, 13 Nov 2025 20:39:14 +0000 (14:39 -0600)
committerDavid Bremner <david@tethera.net>
Sat, 24 Jan 2026 23:15:12 +0000 (08:15 +0900)
`notmuch-tree-filter-by-tag' and `notmuch-search-filter-by-tag' are
described, in their docstrings, as matching all the messages in the
current view that are ALSO tagged by a given tag.  However, since the
current view's search query was not logically grouped together (with
parentheses), the actual behavior was different for sufficiently
complex search queries.

Fix this by grouping the current view's search query in parentheses
first.

emacs/notmuch-tree.el
emacs/notmuch.el

index aa0d92a75c8fa89698b5ea60b626cc271c27a9a7..7c4b6d8f9b670ea1d234a9f7be41a34594d108a7 100644 (file)
@@ -1308,7 +1308,7 @@ search results and that are also tagged with the given TAG."
                                             notmuch-tree-basic-query)))
   (let ((notmuch-show-process-crypto (notmuch-tree--message-process-crypto)))
     (notmuch-tree-close-message-window)
-    (notmuch-tree (concat notmuch-tree-basic-query " and tag:" tag)
+    (notmuch-tree (format "(%s) and tag:%s" notmuch-tree-basic-query tag)
                  notmuch-tree-query-context
                  nil
                  nil
index 69aff3475508e6c518b2f3fbec10e93eaf7d883a..c61c263d7cc16f5e78bad54c89f34e2cef25dd02 100644 (file)
@@ -1192,7 +1192,7 @@ search results and that are also tagged with the given TAG."
   (interactive
    (list (notmuch-select-tag-with-completion "Filter by tag: "
                                             notmuch-search-query-string)))
-  (notmuch-search (concat notmuch-search-query-string " and tag:" tag)
+  (notmuch-search (format "(%s) and tag:%s" notmuch-search-query-string tag)
                  notmuch-search-oldest-first
                  notmuch-search-hide-excluded))