Re: [PATCH 0/2] emacs: User-defined sections in notmuch-hello
On Tue, 05 Jul 2011 02:00:33 +0200, Michal Sojka sojk...@fel.cvut.cz wrote: First, the customization interface for the custom sections (not the predefined ones) is very confusing. I was not able to use it at all. Instead I hacked the source code (see below) to add my section to the notmuch-hello-sections list. What specifically did you find confusing? The first customization-option is intended for sections like the all tags section which various configuration options which should be explained by the docstrings next to the options. The second item allows saved-searches-like sections. By the way: Instead of editing the source directly, you can also put all customizations like that in your configuration files and set notmuch-hello-sections from there. Nevertheless your inbox-display functions look useful in general so they should indeed be included. Second, when I tried to understand your patch, I found some names of functions and variables quite confusing. In the patch below, I tried to give them a better names and I also updated the documentation. Feel free to use my changes for your later patch submission. Thanks, those look quite a bit clearer, naming things like that is really not my strong suit. I'll include them in the next version of the patch. And last but not least, you allow quite wild modifications of tag searches (e.g. in notmuch-hello-generate-tag-alist), but is might be also useful to use such modifications for other searches. For example, I want to modify the saved searches in a similar way. Are you referring to things like specifying a filter for each tag or count in saved-searches? My thinking was that since you specify each item manually anyway, you can append any filter you might want to use there. But I guess you're right that it's a bit more convenient to be able to specify those once and not having to repeat it for each item. And here are my changes to your patch, which you might use as a suggestions for a next version of your patch. As I wrote above, it renames some functions and variables to more understandable names, updates documentation and adds a custom section for my personal use (I can live with this custom section in my .emacs if others do not like it). If we add the same configuration options that notmuch-hello-generate-tag-alist accepts, this section should be easy to specify in your ~/.emacs with one or two lines anyway. Cheers, Daniel pgpYz0VlBurE2.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 0/2] emacs: User-defined sections in notmuch-hello
On Tue, 05 Jul 2011, Daniel Schoepe wrote: Non-text part: multipart/signed On Tue, 05 Jul 2011 02:00:33 +0200, Michal Sojka sojk...@fel.cvut.cz wrote: First, the customization interface for the custom sections (not the predefined ones) is very confusing. I was not able to use it at all. Instead I hacked the source code (see below) to add my section to the notmuch-hello-sections list. What specifically did you find confusing? Sorry for not being clear - I wrote the mail late at night, looking forward to some sleep :) The first customization-option is intended for sections like the all tags section which various configuration options which should be explained by the docstrings next to the options. The second item allows saved-searches-like sections. I'm talking about notmuch-hello-section. It seems it is not possible easily specify there your own function. You can either select a predefined section or Customized section, which is in fact Customized all-tags section. So I propose to renaming this entry like this and adding another one called Custom function, where you could enter the name of your function. By the way: Instead of editing the source directly, you can also put all customizations like that in your configuration files and set notmuch-hello-sections from there. Nevertheless your inbox-display functions look useful in general so they should indeed be included. I know that, but I wanted to do the experiment quickly and this was the easiest way for me. Regarding setting of notmuch-hello-sections from .emacs, I prefer customizing it through the customization interface because when somebody else introduces a new section it is more convenient for me to try it by choosing from predefined values than modifying that in .emacs. And last but not least, you allow quite wild modifications of tag searches (e.g. in notmuch-hello-generate-tag-alist), but is might be also useful to use such modifications for other searches. For example, I want to modify the saved searches in a similar way. Are you referring to things like specifying a filter for each tag or count in saved-searches? My thinking was that since you specify each item manually anyway, you can append any filter you might want to use there. But I guess you're right that it's a bit more convenient to be able to specify those once and not having to repeat it for each item. It seems that I still do not understand what the Customized section was intended to provide. I have to say I'm not able to fully decode the definition of notmuch-hello-customized-section, but it seems to me that it is a way how to customize a call to notmuch-hello-insert-all-tags. I wanted to say that it might be useful to have the similar options for saved searches. For example, what I do in my notmuch-hello-insert-inbox is to take the saved searches and filter them by tag:inbox. I guess that if there is a possibility to do that without coding in elisp, some people may find it useful. What do you think? -Michal ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 0/2] emacs: User-defined sections in notmuch-hello
On Tue, 05 Jul 2011 16:09:14 +0200, Michal Sojka sojk...@fel.cvut.cz wrote: I wanted to say that it might be useful to have the similar options for saved searches. For example, what I do in my notmuch-hello-insert-inbox is to take the saved searches and filter them by tag:inbox. I guess that if there is a possibility to do that without coding in elisp, some people may find it useful. What do you think? I sent a new version of the patch that incorporates your suggestions with one exception: I removed notmuch-hello-insert-inbox from the default value for notmuch-hello-sections, since personally I find it a bit confusing to have all tags with inbox-tagged messages mixed with the saved searches in one place. pgpialJiBAPxg.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 0/2] emacs: User-defined sections in notmuch-hello
On Wed, 29 Jun 2011, Daniel Schoepe wrote: Unfortunately the customize-interface for more customized entries in notmuch-hello-sections looks a bit weird, but I couldn't figure out how to get rid of the empty lines produced by generating the lambda expression needed. Hi Daniel, this looks really great and it comes at the right time for me. I can use it for creating a custom section What's in your inbox - a functionality which I previously implemented in my personal branch [*] but I was unable to rebase it on the current HEAD. Basically, it took all saved searches and tag searches, filtered them with tag:inbox and displayed the buttons for those searches. With your patch it is quite easy to implement such a functionality. There are a few problems, though. First, the customization interface for the custom sections (not the predefined ones) is very confusing. I was not able to use it at all. Instead I hacked the source code (see below) to add my section to the notmuch-hello-sections list. Second, when I tried to understand your patch, I found some names of functions and variables quite confusing. In the patch below, I tried to give them a better names and I also updated the documentation. Feel free to use my changes for your later patch submission. And last but not least, you allow quite wild modifications of tag searches (e.g. in notmuch-hello-generate-tag-alist), but is might be also useful to use such modifications for other searches. For example, I want to modify the saved searches in a similar way. To avoid unnecessary complexity in the code this patch removes aligning all the tag entries in different sections (e.g. saved searches and all tags) the same way. So if someone really thinks this was an important features, please yell loudly. I do not miss this at all. And here are my changes to your patch, which you might use as a suggestions for a next version of your patch. As I wrote above, it renames some functions and variables to more understandable names, updates documentation and adds a custom section for my personal use (I can live with this custom section in my .emacs if others do not like it). Cheers, -Michal diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index e4c9307..226024c 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -124,6 +124,7 @@ Typically \,\ in the US and UK and \.\ in Europe. (defcustom notmuch-hello-sections (list #'notmuch-hello-insert-header + #'notmuch-hello-insert-inbox #'notmuch-hello-insert-saved-searches #'notmuch-hello-insert-search #'notmuch-hello-insert-recent-searches @@ -205,8 +206,8 @@ in the order they appear in this list. (message Saved '%s' as '%s'. search name) (notmuch-hello-update))) -(defun notmuch-hello-longest-label (tag-alist) - (or (loop for elem in tag-alist +(defun notmuch-hello-longest-label (searches-alist) + (or (loop for elem in searches-alist maximize (length (car elem))) 0)) @@ -270,11 +271,18 @@ should be. Returns a cons cell `(tags-per-line width)'. (* tags-per-line (+ 9 1 tags-per-line -(defun notmuch-hello-query-entries (tag-alist optional hide-empty) - Compute list of counts and queries for TAG-ALIST. +(defun notmuch-hello-query-counts (query-alist optional hide-empty) + Compute list of counts of matched messages from QUERY-ALIST. -If HIDE-EMPTY is non-nil, entries with no matching messages will be -removed from the result. +QUERY-ALIST must be a list containing elements of the form (NAME . QUERY) +or (NAME QUERY COUNT-QUERY). If the latter form is used, +COUNT-QUERY specifies an alternate query to be used to generate +the count for the associated query. + +The result is the list of elements of the form (NAME QUERY COUNT). + +If HIDE-EMPTY is non-nil, searches with no matching messages +(COUNT equal to zero) will be removed from the result. (notmuch-remove-if-not #'identity (mapcar @@ -289,21 +297,21 @@ removed from the result. (cdr query-and-count) (and (or (not hide-empty) ( message-count 0)) (list name (car query-and-count) message-count -tag-alist))) +query-alist))) -(defun notmuch-hello-insert-tags (entries) - Insert query items from ENTRIES. +(defun notmuch-hello-insert-buttons (searches) + Insert buttons for SEARCHES. -ENTRIES must be a list containing lists of the form (NAME QUERY COUNT), where +SEARCHES must be a list containing lists of the form (NAME QUERY COUNT), where QUERY is the query to start when the button for the corresponding entry is activated. COUNT should be the number of messages matching the query. -Such a list can be computed with `notmuch-hello-query-entries'. - (let* ((widest (notmuch-hello-longest-label entries)) +Such a list can be computed with `notmuch-hello-query-counts'. + (let* ((widest (notmuch-hello-longest-label searches))