unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: Make the queries used in the all-tags section
@ 2011-05-19 23:18 Daniel Schoepe
  2011-05-24 20:39 ` Carl Worth
  2011-05-25  4:10 ` Austin Clements
  0 siblings, 2 replies; 17+ messages in thread
From: Daniel Schoepe @ 2011-05-19 23:18 UTC (permalink / raw)
  To: notmuch


[-- Attachment #1.1: Type: text/plain, Size: 565 bytes --]


From the commit message:

    emacs: Make queries used in the all-tags section configurable
    
    This patch adds a customization variable that controls what queries
    are used to construct the all-tags section in notmuch-hello. It allows
    the user to specify a function to construct the query given a tag. It
    also allows hiding tags by returning nil.

Possible uses would be things like displaying the unread count for
tags instead of all messages with that tag and/or hiding uninteresting
tags like "signed" or "encrypted".

-- Daniel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-emacs-Make-queries-used-in-the-all-tags-section-conf.patch --]
[-- Type: text/x-diff, Size: 2763 bytes --]

From bc4e046537518255ad02254c88e7b5bedd347c2b Mon Sep 17 00:00:00 2001
From: Daniel Schoepe <daniel.schoepe@googlemail.com>
Date: Fri, 20 May 2011 00:53:50 +0200
Subject: [PATCH] emacs: Make queries used in the all-tags section
 configurable

This patch adds a customization variable that controls what queries
are used to construct the all-tags section in notmuch-hello. It allows
the user to specify a function to construct the query given a tag. It
also allows hiding tags by returning nil.

Signed-off-by: Daniel Schoepe <daniel.schoepe@googlemail.com>
---
 emacs/notmuch-hello.el |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index e58dd24..0b8c0b9 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -55,6 +55,17 @@
   :type 'boolean
   :group 'notmuch)
 
+(defcustom notmuch-hello-tag-list-make-query nil
+  "Function to generate queries for the all tags list.
+
+This variable controls which query results are shown for each tag
+in the \"all tags\" list. If this is nil, it uses the default of
+\"tag:TAG\", otherwise it should be a function of one argument,
+the tag, that should return the query to be used for that tag, or
+nil, in which case the tag will be hidden."
+  :type '(choice function (const nil :tag "tag:TAG"))
+  :group 'notmuch)
+
 (defface notmuch-hello-logo-background
   '((((class color)
       (background dark))
@@ -318,6 +329,16 @@ Complete list of currently available key bindings:
  ;;(setq buffer-read-only t)
 )
 
+(defun notmuch-hello-generate-tag-alist ()
+  "Return an alist from tags to queries to display in the all-tags section."
+  (filter 'cdr
+	  (mapcar '(lambda (tag)
+		     (cons tag
+			   (if notmuch-hello-tag-list-make-query
+			       (funcall notmuch-hello-tag-list-make-query tag)
+			     (concat "tag:" tag))))
+		  (process-lines notmuch-command "search-tags"))))
+
 ;;;###autoload
 (defun notmuch-hello (&optional no-display)
   "Run notmuch and display saved searches, known tags, etc."
@@ -396,9 +417,7 @@ Complete list of currently available key bindings:
 		      if (> (string-to-number (notmuch-saved-search-count (cdr elem))) 0)
 		      collect elem)))
 	     (saved-widest (notmuch-hello-longest-label saved-alist))
-	     (alltags-alist (if notmuch-show-all-tags-list
-				(mapcar '(lambda (tag) (cons tag (concat "tag:" tag)))
-					(process-lines notmuch-command "search-tags"))))
+	     (alltags-alist (if notmuch-show-all-tags-list (notmuch-hello-generate-tag-alist)))
 	     (alltags-widest (notmuch-hello-longest-label alltags-alist))
 	     (widest (max saved-widest alltags-widest)))
 
-- 
1.7.5.1


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

^ permalink raw reply related	[flat|nested] 17+ messages in thread
* Re: [PATCH] emacs: Make the queries used in the all-tags section
@ 2011-05-26  3:27 Austin Clements
  0 siblings, 0 replies; 17+ messages in thread
From: Austin Clements @ 2011-05-26  3:27 UTC (permalink / raw)
  To: Daniel Schoepe; +Cc: notmuch

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

On May 25, 2011 7:21 PM, "Daniel Schoepe" <daniel.schoepe@googlemail.com>
wrote:
>
> On Wed, 25 May 2011 18:42:30 -0400, Austin Clements <amdragon@mit.edu>
wrote:
> > 'Doh.  That's what I get for not reading the surrounding code.  I
> > misunderstood what your patch was going for and assumed it was what
> > *I* wanted notmuch to do, which is to show me useful counts (e.g.,
> > unread count), but not to change the underlying query.  ]:--8)
>
> I thought about that too, but figured it should be rather rare that
> someone wants only a portion of some messages _counted_, but all
> displayed when clicking on the search next to the count.

My use case of counting only unread messages (but still showing all of them,
like just about every other mail client out there) is an example of this.
But you're right that I can't think of any other examples (which is why I
suggested just baking this specific thing in earlier).

> I'm somewhat indifferent, since I rarely use those links
> directly, so any more opinions on this are very much appreciated.

Actually, here's a new thought that may help address your original problem
(assuming I understand it correctly now).  One of my design criteria for the
custom query parser (need to get back to those patches...) was to support
"implicit tag filters" such as hiding everything with tag:spam or tag:killed
(or tag:muted, etc) unless these tags are specifically requested by a
query.  That would apply equally to generated queries like the all tags
list, so you could filter out tag:killed messages centrally using a
mechanism like this, rather than having to work it in to every query
somehow.

> > So, to me, it seems like this turns the all tags section into another
> > saved searches section, just with a slight twist, and makes me wonder
> > if there's a better way to reconcile these.
>
> Well, it already was sort of a non-configurable saved searches section
> before, so I didn't really turn it into one. :)

True.

> Since the main difference between those sections is the clear visual
> distinction, it might be an option to provide the user with functions to
> easily declare new sections for the hello screen, where this sort of
> thing is configurable. (One possible use that comes to mind would be to
> group tags into different categories.)

That would be awesome.

[-- Attachment #2: Type: text/html, Size: 2738 bytes --]

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

end of thread, other threads:[~2011-05-27  3:57 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-19 23:18 [PATCH] emacs: Make the queries used in the all-tags section Daniel Schoepe
2011-05-24 20:39 ` Carl Worth
2011-05-24 21:01   ` Daniel Schoepe
2011-05-24 22:04     ` Carl Worth
2011-05-25  4:10 ` Austin Clements
2011-05-25 10:04   ` Daniel Schoepe
2011-05-25 14:44     ` Austin Clements
2011-05-25 16:51       ` Daniel Schoepe
2011-05-25 17:56         ` Daniel Schoepe
2011-05-25 19:11           ` Austin Clements
2011-05-25 21:21             ` Daniel Schoepe
2011-05-25 22:42               ` Austin Clements
2011-05-25 23:21                 ` Daniel Schoepe
2011-05-26  1:05                   ` Carl Worth
2011-05-26 22:04               ` Carl Worth
2011-05-27  3:56                 ` Daniel Kahn Gillmor
  -- strict thread matches above, loose matches on Subject: below --
2011-05-26  3:27 Austin Clements

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).