X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=emacs%2Fnotmuch.el;h=a84852756d66366ef54be50924f210ea485821f5;hb=c9e0da3a1aaa640da330fe82fa906bb84463736b;hp=42619b266ba347101445dd4e7de09eb6bfc2142c;hpb=31a5e5a12595c4130d3a7b95b53567003de0b2c9;p=notmuch diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 42619b26..a8485275 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) @@ -575,9 +575,10 @@ This function advances the next thread when finished." (if (and atbob (not (string= notmuch-search-target-thread "found"))) (set 'never-found-target-thread t)))))) - (if (and never-found-target-thread + (when (and never-found-target-thread notmuch-search-target-line) - (goto-line notmuch-search-target-line))))))) + (goto-char (point-min)) + (forward-line (1- notmuch-search-target-line)))))))) (defcustom notmuch-search-line-faces nil "Tag/face mapping for line highlighting in notmuch-search. @@ -741,10 +742,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)) @@ -789,9 +796,12 @@ The optional parameters are used as follows: (goto-char (point-min)) (save-excursion (let ((proc (start-process-shell-command - "notmuch-search" buffer notmuch-command "search" - (if oldest-first "--sort=oldest-first" "--sort=newest-first") - (shell-quote-argument query)))) + "notmuch-search" buffer + (concat notmuch-command " search " + (if oldest-first + "--sort=oldest-first " + "--sort=newest-first ") + (shell-quote-argument query))))) (set-process-sentinel proc 'notmuch-search-process-sentinel) (set-process-filter proc 'notmuch-search-process-filter)))) (run-hooks 'notmuch-search-hook)))