X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=emacs%2Fnotmuch.el;h=488458af98bf516cd55a712ca45567caa49a11e7;hb=9b85872ed4526688a6195cfa8af19be20ed869c2;hp=27e3a4094c398f9b7393ae19565ba611a1bab21b;hpb=f2ebe3ac446afda9ced6507dc391865464ccdcaa;p=notmuch diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 27e3a409..488458af 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -662,19 +662,19 @@ characters as well as `_.+-'. (defun notmuch-search-buffer-title (query) "Returns the title for a buffer with notmuch search results." - (let* ((folder (rassoc-if (lambda (key) - (string-match (concat "^" (regexp-quote key) "$") - query)) - (notmuch-saved-searches))) - (folder-name (car folder)) - (folder-query (cdr folder))) - (cond ((and folder (equal folder-query query)) - ;; Query is the same as folder search (ignoring case) - (concat "*notmuch-folder-" folder-name "*")) - (folder + (let* ((saved-search (rassoc-if (lambda (key) + (string-match (concat "^" (regexp-quote key)) + query)) + (reverse (notmuch-saved-searches)))) + (saved-search-name (car saved-search)) + (saved-search-query (cdr saved-search))) + (cond ((and saved-search (equal saved-search-query query)) + ;; Query is the same as saved search (ignoring case) + (concat "*notmuch-saved-search-" saved-search-name "*")) + (saved-search (concat "*notmuch-search-" - (replace-regexp-in-string (concat "^" (regexp-quote folder-query)) - (concat "[ " folder-name " ]") + (replace-regexp-in-string (concat "^" (regexp-quote saved-search-query)) + (concat "[ " saved-search-name " ]") query) "*")) (t