unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 0/5] emacs: hello: convert saved-searches to plists
@ 2014-04-05 21:24 Mark Walters
  2014-04-05 21:24 ` [PATCH 1/5] emacs: hello: add helper functions for saved-searches Mark Walters
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Mark Walters @ 2014-04-05 21:24 UTC (permalink / raw)
  To: notmuch

This series converts the saved-search format to plists. This should
make it much easier to extend their functionality. The final patch
illustrates this by adding a sort-order option to the saved
searches. It also exposes the count-query functionality that is
already present internally, and could be used to store keyboard
shortcuts for searches.

The series tries hard to be backwardly compatible and seems to work in
most cases. However, notmuch-hello is very interconnected so some
corner cases may fail: for example if people are doing strange things
with notmuch-saved-search-sort-function then it may break.

Also note that the functions used for saved-searches are also used for
the "all tags" section: I have not converted them as they are purely
internal. Since we have backwards compatibility they still work.

Best wishes

Mark







Mark Walters (5):
  emacs: hello: add helper functions for saved-searches
  emacs: hello: use the saved-search helper functions
  emacs: hello: add a customize for saved-searches
  emacs: hello: switch notmuch-hello-insert-buttons to plists
  emacs: Add a sort-order option to saved-searches

 emacs/notmuch-hello.el |  129 +++++++++++++++++++++++++++++++++---------------
 emacs/notmuch-lib.el   |   33 +++++++++++--
 emacs/notmuch.el       |    6 +--
 3 files changed, 122 insertions(+), 46 deletions(-)

-- 
1.7.10.4

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

* [PATCH 1/5] emacs: hello: add helper functions for saved-searches
  2014-04-05 21:24 [PATCH 0/5] emacs: hello: convert saved-searches to plists Mark Walters
@ 2014-04-05 21:24 ` Mark Walters
  2014-04-06  0:58   ` Austin Clements
  2014-04-05 21:24 ` [PATCH 2/5] emacs: hello: use the saved-search helper functions Mark Walters
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 15+ messages in thread
From: Mark Walters @ 2014-04-05 21:24 UTC (permalink / raw)
  To: notmuch

Add helper functions to for saved searches to ease the transition to
the new plist form while maintaining backwards compatibility. They
will be used in the next patch.
---
 emacs/notmuch-hello.el |   39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index e325cd3..0b9ed16 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -269,6 +269,45 @@ (defun notmuch-hello-search (&optional search)
       (add-to-history 'notmuch-search-history search)))
   (notmuch-search search notmuch-search-oldest-first))
 
+(defun notmuch-saved-search-get (saved-search field)
+  "Get FIELD from SAVED-SEARCH.
+
+In the new style saved-search (a plist) this is just plist-get
+but, for backwards compatibility, this deals with the two
+old-style forms: cons cells (NAME . QUERY) and lists (NAME QUERY
+COUNT-QUERY)."
+  (cond
+   ((plist-get saved-search :name)
+    (plist-get saved-search field))
+   ;; It is not a plist so it is an old-style entry.
+   ((consp (cdr saved-search)) ;; It is a list (NAME QUERY COUNT-QUERY)
+    (case field
+      (:name (car saved-search))
+      (:query (second saved-search))
+      (:count-query (third saved-search))
+      (t nil)))
+   (t  ;; It is a cons-cell (NAME . QUERY)
+    (case field
+      (:name (car saved-search))
+      (:query (cdr saved-search))
+      (t nil)))))
+
+(defun notmuch-hello-saved-search-to-plist (saved-search)
+  "Convert a saved-search variable into plist form.
+
+The new style saved search is just a plist, but for backwards
+compatatibility we use this function to give them in
+plist-form. In all cases a new copy is returned so it is safe to
+modify the returned value."
+  (if (and (listp (cdr saved-search)) (plist-member saved-search :name))
+      (copy-seq saved-search)
+    (let ((fields (list :name :query :count-query))
+	  (plist-search))
+      (dolist (field fields plist-search)
+	(let ((string (notmuch-saved-search-get saved-search field)))
+	  (when string
+	    (setq plist-search (append plist-search (list field string)))))))))
+
 (defun notmuch-hello-add-saved-search (widget)
   (interactive)
   (let ((search (widget-value
-- 
1.7.10.4

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

* [PATCH 2/5] emacs: hello: use the saved-search helper functions
  2014-04-05 21:24 [PATCH 0/5] emacs: hello: convert saved-searches to plists Mark Walters
  2014-04-05 21:24 ` [PATCH 1/5] emacs: hello: add helper functions for saved-searches Mark Walters
@ 2014-04-05 21:24 ` Mark Walters
  2014-04-06  1:06   ` Austin Clements
  2014-04-05 21:24 ` [PATCH 3/5] emacs: hello: add a customize for saved-searches Mark Walters
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 15+ messages in thread
From: Mark Walters @ 2014-04-05 21:24 UTC (permalink / raw)
  To: notmuch

This uses the helper functions: the saved searches format has not
changed yet but backwards compatibility means everything still works.
---
 emacs/notmuch-hello.el |   48 ++++++++++++++++++++++--------------------------
 emacs/notmuch.el       |    6 +++---
 2 files changed, 25 insertions(+), 29 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 0b9ed16..733208b 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -319,7 +319,7 @@ (defun notmuch-hello-add-saved-search (widget)
     (setq notmuch-saved-searches
 	  (loop for elem in notmuch-saved-searches
 		if (not (equal name
-			       (car elem)))
+			       (notmuch-saved-search-get elem :name)))
 		collect elem))
     ;; Add the new one.
     (customize-save-variable 'notmuch-saved-searches
@@ -339,7 +339,7 @@ (defun notmuch-hello-delete-search-from-history (widget)
 
 (defun notmuch-hello-longest-label (searches-alist)
   (or (loop for elem in searches-alist
-	    maximize (length (car elem)))
+	    maximize (length (notmuch-saved-search-get elem :name)))
       0))
 
 (defun notmuch-hello-reflect-generate-row (ncols nrows row list)
@@ -418,13 +418,12 @@ (defun notmuch-hello-filtered-query (query filter)
     (concat "(" query ") and (" filter ")"))
    (t query)))
 
-(defun notmuch-hello-query-counts (query-alist &rest options)
-  "Compute list of counts of matched messages from QUERY-ALIST.
+(defun notmuch-hello-query-counts (query-list &rest options)
+  "Compute list of counts of matched messages from QUERY-LIST.
 
-QUERY-ALIST must be a list containing elements of the form (NAME . QUERY)
-or (NAME QUERY COUNT-QUERY). If the latter form is used,
-COUNT-QUERY specifies an alternate query to be used to generate
-the count for the associated query.
+QUERY-LIST must be a list of saved-searches. Ideally each of
+these is a plist but other options are available for backwards
+compatibility: see notmuch-saved-search-get for details.
 
 The result is the list of elements of the form (NAME QUERY COUNT).
 
@@ -432,11 +431,9 @@ (defun notmuch-hello-query-counts (query-alist &rest options)
 options will be handled as specified for
 `notmuch-hello-insert-searches'."
   (with-temp-buffer
-    (dolist (elem query-alist nil)
-      (let ((count-query (if (consp (cdr elem))
-			     ;; do we have a different query for the message count?
-			     (third elem)
-			   (cdr elem))))
+    (dolist (elem query-list nil)
+      (let ((count-query (or (notmuch-saved-search-get elem :count-query)
+			     (notmuch-saved-search-get elem :query))))
 	(insert
 	 (replace-regexp-in-string
 	  "\n" " "
@@ -458,18 +455,15 @@ (defun notmuch-hello-query-counts (query-alist &rest options)
      #'identity
      (mapcar
       (lambda (elem)
-	(let ((name (car elem))
-	      (search-query (if (consp (cdr elem))
-				 ;; do we have a different query for the message count?
-				 (second elem)
-			      (cdr elem)))
+	(let ((name (notmuch-saved-search-get elem :name))
+	      (search-query (notmuch-saved-search-get elem :query))
 	      (message-count (prog1 (read (current-buffer))
 				(forward-line 1))))
 	  (and (or (plist-get options :show-empty-searches) (> message-count 0))
 	       (list name (notmuch-hello-filtered-query
 			   search-query (plist-get options :filter))
 		     message-count))))
-      query-alist))))
+      query-list))))
 
 (defun notmuch-hello-insert-buttons (searches)
   "Insert buttons for SEARCHES.
@@ -728,13 +722,15 @@ (defun notmuch-hello-insert-recent-searches ()
       (indent-rigidly start (point) notmuch-hello-indent))
     nil))
 
-(defun notmuch-hello-insert-searches (title query-alist &rest options)
-  "Insert a section with TITLE showing a list of buttons made from QUERY-ALIST.
+(defun notmuch-hello-insert-searches (title query-list &rest options)
+  "Insert a section with TITLE showing a list of buttons made from QUERY-LIST.
 
-QUERY-ALIST must be a list containing elements of the form (NAME . QUERY)
-or (NAME QUERY COUNT-QUERY). If the latter form is used,
-COUNT-QUERY specifies an alternate query to be used to generate
-the count for the associated item.
+QUERY-LIST should ideally be a plist but for backwards
+compatibility other forms are also accepted (see
+`notmuch-saved-search-get' for details).  The plist should
+contain keys :name and :query; if :count-query is also present
+then it specifies an alternate query to be used to generate the
+count for the associated search.
 
 Supports the following entries in OPTIONS as a plist:
 :initially-hidden - if non-nil, section will be hidden on startup
@@ -768,7 +764,7 @@ (defun notmuch-hello-insert-searches (title query-alist &rest options)
 		     "hide"))
     (widget-insert "\n")
     (when (not is-hidden)
-      (let ((searches (apply 'notmuch-hello-query-counts query-alist options)))
+      (let ((searches (apply 'notmuch-hello-query-counts query-list options)))
 	(when (or (not (plist-get options :hide-if-empty))
 		  searches)
 	  (widget-insert "\n")
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 233c784..1346b90 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -823,14 +823,14 @@ (defun notmuch-search-buffer-title (query)
 	  (let (longest
 		(longest-length 0))
 	    (loop for tuple in notmuch-saved-searches
-		  if (let ((quoted-query (regexp-quote (cdr tuple))))
+		  if (let ((quoted-query (regexp-quote (notmuch-saved-search-get tuple :query))))
 		       (and (string-match (concat "^" quoted-query) query)
 			    (> (length (match-string 0 query))
 			       longest-length)))
 		  do (setq longest tuple))
 	    longest))
-	 (saved-search-name (car saved-search))
-	 (saved-search-query (cdr saved-search)))
+	 (saved-search-name (notmuch-saved-search-get saved-search :name))
+	 (saved-search-query (notmuch-saved-search-get saved-search :query)))
     (cond ((and saved-search (equal saved-search-query query))
 	   ;; Query is the same as saved search (ignoring case)
 	   (concat "*notmuch-saved-search-" saved-search-name "*"))
-- 
1.7.10.4

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

* [PATCH 3/5] emacs: hello: add a customize for saved-searches
  2014-04-05 21:24 [PATCH 0/5] emacs: hello: convert saved-searches to plists Mark Walters
  2014-04-05 21:24 ` [PATCH 1/5] emacs: hello: add helper functions for saved-searches Mark Walters
  2014-04-05 21:24 ` [PATCH 2/5] emacs: hello: use the saved-search helper functions Mark Walters
@ 2014-04-05 21:24 ` Mark Walters
  2014-04-05 21:24 ` [PATCH 4/5] emacs: hello: switch notmuch-hello-insert-buttons to plists Mark Walters
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: Mark Walters @ 2014-04-05 21:24 UTC (permalink / raw)
  To: notmuch

Make the defcustom for notmuch-saved-searches use the new plist
format. It should still work with oldstyle saved-searches but will
write the newstyle form.
---
 emacs/notmuch-hello.el |    2 +-
 emacs/notmuch-lib.el   |   28 +++++++++++++++++++++++++---
 2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 733208b..c729af2 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -324,7 +324,7 @@ (defun notmuch-hello-add-saved-search (widget)
     ;; Add the new one.
     (customize-save-variable 'notmuch-saved-searches
 			     (add-to-list 'notmuch-saved-searches
-					  (cons name search) t))
+					  (list :name name :query search) t))
     (message "Saved '%s' as '%s'." search name)
     (notmuch-hello-update)))
 
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 959764e..8a12f91 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -107,10 +107,32 @@ (defcustom notmuch-poll-script nil
 (defvar notmuch-search-history nil
   "Variable to store notmuch searches history.")
 
-(defcustom notmuch-saved-searches '(("inbox" . "tag:inbox")
-				    ("unread" . "tag:unread"))
+(defun notmuch--saved-searches-to-plist (symbol)
+  "Extract a saved-search variable into plist form.
+
+The new style saved search is just a plist, but for backwards
+compatatibility we use this function to extract old style saved
+searches so they still work in customize."
+  (let ((saved-searches (default-value symbol)))
+    (mapcar #'notmuch-hello-saved-search-to-plist saved-searches)))
+
+(define-widget 'notmuch-saved-search-plist 'list
+  "A single saved search property list."
+  :tag "Saved Search"
+  :args '((list :inline t
+		:format "%v"
+		(group :format "%v" :inline t (const :format "   Name: " :name) (string :format "%v"))
+		(group :format "%v" :inline t (const :format "  Query: " :query) (string :format "%v")))
+	  (checklist :inline t
+		     :format "%v"
+		     (group :format "%v" :inline t (const :format "Count-Query: " :count-query) (string :format "%v")))))
+
+(defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox")
+				    (:name "unread" :query "tag:unread"))
   "A list of saved searches to display."
-  :type '(alist :key-type string :value-type string)
+  :get 'notmuch--saved-searches-to-plist
+  :type '(repeat notmuch-saved-search-plist)
+  :tag "List of Saved Searches"
   :group 'notmuch-hello)
 
 (defcustom notmuch-archive-tags '("-inbox")
-- 
1.7.10.4

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

* [PATCH 4/5] emacs: hello: switch notmuch-hello-insert-buttons to plists
  2014-04-05 21:24 [PATCH 0/5] emacs: hello: convert saved-searches to plists Mark Walters
                   ` (2 preceding siblings ...)
  2014-04-05 21:24 ` [PATCH 3/5] emacs: hello: add a customize for saved-searches Mark Walters
@ 2014-04-05 21:24 ` Mark Walters
  2014-04-06  1:24   ` Austin Clements
  2014-04-05 21:24 ` [PATCH 5/5] emacs: Add a sort-order option to saved-searches Mark Walters
  2014-04-06  0:52 ` [PATCH 0/5] emacs: hello: convert saved-searches to plists David Bremner
  5 siblings, 1 reply; 15+ messages in thread
From: Mark Walters @ 2014-04-05 21:24 UTC (permalink / raw)
  To: notmuch

Switching notmuch-hello-insert-buttons to plists means we can easily
pass extra options through to the buttons.
---
 emacs/notmuch-hello.el |   33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index c729af2..aa40e6f 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -425,7 +425,9 @@ (defun notmuch-hello-query-counts (query-list &rest options)
 these is a plist but other options are available for backwards
 compatibility: see notmuch-saved-search-get for details.
 
-The result is the list of elements of the form (NAME QUERY COUNT).
+The result is a list of plists each of which includes the
+pairs :name NAME, :query QUERY and :count COUNT, together with
+any pairs in the original saved-search.
 
 The values :show-empty-searches, :filter and :filter-count from
 options will be handled as specified for
@@ -455,23 +457,26 @@ (defun notmuch-hello-query-counts (query-list &rest options)
      #'identity
      (mapcar
       (lambda (elem)
-	(let ((name (notmuch-saved-search-get elem :name))
-	      (search-query (notmuch-saved-search-get elem :query))
-	      (message-count (prog1 (read (current-buffer))
+	(let* ((elem-plist (notmuch-hello-saved-search-to-plist elem))
+	       (search-query (plist-get elem-plist :query))
+	       (filtered-query (notmuch-hello-filtered-query
+				search-query (plist-get options :filter)))
+	       (message-count (prog1 (read (current-buffer))
 				(forward-line 1))))
 	  (and (or (plist-get options :show-empty-searches) (> message-count 0))
-	       (list name (notmuch-hello-filtered-query
-			   search-query (plist-get options :filter))
-		     message-count))))
+	       (setq elem-plist (plist-put elem-plist :query filtered-query))
+	       (plist-put elem-plist :count message-count))))
       query-list))))
 
 (defun notmuch-hello-insert-buttons (searches)
   "Insert buttons for SEARCHES.
 
-SEARCHES must be a list containing lists of the form (NAME QUERY COUNT), where
-QUERY is the query to start when the button for the corresponding entry is
-activated. COUNT should be the number of messages matching the query.
-Such a list can be computed with `notmuch-hello-query-counts'."
+SEARCHES must be a list of plists each of which should contain at
+least pairs for :name NAME :query QUERY and :count COUNT, where
+QUERY is the query to start when the button for the corresponding
+entry is activated, and COUNT should be the number of messages
+matching the query.  Such a plist can be computed with
+`notmuch-hello-query-counts'."
   (let* ((widest (notmuch-hello-longest-label searches))
 	 (tags-and-width (notmuch-hello-tags-per-line widest))
 	 (tags-per-line (car tags-and-width))
@@ -489,9 +494,9 @@ (defun notmuch-hello-insert-buttons (searches)
 	    (when elem
 	      (if (> column-indent 0)
 		  (widget-insert (make-string column-indent ? )))
-	      (let* ((name (first elem))
-		     (query (second elem))
-		     (msg-count (third elem)))
+	      (let* ((name (plist-get elem :name))
+		     (query (plist-get elem :query))
+		     (msg-count (plist-get elem :count)))
 		(widget-insert (format "%8s "
 				       (notmuch-hello-nice-number msg-count)))
 		(widget-create 'push-button
-- 
1.7.10.4

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

* [PATCH 5/5] emacs: Add a sort-order option to saved-searches
  2014-04-05 21:24 [PATCH 0/5] emacs: hello: convert saved-searches to plists Mark Walters
                   ` (3 preceding siblings ...)
  2014-04-05 21:24 ` [PATCH 4/5] emacs: hello: switch notmuch-hello-insert-buttons to plists Mark Walters
@ 2014-04-05 21:24 ` Mark Walters
  2014-04-06  1:30   ` Austin Clements
  2014-04-06  0:52 ` [PATCH 0/5] emacs: hello: convert saved-searches to plists David Bremner
  5 siblings, 1 reply; 15+ messages in thread
From: Mark Walters @ 2014-04-05 21:24 UTC (permalink / raw)
  To: notmuch

This adds a sort-order option to saved-searches, stores it in the
saved-search buttons (widgets), and uses the stored value when the
button is pressed.

Storing the sort-order in the widget was suggested by Jani in
id:4c3876274126985683e888641b29cf18142a5eb8.1391771337.git.jani@nikula.org.
---
 emacs/notmuch-hello.el |   11 ++++++++++-
 emacs/notmuch-lib.el   |    7 ++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index aa40e6f..6a28372 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -364,7 +364,8 @@ (defun notmuch-hello-reflect (list ncols)
 (defun notmuch-hello-widget-search (widget &rest ignore)
   (notmuch-search (widget-get widget
 			      :notmuch-search-terms)
-		  notmuch-search-oldest-first))
+		  (widget-get widget
+			      :notmuch-search-oldest-first)))
 
 (defun notmuch-saved-search-count (search)
   (car (process-lines notmuch-command "count" search)))
@@ -496,12 +497,20 @@ (defun notmuch-hello-insert-buttons (searches)
 		  (widget-insert (make-string column-indent ? )))
 	      (let* ((name (plist-get elem :name))
 		     (query (plist-get elem :query))
+		     (oldest-first (cond
+				    ((eq (plist-get elem :sort-order) 'newest-first)
+				     nil)
+				    ((eq (plist-get elem :sort-order) 'oldest-first)
+				     t)
+				    (t
+				     notmuch-search-oldest-first)))
 		     (msg-count (plist-get elem :count)))
 		(widget-insert (format "%8s "
 				       (notmuch-hello-nice-number msg-count)))
 		(widget-create 'push-button
 			       :notify #'notmuch-hello-widget-search
 			       :notmuch-search-terms query
+			       :notmuch-search-oldest-first 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 8a12f91..8aa8cfc 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -125,7 +125,12 @@ (define-widget 'notmuch-saved-search-plist 'list
 		(group :format "%v" :inline t (const :format "  Query: " :query) (string :format "%v")))
 	  (checklist :inline t
 		     :format "%v"
-		     (group :format "%v" :inline t (const :format "Count-Query: " :count-query) (string :format "%v")))))
+		     (group :format "%v" :inline t (const :format "Count-Query: " :count-query) (string :format "%v"))
+		     (group :format "%v" :inline t (const :format "" :sort-order)
+			    (choice :tag " Sort Order"
+				    (const :tag "Default" nil)
+				    (const :tag "Oldest-first" oldest-first)
+				    (const :tag "Newest-first" newest-first))))))
 
 (defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox")
 				    (:name "unread" :query "tag:unread"))
-- 
1.7.10.4

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

* Re: [PATCH 0/5] emacs: hello: convert saved-searches to plists
  2014-04-05 21:24 [PATCH 0/5] emacs: hello: convert saved-searches to plists Mark Walters
                   ` (4 preceding siblings ...)
  2014-04-05 21:24 ` [PATCH 5/5] emacs: Add a sort-order option to saved-searches Mark Walters
@ 2014-04-06  0:52 ` David Bremner
  2014-04-06  5:34   ` Mark Walters
  2014-04-06  8:04   ` Tomi Ollila
  5 siblings, 2 replies; 15+ messages in thread
From: David Bremner @ 2014-04-06  0:52 UTC (permalink / raw)
  To: Mark Walters, notmuch

Mark Walters <markwalters1009@gmail.com> writes:

> This series converts the saved-search format to plists. This should
> make it much easier to extend their functionality. The final patch
> illustrates this by adding a sort-order option to the saved
> searches. It also exposes the count-query functionality that is
> already present internally, and could be used to store keyboard
> shortcuts for searches.

Not necessarily an issue for this series, but I'd like start thinking
about a front-end-independent representation for saved searches; perhaps
json for want of better ideas.  

d

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

* Re: [PATCH 1/5] emacs: hello: add helper functions for saved-searches
  2014-04-05 21:24 ` [PATCH 1/5] emacs: hello: add helper functions for saved-searches Mark Walters
@ 2014-04-06  0:58   ` Austin Clements
  0 siblings, 0 replies; 15+ messages in thread
From: Austin Clements @ 2014-04-06  0:58 UTC (permalink / raw)
  To: Mark Walters; +Cc: notmuch

Quoth Mark Walters on Apr 05 at 10:24 pm:
> Add helper functions to for saved searches to ease the transition to
> the new plist form while maintaining backwards compatibility. They
> will be used in the next patch.
> ---
>  emacs/notmuch-hello.el |   39 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 39 insertions(+)
> 
> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> index e325cd3..0b9ed16 100644
> --- a/emacs/notmuch-hello.el
> +++ b/emacs/notmuch-hello.el
> @@ -269,6 +269,45 @@ (defun notmuch-hello-search (&optional search)
>        (add-to-history 'notmuch-search-history search)))
>    (notmuch-search search notmuch-search-oldest-first))
>  
> +(defun notmuch-saved-search-get (saved-search field)
> +  "Get FIELD from SAVED-SEARCH.
> +
> +In the new style saved-search (a plist) this is just plist-get

It won't be "new style" once this has been in for a while.  Perhaps
"If SAVED-SEARCH is a plist, this is just `plist-get', but for
backwards compatibility, ..."

> +but, for backwards compatibility, this deals with the two
> +old-style forms: cons cells (NAME . QUERY) and lists (NAME QUERY
> +COUNT-QUERY)."
> +  (cond
> +   ((plist-get saved-search :name)

Rather than depending on :name, maybe this should be a more generic
plist test like (keywordp (car saved-search))?

> +    (plist-get saved-search field))
> +   ;; It is not a plist so it is an old-style entry.
> +   ((consp (cdr saved-search)) ;; It is a list (NAME QUERY COUNT-QUERY)
> +    (case field
> +      (:name (car saved-search))

Use `first' for consistency with the other case cases?

> +      (:query (second saved-search))
> +      (:count-query (third saved-search))
> +      (t nil)))
> +   (t  ;; It is a cons-cell (NAME . QUERY)
> +    (case field
> +      (:name (car saved-search))
> +      (:query (cdr saved-search))
> +      (t nil)))))
> +
> +(defun notmuch-hello-saved-search-to-plist (saved-search)
> +  "Convert a saved-search variable into plist form.

This takes a value, not a variable.  But it could be more succinct and
more accurate: "Return a copy of SAVED-SEARCH in plist form."

> +
> +The new style saved search is just a plist, but for backwards

Same comment about "new style".

> +compatatibility we use this function to give them in
> +plist-form. In all cases a new copy is returned so it is safe to

Grammar error?

> +modify the returned value."
> +  (if (and (listp (cdr saved-search)) (plist-member saved-search :name))
> +      (copy-seq saved-search)
> +    (let ((fields (list :name :query :count-query))
> +	  (plist-search))

Personally I prefer to either explicitly initialize nil variables or
to list them without the parenthesis at all (for some reason my brain
automatically reads this as an application), but if you prefer this,
that's fine, too.

> +      (dolist (field fields plist-search)
> +	(let ((string (notmuch-saved-search-get saved-search field)))
> +	  (when string
> +	    (setq plist-search (append plist-search (list field string)))))))))
> +
>  (defun notmuch-hello-add-saved-search (widget)
>    (interactive)
>    (let ((search (widget-value

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

* Re: [PATCH 2/5] emacs: hello: use the saved-search helper functions
  2014-04-05 21:24 ` [PATCH 2/5] emacs: hello: use the saved-search helper functions Mark Walters
@ 2014-04-06  1:06   ` Austin Clements
  0 siblings, 0 replies; 15+ messages in thread
From: Austin Clements @ 2014-04-06  1:06 UTC (permalink / raw)
  To: Mark Walters; +Cc: notmuch

Quoth Mark Walters on Apr 05 at 10:24 pm:
> This uses the helper functions: the saved searches format has not
> changed yet but backwards compatibility means everything still works.
> ---
>  emacs/notmuch-hello.el |   48 ++++++++++++++++++++++--------------------------
>  emacs/notmuch.el       |    6 +++---
>  2 files changed, 25 insertions(+), 29 deletions(-)
> 
> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> index 0b9ed16..733208b 100644
> --- a/emacs/notmuch-hello.el
> +++ b/emacs/notmuch-hello.el
> @@ -319,7 +319,7 @@ (defun notmuch-hello-add-saved-search (widget)
>      (setq notmuch-saved-searches
>  	  (loop for elem in notmuch-saved-searches
>  		if (not (equal name
> -			       (car elem)))
> +			       (notmuch-saved-search-get elem :name)))
>  		collect elem))
>      ;; Add the new one.
>      (customize-save-variable 'notmuch-saved-searches
> @@ -339,7 +339,7 @@ (defun notmuch-hello-delete-search-from-history (widget)
>  
>  (defun notmuch-hello-longest-label (searches-alist)
>    (or (loop for elem in searches-alist
> -	    maximize (length (car elem)))
> +	    maximize (length (notmuch-saved-search-get elem :name)))
>        0))
>  
>  (defun notmuch-hello-reflect-generate-row (ncols nrows row list)
> @@ -418,13 +418,12 @@ (defun notmuch-hello-filtered-query (query filter)
>      (concat "(" query ") and (" filter ")"))
>     (t query)))
>  
> -(defun notmuch-hello-query-counts (query-alist &rest options)
> -  "Compute list of counts of matched messages from QUERY-ALIST.
> +(defun notmuch-hello-query-counts (query-list &rest options)
> +  "Compute list of counts of matched messages from QUERY-LIST.
>  
> -QUERY-ALIST must be a list containing elements of the form (NAME . QUERY)
> -or (NAME QUERY COUNT-QUERY). If the latter form is used,
> -COUNT-QUERY specifies an alternate query to be used to generate
> -the count for the associated query.
> +QUERY-LIST must be a list of saved-searches. Ideally each of
> +these is a plist but other options are available for backwards
> +compatibility: see notmuch-saved-search-get for details.

s/:/./  Also `'s around notmuch-saved-search-get.

Actually, the accepted formats (including the understood keys in plist
form) should be documented in `notmuch-saved-searches' and this
information should be cited elsewhere and not duplicated.

>  
>  The result is the list of elements of the form (NAME QUERY COUNT).
>  
> @@ -432,11 +431,9 @@ (defun notmuch-hello-query-counts (query-alist &rest options)
>  options will be handled as specified for
>  `notmuch-hello-insert-searches'."
>    (with-temp-buffer
> -    (dolist (elem query-alist nil)
> -      (let ((count-query (if (consp (cdr elem))
> -			     ;; do we have a different query for the message count?
> -			     (third elem)
> -			   (cdr elem))))
> +    (dolist (elem query-list nil)
> +      (let ((count-query (or (notmuch-saved-search-get elem :count-query)
> +			     (notmuch-saved-search-get elem :query))))
>  	(insert
>  	 (replace-regexp-in-string
>  	  "\n" " "
> @@ -458,18 +455,15 @@ (defun notmuch-hello-query-counts (query-alist &rest options)
>       #'identity
>       (mapcar
>        (lambda (elem)
> -	(let ((name (car elem))
> -	      (search-query (if (consp (cdr elem))
> -				 ;; do we have a different query for the message count?
> -				 (second elem)
> -			      (cdr elem)))
> +	(let ((name (notmuch-saved-search-get elem :name))
> +	      (search-query (notmuch-saved-search-get elem :query))
>  	      (message-count (prog1 (read (current-buffer))
>  				(forward-line 1))))
>  	  (and (or (plist-get options :show-empty-searches) (> message-count 0))
>  	       (list name (notmuch-hello-filtered-query
>  			   search-query (plist-get options :filter))
>  		     message-count))))
> -      query-alist))))
> +      query-list))))
>  
>  (defun notmuch-hello-insert-buttons (searches)
>    "Insert buttons for SEARCHES.
> @@ -728,13 +722,15 @@ (defun notmuch-hello-insert-recent-searches ()
>        (indent-rigidly start (point) notmuch-hello-indent))
>      nil))
>  
> -(defun notmuch-hello-insert-searches (title query-alist &rest options)
> -  "Insert a section with TITLE showing a list of buttons made from QUERY-ALIST.
> +(defun notmuch-hello-insert-searches (title query-list &rest options)
> +  "Insert a section with TITLE showing a list of buttons made from QUERY-LIST.
>  
> -QUERY-ALIST must be a list containing elements of the form (NAME . QUERY)
> -or (NAME QUERY COUNT-QUERY). If the latter form is used,
> -COUNT-QUERY specifies an alternate query to be used to generate
> -the count for the associated item.
> +QUERY-LIST should ideally be a plist but for backwards
> +compatibility other forms are also accepted (see
> +`notmuch-saved-search-get' for details).  The plist should
> +contain keys :name and :query; if :count-query is also present
> +then it specifies an alternate query to be used to generate the
> +count for the associated search.

Same comment about moving this format documentation to
`notmuch-saved-searches'.

>  
>  Supports the following entries in OPTIONS as a plist:
>  :initially-hidden - if non-nil, section will be hidden on startup
> @@ -768,7 +764,7 @@ (defun notmuch-hello-insert-searches (title query-alist &rest options)
>  		     "hide"))
>      (widget-insert "\n")
>      (when (not is-hidden)
> -      (let ((searches (apply 'notmuch-hello-query-counts query-alist options)))
> +      (let ((searches (apply 'notmuch-hello-query-counts query-list options)))
>  	(when (or (not (plist-get options :hide-if-empty))
>  		  searches)
>  	  (widget-insert "\n")
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index 233c784..1346b90 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -823,14 +823,14 @@ (defun notmuch-search-buffer-title (query)
>  	  (let (longest
>  		(longest-length 0))
>  	    (loop for tuple in notmuch-saved-searches
> -		  if (let ((quoted-query (regexp-quote (cdr tuple))))
> +		  if (let ((quoted-query (regexp-quote (notmuch-saved-search-get tuple :query))))
>  		       (and (string-match (concat "^" quoted-query) query)
>  			    (> (length (match-string 0 query))
>  			       longest-length)))
>  		  do (setq longest tuple))
>  	    longest))
> -	 (saved-search-name (car saved-search))
> -	 (saved-search-query (cdr saved-search)))
> +	 (saved-search-name (notmuch-saved-search-get saved-search :name))
> +	 (saved-search-query (notmuch-saved-search-get saved-search :query)))
>      (cond ((and saved-search (equal saved-search-query query))
>  	   ;; Query is the same as saved search (ignoring case)
>  	   (concat "*notmuch-saved-search-" saved-search-name "*"))

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

* Re: [PATCH 4/5] emacs: hello: switch notmuch-hello-insert-buttons to plists
  2014-04-05 21:24 ` [PATCH 4/5] emacs: hello: switch notmuch-hello-insert-buttons to plists Mark Walters
@ 2014-04-06  1:24   ` Austin Clements
  2014-04-06  5:31     ` Mark Walters
  0 siblings, 1 reply; 15+ messages in thread
From: Austin Clements @ 2014-04-06  1:24 UTC (permalink / raw)
  To: Mark Walters; +Cc: notmuch

Quoth Mark Walters on Apr 05 at 10:24 pm:
> Switching notmuch-hello-insert-buttons to plists means we can easily
> pass extra options through to the buttons.
> ---
>  emacs/notmuch-hello.el |   33 +++++++++++++++++++--------------
>  1 file changed, 19 insertions(+), 14 deletions(-)
> 
> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> index c729af2..aa40e6f 100644
> --- a/emacs/notmuch-hello.el
> +++ b/emacs/notmuch-hello.el
> @@ -425,7 +425,9 @@ (defun notmuch-hello-query-counts (query-list &rest options)
>  these is a plist but other options are available for backwards
>  compatibility: see notmuch-saved-search-get for details.
>  
> -The result is the list of elements of the form (NAME QUERY COUNT).
> +The result is a list of plists each of which includes the
> +pairs :name NAME, :query QUERY and :count COUNT, together with
> +any pairs in the original saved-search.

"Pair" can be synonymous with "cons", which is not what you mean here.
"Properties"?

>  
>  The values :show-empty-searches, :filter and :filter-count from
>  options will be handled as specified for
> @@ -455,23 +457,26 @@ (defun notmuch-hello-query-counts (query-list &rest options)
>       #'identity
>       (mapcar
>        (lambda (elem)
> -	(let ((name (notmuch-saved-search-get elem :name))
> -	      (search-query (notmuch-saved-search-get elem :query))
> -	      (message-count (prog1 (read (current-buffer))
> +	(let* ((elem-plist (notmuch-hello-saved-search-to-plist elem))
> +	       (search-query (plist-get elem-plist :query))
> +	       (filtered-query (notmuch-hello-filtered-query
> +				search-query (plist-get options :filter)))
> +	       (message-count (prog1 (read (current-buffer))
>  				(forward-line 1))))
>  	  (and (or (plist-get options :show-empty-searches) (> message-count 0))
> -	       (list name (notmuch-hello-filtered-query
> -			   search-query (plist-get options :filter))
> -		     message-count))))
> +	       (setq elem-plist (plist-put elem-plist :query filtered-query))

This technically works, but `setq' is a strange thing to see in an
`and'.  But the problem isn't the `setq'; it's that crazy `and'.  I'd
replace the `and' with `when', keep the `setq' and `plist-put' in the
body, and squint a lot less at this code.

> +	       (plist-put elem-plist :count message-count))))
>        query-list))))
>  
>  (defun notmuch-hello-insert-buttons (searches)
>    "Insert buttons for SEARCHES.
>  
> -SEARCHES must be a list containing lists of the form (NAME QUERY COUNT), where
> -QUERY is the query to start when the button for the corresponding entry is
> -activated. COUNT should be the number of messages matching the query.
> -Such a list can be computed with `notmuch-hello-query-counts'."
> +SEARCHES must be a list of plists each of which should contain at
> +least pairs for :name NAME :query QUERY and :count COUNT, where

Same comment about "pairs".

> +QUERY is the query to start when the button for the corresponding
> +entry is activated, and COUNT should be the number of messages
> +matching the query.  Such a plist can be computed with
> +`notmuch-hello-query-counts'."
>    (let* ((widest (notmuch-hello-longest-label searches))
>  	 (tags-and-width (notmuch-hello-tags-per-line widest))
>  	 (tags-per-line (car tags-and-width))
> @@ -489,9 +494,9 @@ (defun notmuch-hello-insert-buttons (searches)
>  	    (when elem
>  	      (if (> column-indent 0)
>  		  (widget-insert (make-string column-indent ? )))
> -	      (let* ((name (first elem))
> -		     (query (second elem))
> -		     (msg-count (third elem)))
> +	      (let* ((name (plist-get elem :name))
> +		     (query (plist-get elem :query))
> +		     (msg-count (plist-get elem :count)))
>  		(widget-insert (format "%8s "
>  				       (notmuch-hello-nice-number msg-count)))
>  		(widget-create 'push-button

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

* Re: [PATCH 5/5] emacs: Add a sort-order option to saved-searches
  2014-04-05 21:24 ` [PATCH 5/5] emacs: Add a sort-order option to saved-searches Mark Walters
@ 2014-04-06  1:30   ` Austin Clements
  2014-04-06  5:32     ` Mark Walters
  0 siblings, 1 reply; 15+ messages in thread
From: Austin Clements @ 2014-04-06  1:30 UTC (permalink / raw)
  To: Mark Walters; +Cc: notmuch

Quoth Mark Walters on Apr 05 at 10:24 pm:
> This adds a sort-order option to saved-searches, stores it in the
> saved-search buttons (widgets), and uses the stored value when the
> button is pressed.
> 
> Storing the sort-order in the widget was suggested by Jani in
> id:4c3876274126985683e888641b29cf18142a5eb8.1391771337.git.jani@nikula.org.
> ---
>  emacs/notmuch-hello.el |   11 ++++++++++-
>  emacs/notmuch-lib.el   |    7 ++++++-
>  2 files changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> index aa40e6f..6a28372 100644
> --- a/emacs/notmuch-hello.el
> +++ b/emacs/notmuch-hello.el
> @@ -364,7 +364,8 @@ (defun notmuch-hello-reflect (list ncols)
>  (defun notmuch-hello-widget-search (widget &rest ignore)
>    (notmuch-search (widget-get widget
>  			      :notmuch-search-terms)
> -		  notmuch-search-oldest-first))
> +		  (widget-get widget
> +			      :notmuch-search-oldest-first)))
>  
>  (defun notmuch-saved-search-count (search)
>    (car (process-lines notmuch-command "count" search)))
> @@ -496,12 +497,20 @@ (defun notmuch-hello-insert-buttons (searches)
>  		  (widget-insert (make-string column-indent ? )))
>  	      (let* ((name (plist-get elem :name))
>  		     (query (plist-get elem :query))
> +		     (oldest-first (cond
> +				    ((eq (plist-get elem :sort-order) 'newest-first)
> +				     nil)
> +				    ((eq (plist-get elem :sort-order) 'oldest-first)
> +				     t)
> +				    (t
> +				     notmuch-search-oldest-first)))

(case (plist-get elem :sort-order)
  (newest-first nil)
  (oldest-first t)
  (otherwise notmuch-search-oldest-first))

>  		     (msg-count (plist-get elem :count)))
>  		(widget-insert (format "%8s "
>  				       (notmuch-hello-nice-number msg-count)))
>  		(widget-create 'push-button
>  			       :notify #'notmuch-hello-widget-search
>  			       :notmuch-search-terms query
> +			       :notmuch-search-oldest-first 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 8a12f91..8aa8cfc 100644
> --- a/emacs/notmuch-lib.el
> +++ b/emacs/notmuch-lib.el
> @@ -125,7 +125,12 @@ (define-widget 'notmuch-saved-search-plist 'list
>  		(group :format "%v" :inline t (const :format "  Query: " :query) (string :format "%v")))
>  	  (checklist :inline t
>  		     :format "%v"
> -		     (group :format "%v" :inline t (const :format "Count-Query: " :count-query) (string :format "%v")))))
> +		     (group :format "%v" :inline t (const :format "Count-Query: " :count-query) (string :format "%v"))
> +		     (group :format "%v" :inline t (const :format "" :sort-order)
> +			    (choice :tag " Sort Order"

Should there be a colon?  (I haven't applied the patches and I'm
afraid this is beyond my mental implementation of define-widget!)

> +				    (const :tag "Default" nil)
> +				    (const :tag "Oldest-first" oldest-first)
> +				    (const :tag "Newest-first" newest-first))))))
>  
>  (defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox")
>  				    (:name "unread" :query "tag:unread"))

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

* Re: [PATCH 4/5] emacs: hello: switch notmuch-hello-insert-buttons to plists
  2014-04-06  1:24   ` Austin Clements
@ 2014-04-06  5:31     ` Mark Walters
  0 siblings, 0 replies; 15+ messages in thread
From: Mark Walters @ 2014-04-06  5:31 UTC (permalink / raw)
  To: Austin Clements; +Cc: notmuch


Hello

>> @@ -455,23 +457,26 @@ (defun notmuch-hello-query-counts (query-list &rest options)
>>       #'identity
>>       (mapcar
>>        (lambda (elem)
>> -	(let ((name (notmuch-saved-search-get elem :name))
>> -	      (search-query (notmuch-saved-search-get elem :query))
>> -	      (message-count (prog1 (read (current-buffer))
>> +	(let* ((elem-plist (notmuch-hello-saved-search-to-plist elem))
>> +	       (search-query (plist-get elem-plist :query))
>> +	       (filtered-query (notmuch-hello-filtered-query
>> +				search-query (plist-get options :filter)))
>> +	       (message-count (prog1 (read (current-buffer))
>>  				(forward-line 1))))
>>  	  (and (or (plist-get options :show-empty-searches) (> message-count 0))
>> -	       (list name (notmuch-hello-filtered-query
>> -			   search-query (plist-get options :filter))
>> -		     message-count))))
>> +	       (setq elem-plist (plist-put elem-plist :query filtered-query))
>
> This technically works, but `setq' is a strange thing to see in an
> `and'.  But the problem isn't the `setq'; it's that crazy `and'.  I'd
> replace the `and' with `when', keep the `setq' and `plist-put' in the
> body, and squint a lot less at this code.

This was actually a bug on my part: the filtered query can be nil (which
is used to mean hide this search); in earlier versions having a setq
inside the `and' achieved this but obviously not in this plist form. I
have switched to the when as suggested and added a test for
filtered-query being nil.

Best wishes

Mark

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

* Re: [PATCH 5/5] emacs: Add a sort-order option to saved-searches
  2014-04-06  1:30   ` Austin Clements
@ 2014-04-06  5:32     ` Mark Walters
  0 siblings, 0 replies; 15+ messages in thread
From: Mark Walters @ 2014-04-06  5:32 UTC (permalink / raw)
  To: Austin Clements; +Cc: notmuch


Hi

On Sun, 06 Apr 2014, Austin Clements <amdragon@MIT.EDU> wrote:
> Quoth Mark Walters on Apr 05 at 10:24 pm:
>> This adds a sort-order option to saved-searches, stores it in the
>> saved-search buttons (widgets), and uses the stored value when the
>> button is pressed.
>> 
>> Storing the sort-order in the widget was suggested by Jani in
>> id:4c3876274126985683e888641b29cf18142a5eb8.1391771337.git.jani@nikula.org.
>> ---
>>  emacs/notmuch-hello.el |   11 ++++++++++-
>>  emacs/notmuch-lib.el   |    7 ++++++-
>>  2 files changed, 16 insertions(+), 2 deletions(-)
>> 
>> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
>> index aa40e6f..6a28372 100644
>> --- a/emacs/notmuch-hello.el
>> +++ b/emacs/notmuch-hello.el
>> @@ -364,7 +364,8 @@ (defun notmuch-hello-reflect (list ncols)
>>  (defun notmuch-hello-widget-search (widget &rest ignore)
>>    (notmuch-search (widget-get widget
>>  			      :notmuch-search-terms)
>> -		  notmuch-search-oldest-first))
>> +		  (widget-get widget
>> +			      :notmuch-search-oldest-first)))
>>  
>>  (defun notmuch-saved-search-count (search)
>>    (car (process-lines notmuch-command "count" search)))
>> @@ -496,12 +497,20 @@ (defun notmuch-hello-insert-buttons (searches)
>>  		  (widget-insert (make-string column-indent ? )))
>>  	      (let* ((name (plist-get elem :name))
>>  		     (query (plist-get elem :query))
>> +		     (oldest-first (cond
>> +				    ((eq (plist-get elem :sort-order) 'newest-first)
>> +				     nil)
>> +				    ((eq (plist-get elem :sort-order) 'oldest-first)
>> +				     t)
>> +				    (t
>> +				     notmuch-search-oldest-first)))
>
> (case (plist-get elem :sort-order)
>   (newest-first nil)
>   (oldest-first t)
>   (otherwise notmuch-search-oldest-first))

This is much better.

>
>>  		     (msg-count (plist-get elem :count)))
>>  		(widget-insert (format "%8s "
>>  				       (notmuch-hello-nice-number msg-count)))
>>  		(widget-create 'push-button
>>  			       :notify #'notmuch-hello-widget-search
>>  			       :notmuch-search-terms query
>> +			       :notmuch-search-oldest-first 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 8a12f91..8aa8cfc 100644
>> --- a/emacs/notmuch-lib.el
>> +++ b/emacs/notmuch-lib.el
>> @@ -125,7 +125,12 @@ (define-widget 'notmuch-saved-search-plist 'list
>>  		(group :format "%v" :inline t (const :format "  Query: " :query) (string :format "%v")))
>>  	  (checklist :inline t
>>  		     :format "%v"
>> -		     (group :format "%v" :inline t (const :format "Count-Query: " :count-query) (string :format "%v")))))
>> +		     (group :format "%v" :inline t (const :format "Count-Query: " :count-query) (string :format "%v"))
>> +		     (group :format "%v" :inline t (const :format "" :sort-order)
>> +			    (choice :tag " Sort Order"
>
> Should there be a colon?  (I haven't applied the patches and I'm
> afraid this is beyond my mental implementation of define-widget!)

I think it is OK without: since this is using :tag rather than :format
the colon is supplied automatically.

Many thanks

Mark

>
>> +				    (const :tag "Default" nil)
>> +				    (const :tag "Oldest-first" oldest-first)
>> +				    (const :tag "Newest-first" newest-first))))))
>>  
>>  (defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox")
>>  				    (:name "unread" :query "tag:unread"))

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

* Re: [PATCH 0/5] emacs: hello: convert saved-searches to plists
  2014-04-06  0:52 ` [PATCH 0/5] emacs: hello: convert saved-searches to plists David Bremner
@ 2014-04-06  5:34   ` Mark Walters
  2014-04-06  8:04   ` Tomi Ollila
  1 sibling, 0 replies; 15+ messages in thread
From: Mark Walters @ 2014-04-06  5:34 UTC (permalink / raw)
  To: David Bremner, notmuch


On Sun, 06 Apr 2014, David Bremner <david@tethera.net> wrote:
> Mark Walters <markwalters1009@gmail.com> writes:
>
>> This series converts the saved-search format to plists. This should
>> make it much easier to extend their functionality. The final patch
>> illustrates this by adding a sort-order option to the saved
>> searches. It also exposes the count-query functionality that is
>> already present internally, and could be used to store keyboard
>> shortcuts for searches.
>
> Not necessarily an issue for this series, but I'd like start thinking
> about a front-end-independent representation for saved searches; perhaps
> json for want of better ideas.  

Yes that sounds good. I think it would be natural to parse the JSON (or
sexp if we allow both formats) into a plist for the saved search so that
could fit in quite neatly.

Best wishes

Mark

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

* Re: [PATCH 0/5] emacs: hello: convert saved-searches to plists
  2014-04-06  0:52 ` [PATCH 0/5] emacs: hello: convert saved-searches to plists David Bremner
  2014-04-06  5:34   ` Mark Walters
@ 2014-04-06  8:04   ` Tomi Ollila
  1 sibling, 0 replies; 15+ messages in thread
From: Tomi Ollila @ 2014-04-06  8:04 UTC (permalink / raw)
  To: notmuch

On Sun, Apr 06 2014, David Bremner <david@tethera.net> wrote:

> Mark Walters <markwalters1009@gmail.com> writes:
>
>> This series converts the saved-search format to plists. This should
>> make it much easier to extend their functionality. The final patch
>> illustrates this by adding a sort-order option to the saved
>> searches. It also exposes the count-query functionality that is
>> already present internally, and could be used to store keyboard
>> shortcuts for searches.
>
> Not necessarily an issue for this series, but I'd like start thinking
> about a front-end-independent representation for saved searches; perhaps
> json for want of better ideas.  

I think something like this has been (briefly) discussed on IRC -- how
about storing saved searches on lib/cli interface; then the same saved
searches could be used wherever the MUA is running (remoteusage!)

>
> d

Tomi

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

end of thread, other threads:[~2014-04-06  8:04 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-05 21:24 [PATCH 0/5] emacs: hello: convert saved-searches to plists Mark Walters
2014-04-05 21:24 ` [PATCH 1/5] emacs: hello: add helper functions for saved-searches Mark Walters
2014-04-06  0:58   ` Austin Clements
2014-04-05 21:24 ` [PATCH 2/5] emacs: hello: use the saved-search helper functions Mark Walters
2014-04-06  1:06   ` Austin Clements
2014-04-05 21:24 ` [PATCH 3/5] emacs: hello: add a customize for saved-searches Mark Walters
2014-04-05 21:24 ` [PATCH 4/5] emacs: hello: switch notmuch-hello-insert-buttons to plists Mark Walters
2014-04-06  1:24   ` Austin Clements
2014-04-06  5:31     ` Mark Walters
2014-04-05 21:24 ` [PATCH 5/5] emacs: Add a sort-order option to saved-searches Mark Walters
2014-04-06  1:30   ` Austin Clements
2014-04-06  5:32     ` Mark Walters
2014-04-06  0:52 ` [PATCH 0/5] emacs: hello: convert saved-searches to plists David Bremner
2014-04-06  5:34   ` Mark Walters
2014-04-06  8:04   ` Tomi Ollila

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