Re: [PATCH v4 1/2] emacs: User-defined sections in notmuch-hello

Subject: Re: [PATCH v4 1/2] emacs: User-defined sections in notmuch-hello

Date: Sat, 09 Jul 2011 01:00:03 +0200

To: Daniel Schoepe, notmuch@notmuchmail.org

Cc:

From: Michal Sojka


On Fri, 08 Jul 2011, Daniel Schoepe wrote:
> This has been done in v4 of the patch, for which I screwed up the
> In-Reply-To header and hence is listed as a separate thread:
> 
> id:"1310079227-19120-1-git-send-email-daniel.schoepe@googlemail.com"

Oh, you always send new versions faster than I can investigate the older
ones :-)

> > - The title of custom tags section was not passed correctly to the
> >   functions. This is also fixed in the patch below.
> 
> I changed title to a mandatory argument for consistency with
> notmuch-insert-searches and because a title-less section wouldn't make
> much sense anyway.

Yes, this is definitely a good idea. My last comment to the patch is
that I do not like the use of plists in customization interface. It is
especially weird in the case of boolean options like hide-if-empty,
because they actually have three states: disabled, off and on. And this
make not a lot of sense.

I think that the customization interface is much better arranged when it
is modified like in the patch below (it is against v3).

-Michal

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index d3b146e..3e883ff 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -106,17 +106,14 @@ Typically \",\" in the US and UK and \".\" in Europe."
 (define-widget 'notmuch-hello-tags-section 'lazy
   "Customize-type for notmuch-hello tag-list sections."
   :tag "Customized tag-list"
-  :type
-  (let ((opts
-        '((:title (string :tag "Title for this section"))
-          (:make-query (string :tag "Filter for each tag"))
-          (:make-count (string :tag "Different query to generate counts"))
-          (:hide-tags (repeat :tag "Tags that will be hidden" string))
-          (:initially-hidden (boolean :tag "Hide this on startup?"))
-          (:hide-empty-tags (boolean :tag "Hide tags with no matching messages"))
-          (:hide-if-empty (boolean :tag "Hide if empty")))))
-    `(list (const :tag "" notmuch-hello-insert-tags-section)
-          (plist :inline t :options ,opts))))
+  :type '(list (const :tag "" notmuch-hello-insert-tags-section)
+              (string :tag "Title for this section")
+              (string :tag "Filter for each tag")
+              (string :tag "Different filter to generate counts")
+              (repeat :tag "Tags that will be hidden" string)
+              (boolean :tag "Hide this on startup?")
+              (boolean :tag "Hide tags with no matching messages")
+              (boolean :tag "Hide if empty")))
 
 (define-widget 'notmuch-hello-query-section 'lazy
   "Customize-type for custom saved-search-like sections"
@@ -629,7 +626,8 @@ Supports the following entries in OPTIONS as a plist:
        (indent-rigidly start (point) notmuch-hello-indent)
        target-pos))))
 
-(defun notmuch-hello-insert-tags-section (&rest options)
+(defun notmuch-hello-insert-tags-section (title &optional filter filter-count hide-tags initially-hidden
+                                               hide-empty-searches hide-if-empty)
   "Insert a section displaying all tags and message counts for each.
 
 TITLE defaults to \"All tags: \".
@@ -637,13 +635,13 @@ Allowed options are those accepted by `notmuch-hello-insert-searches' and the
 following:
 
 :hide-tags - List of tags that should be excluded."
-  (apply 'notmuch-hello-insert-searches
-        (plist-get options :title)
-        (notmuch-hello-generate-tag-alist
-         (plist-get options :hide-tags)
-         (plist-get options :make-query)
-         (plist-get options :make-count))
-        options))
+  (notmuch-hello-insert-searches title
+                                (notmuch-hello-generate-tag-alist hide-tags filter
+                                                                  (if (string= "" filter-count)
+                                                                      nil filter-count))
+                                :initially-hidden initially-hidden
+                                :hide-empty-searches hide-empty-searches
+                                :hide-if-empty hide-if-empty))
 
 (defun notmuch-hello-insert-inbox ()
   "Show an entry for each saved search and inboxed messages for each tag"

Thread: