unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 0/2] emacs: per saved search sort order
@ 2012-10-02 20:18 Jani Nikula
  2012-10-02 20:18 ` [PATCH 1/2] emacs: store sort order in the widgets in notmuch-hello Jani Nikula
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jani Nikula @ 2012-10-02 20:18 UTC (permalink / raw)
  To: notmuch

These (fairly unpolished) patches add support for defining the sort order
for each saved search individually. The approach is very low-tech and
simple; providing a separate alist which maps saved search names with sort
order for the saved searches that should have a sort order overriding the
default notmuch-search-oldest-first.

Having this embedded directly in notmuch-saved-searches would be nicer, but
also much more complicated due to backwards compatibility issues. I presume
the diffstat would be at least an order of magnitude bigger.

The patches may not be up to notmuch standards, but I'm providing them
anyway should anyone find them useful.

BR,
Jani.


Jani Nikula (2):
  emacs: store sort order in the widgets in notmuch-hello
  emacs: add support for defining custom sort order for saved searches

 emacs/notmuch-hello.el |   10 +++++++---
 emacs/notmuch-lib.el   |    9 +++++++++
 2 files changed, 16 insertions(+), 3 deletions(-)

-- 
1.7.2.5

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

* [PATCH 1/2] emacs: store sort order in the widgets in notmuch-hello
  2012-10-02 20:18 [PATCH 0/2] emacs: per saved search sort order Jani Nikula
@ 2012-10-02 20:18 ` Jani Nikula
  2012-10-02 20:18 ` [PATCH 2/2] emacs: add support for defining custom sort order for saved searches Jani Nikula
  2012-10-02 23:04 ` [PATCH 0/2] emacs: per saved search sort order Jeremy Nickurak
  2 siblings, 0 replies; 5+ messages in thread
From: Jani Nikula @ 2012-10-02 20:18 UTC (permalink / raw)
  To: notmuch

Move decision about sort order from the notify handler to the widget
setup. This keeps the handler simple when more fancy stuff is added.
---
 emacs/notmuch-hello.el |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 052aaeb..532f06d 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -311,9 +311,8 @@ diagonal."
 	  append (notmuch-hello-reflect-generate-row ncols nrows row list))))
 
 (defun notmuch-hello-widget-search (widget &rest ignore)
-  (notmuch-search (widget-get widget
-			      :notmuch-search-terms)
-		  notmuch-search-oldest-first
+  (notmuch-search (widget-get widget :notmuch-search-terms)
+		  (widget-get widget :notmuch-search-oldest-first)
 		  nil nil #'notmuch-hello-search-continuation))
 
 (defun notmuch-saved-search-count (search)
@@ -434,6 +433,7 @@ Such a list can be computed with `notmuch-hello-query-counts'."
 		(widget-create 'push-button
 			       :notify #'notmuch-hello-widget-search
 			       :notmuch-search-terms query
+			       :notmuch-search-oldest-first notmuch-search-oldest-first
 			       name)
 		(setq column-indent
 		      (1+ (max 0 (- column-width (length name)))))))
-- 
1.7.2.5

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

* [PATCH 2/2] emacs: add support for defining custom sort order for saved searches
  2012-10-02 20:18 [PATCH 0/2] emacs: per saved search sort order Jani Nikula
  2012-10-02 20:18 ` [PATCH 1/2] emacs: store sort order in the widgets in notmuch-hello Jani Nikula
@ 2012-10-02 20:18 ` Jani Nikula
  2012-10-02 23:04 ` [PATCH 0/2] emacs: per saved search sort order Jeremy Nickurak
  2 siblings, 0 replies; 5+ messages in thread
From: Jani Nikula @ 2012-10-02 20:18 UTC (permalink / raw)
  To: notmuch

Add a new customization option notmuch-saved-searches-oldest-first to
define custom sort order for saved searches. Do this as a separate
option from notmuch-saved-searches to dodge backwards compatibility
issues.

NOTES:

If the name of a tag matches the name of a saved search with a custom
sort order, then the search for that tag using the all tags section of
notmuch-hello will use the custom sort order too.

If you change any sort orders, you must refresh notmuch-hello for the
changes to take effect.

Only searches initiated from notmuch-hello will be affected.
---
 emacs/notmuch-hello.el |    6 +++++-
 emacs/notmuch-lib.el   |    9 +++++++++
 2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 532f06d..e410357 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -433,7 +433,11 @@ Such a list can be computed with `notmuch-hello-query-counts'."
 		(widget-create 'push-button
 			       :notify #'notmuch-hello-widget-search
 			       :notmuch-search-terms query
-			       :notmuch-search-oldest-first notmuch-search-oldest-first
+			       :notmuch-search-oldest-first
+			       (let ((m (assoc
+					 name
+					 notmuch-saved-searches-oldest-first)))
+				 (if m (cdr m) notmuch-search-oldest-first))
 			       name)
 		(setq column-indent
 		      (1+ (max 0 (- column-width (length name)))))))
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 69867ad..e1cd7d2 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -82,6 +82,15 @@
   :type '(alist :key-type string :value-type string)
   :group 'notmuch-hello)
 
+(defcustom notmuch-saved-searches-oldest-first nil
+  "List of saved searches with custom sort order.
+
+For each saved search name appearing in the list, use t for
+oldest-first, nil for newest-first. Saved searches not present in
+this list will use `notmuch-search-oldest-first' sort order."
+  :type '(alist :key-type string :value-type boolean)
+  :group 'notmuch-hello)
+
 (defcustom notmuch-archive-tags '("-inbox")
   "List of tag changes to apply to a message or a thread when it is archived.
 
-- 
1.7.2.5

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

* Re: [PATCH 0/2] emacs: per saved search sort order
  2012-10-02 20:18 [PATCH 0/2] emacs: per saved search sort order Jani Nikula
  2012-10-02 20:18 ` [PATCH 1/2] emacs: store sort order in the widgets in notmuch-hello Jani Nikula
  2012-10-02 20:18 ` [PATCH 2/2] emacs: add support for defining custom sort order for saved searches Jani Nikula
@ 2012-10-02 23:04 ` Jeremy Nickurak
  2 siblings, 0 replies; 5+ messages in thread
From: Jeremy Nickurak @ 2012-10-02 23:04 UTC (permalink / raw)
  To: notmuch

Would it be better to include sorting options in the query string?
Then it could just be stored in the saved search, and used outside
saved searches.

On Tue, Oct 2, 2012 at 2:18 PM, Jani Nikula <jani@nikula.org> wrote:
> These (fairly unpolished) patches add support for defining the sort order
> for each saved search individually. The approach is very low-tech and
> simple; providing a separate alist which maps saved search names with sort
> order for the saved searches that should have a sort order overriding the
> default notmuch-search-oldest-first.
>
> Having this embedded directly in notmuch-saved-searches would be nicer, but
> also much more complicated due to backwards compatibility issues. I presume
> the diffstat would be at least an order of magnitude bigger.
>
> The patches may not be up to notmuch standards, but I'm providing them
> anyway should anyone find them useful.
>
> BR,
> Jani.
>
>
> Jani Nikula (2):
>   emacs: store sort order in the widgets in notmuch-hello
>   emacs: add support for defining custom sort order for saved searches
>
>  emacs/notmuch-hello.el |   10 +++++++---
>  emacs/notmuch-lib.el   |    9 +++++++++
>  2 files changed, 16 insertions(+), 3 deletions(-)
>
> --
> 1.7.2.5
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

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

* [PATCH 0/2] emacs: per saved search sort order
       [not found] <1391727088-22172-1-git-send-email-cworth@cworth.org>
@ 2014-02-07 11:25 ` Jani Nikula
  0 siblings, 0 replies; 5+ messages in thread
From: Jani Nikula @ 2014-02-07 11:25 UTC (permalink / raw)
  To: notmuch, cworth

On Thu, 06 Feb 2014, Carl Worth <cworth@cworth.org> wrote:
> This allows for the user to control the order that results are
> returned from saved-searches, (and independently from the order of all
> other searches which is controlled by notmuch-search-oldest-first).
> ---
>
> This allows me to get back to the behavior that notmuch had long ago,
> (the documentation for the changed behavior was updated in commit
> c1a42652a173a4bb70ab72388e6ad150d19a2b06). I'm not sure when the
> actual behavioral change was made.

I seem to have fixed the documentation (I'd forgotten!) but I'm pretty
sure I had nothing to do with changing the behaviour! :)

> A fanicer change might allow for a configurable sort order for each
> saved search, but this more minimal change at least lets me use the
> latest notmuch once again.

Here are simple patches to support per saved search sort order. I seem
to have been running these for more than a year now [1]. It's not
perfect or pretty but works for me.

BR,
Jani.

[1] id:1349209083-7170-1-git-send-email-jani@nikula.org


Jani Nikula (2):
  emacs: store sort order in the widgets in notmuch-hello
  emacs: add support for defining custom sort order for saved searches

 emacs/notmuch-hello.el |    8 +++++++-
 emacs/notmuch-lib.el   |    9 +++++++++
 2 files changed, 16 insertions(+), 1 deletions(-)

-- 
1.7.2.5

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

end of thread, other threads:[~2014-02-07 11:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-02 20:18 [PATCH 0/2] emacs: per saved search sort order Jani Nikula
2012-10-02 20:18 ` [PATCH 1/2] emacs: store sort order in the widgets in notmuch-hello Jani Nikula
2012-10-02 20:18 ` [PATCH 2/2] emacs: add support for defining custom sort order for saved searches Jani Nikula
2012-10-02 23:04 ` [PATCH 0/2] emacs: per saved search sort order Jeremy Nickurak
     [not found] <1391727088-22172-1-git-send-email-cworth@cworth.org>
2014-02-07 11:25 ` Jani Nikula

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