X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;ds=sidebyside;f=emacs%2Fnotmuch.el;h=8d69fc8751082b12fedea6e042c066e33f9b77a2;hb=c506e1034b5adb54b3e4f8d3e59086756f2bb126;hp=42619b266ba347101445dd4e7de09eb6bfc2142c;hpb=31a5e5a12595c4130d3a7b95b53567003de0b2c9;p=obsolete%2Fnotmuch-old diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 42619b26..8d69fc87 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -47,7 +47,7 @@ ; kudos: Notmuch list (subscription is not ; required, but is available from http://notmuchmail.org). -(require 'cl) +(eval-when-compile (require 'cl)) (require 'mm-view) (require 'message) @@ -741,10 +741,16 @@ characters as well as `_.+-'. (defun notmuch-search-buffer-title (query) "Returns the title for a buffer with notmuch search results." - (let* ((saved-search (rassoc-if (lambda (key) - (string-match (concat "^" (regexp-quote key)) - query)) - (reverse (notmuch-saved-searches)))) + (let* ((saved-search + (let (longest + (longest-length 0)) + (loop for tuple in notmuch-saved-searches + if (let ((quoted-query (regexp-quote (cdr tuple)))) + (and (string-match (concat "^" quoted-query) query) + (> (length (match-string 0 query)) + longest-length))) + do (setq longest tuple)) + longest)) (saved-search-name (car saved-search)) (saved-search-query (cdr saved-search))) (cond ((and saved-search (equal saved-search-query query))