* [PATCH] emacs: Sort saved searches @ 2011-09-02 12:28 Jani Nikula 2011-09-02 15:02 ` Adam Wolfe Gordon 2011-09-03 11:56 ` Tomi Ollila 0 siblings, 2 replies; 12+ messages in thread From: Jani Nikula @ 2011-09-02 12:28 UTC (permalink / raw) To: notmuch Display saved searches sorted, like tags are displayed. This only affects the display of the saved searches, not the order in which they are stored in .emacs. Signed-off-by: Jani Nikula <jani@nikula.org> --- emacs/notmuch-hello.el | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 65fde75..13758e5 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -440,6 +440,9 @@ Complete list of currently available key bindings: (widest (max saved-widest alltags-widest))) (when saved-alist + ;; Sort saved searches. + (setq saved-alist + (sort saved-alist (lambda (a b) (string< (car a) (car b))))) (widget-insert "\nSaved searches: ") (widget-create 'push-button :notify (lambda (&rest ignore) -- 1.7.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] emacs: Sort saved searches 2011-09-02 12:28 [PATCH] emacs: Sort saved searches Jani Nikula @ 2011-09-02 15:02 ` Adam Wolfe Gordon 2011-09-03 11:56 ` Tomi Ollila 1 sibling, 0 replies; 12+ messages in thread From: Adam Wolfe Gordon @ 2011-09-02 15:02 UTC (permalink / raw) To: notmuch Jani Nikula wrote: > > Display saved searches sorted, like tags are displayed. > > This only affects the display of the saved searches, not the order in > which > they are stored in .emacs. > I think there should be an option for this behavior. Personally, I have my saved searches in a specific order (unread, inbox, sent mail, all mail). Sorting by name would put all mail first, even though it's the one I use least often. ----- -- Adam Wolfe Gordon -- View this message in context: http://notmuch.198994.n3.nabble.com/PATCH-emacs-Sort-saved-searches-tp3304068p3304466.html Sent from the notmuch mailing list archive at Nabble.com. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] emacs: Sort saved searches 2011-09-02 12:28 [PATCH] emacs: Sort saved searches Jani Nikula 2011-09-02 15:02 ` Adam Wolfe Gordon @ 2011-09-03 11:56 ` Tomi Ollila 2011-09-03 22:02 ` Jani Nikula 1 sibling, 1 reply; 12+ messages in thread From: Tomi Ollila @ 2011-09-03 11:56 UTC (permalink / raw) To: Jani Nikula; +Cc: notmuch On Fri 02 Sep 2011 15:28, Jani Nikula <jani@nikula.org> writes: > Display saved searches sorted, like tags are displayed. > > This only affects the display of the saved searches, not the order in which > they are stored in .emacs. > > Signed-off-by: Jani Nikula <jani@nikula.org> > --- Fun! I reveresed the sorting order so I got 'unread' first ;). Well, I prefer to sort the value of the (customizable) variable 'notmuch-saved-searches' myself (unless there is another variable which also provides 'saved searches' into notmuch-hello buffer)... Tomi > emacs/notmuch-hello.el | 3 +++ > 1 files changed, 3 insertions(+), 0 deletions(-) > > diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el > index 65fde75..13758e5 100644 > --- a/emacs/notmuch-hello.el > +++ b/emacs/notmuch-hello.el > @@ -440,6 +440,9 @@ Complete list of currently available key bindings: > (widest (max saved-widest alltags-widest))) > > (when saved-alist > + ;; Sort saved searches. > + (setq saved-alist > + (sort saved-alist (lambda (a b) (string< (car a) (car b))))) > (widget-insert "\nSaved searches: ") > (widget-create 'push-button > :notify (lambda (&rest ignore) > -- > 1.7.1 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] emacs: Sort saved searches 2011-09-03 11:56 ` Tomi Ollila @ 2011-09-03 22:02 ` Jani Nikula 2011-09-04 7:57 ` Jameson Graef Rollins 0 siblings, 1 reply; 12+ messages in thread From: Jani Nikula @ 2011-09-03 22:02 UTC (permalink / raw) To: Tomi Ollila; +Cc: notmuch On Sat, 03 Sep 2011 14:56:09 +0300, Tomi Ollila <tomi.ollila@nixu.com> wrote: > On Fri 02 Sep 2011 15:28, Jani Nikula <jani@nikula.org> writes: > > > Display saved searches sorted, like tags are displayed. > > > > This only affects the display of the saved searches, not the order in which > > they are stored in .emacs. > > > > Signed-off-by: Jani Nikula <jani@nikula.org> > > --- > > Fun! I reveresed the sorting order so I got 'unread' first ;). Well, I > prefer to sort the value of the (customizable) variable > 'notmuch-saved-searches' myself (unless there is another variable which > also provides 'saved searches' into notmuch-hello buffer)... Well, this is obviously easy to customize... and indeed I've got a ready patch to do just that... but I've been told before to avoid customization and prefer sane defaults instead. So which do we want, really? If you want sorting customizable, then I'll also include a patch to make saving new saved searches append vs. prepend customizable too, as that's important if you don't want sorting. It's fine for me either way, really, with or without customization, as long as one of these ways is upstreamed and I don't have to carry the patches for myself... BR, Jani. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] emacs: Sort saved searches 2011-09-03 22:02 ` Jani Nikula @ 2011-09-04 7:57 ` Jameson Graef Rollins 2011-09-04 18:21 ` Jani Nikula 0 siblings, 1 reply; 12+ messages in thread From: Jameson Graef Rollins @ 2011-09-04 7:57 UTC (permalink / raw) To: Jani Nikula, Tomi Ollila; +Cc: notmuch [-- Attachment #1: Type: text/plain, Size: 936 bytes --] On Sun, 04 Sep 2011 01:02:03 +0300, Jani Nikula <jani@nikula.org> wrote: > Well, this is obviously easy to customize... and indeed I've got a ready > patch to do just that... but I've been told before to avoid > customization and prefer sane defaults instead. So which do we want, > really? If you want sorting customizable, then I'll also include a patch > to make saving new saved searches append vs. prepend customizable too, > as that's important if you don't want sorting. > > It's fine for me either way, really, with or without customization, as > long as one of these ways is upstreamed and I don't have to carry the > patches for myself... I personally think it's nice the way it is, such that the entry order in the customization variable is the display order. Users can then set the order however they prefer. But I honestly don't use notmuch-hello enough to really care one way or the other. jamie. [-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] emacs: Sort saved searches 2011-09-04 7:57 ` Jameson Graef Rollins @ 2011-09-04 18:21 ` Jani Nikula 2011-09-05 2:22 ` Antono Vasiljev 2011-09-06 15:23 ` Adam Wolfe Gordon 0 siblings, 2 replies; 12+ messages in thread From: Jani Nikula @ 2011-09-04 18:21 UTC (permalink / raw) To: Jameson Graef Rollins, Tomi Ollila; +Cc: notmuch On Sun, 04 Sep 2011 00:57:26 -0700, Jameson Graef Rollins <jrollins@finestructure.net> wrote: > I personally think it's nice the way it is, such that the entry order in > the customization variable is the display order. Users can then set the > order however they prefer. Hmm. Let's look at this from another perspective: do you know if there's a reasonable way to make ordering of the customized saved searches easier? It's not exactly user friendly to move items up and down in the list. Or to sort them. On the other hand, the tags are sorted. Saved searches are not. Should it be possible to display tags in user defined order...? I know I can twist this the way I want and carry my own modifications, but I'd like to make notmuch user friendly for people who don't know elisp. BR, Jani. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] emacs: Sort saved searches 2011-09-04 18:21 ` Jani Nikula @ 2011-09-05 2:22 ` Antono Vasiljev 2011-09-06 15:23 ` Adam Wolfe Gordon 1 sibling, 0 replies; 12+ messages in thread From: Antono Vasiljev @ 2011-09-05 2:22 UTC (permalink / raw) To: Jani Nikula, Jameson Graef Rollins, Tomi Ollila; +Cc: notmuch On Sun, 04 Sep 2011 21:21:44 +0300, Jani Nikula <jani@nikula.org> wrote: > Hmm. Let's look at this from another perspective: do you know if there's > a reasonable way to make ordering of the customized saved searches > easier? It's not exactly user friendly to move items up and down in the > list. Or to sort them. > > On the other hand, the tags are sorted. Saved searches are not. Should > it be possible to display tags in user defined order...? > > I know I can twist this the way I want and carry my own modifications, > but I'd like to make notmuch user friendly for people who don't know > elisp. Note exactrly on Your topic, but my solution for the problem is anything-notmuch: ;; Notmuch Anything Source ;; anything-sources (defvar notmuch-anything-source-saved-searches '((name . "Notmuch Mail - Saved Searches") (candidates . notmuch-saved-searches) (action ("Search with notmuch" . notmuch-search)) (candidate-number-limit . 100) ;; (requires-pattern . 2) "Source for completing anything saved searches.")) (defun notmuch-anything (&optional rehash) (interactive (list current-prefix-arg)) (anything :sources 'notmuch-anything-source-saved-searches :preselect "inbox" :buffer "*notmuch-saved-searches*")) (define-key notmuch-hello-mode-map "S" 'notmuch-anything) It is possible to include this directly to notmuch, wrapped to (eval-after-load 'notmuch '(progn code ...)) ? -- http://antono.info/ http://twitter.com/antono http://github.com/antono ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] emacs: Sort saved searches 2011-09-04 18:21 ` Jani Nikula 2011-09-05 2:22 ` Antono Vasiljev @ 2011-09-06 15:23 ` Adam Wolfe Gordon 2011-09-07 8:01 ` [PATCH v2 0/2] sort saved searches, again Jani Nikula 1 sibling, 1 reply; 12+ messages in thread From: Adam Wolfe Gordon @ 2011-09-06 15:23 UTC (permalink / raw) To: notmuch Jani Nikula wrote: > > Hmm. Let's look at this from another perspective: do you know if there's > a reasonable way to make ordering of the customized saved searches > easier? It's not exactly user friendly to move items up and down in the > list. Or to sort them. > > On the other hand, the tags are sorted. Saved searches are not. Should > it be possible to display tags in user defined order...? > > I know I can twist this the way I want and carry my own modifications, > but I'd like to make notmuch user friendly for people who don't know > elisp. > My two cents on this, as someone who uses notmuch as a Gmail-alike for non-Gmail email: I keep my saved searches in a particular order, kind of emulating the Gmail sidebar: unread, inbox, sent, all mail. Putting these in alphabetical order either direction would not achieve the goal of having the most used/important saved searches first (i.e. I hardly ever use all mail, so it shouldn't be first in the list). The tags list, on the other hand, I like having sorted to make tags easy to find. It has a different purpose than saved searches for me, so its behavior is different. I think having an option to sort the saved searches is a fine idea. The Emacs Way would probably be to have an option for the sort order that takes the name of a function, which is called to sort the searches. My first thought is that this isn't very user-friendly. But, thinking about it a bit more, if the default causes the searches to be sorted alphabetically, and setting the value to nil causes them not to be sorted, then it's user-friendly for the two most common cases, and still 100% customizable for those who want different sort orders. ----- -- Adam Wolfe Gordon -- View this message in context: http://notmuch.198994.n3.nabble.com/PATCH-emacs-Sort-saved-searches-tp3304068p3313863.html Sent from the notmuch mailing list archive at Nabble.com. ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 0/2] sort saved searches, again 2011-09-06 15:23 ` Adam Wolfe Gordon @ 2011-09-07 8:01 ` Jani Nikula 2011-09-07 8:01 ` [PATCH v2 1/2] emacs: Add new customization option to sort saved searches Jani Nikula ` (2 more replies) 0 siblings, 3 replies; 12+ messages in thread From: Jani Nikula @ 2011-09-07 8:01 UTC (permalink / raw) To: notmuch Hi, and thanks for all the comments - [I took the liberty of reordering Adam's paragraphs in my reply.] On Tue, 6 Sep 2011 08:23:43 -0700 (PDT), Adam Wolfe Gordon <awg+notmuch@xvx.ca> wrote: > I think having an option to sort the saved searches is a fine idea. > The Emacs Way would probably be to have an option for the sort order > that takes the name of a function, which is called to sort the > searches. My first thought is that this isn't very user-friendly. > But, thinking about it a bit more, if the default causes the searches > to be sorted alphabetically, and setting the value to nil causes them > not to be sorted, then it's user-friendly for the two most common > cases, and still 100% customizable for those who want different sort > orders. Please find this implemented in patch 1. > I keep my saved searches in a particular order, kind of emulating the > Gmail sidebar: unread, inbox, sent, all mail. Putting these in > alphabetical order either direction would not achieve the goal of > having the most used/important saved searches first (i.e. I hardly > ever use all mail, so it shouldn't be first in the list). > The tags list, on the other hand, I like having sorted to make tags > easy to find. It has a different purpose than saved searches for me, > so its behavior is different. I hardly use tags at all. I have dozens of saved searches instead. Thus I want the saved searches to be easy to find, and I'd rather have the computer sort them for me. I do admit to renaming the most important ones to start with capital letters so they pop up first even when sorted. Since it seems that people generally prefer to keep the most important saved searches first in the list, I've included patch 2 to make new saved searches be added to the end of the list rather than inserted in the beginning. BR, Jani. Jani Nikula (2): emacs: Add new customization option to sort saved searches emacs: Make saving new saved searches append, not prepend emacs/notmuch-hello.el | 28 ++++++++++++++++++++++++++-- 1 files changed, 26 insertions(+), 2 deletions(-) ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 1/2] emacs: Add new customization option to sort saved searches 2011-09-07 8:01 ` [PATCH v2 0/2] sort saved searches, again Jani Nikula @ 2011-09-07 8:01 ` Jani Nikula 2011-09-07 8:01 ` [PATCH v2 2/2] emacs: Make saving new saved searches append, not prepend Jani Nikula 2011-09-07 15:53 ` [PATCH v2 0/2] sort saved searches, again Adam Wolfe Gordon 2 siblings, 0 replies; 12+ messages in thread From: Jani Nikula @ 2011-09-07 8:01 UTC (permalink / raw) To: notmuch Add new customization option notmuch-saved-search-sort-function to sort saved searches in user-defined order. Provide a sort function to sort the saved searches in alphabetical order. Setting the search function to nil causes the saved searches not to be sorted, as before. This also remains the default. The function only affects display of the saved searches, not the order in which they are stored by custom. Signed-off-by: Jani Nikula <jani@nikula.org> --- emacs/notmuch-hello.el | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 65fde75..6c8e265 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -42,6 +42,26 @@ :type 'boolean :group 'notmuch) +(defun notmuch-sort-saved-searches (alist) + "Generate an alphabetically sorted saved searches alist." + (sort alist (lambda (a b) (string< (car a) (car b))))) + +(defcustom notmuch-saved-search-sort-function nil + "Function used to sort the saved searches for the notmuch-hello view. + +This variable controls how saved searches should be sorted. No +sorting (nil) displays the saved searches in the order they are +stored in `notmuch-saved-searches'. Sort alphabetically sorts the +saved searches in alphabetical order. Custom sort function should +be a function or a lambda expression that takes the saved +searches alist as a parameter, and returns a new saved searches +alist to be used." + :type '(choice (const :tag "No sorting" nil) + (const :tag "Sort alphabetically" notmuch-sort-saved-searches) + (function :tag "Custom sort function" + :value notmuch-sort-saved-searches)) + :group 'notmuch) + (defvar notmuch-hello-indent 4 "How much to indent non-headers.") @@ -440,6 +460,10 @@ Complete list of currently available key bindings: (widest (max saved-widest alltags-widest))) (when saved-alist + ;; Sort saved searches if required. + (when notmuch-saved-search-sort-function + (setq saved-alist + (funcall notmuch-saved-search-sort-function saved-alist))) (widget-insert "\nSaved searches: ") (widget-create 'push-button :notify (lambda (&rest ignore) -- 1.7.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 2/2] emacs: Make saving new saved searches append, not prepend 2011-09-07 8:01 ` [PATCH v2 0/2] sort saved searches, again Jani Nikula 2011-09-07 8:01 ` [PATCH v2 1/2] emacs: Add new customization option to sort saved searches Jani Nikula @ 2011-09-07 8:01 ` Jani Nikula 2011-09-07 15:53 ` [PATCH v2 0/2] sort saved searches, again Adam Wolfe Gordon 2 siblings, 0 replies; 12+ messages in thread From: Jani Nikula @ 2011-09-07 8:01 UTC (permalink / raw) To: notmuch Append new saved searches at the end of saved searches rather than insert in front. Signed-off-by: Jani Nikula <jani@nikula.org> --- emacs/notmuch-hello.el | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 6c8e265..dc34ebe 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -188,8 +188,8 @@ Typically \",\" in the US and UK and \".\" in Europe." collect elem)) ;; Add the new one. (customize-save-variable 'notmuch-saved-searches - (push (cons name search) - notmuch-saved-searches)) + (add-to-list 'notmuch-saved-searches + (cons name search) t)) (message "Saved '%s' as '%s'." search name) (notmuch-hello-update))) -- 1.7.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v2 0/2] sort saved searches, again 2011-09-07 8:01 ` [PATCH v2 0/2] sort saved searches, again Jani Nikula 2011-09-07 8:01 ` [PATCH v2 1/2] emacs: Add new customization option to sort saved searches Jani Nikula 2011-09-07 8:01 ` [PATCH v2 2/2] emacs: Make saving new saved searches append, not prepend Jani Nikula @ 2011-09-07 15:53 ` Adam Wolfe Gordon 2 siblings, 0 replies; 12+ messages in thread From: Adam Wolfe Gordon @ 2011-09-07 15:53 UTC (permalink / raw) To: notmuch (Sorry if anyone gets this twice; I sent it to the list initially from the wrong email address.) On Wed, Sep 7, 2011 at 02:01, Jani Nikula <jani@nikula.org> wrote: > On Tue, 6 Sep 2011 08:23:43 -0700 (PDT), Adam Wolfe Gordon <awg+notmuch@xvx.ca> wrote: >> I think having an option to sort the saved searches is a fine idea. >> The Emacs Way would probably be to have an option for the sort order >> that takes the name of a function, which is called to sort the >> searches. My first thought is that this isn't very user-friendly. >> But, thinking about it a bit more, if the default causes the searches >> to be sorted alphabetically, and setting the value to nil causes them >> not to be sorted, then it's user-friendly for the two most common >> cases, and still 100% customizable for those who want different sort >> orders. > > Please find this implemented in patch 1. I've tried the patches, and they work properly for me. I think this looks good; hopefully others agree. > I hardly use tags at all. I have dozens of saved searches instead. Thus > I want the saved searches to be easy to find, and I'd rather have the > computer sort them for me. I do admit to renaming the most important > ones to start with capital letters so they pop up first even when > sorted. > > Since it seems that people generally prefer to keep the most important > saved searches first in the list, I've included patch 2 to make new > saved searches be added to the end of the list rather than inserted in > the beginning. Indeed, I expect there are many different notmuch workflows. I think these patches keep notmuch general enough to support any workflow, while making the common ones very easy to use. -- Adam Wolfe Gordon ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2011-09-07 15:53 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-09-02 12:28 [PATCH] emacs: Sort saved searches Jani Nikula 2011-09-02 15:02 ` Adam Wolfe Gordon 2011-09-03 11:56 ` Tomi Ollila 2011-09-03 22:02 ` Jani Nikula 2011-09-04 7:57 ` Jameson Graef Rollins 2011-09-04 18:21 ` Jani Nikula 2011-09-05 2:22 ` Antono Vasiljev 2011-09-06 15:23 ` Adam Wolfe Gordon 2011-09-07 8:01 ` [PATCH v2 0/2] sort saved searches, again Jani Nikula 2011-09-07 8:01 ` [PATCH v2 1/2] emacs: Add new customization option to sort saved searches Jani Nikula 2011-09-07 8:01 ` [PATCH v2 2/2] emacs: Make saving new saved searches append, not prepend Jani Nikula 2011-09-07 15:53 ` [PATCH v2 0/2] sort saved searches, again Adam Wolfe Gordon
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).