unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: Try to name search buffers using info in  notmuch-folders
@ 2010-04-19  3:55 Servilio Afre Puentes
  2010-04-22  0:10 ` Carl Worth
  0 siblings, 1 reply; 3+ messages in thread
From: Servilio Afre Puentes @ 2010-04-19  3:55 UTC (permalink / raw)
  To: notmuch

This patch obsoletes the one sent in message:

r2sb22065d01004150516jf099f3dcw180a7db0dc972c76@mail.gmail.com

8<------

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.
---
 emacs/notmuch.el |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 0adaf8b..f18b1ac 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -695,6 +695,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.
@@ -707,7 +728,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)
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] emacs: Try to name search buffers using info in notmuch-folders
  2010-04-19  3:55 [PATCH] emacs: Try to name search buffers using info in notmuch-folders Servilio Afre Puentes
@ 2010-04-22  0:10 ` Carl Worth
  2010-04-22  1:03   ` Servilio Afre Puentes
  0 siblings, 1 reply; 3+ messages in thread
From: Carl Worth @ 2010-04-22  0:10 UTC (permalink / raw)
  To: Servilio Afre Puentes, notmuch

[-- Attachment #1: Type: text/plain, Size: 894 bytes --]

On Sun, 18 Apr 2010 23:55:50 -0400, Servilio Afre Puentes <servilio@gmail.com> wrote:
> 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.

A lovely feature, thanks!

I've pushed this out now (along with a tiny follow-up to avoid a warning
From the emacs compiler).

It does occur to me that once we have saved searches supported at a
lower level within notmuch, then this functionality won't be needed in
the emacs interface at all, (since the nice name and the search strings
will then be equivalent).

And this patch even makes a proposal for what the saved-search syntax
could be. It uses "[ inbox ]" for a saved search named "inbox". I
believe that sup is already using "{inbox}" for a similar
feature. Perhaps a bracketed style like that is what we want.

-Carl

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] emacs: Try to name search buffers using info in  notmuch-folders
  2010-04-22  0:10 ` Carl Worth
@ 2010-04-22  1:03   ` Servilio Afre Puentes
  0 siblings, 0 replies; 3+ messages in thread
From: Servilio Afre Puentes @ 2010-04-22  1:03 UTC (permalink / raw)
  To: Carl Worth; +Cc: notmuch

On 21 April 2010 20:10, Carl Worth <cworth@cworth.org> wrote:
> On Sun, 18 Apr 2010 23:55:50 -0400, Servilio Afre Puentes <servilio@gmail.com> wrote:
>> 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.
>
> A lovely feature, thanks!

My pleasure! Thanks to you for notmuch!

> I've pushed this out now (along with a tiny follow-up to avoid a warning
> From the emacs compiler).

Great, I noticed that when building, but as everything worked fine
afterwards, I decided to wait to get some feedback on the list. But
you were faster!

> It does occur to me that once we have saved searches supported at a
> lower level within notmuch, then this functionality won't be needed in
> the emacs interface at all, (since the nice name and the search strings
> will then be equivalent).

Yep.

> And this patch even makes a proposal for what the saved-search syntax
> could be. It uses "[ inbox ]" for a saved search named "inbox". I
> believe that sup is already using "{inbox}" for a similar
> feature. Perhaps a bracketed style like that is what we want.

For me it was the easier thing to read, I suppose that this can be
made to be customizable so the user can set it up to be whatever is
easier to read.

Servilio

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-04-22  1:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-19  3:55 [PATCH] emacs: Try to name search buffers using info in notmuch-folders Servilio Afre Puentes
2010-04-22  0:10 ` Carl Worth
2010-04-22  1:03   ` Servilio Afre Puentes

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).