X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=emacs%2Fnotmuch.el;h=060af8eb0a361a613b92cf354c37589f1e86115b;hp=6564816f078659f23ab5f6a6c6fc51478aa695ae;hb=c689d1ff13ed48507230ca7035021ce42d3dcd64;hpb=8cca886b10c5ec44f3214701c0c1e3c896d53d5c diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 6564816f..060af8eb 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -61,10 +61,6 @@ (require 'notmuch-message) (require 'notmuch-parser) -(unless (require 'notmuch-version nil t) - (defconst notmuch-emacs-version "unknown" - "Placeholder variable when notmuch-version.el[c] is not available.")) - (defcustom notmuch-search-result-format `(("date" . "%12s ") ("count" . "%-7s ") @@ -166,7 +162,7 @@ there will be called at other points of notmuch execution." (define-key map "o" 'notmuch-search-toggle-order) (define-key map "c" 'notmuch-search-stash-map) (define-key map "t" 'notmuch-search-filter-by-tag) - (define-key map "f" 'notmuch-search-filter) + (define-key map "l" 'notmuch-search-filter) (define-key map [mouse-1] 'notmuch-search-show-thread) (define-key map "*" 'notmuch-search-tag-all) (define-key map "a" 'notmuch-search-archive-thread) @@ -462,7 +458,11 @@ no messages in the region then return nil." (notmuch-search-properties-in-region :subject beg end)) (defun notmuch-search-show-thread (&optional elide-toggle) - "Display the currently selected thread." + "Display the currently selected thread. + +With a prefix argument, invert the default value of +`notmuch-show-only-matching-messages' when displaying the +thread." (interactive "P") (let ((thread-id (notmuch-search-find-thread-id)) (subject (notmuch-search-find-subject))) @@ -982,18 +982,28 @@ default sort order is defined by `notmuch-search-oldest-first'." (set 'notmuch-search-oldest-first (not notmuch-search-oldest-first)) (notmuch-search-refresh-view)) +(defun notmuch-group-disjunctive-query-string (query-string) + "Group query if it contains a complex expression. + +Enclose QUERY-STRING in parentheses if it matches +`notmuch-search-disjunctive-regexp'." + (if (string-match-p notmuch-search-disjunctive-regexp query-string) + (concat "( " query-string " )") + query-string)) + (defun notmuch-search-filter (query) - "Filter the current search results based on an additional query string. + "Filter or LIMIT the current search results based on an additional query string. Runs a new search matching only messages that match both the current search results AND the additional query string provided." (interactive (list (notmuch-read-query "Filter search: "))) - (let ((grouped-query (if (string-match-p notmuch-search-disjunctive-regexp query) - (concat "( " query " )") - query))) - (notmuch-search (if (string= notmuch-search-query-string "*") + (let ((grouped-query (notmuch-group-disjunctive-query-string query)) + (grouped-original-query (notmuch-group-disjunctive-query-string + notmuch-search-query-string))) + (notmuch-search (if (string= grouped-original-query "*") grouped-query - (concat notmuch-search-query-string " and " grouped-query)) notmuch-search-oldest-first))) + (concat grouped-original-query " and " grouped-query)) + notmuch-search-oldest-first))) (defun notmuch-search-filter-by-tag (tag) "Filter the current search results based on a single tag.