[PATCH v2 5/5] emacs: Add a sort-order option to saved-searches
[notmuch-archives.git] / 74 / b776b5881b0744497f748290e37eccc513f407
1 Return-Path: <markwalters1009@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 4FE9A431FC2\r
6         for <notmuch@notmuchmail.org>; Sat,  5 Apr 2014 22:45:35 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.201\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
14         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id sDtzSEzRbAc4 for <notmuch@notmuchmail.org>;\r
18         Sat,  5 Apr 2014 22:45:28 -0700 (PDT)\r
19 Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com\r
20         [209.85.212.176]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id 8386E431FCB\r
23         for <notmuch@notmuchmail.org>; Sat,  5 Apr 2014 22:45:12 -0700 (PDT)\r
24 Received: by mail-wi0-f176.google.com with SMTP id r20so3354395wiv.3\r
25         for <notmuch@notmuchmail.org>; Sat, 05 Apr 2014 22:45:11 -0700 (PDT)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
28         bh=cvOGaj5FMk+DCB/r36KSs/XY/pjMLi35LiNhnr0ok6w=;\r
29         b=ibFDmxNIzxLiO0ZjP2Y33DkNFjYzTqyZc8weO4I19hTO0rn3AZ6rWBO+9WHbFgAUHv\r
30         yRBr3KK9RhBEI7ryN4e9ehza2Ea0VFEHnvm9WHhLF9IsktL7xAyiV518A4sKePMsInbK\r
31         OR45RdxD1cFKS83LGn/KOom2WMraiqKDxNyV5C3IBg9YKi4IdFPHM6v81sYxXXeNpQV2\r
32         NIg3KboEh4I0LTwTZdvXuV44Af39EXyYo1nYiRCnfxAvMahycTWr8XuhR7nElmFBf3C6\r
33         ANCU0XhOfaQT0jT7Z/dcjm72ZlasMfBvd5XB3swv44iMSaIFoZJvLo0eXrDl+xeDNu3L\r
34         hv+w==\r
35 X-Received: by 10.180.219.44 with SMTP id pl12mr16574095wic.12.1396763111466; \r
36         Sat, 05 Apr 2014 22:45:11 -0700 (PDT)\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
38         by mx.google.com with ESMTPSA id v6sm15204280wif.0.2014.04.05.22.45.10\r
39         for <multiple recipients>\r
40         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
41         Sat, 05 Apr 2014 22:45:11 -0700 (PDT)\r
42 From: Mark Walters <markwalters1009@gmail.com>\r
43 To: notmuch@notmuchmail.org,\r
44         amdragon@MIT.EDU\r
45 Subject: [PATCH v2 5/5] emacs: Add a sort-order option to saved-searches\r
46 Date: Sun,  6 Apr 2014 06:44:49 +0100\r
47 Message-Id: <1396763089-32452-6-git-send-email-markwalters1009@gmail.com>\r
48 X-Mailer: git-send-email 1.7.10.4\r
49 In-Reply-To: <1396763089-32452-1-git-send-email-markwalters1009@gmail.com>\r
50 References: <1396763089-32452-1-git-send-email-markwalters1009@gmail.com>\r
51 X-BeenThere: notmuch@notmuchmail.org\r
52 X-Mailman-Version: 2.1.13\r
53 Precedence: list\r
54 List-Id: "Use and development of the notmuch mail system."\r
55         <notmuch.notmuchmail.org>\r
56 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
58 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
59 List-Post: <mailto:notmuch@notmuchmail.org>\r
60 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
61 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
63 X-List-Received-Date: Sun, 06 Apr 2014 05:45:35 -0000\r
64 \r
65 This adds a sort-order option to saved-searches, stores it in the\r
66 saved-search buttons (widgets), and uses the stored value when the\r
67 button is pressed.\r
68 \r
69 Storing the sort-order in the widget was suggested by Jani in\r
70 id:4c3876274126985683e888641b29cf18142a5eb8.1391771337.git.jani@nikula.org.\r
71 ---\r
72  emacs/notmuch-hello.el |    8 +++++++-\r
73  emacs/notmuch-lib.el   |   10 +++++++++-\r
74  2 files changed, 16 insertions(+), 2 deletions(-)\r
75 \r
76 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
77 index f440352..f0675f2 100644\r
78 --- a/emacs/notmuch-hello.el\r
79 +++ b/emacs/notmuch-hello.el\r
80 @@ -363,7 +363,8 @@ (defun notmuch-hello-reflect (list ncols)\r
81  (defun notmuch-hello-widget-search (widget &rest ignore)\r
82    (notmuch-search (widget-get widget\r
83                               :notmuch-search-terms)\r
84 -                 notmuch-search-oldest-first))\r
85 +                 (widget-get widget\r
86 +                             :notmuch-search-oldest-first)))\r
87  \r
88  (defun notmuch-saved-search-count (search)\r
89    (car (process-lines notmuch-command "count" search)))\r
90 @@ -495,12 +496,17 @@ (defun notmuch-hello-insert-buttons (searches)\r
91                   (widget-insert (make-string column-indent ? )))\r
92               (let* ((name (plist-get elem :name))\r
93                      (query (plist-get elem :query))\r
94 +                    (oldest-first (case (plist-get elem :sort-order)\r
95 +                                    (newest-first nil)\r
96 +                                    (oldest-first t)\r
97 +                                    (otherwise notmuch-search-oldest-first)))\r
98                      (msg-count (plist-get elem :count)))\r
99                 (widget-insert (format "%8s "\r
100                                        (notmuch-hello-nice-number msg-count)))\r
101                 (widget-create 'push-button\r
102                                :notify #'notmuch-hello-widget-search\r
103                                :notmuch-search-terms query\r
104 +                              :notmuch-search-oldest-first oldest-first\r
105                                name)\r
106                 (setq column-indent\r
107                       (1+ (max 0 (- column-width (length name)))))))\r
108 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
109 index a54a055..3a3c69d 100644\r
110 --- a/emacs/notmuch-lib.el\r
111 +++ b/emacs/notmuch-lib.el\r
112 @@ -125,7 +125,12 @@ (define-widget 'notmuch-saved-search-plist 'list\r
113                 (group :format "%v" :inline t (const :format "  Query: " :query) (string :format "%v")))\r
114           (checklist :inline t\r
115                      :format "%v"\r
116 -                    (group :format "%v" :inline t (const :format "Count-Query: " :count-query) (string :format "%v")))))\r
117 +                    (group :format "%v" :inline t (const :format "Count-Query: " :count-query) (string :format "%v"))\r
118 +                    (group :format "%v" :inline t (const :format "" :sort-order)\r
119 +                           (choice :tag " Sort Order"\r
120 +                                   (const :tag "Default" nil)\r
121 +                                   (const :tag "Oldest-first" oldest-first)\r
122 +                                   (const :tag "Newest-first" newest-first))))))\r
123  \r
124  (defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox")\r
125                                     (:name "unread" :query "tag:unread"))\r
126 @@ -139,6 +144,9 @@ (defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox")\r
127    :count-query     Optional extra query to generate the count\r
128                     shown. If not present then the :query property\r
129                     is used.\r
130 +  :sort-order      Specify the sort order to be used for the search.\r
131 +                   Possible values are 'oldest-first 'newest-first or\r
132 +                   nil. Nil means use the default sort order.\r
133  \r
134  Other accepted forms are a cons cell of the form (NAME . QUERY)\r
135  or a list of the form (NAME QUERY COUNT-QUERY)."\r
136 -- \r
137 1.7.10.4\r
138 \r