diff options
author | Servilio Afre Puentes <servilio@gmail.com> | 2010-04-18 23:55:50 -0400 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2010-04-21 16:58:46 -0700 |
commit | 3bf27d6c5867a14c58735adba36a3a9ead06a8ff (patch) | |
tree | 0a89dd61fe81a8c70c0611ee6883249090c29174 /emacs | |
parent | 40ff2ab62a4b1b4a5fad4cc8c102afb09135b9ca (diff) |
emacs: Try to name search buffers using info in notmuch-folders
As the user has already defined aliases for certain searches in
notmuch-folders, search buffer names that use these aliases will
be easier to identify.
Diffstat (limited to 'emacs')
-rw-r--r-- | emacs/notmuch.el | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 37ef63d..6eff654 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -665,6 +665,27 @@ characters as well as `_.+-'. (apply 'notmuch-call-notmuch-process "tag" (append action-split (list notmuch-search-query-string) nil)))) +(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-folders)) + (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 + (concat "*notmuch-search-" + (replace-regexp-in-string (concat "^" (regexp-quote folder-query)) + (concat "[ " folder-name " ]") + query) + "*")) + (t + (concat "*notmuch-search-" query "*")) + ))) + ;;;###autoload (defun notmuch-search (query &optional oldest-first target-thread target-line) "Run \"notmuch search\" with the given query string and display results. @@ -677,7 +698,7 @@ The optional parameters are used as follows: target-line: The line number to move to if the target thread does not appear in the search results." (interactive "sNotmuch search: ") - (let ((buffer (get-buffer-create (concat "*notmuch-search-" query "*")))) + (let ((buffer (get-buffer-create (notmuch-search-buffer-title query)))) (switch-to-buffer buffer) (notmuch-search-mode) (set 'notmuch-search-query-string query) |