unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Mark Walters <markwalters1009@gmail.com>
To: notmuch@notmuchmail.org
Subject: [PATCH v2 1/2] emacs: hello: bugfix: make alphabetically sorted saved searches work
Date: Sat, 12 Apr 2014 13:46:26 +0100	[thread overview]
Message-ID: <1397306787-12207-2-git-send-email-markwalters1009@gmail.com> (raw)
In-Reply-To: <1397306787-12207-1-git-send-email-markwalters1009@gmail.com>

My recent changes to the saved search format broke the alphabetically
sorted saved sort option. This makes it work again.

Also update docs for saved-search sort defcustom to match the new
format.

Finally, since the saved-search list is no longer an alist change the
names in the sort function to avoid confusion.
---
 emacs/notmuch-hello.el |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 4900a24..b8ec665 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -39,9 +39,12 @@ (defcustom notmuch-show-empty-saved-searches nil
   :type 'boolean
   :group 'notmuch-hello)
 
-(defun notmuch-sort-saved-searches (alist)
-  "Generate an alphabetically sorted saved searches alist."
-  (sort (copy-sequence alist) (lambda (a b) (string< (car a) (car b)))))
+(defun notmuch-sort-saved-searches (saved-searches)
+  "Generate an alphabetically sorted saved searches list."
+  (sort (copy-sequence saved-searches)
+	(lambda (a b)
+	  (string< (notmuch-saved-search-get a :name)
+		   (notmuch-saved-search-get b :name)))))
 
 (defcustom notmuch-saved-search-sort-function nil
   "Function used to sort the saved searches for the notmuch-hello view.
@@ -51,8 +54,10 @@ (defcustom notmuch-saved-search-sort-function nil
 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."
+searches list as a parameter, and returns a new saved searches
+list to be used. For compatibility with the various saved-search
+formats it should use notmuch-saved-search-get to access the
+fields of the search."
   :type '(choice (const :tag "No sorting" nil)
 		 (const :tag "Sort alphabetically" notmuch-sort-saved-searches)
 		 (function :tag "Custom sort function"
-- 
1.7.10.4

  reply	other threads:[~2014-04-12 12:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-12 12:46 [PATCH v2 0/2] emacs: hello: saved search sort fixes Mark Walters
2014-04-12 12:46 ` Mark Walters [this message]
2014-04-15 10:02   ` [PATCH v2 1/2] emacs: hello: bugfix: make alphabetically sorted saved searches work David Bremner
2014-04-12 12:46 ` [PATCH v2 2/2] NEWS: document possible breakage from saved-search format change Mark Walters
2014-04-12 13:04 ` [PATCH v2 0/2] emacs: hello: saved search sort fixes Tomi Ollila

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1397306787-12207-2-git-send-email-markwalters1009@gmail.com \
    --to=markwalters1009@gmail.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).