unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH RESEND 0/2] emacs: sort saved searches
@ 2011-09-23 18:57 Jani Nikula
  2011-09-23 18:57 ` [PATCH RESEND 1/2] emacs: Add new customization option to " Jani Nikula
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jani Nikula @ 2011-09-23 18:57 UTC (permalink / raw)
  To: notmuch

Hi, resending as this seems forgotten. Last time [1] there was no objections to
this improved approach.

BR,
Jani.

[1] id:"cover.1315341018.git.jani@nikula.org"

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

-- 
1.7.4.1

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

* [PATCH RESEND 1/2] emacs: Add new customization option to sort saved searches
  2011-09-23 18:57 [PATCH RESEND 0/2] emacs: sort saved searches Jani Nikula
@ 2011-09-23 18:57 ` Jani Nikula
  2011-09-23 18:57 ` [PATCH RESEND 2/2] emacs: Make saving new saved searches append, not prepend Jani Nikula
  2011-11-23  2:59 ` [PATCH RESEND 0/2] emacs: sort saved searches David Bremner
  2 siblings, 0 replies; 4+ messages in thread
From: Jani Nikula @ 2011-09-23 18:57 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.4.1

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

* [PATCH RESEND 2/2] emacs: Make saving new saved searches append, not prepend
  2011-09-23 18:57 [PATCH RESEND 0/2] emacs: sort saved searches Jani Nikula
  2011-09-23 18:57 ` [PATCH RESEND 1/2] emacs: Add new customization option to " Jani Nikula
@ 2011-09-23 18:57 ` Jani Nikula
  2011-11-23  2:59 ` [PATCH RESEND 0/2] emacs: sort saved searches David Bremner
  2 siblings, 0 replies; 4+ messages in thread
From: Jani Nikula @ 2011-09-23 18:57 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.4.1

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

* Re: [PATCH RESEND 0/2] emacs: sort saved searches
  2011-09-23 18:57 [PATCH RESEND 0/2] emacs: sort saved searches Jani Nikula
  2011-09-23 18:57 ` [PATCH RESEND 1/2] emacs: Add new customization option to " Jani Nikula
  2011-09-23 18:57 ` [PATCH RESEND 2/2] emacs: Make saving new saved searches append, not prepend Jani Nikula
@ 2011-11-23  2:59 ` David Bremner
  2 siblings, 0 replies; 4+ messages in thread
From: David Bremner @ 2011-11-23  2:59 UTC (permalink / raw)
  To: Jani Nikula, notmuch

On Fri, 23 Sep 2011 21:57:36 +0300, Jani Nikula <jani@nikula.org> wrote:
> Hi, resending as this seems forgotten. Last time [1] there was no objections to
> this improved approach.
> 
> BR,
> Jani.

Pushed to master.

d

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

end of thread, other threads:[~2011-11-23  2:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-23 18:57 [PATCH RESEND 0/2] emacs: sort saved searches Jani Nikula
2011-09-23 18:57 ` [PATCH RESEND 1/2] emacs: Add new customization option to " Jani Nikula
2011-09-23 18:57 ` [PATCH RESEND 2/2] emacs: Make saving new saved searches append, not prepend Jani Nikula
2011-11-23  2:59 ` [PATCH RESEND 0/2] emacs: sort saved searches David Bremner

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