unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer
@ 2012-01-17 19:34 Dmitry Kurochkin
  2012-01-17 19:34 ` [PATCH 2/3] emacs: use a single history for all searches Dmitry Kurochkin
                   ` (4 more replies)
  0 siblings, 5 replies; 28+ messages in thread
From: Dmitry Kurochkin @ 2012-01-17 19:34 UTC (permalink / raw)
  To: notmuch

Before the change, "s" in notmuch-hello buffer would jump to the
search box.  The patch changes the binding to `notmuch-search' which
is consistent with all other notmuch buffers.
---
 emacs/notmuch-hello.el |   19 ++++++-------------
 1 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 02017ce..08fcd22 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -29,9 +29,6 @@
 (declare-function notmuch-search "notmuch" (query &optional oldest-first target-thread target-line continuation))
 (declare-function notmuch-poll "notmuch" ())
 
-(defvar notmuch-hello-search-bar-marker nil
-  "The position of the search bar within the notmuch-hello buffer.")
-
 (defcustom notmuch-recent-searches-max 10
   "The number of recent searches to store and display."
   :type 'integer
@@ -321,11 +318,6 @@ should be. Returns a cons cell `(tags-per-line width)'."
 	(widget-insert "\n"))
     found-target-pos))
 
-(defun notmuch-hello-goto-search ()
-  "Put point inside the `search' widget."
-  (interactive)
-  (goto-char notmuch-hello-search-bar-marker))
-
 (defimage notmuch-hello-logo ((:type png :file "notmuch-logo.png")))
 
 (defun notmuch-hello-search-continuation()
@@ -355,7 +347,7 @@ should be. Returns a cons cell `(tags-per-line width)'."
     (define-key map "G" 'notmuch-hello-poll-and-update)
     (define-key map (kbd "<C-tab>") 'widget-backward)
     (define-key map "m" 'notmuch-mua-new-mail)
-    (define-key map "s" 'notmuch-hello-goto-search)
+    (define-key map "s" 'notmuch-search)
     map)
   "Keymap for \"notmuch hello\" buffers.")
 (fset 'notmuch-hello-mode-map notmuch-hello-mode-map)
@@ -468,7 +460,8 @@ Complete list of currently available key bindings:
       (widget-insert " messages.\n"))
 
     (let ((found-target-pos nil)
-	  (final-target-pos nil))
+	  (final-target-pos nil)
+	  (search-bar-pos))
       (let* ((saved-alist
 	      ;; Filter out empty saved searches if required.
 	      (if notmuch-show-empty-saved-searches
@@ -500,7 +493,7 @@ Complete list of currently available key bindings:
 	    (indent-rigidly start (point) notmuch-hello-indent)))
 
 	(widget-insert "\nSearch: ")
-	(setq notmuch-hello-search-bar-marker (point-marker))
+	(setq search-bar-pos (point-marker))
 	(widget-create 'editable-field
 		       ;; Leave some space at the start and end of the
 		       ;; search boxes.
@@ -589,7 +582,7 @@ Complete list of currently available key bindings:
 	(when notmuch-saved-searches
 	  (widget-insert "Edit saved searches with the `edit' button.\n"))
 	(widget-insert "Hit RET or click on a saved search or tag name to view matching threads.\n")
-	(widget-insert "`=' refreshes this screen. `s' jumps to the search box. `q' to quit.\n")
+	(widget-insert "`=' refreshes this screen. `s' to search messages. `q' to quit.\n")
 	(let ((fill-column (- (window-width) notmuch-hello-indent)))
 	  (center-region start (point))))
 
@@ -601,7 +594,7 @@ Complete list of currently available key bindings:
 	  (widget-forward 1)))
 
       (unless (widget-at)
-	(notmuch-hello-goto-search))))
+	(goto-char search-bar-pos))))
 
   (run-hooks 'notmuch-hello-refresh-hook))
 
-- 
1.7.8.3

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

* [PATCH 2/3] emacs: use a single history for all searches
  2012-01-17 19:34 [PATCH 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer Dmitry Kurochkin
@ 2012-01-17 19:34 ` Dmitry Kurochkin
  2012-01-18  8:25   ` David Edmondson
  2012-01-17 19:34 ` [PATCH 3/3] emacs: bind "s" to `notmuch-hello-search' in notmuch-hello buffer Dmitry Kurochkin
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 28+ messages in thread
From: Dmitry Kurochkin @ 2012-01-17 19:34 UTC (permalink / raw)
  To: notmuch

There are two ways to do search in Emacs UI: search widget in
notmuch-hello buffer and `notmuch-search' function bound to "s".
Before the change, these search mechanisms used different history
lists.  The patch makes notmuch-hello search use the same history list
as `notmuch-search' function.
---
 emacs/notmuch-hello.el                             |   49 ++++++--------------
 emacs/notmuch-lib.el                               |    9 ++++
 emacs/notmuch.el                                   |   19 +++++--
 test/emacs.expected-output/notmuch-hello           |    2 +-
 .../notmuch-hello-no-saved-searches                |    2 +-
 .../emacs.expected-output/notmuch-hello-with-empty |    2 +-
 6 files changed, 40 insertions(+), 43 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 08fcd22..cb36977 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -29,8 +29,8 @@
 (declare-function notmuch-search "notmuch" (query &optional oldest-first target-thread target-line continuation))
 (declare-function notmuch-poll "notmuch" ())
 
-(defcustom notmuch-recent-searches-max 10
-  "The number of recent searches to store and display."
+(defcustom notmuch-hello-recent-searches-max 10
+  "The number of recent searches to display."
   :type 'integer
   :group 'notmuch)
 
@@ -151,16 +151,6 @@ International Bureau of Weights and Measures."
 (defvar notmuch-hello-url "http://notmuchmail.org"
   "The `notmuch' web site.")
 
-(defvar notmuch-hello-recent-searches nil)
-
-(defun notmuch-hello-remember-search (search)
-  (setq notmuch-hello-recent-searches
-	(delete search notmuch-hello-recent-searches))
-  (push search notmuch-hello-recent-searches)
-  (if (> (length notmuch-hello-recent-searches)
-	 notmuch-recent-searches-max)
-      (setq notmuch-hello-recent-searches (butlast notmuch-hello-recent-searches))))
-
 (defun notmuch-hello-nice-number (n)
   (let (result)
     (while (> n 0)
@@ -173,16 +163,9 @@ International Bureau of Weights and Measures."
 	      (format "%s%03d" notmuch-hello-thousands-separator elem))
 	     (cdr result)))))
 
-(defun notmuch-hello-trim (search)
-  "Trim whitespace."
-  (if (string-match "^[[:space:]]*\\(.*[^[:space:]]\\)[[:space:]]*$" search)
-      (match-string 1 search)
-    search))
-
 (defun notmuch-hello-search (search)
-  (let ((search (notmuch-hello-trim search)))
-    (notmuch-hello-remember-search search)
-    (notmuch-search search notmuch-search-oldest-first nil nil #'notmuch-hello-search-continuation)))
+  (notmuch-search search notmuch-search-oldest-first nil nil
+		  #'notmuch-hello-search-continuation))
 
 (defun notmuch-hello-add-saved-search (widget)
   (interactive)
@@ -461,7 +444,7 @@ Complete list of currently available key bindings:
 
     (let ((found-target-pos nil)
 	  (final-target-pos nil)
-	  (search-bar-pos))
+	  (default-pos))
       (let* ((saved-alist
 	      ;; Filter out empty saved searches if required.
 	      (if notmuch-show-empty-saved-searches
@@ -493,7 +476,7 @@ Complete list of currently available key bindings:
 	    (indent-rigidly start (point) notmuch-hello-indent)))
 
 	(widget-insert "\nSearch: ")
-	(setq search-bar-pos (point-marker))
+	(setq default-pos (point-marker))
 	(widget-create 'editable-field
 		       ;; Leave some space at the start and end of the
 		       ;; search boxes.
@@ -507,18 +490,18 @@ Complete list of currently available key bindings:
 	(put-text-property (1- (point)) (point) 'invisible t)
 	(widget-insert "\n")
 
-	(when notmuch-hello-recent-searches
+	(when notmuch-search-history
 	  (widget-insert "\nRecent searches: ")
 	  (widget-create 'push-button
 			 :notify (lambda (&rest ignore)
-				   (setq notmuch-hello-recent-searches nil)
+				   (setq notmuch-search-history nil)
 				   (notmuch-hello-update))
 			 "clear")
 	  (widget-insert "\n\n")
-	  (let ((start (point))
-		(nth 0))
-	    (mapc (lambda (search)
-		    (let ((widget-symbol (intern (format "notmuch-hello-search-%d" nth))))
+	  (let ((start (point)))
+	    (loop for i from 1 to notmuch-hello-recent-searches-max
+		  for search in notmuch-search-history do
+		    (let ((widget-symbol (intern (format "notmuch-hello-search-%d" i))))
 		      (set widget-symbol
 			   (widget-create 'editable-field
 					  ;; Don't let the search boxes be
@@ -545,9 +528,7 @@ Complete list of currently available key bindings:
 					       (notmuch-hello-add-saved-search widget))
 				     :notmuch-saved-search-widget widget-symbol
 				     "save"))
-		    (widget-insert "\n")
-		    (setq nth (1+ nth)))
-		  notmuch-hello-recent-searches)
+		    (widget-insert "\n"))
 	    (indent-rigidly start (point) notmuch-hello-indent)))
 
 	(when alltags-alist
@@ -576,7 +557,7 @@ Complete list of currently available key bindings:
       (let ((start (point)))
 	(widget-insert "\n\n")
 	(widget-insert "Type a search query and hit RET to view matching threads.\n")
-	(when notmuch-hello-recent-searches
+	(when notmuch-search-history
 	  (widget-insert "Hit RET to re-submit a previous search. Edit it first if you like.\n")
 	  (widget-insert "Save recent searches with the `save' button.\n"))
 	(when notmuch-saved-searches
@@ -594,7 +575,7 @@ Complete list of currently available key bindings:
 	  (widget-forward 1)))
 
       (unless (widget-at)
-	(goto-char search-bar-pos))))
+	(goto-char default-pos))))
 
   (run-hooks 'notmuch-hello-refresh-hook))
 
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 0f856bf..dfbc2e0 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -35,6 +35,9 @@
 
 ;;
 
+(defvar notmuch-search-history nil
+  "Variable to store notmuch searches history.")
+
 (defcustom notmuch-saved-searches nil
   "A list of saved searches to display."
   :type '(alist :key-type string :value-type string)
@@ -114,6 +117,12 @@ the user hasn't set this variable with the old or new value."
       (setq list (cdr list)))
     (nreverse out)))
 
+(defun notmuch-trim (search)
+  "Trim whitespaces."
+  (if (string-match "^[[:space:]]*\\(.*[^[:space:]]\\)[[:space:]]*$" search)
+      (match-string 1 search)
+    search))
+
 ; This lets us avoid compiling these replacement functions when emacs
 ; is sufficiently new enough to supply them alone. We do the macro
 ; treatment rather than just wrapping our defun calls in a when form
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index ef4dcc7..450c0c1 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -916,21 +916,28 @@ PROMPT is the string to prompt with."
 	       (t (list string)))))))
       ;; this was simpler than convincing completing-read to accept spaces:
       (define-key keymap (kbd "<tab>") 'minibuffer-complete)
-      (read-from-minibuffer prompt nil keymap nil
-			    'notmuch-query-history nil nil))))
+      (let ((history-delete-duplicates t))
+	(read-from-minibuffer prompt nil keymap nil
+			      'notmuch-search-history nil nil)))))
 
 ;;;###autoload
-(defun notmuch-search (query &optional oldest-first target-thread target-line continuation)
-  "Run \"notmuch search\" with the given query string and display results.
+(defun notmuch-search (&optional query oldest-first target-thread target-line continuation)
+  "Run \"notmuch search\" with the given `query' and display results.
 
-The optional parameters are used as follows:
+If `query' is nil, it is read interactively from the minibuffer.
+Other optional parameters are used as follows:
 
   oldest-first: A Boolean controlling the sort order of returned threads
   target-thread: A thread ID (with the thread: prefix) that will be made
                  current if it appears in the search results.
   target-line: The line number to move to if the target thread does not
                appear in the search results."
-  (interactive (list (notmuch-read-query "Notmuch search: ")))
+  (interactive)
+  (if (null query)
+      (setq query (notmuch-read-query "Notmuch search: "))
+    (setq query (notmuch-trim query))
+    (let ((history-delete-duplicates t))
+      (add-to-history 'notmuch-search-history query)))
   (let ((buffer (get-buffer-create (notmuch-search-buffer-title query))))
     (switch-to-buffer buffer)
     (notmuch-search-mode)
diff --git a/test/emacs.expected-output/notmuch-hello b/test/emacs.expected-output/notmuch-hello
index de57de2..da47a6b 100644
--- a/test/emacs.expected-output/notmuch-hello
+++ b/test/emacs.expected-output/notmuch-hello
@@ -11,4 +11,4 @@ Search:
 	 Type a search query and hit RET to view matching threads.
 		Edit saved searches with the `edit' button.
   Hit RET or click on a saved search or tag name to view matching threads.
-    `=' refreshes this screen. `s' jumps to the search box. `q' to quit.
+      `=' refreshes this screen. `s' to search messages. `q' to quit.
diff --git a/test/emacs.expected-output/notmuch-hello-no-saved-searches b/test/emacs.expected-output/notmuch-hello-no-saved-searches
index f1fc4d6..202d7d2 100644
--- a/test/emacs.expected-output/notmuch-hello-no-saved-searches
+++ b/test/emacs.expected-output/notmuch-hello-no-saved-searches
@@ -7,4 +7,4 @@ Search:
 	 Type a search query and hit RET to view matching threads.
 		Edit saved searches with the `edit' button.
   Hit RET or click on a saved search or tag name to view matching threads.
-    `=' refreshes this screen. `s' jumps to the search box. `q' to quit.
+      `=' refreshes this screen. `s' to search messages. `q' to quit.
diff --git a/test/emacs.expected-output/notmuch-hello-with-empty b/test/emacs.expected-output/notmuch-hello-with-empty
index dd8728b..d810b51 100644
--- a/test/emacs.expected-output/notmuch-hello-with-empty
+++ b/test/emacs.expected-output/notmuch-hello-with-empty
@@ -11,4 +11,4 @@ Search:
 	 Type a search query and hit RET to view matching threads.
 		Edit saved searches with the `edit' button.
   Hit RET or click on a saved search or tag name to view matching threads.
-    `=' refreshes this screen. `s' jumps to the search box. `q' to quit.
+      `=' refreshes this screen. `s' to search messages. `q' to quit.
-- 
1.7.8.3

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

* [PATCH 3/3] emacs: bind "s" to `notmuch-hello-search' in notmuch-hello buffer
  2012-01-17 19:34 [PATCH 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer Dmitry Kurochkin
  2012-01-17 19:34 ` [PATCH 2/3] emacs: use a single history for all searches Dmitry Kurochkin
@ 2012-01-17 19:34 ` Dmitry Kurochkin
  2012-01-18  8:26   ` David Edmondson
  2012-01-17 21:22 ` [PATCH 1/3] emacs: bind "s" to `notmuch-search' " Jani Nikula
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 28+ messages in thread
From: Dmitry Kurochkin @ 2012-01-17 19:34 UTC (permalink / raw)
  To: notmuch

`notmuch-hello-search' uses `notmuch-search' function but refreshes
notmuch-hello buffer when the search buffer is closed.
---
 emacs/notmuch-hello.el |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index cb36977..e908659 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -163,7 +163,8 @@ International Bureau of Weights and Measures."
 	      (format "%s%03d" notmuch-hello-thousands-separator elem))
 	     (cdr result)))))
 
-(defun notmuch-hello-search (search)
+(defun notmuch-hello-search (&optional search)
+  (interactive)
   (notmuch-search search notmuch-search-oldest-first nil nil
 		  #'notmuch-hello-search-continuation))
 
@@ -330,7 +331,7 @@ should be. Returns a cons cell `(tags-per-line width)'."
     (define-key map "G" 'notmuch-hello-poll-and-update)
     (define-key map (kbd "<C-tab>") 'widget-backward)
     (define-key map "m" 'notmuch-mua-new-mail)
-    (define-key map "s" 'notmuch-search)
+    (define-key map "s" 'notmuch-hello-search)
     map)
   "Keymap for \"notmuch hello\" buffers.")
 (fset 'notmuch-hello-mode-map notmuch-hello-mode-map)
-- 
1.7.8.3

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

* Re: [PATCH 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer
  2012-01-17 19:34 [PATCH 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer Dmitry Kurochkin
  2012-01-17 19:34 ` [PATCH 2/3] emacs: use a single history for all searches Dmitry Kurochkin
  2012-01-17 19:34 ` [PATCH 3/3] emacs: bind "s" to `notmuch-hello-search' in notmuch-hello buffer Dmitry Kurochkin
@ 2012-01-17 21:22 ` Jani Nikula
  2012-01-17 21:29   ` Dmitry Kurochkin
  2012-01-26 13:48   ` Pieter Praet
  2012-01-18  8:20 ` David Edmondson
  2012-01-18 20:22 ` [PATCH v2 0/3] emacs: notmuch-hello search cleanup Dmitry Kurochkin
  4 siblings, 2 replies; 28+ messages in thread
From: Jani Nikula @ 2012-01-17 21:22 UTC (permalink / raw)
  To: Dmitry Kurochkin, notmuch

On Tue, 17 Jan 2012 23:34:08 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
> Before the change, "s" in notmuch-hello buffer would jump to the
> search box.  The patch changes the binding to `notmuch-search' which
> is consistent with all other notmuch buffers.
> ---
>  emacs/notmuch-hello.el |   19 ++++++-------------
>  1 files changed, 6 insertions(+), 13 deletions(-)
> 
> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> index 02017ce..08fcd22 100644
> --- a/emacs/notmuch-hello.el
> +++ b/emacs/notmuch-hello.el
> @@ -29,9 +29,6 @@
>  (declare-function notmuch-search "notmuch" (query &optional oldest-first target-thread target-line continuation))
>  (declare-function notmuch-poll "notmuch" ())
>  
> -(defvar notmuch-hello-search-bar-marker nil
> -  "The position of the search bar within the notmuch-hello buffer.")
> -
>  (defcustom notmuch-recent-searches-max 10
>    "The number of recent searches to store and display."
>    :type 'integer
> @@ -321,11 +318,6 @@ should be. Returns a cons cell `(tags-per-line width)'."
>  	(widget-insert "\n"))
>      found-target-pos))
>  
> -(defun notmuch-hello-goto-search ()
> -  "Put point inside the `search' widget."
> -  (interactive)
> -  (goto-char notmuch-hello-search-bar-marker))

After this, what would the user have to do to bind some key to put the
point in the search box? If someone wants to restore old behaviour for
themselves.

Also, it's perhaps out of scope for this patch, but it will become more
evident now that notmuch-search does not respect
notmuch-search-oldest-first when called without parameters like the new
's' keybinding does. This is the same in search view.


BR,
Jani.


> -
>  (defimage notmuch-hello-logo ((:type png :file "notmuch-logo.png")))
>  
>  (defun notmuch-hello-search-continuation()
> @@ -355,7 +347,7 @@ should be. Returns a cons cell `(tags-per-line width)'."
>      (define-key map "G" 'notmuch-hello-poll-and-update)
>      (define-key map (kbd "<C-tab>") 'widget-backward)
>      (define-key map "m" 'notmuch-mua-new-mail)
> -    (define-key map "s" 'notmuch-hello-goto-search)
> +    (define-key map "s" 'notmuch-search)
>      map)
>    "Keymap for \"notmuch hello\" buffers.")
>  (fset 'notmuch-hello-mode-map notmuch-hello-mode-map)
> @@ -468,7 +460,8 @@ Complete list of currently available key bindings:
>        (widget-insert " messages.\n"))
>  
>      (let ((found-target-pos nil)
> -	  (final-target-pos nil))
> +	  (final-target-pos nil)
> +	  (search-bar-pos))
>        (let* ((saved-alist
>  	      ;; Filter out empty saved searches if required.
>  	      (if notmuch-show-empty-saved-searches
> @@ -500,7 +493,7 @@ Complete list of currently available key bindings:
>  	    (indent-rigidly start (point) notmuch-hello-indent)))
>  
>  	(widget-insert "\nSearch: ")
> -	(setq notmuch-hello-search-bar-marker (point-marker))
> +	(setq search-bar-pos (point-marker))
>  	(widget-create 'editable-field
>  		       ;; Leave some space at the start and end of the
>  		       ;; search boxes.
> @@ -589,7 +582,7 @@ Complete list of currently available key bindings:
>  	(when notmuch-saved-searches
>  	  (widget-insert "Edit saved searches with the `edit' button.\n"))
>  	(widget-insert "Hit RET or click on a saved search or tag name to view matching threads.\n")
> -	(widget-insert "`=' refreshes this screen. `s' jumps to the search box. `q' to quit.\n")
> +	(widget-insert "`=' refreshes this screen. `s' to search messages. `q' to quit.\n")
>  	(let ((fill-column (- (window-width) notmuch-hello-indent)))
>  	  (center-region start (point))))
>  
> @@ -601,7 +594,7 @@ Complete list of currently available key bindings:
>  	  (widget-forward 1)))
>  
>        (unless (widget-at)
> -	(notmuch-hello-goto-search))))
> +	(goto-char search-bar-pos))))
>  
>    (run-hooks 'notmuch-hello-refresh-hook))
>  
> -- 
> 1.7.8.3
> 
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

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

* Re: [PATCH 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer
  2012-01-17 21:22 ` [PATCH 1/3] emacs: bind "s" to `notmuch-search' " Jani Nikula
@ 2012-01-17 21:29   ` Dmitry Kurochkin
  2012-01-26 13:48   ` Pieter Praet
  1 sibling, 0 replies; 28+ messages in thread
From: Dmitry Kurochkin @ 2012-01-17 21:29 UTC (permalink / raw)
  To: Jani Nikula, notmuch

[of course I sent this email privately, sorry for duplicates]

On Tue, 17 Jan 2012 23:22:30 +0200, Jani Nikula <jani@nikula.org> wrote:
> On Tue, 17 Jan 2012 23:34:08 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
> > Before the change, "s" in notmuch-hello buffer would jump to the
> > search box.  The patch changes the binding to `notmuch-search' which
> > is consistent with all other notmuch buffers.
> > ---
> >  emacs/notmuch-hello.el |   19 ++++++-------------
> >  1 files changed, 6 insertions(+), 13 deletions(-)
> > 
> > diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> > index 02017ce..08fcd22 100644
> > --- a/emacs/notmuch-hello.el
> > +++ b/emacs/notmuch-hello.el
> > @@ -29,9 +29,6 @@
> >  (declare-function notmuch-search "notmuch" (query &optional oldest-first target-thread target-line continuation))
> >  (declare-function notmuch-poll "notmuch" ())
> >  
> > -(defvar notmuch-hello-search-bar-marker nil
> > -  "The position of the search bar within the notmuch-hello buffer.")
> > -
> >  (defcustom notmuch-recent-searches-max 10
> >    "The number of recent searches to store and display."
> >    :type 'integer
> > @@ -321,11 +318,6 @@ should be. Returns a cons cell `(tags-per-line width)'."
> >  	(widget-insert "\n"))
> >      found-target-pos))
> >  
> > -(defun notmuch-hello-goto-search ()
> > -  "Put point inside the `search' widget."
> > -  (interactive)
> > -  (goto-char notmuch-hello-search-bar-marker))
> 
> After this, what would the user have to do to bind some key to put the
> point in the search box? If someone wants to restore old behaviour for
> themselves.
> 

There is no way to do that.  From the previous discussions, I do not
remember anyone wanted the current "s" jumping behavior.  Let's wait for
some feedback and see if anyone wants that.  I would prefer to remove
this function and the global variable it uses.

> Also, it's perhaps out of scope for this patch, but it will become more
> evident now that notmuch-search does not respect
> notmuch-search-oldest-first when called without parameters like the new
> 's' keybinding does. This is the same in search view.
> 

I agree that this is an issue.  But it is outisde of the scope of this
patch series.

Regards,
  Dmitry

> 
> BR,
> Jani.
> 
> 
> > -
> >  (defimage notmuch-hello-logo ((:type png :file "notmuch-logo.png")))
> >  
> >  (defun notmuch-hello-search-continuation()
> > @@ -355,7 +347,7 @@ should be. Returns a cons cell `(tags-per-line width)'."
> >      (define-key map "G" 'notmuch-hello-poll-and-update)
> >      (define-key map (kbd "<C-tab>") 'widget-backward)
> >      (define-key map "m" 'notmuch-mua-new-mail)
> > -    (define-key map "s" 'notmuch-hello-goto-search)
> > +    (define-key map "s" 'notmuch-search)
> >      map)
> >    "Keymap for \"notmuch hello\" buffers.")
> >  (fset 'notmuch-hello-mode-map notmuch-hello-mode-map)
> > @@ -468,7 +460,8 @@ Complete list of currently available key bindings:
> >        (widget-insert " messages.\n"))
> >  
> >      (let ((found-target-pos nil)
> > -	  (final-target-pos nil))
> > +	  (final-target-pos nil)
> > +	  (search-bar-pos))
> >        (let* ((saved-alist
> >  	      ;; Filter out empty saved searches if required.
> >  	      (if notmuch-show-empty-saved-searches
> > @@ -500,7 +493,7 @@ Complete list of currently available key bindings:
> >  	    (indent-rigidly start (point) notmuch-hello-indent)))
> >  
> >  	(widget-insert "\nSearch: ")
> > -	(setq notmuch-hello-search-bar-marker (point-marker))
> > +	(setq search-bar-pos (point-marker))
> >  	(widget-create 'editable-field
> >  		       ;; Leave some space at the start and end of the
> >  		       ;; search boxes.
> > @@ -589,7 +582,7 @@ Complete list of currently available key bindings:
> >  	(when notmuch-saved-searches
> >  	  (widget-insert "Edit saved searches with the `edit' button.\n"))
> >  	(widget-insert "Hit RET or click on a saved search or tag name to view matching threads.\n")
> > -	(widget-insert "`=' refreshes this screen. `s' jumps to the search box. `q' to quit.\n")
> > +	(widget-insert "`=' refreshes this screen. `s' to search messages. `q' to quit.\n")
> >  	(let ((fill-column (- (window-width) notmuch-hello-indent)))
> >  	  (center-region start (point))))
> >  
> > @@ -601,7 +594,7 @@ Complete list of currently available key bindings:
> >  	  (widget-forward 1)))
> >  
> >        (unless (widget-at)
> > -	(notmuch-hello-goto-search))))
> > +	(goto-char search-bar-pos))))
> >  
> >    (run-hooks 'notmuch-hello-refresh-hook))
> >  
> > -- 
> > 1.7.8.3
> > 
> > _______________________________________________
> > notmuch mailing list
> > notmuch@notmuchmail.org
> > http://notmuchmail.org/mailman/listinfo/notmuch

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

* Re: [PATCH 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer
  2012-01-17 19:34 [PATCH 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer Dmitry Kurochkin
                   ` (2 preceding siblings ...)
  2012-01-17 21:22 ` [PATCH 1/3] emacs: bind "s" to `notmuch-search' " Jani Nikula
@ 2012-01-18  8:20 ` David Edmondson
  2012-01-18 20:22 ` [PATCH v2 0/3] emacs: notmuch-hello search cleanup Dmitry Kurochkin
  4 siblings, 0 replies; 28+ messages in thread
From: David Edmondson @ 2012-01-18  8:20 UTC (permalink / raw)
  To: Dmitry Kurochkin, notmuch

[-- Attachment #1: Type: text/plain, Size: 12 bytes --]

Looks fine.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [PATCH 2/3] emacs: use a single history for all searches
  2012-01-17 19:34 ` [PATCH 2/3] emacs: use a single history for all searches Dmitry Kurochkin
@ 2012-01-18  8:25   ` David Edmondson
  2012-01-18 17:57     ` Dmitry Kurochkin
  0 siblings, 1 reply; 28+ messages in thread
From: David Edmondson @ 2012-01-18  8:25 UTC (permalink / raw)
  To: Dmitry Kurochkin, notmuch

[-- Attachment #1: Type: text/plain, Size: 1724 bytes --]

On Tue, 17 Jan 2012 23:34:09 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
> There are two ways to do search in Emacs UI: search widget in
> notmuch-hello buffer and `notmuch-search' function bound to "s".
> Before the change, these search mechanisms used different history
> lists.  The patch makes notmuch-hello search use the same history list
> as `notmuch-search' function.

The test output updates included here should be with the previous patch,
shouldn't they?

> -(defun notmuch-search (query &optional oldest-first target-thread target-line continuation)
> -  "Run \"notmuch search\" with the given query string and display results.
> +(defun notmuch-search (&optional query oldest-first target-thread target-line continuation)
> +  "Run \"notmuch search\" with the given `query' and display results.
>  
> -The optional parameters are used as follows:
> +If `query' is nil, it is read interactively from the minibuffer.
> +Other optional parameters are used as follows:
>  
>    oldest-first: A Boolean controlling the sort order of returned threads
>    target-thread: A thread ID (with the thread: prefix) that will be made
>                   current if it appears in the search results.
>    target-line: The line number to move to if the target thread does not
>                 appear in the search results."
> -  (interactive (list (notmuch-read-query "Notmuch search: ")))
> +  (interactive)
> +  (if (null query)
> +      (setq query (notmuch-read-query "Notmuch search: "))
> +    (setq query (notmuch-trim query))
> +    (let ((history-delete-duplicates t))
> +      (add-to-history 'notmuch-search-history query)))

Should user-typed queries be trimmed?

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [PATCH 3/3] emacs: bind "s" to `notmuch-hello-search' in notmuch-hello buffer
  2012-01-17 19:34 ` [PATCH 3/3] emacs: bind "s" to `notmuch-hello-search' in notmuch-hello buffer Dmitry Kurochkin
@ 2012-01-18  8:26   ` David Edmondson
  0 siblings, 0 replies; 28+ messages in thread
From: David Edmondson @ 2012-01-18  8:26 UTC (permalink / raw)
  To: Dmitry Kurochkin, notmuch

[-- Attachment #1: Type: text/plain, Size: 4 bytes --]

+1.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [PATCH 2/3] emacs: use a single history for all searches
  2012-01-18  8:25   ` David Edmondson
@ 2012-01-18 17:57     ` Dmitry Kurochkin
  2012-01-18 18:18       ` David Edmondson
  0 siblings, 1 reply; 28+ messages in thread
From: Dmitry Kurochkin @ 2012-01-18 17:57 UTC (permalink / raw)
  To: David Edmondson, notmuch

On Wed, 18 Jan 2012 08:25:22 +0000, David Edmondson <dme@dme.org> wrote:
> On Tue, 17 Jan 2012 23:34:09 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
> > There are two ways to do search in Emacs UI: search widget in
> > notmuch-hello buffer and `notmuch-search' function bound to "s".
> > Before the change, these search mechanisms used different history
> > lists.  The patch makes notmuch-hello search use the same history list
> > as `notmuch-search' function.
> 
> The test output updates included here should be with the previous patch,
> shouldn't they?
> 

Indeed.  Would send v2.

> > -(defun notmuch-search (query &optional oldest-first target-thread target-line continuation)
> > -  "Run \"notmuch search\" with the given query string and display results.
> > +(defun notmuch-search (&optional query oldest-first target-thread target-line continuation)
> > +  "Run \"notmuch search\" with the given `query' and display results.
> >  
> > -The optional parameters are used as follows:
> > +If `query' is nil, it is read interactively from the minibuffer.
> > +Other optional parameters are used as follows:
> >  
> >    oldest-first: A Boolean controlling the sort order of returned threads
> >    target-thread: A thread ID (with the thread: prefix) that will be made
> >                   current if it appears in the search results.
> >    target-line: The line number to move to if the target thread does not
> >                 appear in the search results."
> > -  (interactive (list (notmuch-read-query "Notmuch search: ")))
> > +  (interactive)
> > +  (if (null query)
> > +      (setq query (notmuch-read-query "Notmuch search: "))
> > +    (setq query (notmuch-trim query))
> > +    (let ((history-delete-duplicates t))
> > +      (add-to-history 'notmuch-search-history query)))
> 
> Should user-typed queries be trimmed?

IMO that would not hurt.  But we need to do it before it gets added to
the history.  And that may be tricky.  So this patch does trimming only
for queries from notmuch-hello search box (as it was before).

Regards,
  Dmitry

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

* Re: [PATCH 2/3] emacs: use a single history for all searches
  2012-01-18 17:57     ` Dmitry Kurochkin
@ 2012-01-18 18:18       ` David Edmondson
  0 siblings, 0 replies; 28+ messages in thread
From: David Edmondson @ 2012-01-18 18:18 UTC (permalink / raw)
  To: Dmitry Kurochkin; +Cc: notmuch

[-- Attachment #1: Type: text/plain, Size: 524 bytes --]

On Wed, 18 Jan 2012 21:57:27 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
> > The test output updates included here should be with the previous patch,
> > shouldn't they?
> 
> Indeed.  Would send v2.

That's not necessary for me.

> > Should user-typed queries be trimmed?
> 
> IMO that would not hurt.  But we need to do it before it gets added to
> the history.  And that may be tricky.  So this patch does trimming only
> for queries from notmuch-hello search box (as it was before).

Okay.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* [PATCH v2 0/3] emacs: notmuch-hello search cleanup
  2012-01-17 19:34 [PATCH 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer Dmitry Kurochkin
                   ` (3 preceding siblings ...)
  2012-01-18  8:20 ` David Edmondson
@ 2012-01-18 20:22 ` Dmitry Kurochkin
  2012-01-18 20:22   ` [PATCH v2 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer Dmitry Kurochkin
                     ` (4 more replies)
  4 siblings, 5 replies; 28+ messages in thread
From: Dmitry Kurochkin @ 2012-01-18 20:22 UTC (permalink / raw)
  To: notmuch

Changes in v2 since v1:

* expected results changes for tests moved from patch 2 to 1 where it belong

Regards,
  Dmitry

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

* [PATCH v2 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer
  2012-01-18 20:22 ` [PATCH v2 0/3] emacs: notmuch-hello search cleanup Dmitry Kurochkin
@ 2012-01-18 20:22   ` Dmitry Kurochkin
  2012-01-18 20:22   ` [PATCH v2 2/3] emacs: use a single history for all searches Dmitry Kurochkin
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 28+ messages in thread
From: Dmitry Kurochkin @ 2012-01-18 20:22 UTC (permalink / raw)
  To: notmuch

Before the change, "s" in notmuch-hello buffer would jump to the
search box.  The patch changes the binding to `notmuch-search' which
is consistent with all other notmuch buffers.
---
 emacs/notmuch-hello.el                             |   19 ++++++-------------
 test/emacs.expected-output/notmuch-hello           |    2 +-
 .../notmuch-hello-no-saved-searches                |    2 +-
 .../emacs.expected-output/notmuch-hello-with-empty |    2 +-
 4 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 02017ce..08fcd22 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -29,9 +29,6 @@
 (declare-function notmuch-search "notmuch" (query &optional oldest-first target-thread target-line continuation))
 (declare-function notmuch-poll "notmuch" ())
 
-(defvar notmuch-hello-search-bar-marker nil
-  "The position of the search bar within the notmuch-hello buffer.")
-
 (defcustom notmuch-recent-searches-max 10
   "The number of recent searches to store and display."
   :type 'integer
@@ -321,11 +318,6 @@ should be. Returns a cons cell `(tags-per-line width)'."
 	(widget-insert "\n"))
     found-target-pos))
 
-(defun notmuch-hello-goto-search ()
-  "Put point inside the `search' widget."
-  (interactive)
-  (goto-char notmuch-hello-search-bar-marker))
-
 (defimage notmuch-hello-logo ((:type png :file "notmuch-logo.png")))
 
 (defun notmuch-hello-search-continuation()
@@ -355,7 +347,7 @@ should be. Returns a cons cell `(tags-per-line width)'."
     (define-key map "G" 'notmuch-hello-poll-and-update)
     (define-key map (kbd "<C-tab>") 'widget-backward)
     (define-key map "m" 'notmuch-mua-new-mail)
-    (define-key map "s" 'notmuch-hello-goto-search)
+    (define-key map "s" 'notmuch-search)
     map)
   "Keymap for \"notmuch hello\" buffers.")
 (fset 'notmuch-hello-mode-map notmuch-hello-mode-map)
@@ -468,7 +460,8 @@ Complete list of currently available key bindings:
       (widget-insert " messages.\n"))
 
     (let ((found-target-pos nil)
-	  (final-target-pos nil))
+	  (final-target-pos nil)
+	  (search-bar-pos))
       (let* ((saved-alist
 	      ;; Filter out empty saved searches if required.
 	      (if notmuch-show-empty-saved-searches
@@ -500,7 +493,7 @@ Complete list of currently available key bindings:
 	    (indent-rigidly start (point) notmuch-hello-indent)))
 
 	(widget-insert "\nSearch: ")
-	(setq notmuch-hello-search-bar-marker (point-marker))
+	(setq search-bar-pos (point-marker))
 	(widget-create 'editable-field
 		       ;; Leave some space at the start and end of the
 		       ;; search boxes.
@@ -589,7 +582,7 @@ Complete list of currently available key bindings:
 	(when notmuch-saved-searches
 	  (widget-insert "Edit saved searches with the `edit' button.\n"))
 	(widget-insert "Hit RET or click on a saved search or tag name to view matching threads.\n")
-	(widget-insert "`=' refreshes this screen. `s' jumps to the search box. `q' to quit.\n")
+	(widget-insert "`=' refreshes this screen. `s' to search messages. `q' to quit.\n")
 	(let ((fill-column (- (window-width) notmuch-hello-indent)))
 	  (center-region start (point))))
 
@@ -601,7 +594,7 @@ Complete list of currently available key bindings:
 	  (widget-forward 1)))
 
       (unless (widget-at)
-	(notmuch-hello-goto-search))))
+	(goto-char search-bar-pos))))
 
   (run-hooks 'notmuch-hello-refresh-hook))
 
diff --git a/test/emacs.expected-output/notmuch-hello b/test/emacs.expected-output/notmuch-hello
index de57de2..da47a6b 100644
--- a/test/emacs.expected-output/notmuch-hello
+++ b/test/emacs.expected-output/notmuch-hello
@@ -11,4 +11,4 @@ Search:
 	 Type a search query and hit RET to view matching threads.
 		Edit saved searches with the `edit' button.
   Hit RET or click on a saved search or tag name to view matching threads.
-    `=' refreshes this screen. `s' jumps to the search box. `q' to quit.
+      `=' refreshes this screen. `s' to search messages. `q' to quit.
diff --git a/test/emacs.expected-output/notmuch-hello-no-saved-searches b/test/emacs.expected-output/notmuch-hello-no-saved-searches
index f1fc4d6..202d7d2 100644
--- a/test/emacs.expected-output/notmuch-hello-no-saved-searches
+++ b/test/emacs.expected-output/notmuch-hello-no-saved-searches
@@ -7,4 +7,4 @@ Search:
 	 Type a search query and hit RET to view matching threads.
 		Edit saved searches with the `edit' button.
   Hit RET or click on a saved search or tag name to view matching threads.
-    `=' refreshes this screen. `s' jumps to the search box. `q' to quit.
+      `=' refreshes this screen. `s' to search messages. `q' to quit.
diff --git a/test/emacs.expected-output/notmuch-hello-with-empty b/test/emacs.expected-output/notmuch-hello-with-empty
index dd8728b..d810b51 100644
--- a/test/emacs.expected-output/notmuch-hello-with-empty
+++ b/test/emacs.expected-output/notmuch-hello-with-empty
@@ -11,4 +11,4 @@ Search:
 	 Type a search query and hit RET to view matching threads.
 		Edit saved searches with the `edit' button.
   Hit RET or click on a saved search or tag name to view matching threads.
-    `=' refreshes this screen. `s' jumps to the search box. `q' to quit.
+      `=' refreshes this screen. `s' to search messages. `q' to quit.
-- 
1.7.8.3

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

* [PATCH v2 2/3] emacs: use a single history for all searches
  2012-01-18 20:22 ` [PATCH v2 0/3] emacs: notmuch-hello search cleanup Dmitry Kurochkin
  2012-01-18 20:22   ` [PATCH v2 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer Dmitry Kurochkin
@ 2012-01-18 20:22   ` Dmitry Kurochkin
  2012-01-18 20:22   ` [PATCH v2 3/3] emacs: bind "s" to `notmuch-hello-search' in notmuch-hello buffer Dmitry Kurochkin
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 28+ messages in thread
From: Dmitry Kurochkin @ 2012-01-18 20:22 UTC (permalink / raw)
  To: notmuch

There are two ways to do search in Emacs UI: search widget in
notmuch-hello buffer and `notmuch-search' function bound to "s".
Before the change, these search mechanisms used different history
lists.  The patch makes notmuch-hello search use the same history list
as `notmuch-search' function.
---
 emacs/notmuch-hello.el |   49 ++++++++++++++---------------------------------
 emacs/notmuch-lib.el   |    9 ++++++++
 emacs/notmuch.el       |   19 ++++++++++++-----
 3 files changed, 37 insertions(+), 40 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 08fcd22..cb36977 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -29,8 +29,8 @@
 (declare-function notmuch-search "notmuch" (query &optional oldest-first target-thread target-line continuation))
 (declare-function notmuch-poll "notmuch" ())
 
-(defcustom notmuch-recent-searches-max 10
-  "The number of recent searches to store and display."
+(defcustom notmuch-hello-recent-searches-max 10
+  "The number of recent searches to display."
   :type 'integer
   :group 'notmuch)
 
@@ -151,16 +151,6 @@ International Bureau of Weights and Measures."
 (defvar notmuch-hello-url "http://notmuchmail.org"
   "The `notmuch' web site.")
 
-(defvar notmuch-hello-recent-searches nil)
-
-(defun notmuch-hello-remember-search (search)
-  (setq notmuch-hello-recent-searches
-	(delete search notmuch-hello-recent-searches))
-  (push search notmuch-hello-recent-searches)
-  (if (> (length notmuch-hello-recent-searches)
-	 notmuch-recent-searches-max)
-      (setq notmuch-hello-recent-searches (butlast notmuch-hello-recent-searches))))
-
 (defun notmuch-hello-nice-number (n)
   (let (result)
     (while (> n 0)
@@ -173,16 +163,9 @@ International Bureau of Weights and Measures."
 	      (format "%s%03d" notmuch-hello-thousands-separator elem))
 	     (cdr result)))))
 
-(defun notmuch-hello-trim (search)
-  "Trim whitespace."
-  (if (string-match "^[[:space:]]*\\(.*[^[:space:]]\\)[[:space:]]*$" search)
-      (match-string 1 search)
-    search))
-
 (defun notmuch-hello-search (search)
-  (let ((search (notmuch-hello-trim search)))
-    (notmuch-hello-remember-search search)
-    (notmuch-search search notmuch-search-oldest-first nil nil #'notmuch-hello-search-continuation)))
+  (notmuch-search search notmuch-search-oldest-first nil nil
+		  #'notmuch-hello-search-continuation))
 
 (defun notmuch-hello-add-saved-search (widget)
   (interactive)
@@ -461,7 +444,7 @@ Complete list of currently available key bindings:
 
     (let ((found-target-pos nil)
 	  (final-target-pos nil)
-	  (search-bar-pos))
+	  (default-pos))
       (let* ((saved-alist
 	      ;; Filter out empty saved searches if required.
 	      (if notmuch-show-empty-saved-searches
@@ -493,7 +476,7 @@ Complete list of currently available key bindings:
 	    (indent-rigidly start (point) notmuch-hello-indent)))
 
 	(widget-insert "\nSearch: ")
-	(setq search-bar-pos (point-marker))
+	(setq default-pos (point-marker))
 	(widget-create 'editable-field
 		       ;; Leave some space at the start and end of the
 		       ;; search boxes.
@@ -507,18 +490,18 @@ Complete list of currently available key bindings:
 	(put-text-property (1- (point)) (point) 'invisible t)
 	(widget-insert "\n")
 
-	(when notmuch-hello-recent-searches
+	(when notmuch-search-history
 	  (widget-insert "\nRecent searches: ")
 	  (widget-create 'push-button
 			 :notify (lambda (&rest ignore)
-				   (setq notmuch-hello-recent-searches nil)
+				   (setq notmuch-search-history nil)
 				   (notmuch-hello-update))
 			 "clear")
 	  (widget-insert "\n\n")
-	  (let ((start (point))
-		(nth 0))
-	    (mapc (lambda (search)
-		    (let ((widget-symbol (intern (format "notmuch-hello-search-%d" nth))))
+	  (let ((start (point)))
+	    (loop for i from 1 to notmuch-hello-recent-searches-max
+		  for search in notmuch-search-history do
+		    (let ((widget-symbol (intern (format "notmuch-hello-search-%d" i))))
 		      (set widget-symbol
 			   (widget-create 'editable-field
 					  ;; Don't let the search boxes be
@@ -545,9 +528,7 @@ Complete list of currently available key bindings:
 					       (notmuch-hello-add-saved-search widget))
 				     :notmuch-saved-search-widget widget-symbol
 				     "save"))
-		    (widget-insert "\n")
-		    (setq nth (1+ nth)))
-		  notmuch-hello-recent-searches)
+		    (widget-insert "\n"))
 	    (indent-rigidly start (point) notmuch-hello-indent)))
 
 	(when alltags-alist
@@ -576,7 +557,7 @@ Complete list of currently available key bindings:
       (let ((start (point)))
 	(widget-insert "\n\n")
 	(widget-insert "Type a search query and hit RET to view matching threads.\n")
-	(when notmuch-hello-recent-searches
+	(when notmuch-search-history
 	  (widget-insert "Hit RET to re-submit a previous search. Edit it first if you like.\n")
 	  (widget-insert "Save recent searches with the `save' button.\n"))
 	(when notmuch-saved-searches
@@ -594,7 +575,7 @@ Complete list of currently available key bindings:
 	  (widget-forward 1)))
 
       (unless (widget-at)
-	(goto-char search-bar-pos))))
+	(goto-char default-pos))))
 
   (run-hooks 'notmuch-hello-refresh-hook))
 
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 0f856bf..dfbc2e0 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -35,6 +35,9 @@
 
 ;;
 
+(defvar notmuch-search-history nil
+  "Variable to store notmuch searches history.")
+
 (defcustom notmuch-saved-searches nil
   "A list of saved searches to display."
   :type '(alist :key-type string :value-type string)
@@ -114,6 +117,12 @@ the user hasn't set this variable with the old or new value."
       (setq list (cdr list)))
     (nreverse out)))
 
+(defun notmuch-trim (search)
+  "Trim whitespaces."
+  (if (string-match "^[[:space:]]*\\(.*[^[:space:]]\\)[[:space:]]*$" search)
+      (match-string 1 search)
+    search))
+
 ; This lets us avoid compiling these replacement functions when emacs
 ; is sufficiently new enough to supply them alone. We do the macro
 ; treatment rather than just wrapping our defun calls in a when form
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index ef4dcc7..450c0c1 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -916,21 +916,28 @@ PROMPT is the string to prompt with."
 	       (t (list string)))))))
       ;; this was simpler than convincing completing-read to accept spaces:
       (define-key keymap (kbd "<tab>") 'minibuffer-complete)
-      (read-from-minibuffer prompt nil keymap nil
-			    'notmuch-query-history nil nil))))
+      (let ((history-delete-duplicates t))
+	(read-from-minibuffer prompt nil keymap nil
+			      'notmuch-search-history nil nil)))))
 
 ;;;###autoload
-(defun notmuch-search (query &optional oldest-first target-thread target-line continuation)
-  "Run \"notmuch search\" with the given query string and display results.
+(defun notmuch-search (&optional query oldest-first target-thread target-line continuation)
+  "Run \"notmuch search\" with the given `query' and display results.
 
-The optional parameters are used as follows:
+If `query' is nil, it is read interactively from the minibuffer.
+Other optional parameters are used as follows:
 
   oldest-first: A Boolean controlling the sort order of returned threads
   target-thread: A thread ID (with the thread: prefix) that will be made
                  current if it appears in the search results.
   target-line: The line number to move to if the target thread does not
                appear in the search results."
-  (interactive (list (notmuch-read-query "Notmuch search: ")))
+  (interactive)
+  (if (null query)
+      (setq query (notmuch-read-query "Notmuch search: "))
+    (setq query (notmuch-trim query))
+    (let ((history-delete-duplicates t))
+      (add-to-history 'notmuch-search-history query)))
   (let ((buffer (get-buffer-create (notmuch-search-buffer-title query))))
     (switch-to-buffer buffer)
     (notmuch-search-mode)
-- 
1.7.8.3

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

* [PATCH v2 3/3] emacs: bind "s" to `notmuch-hello-search' in notmuch-hello buffer
  2012-01-18 20:22 ` [PATCH v2 0/3] emacs: notmuch-hello search cleanup Dmitry Kurochkin
  2012-01-18 20:22   ` [PATCH v2 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer Dmitry Kurochkin
  2012-01-18 20:22   ` [PATCH v2 2/3] emacs: use a single history for all searches Dmitry Kurochkin
@ 2012-01-18 20:22   ` Dmitry Kurochkin
  2012-01-19  8:12   ` [PATCH v2 0/3] emacs: notmuch-hello search cleanup David Edmondson
  2012-01-23 23:48   ` [PATCH v3 " Dmitry Kurochkin
  4 siblings, 0 replies; 28+ messages in thread
From: Dmitry Kurochkin @ 2012-01-18 20:22 UTC (permalink / raw)
  To: notmuch

`notmuch-hello-search' uses `notmuch-search' function but refreshes
notmuch-hello buffer when the search buffer is closed.
---
 emacs/notmuch-hello.el |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index cb36977..e908659 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -163,7 +163,8 @@ International Bureau of Weights and Measures."
 	      (format "%s%03d" notmuch-hello-thousands-separator elem))
 	     (cdr result)))))
 
-(defun notmuch-hello-search (search)
+(defun notmuch-hello-search (&optional search)
+  (interactive)
   (notmuch-search search notmuch-search-oldest-first nil nil
 		  #'notmuch-hello-search-continuation))
 
@@ -330,7 +331,7 @@ should be. Returns a cons cell `(tags-per-line width)'."
     (define-key map "G" 'notmuch-hello-poll-and-update)
     (define-key map (kbd "<C-tab>") 'widget-backward)
     (define-key map "m" 'notmuch-mua-new-mail)
-    (define-key map "s" 'notmuch-search)
+    (define-key map "s" 'notmuch-hello-search)
     map)
   "Keymap for \"notmuch hello\" buffers.")
 (fset 'notmuch-hello-mode-map notmuch-hello-mode-map)
-- 
1.7.8.3

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

* Re: [PATCH v2 0/3] emacs: notmuch-hello search cleanup
  2012-01-18 20:22 ` [PATCH v2 0/3] emacs: notmuch-hello search cleanup Dmitry Kurochkin
                     ` (2 preceding siblings ...)
  2012-01-18 20:22   ` [PATCH v2 3/3] emacs: bind "s" to `notmuch-hello-search' in notmuch-hello buffer Dmitry Kurochkin
@ 2012-01-19  8:12   ` David Edmondson
  2012-01-23 23:48   ` [PATCH v3 " Dmitry Kurochkin
  4 siblings, 0 replies; 28+ messages in thread
From: David Edmondson @ 2012-01-19  8:12 UTC (permalink / raw)
  To: Dmitry Kurochkin, notmuch

[-- Attachment #1: Type: text/plain, Size: 236 bytes --]

On Thu, 19 Jan 2012 00:22:53 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
> Changes in v2 since v1:
> 
> * expected results changes for tests moved from patch 2 to 1 where it belong

The patch set looks good to me.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* [PATCH v3 0/3] emacs: notmuch-hello search cleanup
  2012-01-18 20:22 ` [PATCH v2 0/3] emacs: notmuch-hello search cleanup Dmitry Kurochkin
                     ` (3 preceding siblings ...)
  2012-01-19  8:12   ` [PATCH v2 0/3] emacs: notmuch-hello search cleanup David Edmondson
@ 2012-01-23 23:48   ` Dmitry Kurochkin
  2012-01-23 23:48     ` [PATCH v3 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer Dmitry Kurochkin
                       ` (5 more replies)
  4 siblings, 6 replies; 28+ messages in thread
From: Dmitry Kurochkin @ 2012-01-23 23:48 UTC (permalink / raw)
  To: notmuch

Changes:

v3:

* rebased on current master

v2:

* expected results changes for tests moved from patch 2 to 1 where it belong

Regards,
  Dmitry

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

* [PATCH v3 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer
  2012-01-23 23:48   ` [PATCH v3 " Dmitry Kurochkin
@ 2012-01-23 23:48     ` Dmitry Kurochkin
  2012-01-23 23:48     ` [PATCH v3 2/3] emacs: use a single history for all searches Dmitry Kurochkin
                       ` (4 subsequent siblings)
  5 siblings, 0 replies; 28+ messages in thread
From: Dmitry Kurochkin @ 2012-01-23 23:48 UTC (permalink / raw)
  To: notmuch

Before the change, "s" in notmuch-hello buffer would jump to the
search box.  The patch changes the binding to `notmuch-search' which
is consistent with all other notmuch buffers.
---
 emacs/notmuch-hello.el                             |   19 ++++++-------------
 test/emacs.expected-output/notmuch-hello           |    2 +-
 .../notmuch-hello-no-saved-searches                |    2 +-
 .../emacs.expected-output/notmuch-hello-with-empty |    2 +-
 4 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 63f2e07..d88a870 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -29,9 +29,6 @@
 (declare-function notmuch-search "notmuch" (query &optional oldest-first target-thread target-line continuation))
 (declare-function notmuch-poll "notmuch" ())
 
-(defvar notmuch-hello-search-bar-marker nil
-  "The position of the search bar within the notmuch-hello buffer.")
-
 (defcustom notmuch-recent-searches-max 10
   "The number of recent searches to store and display."
   :type 'integer
@@ -324,11 +321,6 @@ should be. Returns a cons cell `(tags-per-line width)'."
       (widget-insert "\n"))
     found-target-pos))
 
-(defun notmuch-hello-goto-search ()
-  "Put point inside the `search' widget."
-  (interactive)
-  (goto-char notmuch-hello-search-bar-marker))
-
 (defimage notmuch-hello-logo ((:type png :file "notmuch-logo.png")))
 
 (defun notmuch-hello-search-continuation()
@@ -358,7 +350,7 @@ should be. Returns a cons cell `(tags-per-line width)'."
     (define-key map "G" 'notmuch-hello-poll-and-update)
     (define-key map (kbd "<C-tab>") 'widget-backward)
     (define-key map "m" 'notmuch-mua-new-mail)
-    (define-key map "s" 'notmuch-hello-goto-search)
+    (define-key map "s" 'notmuch-search)
     map)
   "Keymap for \"notmuch hello\" buffers.")
 (fset 'notmuch-hello-mode-map notmuch-hello-mode-map)
@@ -471,7 +463,8 @@ Complete list of currently available key bindings:
       (widget-insert " messages.\n"))
 
     (let ((found-target-pos nil)
-	  (final-target-pos nil))
+	  (final-target-pos nil)
+	  (search-bar-pos))
       (let* ((saved-alist
 	      ;; Filter out empty saved searches if required.
 	      (if notmuch-show-empty-saved-searches
@@ -503,7 +496,7 @@ Complete list of currently available key bindings:
 	    (indent-rigidly start (point) notmuch-hello-indent)))
 
 	(widget-insert "\nSearch: ")
-	(setq notmuch-hello-search-bar-marker (point-marker))
+	(setq search-bar-pos (point-marker))
 	(widget-create 'editable-field
 		       ;; Leave some space at the start and end of the
 		       ;; search boxes.
@@ -595,7 +588,7 @@ Complete list of currently available key bindings:
 	(when notmuch-saved-searches
 	  (widget-insert "Edit saved searches with the `edit' button.\n"))
 	(widget-insert "Hit RET or click on a saved search or tag name to view matching threads.\n")
-	(widget-insert "`=' refreshes this screen. `s' jumps to the search box. `q' to quit.\n")
+	(widget-insert "`=' refreshes this screen. `s' to search messages. `q' to quit.\n")
 	(let ((fill-column (- (window-width) notmuch-hello-indent)))
 	  (center-region start (point))))
 
@@ -607,7 +600,7 @@ Complete list of currently available key bindings:
 	  (widget-forward 1)))
 
       (unless (widget-at)
-	(notmuch-hello-goto-search))))
+	(goto-char search-bar-pos))))
 
   (run-hooks 'notmuch-hello-refresh-hook))
 
diff --git a/test/emacs.expected-output/notmuch-hello b/test/emacs.expected-output/notmuch-hello
index 196112e..c43ab8c 100644
--- a/test/emacs.expected-output/notmuch-hello
+++ b/test/emacs.expected-output/notmuch-hello
@@ -11,4 +11,4 @@ Search:                                                                     .
 	 Type a search query and hit RET to view matching threads.
 		Edit saved searches with the `edit' button.
   Hit RET or click on a saved search or tag name to view matching threads.
-    `=' refreshes this screen. `s' jumps to the search box. `q' to quit.
+      `=' refreshes this screen. `s' to search messages. `q' to quit.
diff --git a/test/emacs.expected-output/notmuch-hello-no-saved-searches b/test/emacs.expected-output/notmuch-hello-no-saved-searches
index f4cfe49..080a56b 100644
--- a/test/emacs.expected-output/notmuch-hello-no-saved-searches
+++ b/test/emacs.expected-output/notmuch-hello-no-saved-searches
@@ -7,4 +7,4 @@ Search:                                                                     .
 	 Type a search query and hit RET to view matching threads.
 		Edit saved searches with the `edit' button.
   Hit RET or click on a saved search or tag name to view matching threads.
-    `=' refreshes this screen. `s' jumps to the search box. `q' to quit.
+      `=' refreshes this screen. `s' to search messages. `q' to quit.
diff --git a/test/emacs.expected-output/notmuch-hello-with-empty b/test/emacs.expected-output/notmuch-hello-with-empty
index a860a72..a9e312c 100644
--- a/test/emacs.expected-output/notmuch-hello-with-empty
+++ b/test/emacs.expected-output/notmuch-hello-with-empty
@@ -11,4 +11,4 @@ Search:                                                                     .
 	 Type a search query and hit RET to view matching threads.
 		Edit saved searches with the `edit' button.
   Hit RET or click on a saved search or tag name to view matching threads.
-    `=' refreshes this screen. `s' jumps to the search box. `q' to quit.
+      `=' refreshes this screen. `s' to search messages. `q' to quit.
-- 
1.7.8.3

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

* [PATCH v3 2/3] emacs: use a single history for all searches
  2012-01-23 23:48   ` [PATCH v3 " Dmitry Kurochkin
  2012-01-23 23:48     ` [PATCH v3 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer Dmitry Kurochkin
@ 2012-01-23 23:48     ` Dmitry Kurochkin
  2012-01-23 23:48     ` [PATCH v3 3/3] emacs: bind "s" to `notmuch-hello-search' in notmuch-hello buffer Dmitry Kurochkin
                       ` (3 subsequent siblings)
  5 siblings, 0 replies; 28+ messages in thread
From: Dmitry Kurochkin @ 2012-01-23 23:48 UTC (permalink / raw)
  To: notmuch

There are two ways to do search in Emacs UI: search widget in
notmuch-hello buffer and `notmuch-search' function bound to "s".
Before the change, these search mechanisms used different history
lists.  The patch makes notmuch-hello search use the same history list
as `notmuch-search' function.
---
 emacs/notmuch-hello.el |   49 ++++++++++++++---------------------------------
 emacs/notmuch-lib.el   |    9 ++++++++
 emacs/notmuch.el       |   19 ++++++++++++-----
 3 files changed, 37 insertions(+), 40 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index d88a870..004287a 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -29,8 +29,8 @@
 (declare-function notmuch-search "notmuch" (query &optional oldest-first target-thread target-line continuation))
 (declare-function notmuch-poll "notmuch" ())
 
-(defcustom notmuch-recent-searches-max 10
-  "The number of recent searches to store and display."
+(defcustom notmuch-hello-recent-searches-max 10
+  "The number of recent searches to display."
   :type 'integer
   :group 'notmuch-hello)
 
@@ -154,16 +154,6 @@ International Bureau of Weights and Measures."
 (defvar notmuch-hello-url "http://notmuchmail.org"
   "The `notmuch' web site.")
 
-(defvar notmuch-hello-recent-searches nil)
-
-(defun notmuch-hello-remember-search (search)
-  (setq notmuch-hello-recent-searches
-	(delete search notmuch-hello-recent-searches))
-  (push search notmuch-hello-recent-searches)
-  (if (> (length notmuch-hello-recent-searches)
-	 notmuch-recent-searches-max)
-      (setq notmuch-hello-recent-searches (butlast notmuch-hello-recent-searches))))
-
 (defun notmuch-hello-nice-number (n)
   (let (result)
     (while (> n 0)
@@ -176,16 +166,9 @@ International Bureau of Weights and Measures."
 	      (format "%s%03d" notmuch-hello-thousands-separator elem))
 	     (cdr result)))))
 
-(defun notmuch-hello-trim (search)
-  "Trim whitespace."
-  (if (string-match "^[[:space:]]*\\(.*[^[:space:]]\\)[[:space:]]*$" search)
-      (match-string 1 search)
-    search))
-
 (defun notmuch-hello-search (search)
-  (let ((search (notmuch-hello-trim search)))
-    (notmuch-hello-remember-search search)
-    (notmuch-search search notmuch-search-oldest-first nil nil #'notmuch-hello-search-continuation)))
+  (notmuch-search search notmuch-search-oldest-first nil nil
+		  #'notmuch-hello-search-continuation))
 
 (defun notmuch-hello-add-saved-search (widget)
   (interactive)
@@ -464,7 +447,7 @@ Complete list of currently available key bindings:
 
     (let ((found-target-pos nil)
 	  (final-target-pos nil)
-	  (search-bar-pos))
+	  (default-pos))
       (let* ((saved-alist
 	      ;; Filter out empty saved searches if required.
 	      (if notmuch-show-empty-saved-searches
@@ -496,7 +479,7 @@ Complete list of currently available key bindings:
 	    (indent-rigidly start (point) notmuch-hello-indent)))
 
 	(widget-insert "\nSearch: ")
-	(setq search-bar-pos (point-marker))
+	(setq default-pos (point-marker))
 	(widget-create 'editable-field
 		       ;; Leave some space at the start and end of the
 		       ;; search boxes.
@@ -513,18 +496,18 @@ Complete list of currently available key bindings:
 	(put-text-property (1- (point)) (point) 'invisible t)
 	(widget-insert "\n")
 
-	(when notmuch-hello-recent-searches
+	(when notmuch-search-history
 	  (widget-insert "\nRecent searches: ")
 	  (widget-create 'push-button
 			 :notify (lambda (&rest ignore)
-				   (setq notmuch-hello-recent-searches nil)
+				   (setq notmuch-search-history nil)
 				   (notmuch-hello-update))
 			 "clear")
 	  (widget-insert "\n\n")
-	  (let ((start (point))
-		(nth 0))
-	    (mapc (lambda (search)
-		    (let ((widget-symbol (intern (format "notmuch-hello-search-%d" nth))))
+	  (let ((start (point)))
+	    (loop for i from 1 to notmuch-hello-recent-searches-max
+		  for search in notmuch-search-history do
+		    (let ((widget-symbol (intern (format "notmuch-hello-search-%d" i))))
 		      (set widget-symbol
 			   (widget-create 'editable-field
 					  ;; Don't let the search boxes be
@@ -551,9 +534,7 @@ Complete list of currently available key bindings:
 					       (notmuch-hello-add-saved-search widget))
 				     :notmuch-saved-search-widget widget-symbol
 				     "save"))
-		    (widget-insert "\n")
-		    (setq nth (1+ nth)))
-		  notmuch-hello-recent-searches)
+		    (widget-insert "\n"))
 	    (indent-rigidly start (point) notmuch-hello-indent)))
 
 	(when alltags-alist
@@ -582,7 +563,7 @@ Complete list of currently available key bindings:
       (let ((start (point)))
 	(widget-insert "\n\n")
 	(widget-insert "Type a search query and hit RET to view matching threads.\n")
-	(when notmuch-hello-recent-searches
+	(when notmuch-search-history
 	  (widget-insert "Hit RET to re-submit a previous search. Edit it first if you like.\n")
 	  (widget-insert "Save recent searches with the `save' button.\n"))
 	(when notmuch-saved-searches
@@ -600,7 +581,7 @@ Complete list of currently available key bindings:
 	  (widget-forward 1)))
 
       (unless (widget-at)
-	(goto-char search-bar-pos))))
+	(goto-char default-pos))))
 
   (run-hooks 'notmuch-hello-refresh-hook))
 
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 241fe8c..36b895c 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -69,6 +69,9 @@
 
 ;;
 
+(defvar notmuch-search-history nil
+  "Variable to store notmuch searches history.")
+
 (defcustom notmuch-saved-searches nil
   "A list of saved searches to display."
   :type '(alist :key-type string :value-type string)
@@ -148,6 +151,12 @@ the user hasn't set this variable with the old or new value."
       (setq list (cdr list)))
     (nreverse out)))
 
+(defun notmuch-trim (search)
+  "Trim whitespaces."
+  (if (string-match "^[[:space:]]*\\(.*[^[:space:]]\\)[[:space:]]*$" search)
+      (match-string 1 search)
+    search))
+
 ;; This lets us avoid compiling these replacement functions when emacs
 ;; is sufficiently new enough to supply them alone. We do the macro
 ;; treatment rather than just wrapping our defun calls in a when form
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 6b2c252..e9e5dc1 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -925,21 +925,28 @@ PROMPT is the string to prompt with."
 	       (t (list string)))))))
       ;; this was simpler than convincing completing-read to accept spaces:
       (define-key keymap (kbd "<tab>") 'minibuffer-complete)
-      (read-from-minibuffer prompt nil keymap nil
-			    'notmuch-query-history nil nil))))
+      (let ((history-delete-duplicates t))
+	(read-from-minibuffer prompt nil keymap nil
+			      'notmuch-search-history nil nil)))))
 
 ;;;###autoload
-(defun notmuch-search (query &optional oldest-first target-thread target-line continuation)
-  "Run \"notmuch search\" with the given query string and display results.
+(defun notmuch-search (&optional query oldest-first target-thread target-line continuation)
+  "Run \"notmuch search\" with the given `query' and display results.
 
-The optional parameters are used as follows:
+If `query' is nil, it is read interactively from the minibuffer.
+Other optional parameters are used as follows:
 
   oldest-first: A Boolean controlling the sort order of returned threads
   target-thread: A thread ID (with the thread: prefix) that will be made
                  current if it appears in the search results.
   target-line: The line number to move to if the target thread does not
                appear in the search results."
-  (interactive (list (notmuch-read-query "Notmuch search: ")))
+  (interactive)
+  (if (null query)
+      (setq query (notmuch-read-query "Notmuch search: "))
+    (setq query (notmuch-trim query))
+    (let ((history-delete-duplicates t))
+      (add-to-history 'notmuch-search-history query)))
   (let ((buffer (get-buffer-create (notmuch-search-buffer-title query))))
     (switch-to-buffer buffer)
     (notmuch-search-mode)
-- 
1.7.8.3

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

* [PATCH v3 3/3] emacs: bind "s" to `notmuch-hello-search' in notmuch-hello buffer
  2012-01-23 23:48   ` [PATCH v3 " Dmitry Kurochkin
  2012-01-23 23:48     ` [PATCH v3 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer Dmitry Kurochkin
  2012-01-23 23:48     ` [PATCH v3 2/3] emacs: use a single history for all searches Dmitry Kurochkin
@ 2012-01-23 23:48     ` Dmitry Kurochkin
  2012-01-24 15:17     ` [PATCH v3 0/3] emacs: notmuch-hello search cleanup David Edmondson
                       ` (2 subsequent siblings)
  5 siblings, 0 replies; 28+ messages in thread
From: Dmitry Kurochkin @ 2012-01-23 23:48 UTC (permalink / raw)
  To: notmuch

`notmuch-hello-search' uses `notmuch-search' function but refreshes
notmuch-hello buffer when the search buffer is closed.
---
 emacs/notmuch-hello.el |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 004287a..64011d4 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -166,7 +166,8 @@ International Bureau of Weights and Measures."
 	      (format "%s%03d" notmuch-hello-thousands-separator elem))
 	     (cdr result)))))
 
-(defun notmuch-hello-search (search)
+(defun notmuch-hello-search (&optional search)
+  (interactive)
   (notmuch-search search notmuch-search-oldest-first nil nil
 		  #'notmuch-hello-search-continuation))
 
@@ -333,7 +334,7 @@ should be. Returns a cons cell `(tags-per-line width)'."
     (define-key map "G" 'notmuch-hello-poll-and-update)
     (define-key map (kbd "<C-tab>") 'widget-backward)
     (define-key map "m" 'notmuch-mua-new-mail)
-    (define-key map "s" 'notmuch-search)
+    (define-key map "s" 'notmuch-hello-search)
     map)
   "Keymap for \"notmuch hello\" buffers.")
 (fset 'notmuch-hello-mode-map notmuch-hello-mode-map)
-- 
1.7.8.3

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

* Re: [PATCH v3 0/3] emacs: notmuch-hello search cleanup
  2012-01-23 23:48   ` [PATCH v3 " Dmitry Kurochkin
                       ` (2 preceding siblings ...)
  2012-01-23 23:48     ` [PATCH v3 3/3] emacs: bind "s" to `notmuch-hello-search' in notmuch-hello buffer Dmitry Kurochkin
@ 2012-01-24 15:17     ` David Edmondson
  2012-01-24 15:43     ` Austin Clements
  2012-01-25  1:10     ` [PATCH v4 " Dmitry Kurochkin
  5 siblings, 0 replies; 28+ messages in thread
From: David Edmondson @ 2012-01-24 15:17 UTC (permalink / raw)
  To: Dmitry Kurochkin, notmuch

[-- Attachment #1: Type: text/plain, Size: 305 bytes --]

On Tue, 24 Jan 2012 03:48:54 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
> Changes:
> 
> v3:
> 
> * rebased on current master
> 
> v2:
> 
> * expected results changes for tests moved from patch 2 to 1 where it belong

This set look fine to me. Poor Daniel has to re-merge...


[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [PATCH v3 0/3] emacs: notmuch-hello search cleanup
  2012-01-23 23:48   ` [PATCH v3 " Dmitry Kurochkin
                       ` (3 preceding siblings ...)
  2012-01-24 15:17     ` [PATCH v3 0/3] emacs: notmuch-hello search cleanup David Edmondson
@ 2012-01-24 15:43     ` Austin Clements
  2012-01-25  1:10     ` [PATCH v4 " Dmitry Kurochkin
  5 siblings, 0 replies; 28+ messages in thread
From: Austin Clements @ 2012-01-24 15:43 UTC (permalink / raw)
  To: Dmitry Kurochkin; +Cc: notmuch

Quoth Dmitry Kurochkin on Jan 24 at  3:48 am:
> Changes:
> 
> v3:
> 
> * rebased on current master

LGTM.

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

* [PATCH v4 0/3] emacs: notmuch-hello search cleanup
  2012-01-23 23:48   ` [PATCH v3 " Dmitry Kurochkin
                       ` (4 preceding siblings ...)
  2012-01-24 15:43     ` Austin Clements
@ 2012-01-25  1:10     ` Dmitry Kurochkin
  2012-01-25  1:10       ` [PATCH v4 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer Dmitry Kurochkin
                         ` (2 more replies)
  5 siblings, 3 replies; 28+ messages in thread
From: Dmitry Kurochkin @ 2012-01-25  1:10 UTC (permalink / raw)
  To: notmuch

Changes:

v4:

* do not add queries from saved search and tag buttons to the history

v3:

* rebased on current master

v2:

* expected results changes for tests moved from patch 2 to 1 where it belong

Regards,
  Dmitry

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

* [PATCH v4 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer
  2012-01-25  1:10     ` [PATCH v4 " Dmitry Kurochkin
@ 2012-01-25  1:10       ` Dmitry Kurochkin
  2012-01-25 12:46         ` David Bremner
  2012-01-25  1:10       ` [PATCH v4 2/3] emacs: use a single history for all searches Dmitry Kurochkin
  2012-01-25  1:10       ` [PATCH v4 3/3] emacs: bind "s" to `notmuch-hello-search' in notmuch-hello buffer Dmitry Kurochkin
  2 siblings, 1 reply; 28+ messages in thread
From: Dmitry Kurochkin @ 2012-01-25  1:10 UTC (permalink / raw)
  To: notmuch

Before the change, "s" in notmuch-hello buffer would jump to the
search box.  The patch changes the binding to `notmuch-search' which
is consistent with all other notmuch buffers.
---
 emacs/notmuch-hello.el                             |   19 ++++++-------------
 test/emacs.expected-output/notmuch-hello           |    2 +-
 .../notmuch-hello-no-saved-searches                |    2 +-
 .../emacs.expected-output/notmuch-hello-with-empty |    2 +-
 4 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 63f2e07..d88a870 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -29,9 +29,6 @@
 (declare-function notmuch-search "notmuch" (query &optional oldest-first target-thread target-line continuation))
 (declare-function notmuch-poll "notmuch" ())
 
-(defvar notmuch-hello-search-bar-marker nil
-  "The position of the search bar within the notmuch-hello buffer.")
-
 (defcustom notmuch-recent-searches-max 10
   "The number of recent searches to store and display."
   :type 'integer
@@ -324,11 +321,6 @@ should be. Returns a cons cell `(tags-per-line width)'."
       (widget-insert "\n"))
     found-target-pos))
 
-(defun notmuch-hello-goto-search ()
-  "Put point inside the `search' widget."
-  (interactive)
-  (goto-char notmuch-hello-search-bar-marker))
-
 (defimage notmuch-hello-logo ((:type png :file "notmuch-logo.png")))
 
 (defun notmuch-hello-search-continuation()
@@ -358,7 +350,7 @@ should be. Returns a cons cell `(tags-per-line width)'."
     (define-key map "G" 'notmuch-hello-poll-and-update)
     (define-key map (kbd "<C-tab>") 'widget-backward)
     (define-key map "m" 'notmuch-mua-new-mail)
-    (define-key map "s" 'notmuch-hello-goto-search)
+    (define-key map "s" 'notmuch-search)
     map)
   "Keymap for \"notmuch hello\" buffers.")
 (fset 'notmuch-hello-mode-map notmuch-hello-mode-map)
@@ -471,7 +463,8 @@ Complete list of currently available key bindings:
       (widget-insert " messages.\n"))
 
     (let ((found-target-pos nil)
-	  (final-target-pos nil))
+	  (final-target-pos nil)
+	  (search-bar-pos))
       (let* ((saved-alist
 	      ;; Filter out empty saved searches if required.
 	      (if notmuch-show-empty-saved-searches
@@ -503,7 +496,7 @@ Complete list of currently available key bindings:
 	    (indent-rigidly start (point) notmuch-hello-indent)))
 
 	(widget-insert "\nSearch: ")
-	(setq notmuch-hello-search-bar-marker (point-marker))
+	(setq search-bar-pos (point-marker))
 	(widget-create 'editable-field
 		       ;; Leave some space at the start and end of the
 		       ;; search boxes.
@@ -595,7 +588,7 @@ Complete list of currently available key bindings:
 	(when notmuch-saved-searches
 	  (widget-insert "Edit saved searches with the `edit' button.\n"))
 	(widget-insert "Hit RET or click on a saved search or tag name to view matching threads.\n")
-	(widget-insert "`=' refreshes this screen. `s' jumps to the search box. `q' to quit.\n")
+	(widget-insert "`=' refreshes this screen. `s' to search messages. `q' to quit.\n")
 	(let ((fill-column (- (window-width) notmuch-hello-indent)))
 	  (center-region start (point))))
 
@@ -607,7 +600,7 @@ Complete list of currently available key bindings:
 	  (widget-forward 1)))
 
       (unless (widget-at)
-	(notmuch-hello-goto-search))))
+	(goto-char search-bar-pos))))
 
   (run-hooks 'notmuch-hello-refresh-hook))
 
diff --git a/test/emacs.expected-output/notmuch-hello b/test/emacs.expected-output/notmuch-hello
index 196112e..c43ab8c 100644
--- a/test/emacs.expected-output/notmuch-hello
+++ b/test/emacs.expected-output/notmuch-hello
@@ -11,4 +11,4 @@ Search:                                                                     .
 	 Type a search query and hit RET to view matching threads.
 		Edit saved searches with the `edit' button.
   Hit RET or click on a saved search or tag name to view matching threads.
-    `=' refreshes this screen. `s' jumps to the search box. `q' to quit.
+      `=' refreshes this screen. `s' to search messages. `q' to quit.
diff --git a/test/emacs.expected-output/notmuch-hello-no-saved-searches b/test/emacs.expected-output/notmuch-hello-no-saved-searches
index f4cfe49..080a56b 100644
--- a/test/emacs.expected-output/notmuch-hello-no-saved-searches
+++ b/test/emacs.expected-output/notmuch-hello-no-saved-searches
@@ -7,4 +7,4 @@ Search:                                                                     .
 	 Type a search query and hit RET to view matching threads.
 		Edit saved searches with the `edit' button.
   Hit RET or click on a saved search or tag name to view matching threads.
-    `=' refreshes this screen. `s' jumps to the search box. `q' to quit.
+      `=' refreshes this screen. `s' to search messages. `q' to quit.
diff --git a/test/emacs.expected-output/notmuch-hello-with-empty b/test/emacs.expected-output/notmuch-hello-with-empty
index a860a72..a9e312c 100644
--- a/test/emacs.expected-output/notmuch-hello-with-empty
+++ b/test/emacs.expected-output/notmuch-hello-with-empty
@@ -11,4 +11,4 @@ Search:                                                                     .
 	 Type a search query and hit RET to view matching threads.
 		Edit saved searches with the `edit' button.
   Hit RET or click on a saved search or tag name to view matching threads.
-    `=' refreshes this screen. `s' jumps to the search box. `q' to quit.
+      `=' refreshes this screen. `s' to search messages. `q' to quit.
-- 
1.7.8.3

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

* [PATCH v4 2/3] emacs: use a single history for all searches
  2012-01-25  1:10     ` [PATCH v4 " Dmitry Kurochkin
  2012-01-25  1:10       ` [PATCH v4 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer Dmitry Kurochkin
@ 2012-01-25  1:10       ` Dmitry Kurochkin
  2012-01-25  1:10       ` [PATCH v4 3/3] emacs: bind "s" to `notmuch-hello-search' in notmuch-hello buffer Dmitry Kurochkin
  2 siblings, 0 replies; 28+ messages in thread
From: Dmitry Kurochkin @ 2012-01-25  1:10 UTC (permalink / raw)
  To: notmuch

There are two ways to do search in Emacs UI: search widget in
notmuch-hello buffer and `notmuch-search' function bound to "s".
Before the change, these search mechanisms used different history
lists.  The patch makes notmuch-hello search use the same history list
as `notmuch-search' function.
---
 emacs/notmuch-hello.el |   47 +++++++++++++++++++----------------------------
 emacs/notmuch-lib.el   |    3 +++
 emacs/notmuch.el       |   16 ++++++++++------
 3 files changed, 32 insertions(+), 34 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index d88a870..6970bc3 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -29,8 +29,8 @@
 (declare-function notmuch-search "notmuch" (query &optional oldest-first target-thread target-line continuation))
 (declare-function notmuch-poll "notmuch" ())
 
-(defcustom notmuch-recent-searches-max 10
-  "The number of recent searches to store and display."
+(defcustom notmuch-hello-recent-searches-max 10
+  "The number of recent searches to display."
   :type 'integer
   :group 'notmuch-hello)
 
@@ -154,16 +154,6 @@ International Bureau of Weights and Measures."
 (defvar notmuch-hello-url "http://notmuchmail.org"
   "The `notmuch' web site.")
 
-(defvar notmuch-hello-recent-searches nil)
-
-(defun notmuch-hello-remember-search (search)
-  (setq notmuch-hello-recent-searches
-	(delete search notmuch-hello-recent-searches))
-  (push search notmuch-hello-recent-searches)
-  (if (> (length notmuch-hello-recent-searches)
-	 notmuch-recent-searches-max)
-      (setq notmuch-hello-recent-searches (butlast notmuch-hello-recent-searches))))
-
 (defun notmuch-hello-nice-number (n)
   (let (result)
     (while (> n 0)
@@ -183,9 +173,12 @@ International Bureau of Weights and Measures."
     search))
 
 (defun notmuch-hello-search (search)
-  (let ((search (notmuch-hello-trim search)))
-    (notmuch-hello-remember-search search)
-    (notmuch-search search notmuch-search-oldest-first nil nil #'notmuch-hello-search-continuation)))
+  (unless (null search)
+    (setq search (notmuch-hello-trim search))
+    (let ((history-delete-duplicates t))
+      (add-to-history 'notmuch-search-history search)))
+  (notmuch-search search notmuch-search-oldest-first nil nil
+		  #'notmuch-hello-search-continuation))
 
 (defun notmuch-hello-add-saved-search (widget)
   (interactive)
@@ -464,7 +457,7 @@ Complete list of currently available key bindings:
 
     (let ((found-target-pos nil)
 	  (final-target-pos nil)
-	  (search-bar-pos))
+	  (default-pos))
       (let* ((saved-alist
 	      ;; Filter out empty saved searches if required.
 	      (if notmuch-show-empty-saved-searches
@@ -496,7 +489,7 @@ Complete list of currently available key bindings:
 	    (indent-rigidly start (point) notmuch-hello-indent)))
 
 	(widget-insert "\nSearch: ")
-	(setq search-bar-pos (point-marker))
+	(setq default-pos (point-marker))
 	(widget-create 'editable-field
 		       ;; Leave some space at the start and end of the
 		       ;; search boxes.
@@ -513,18 +506,18 @@ Complete list of currently available key bindings:
 	(put-text-property (1- (point)) (point) 'invisible t)
 	(widget-insert "\n")
 
-	(when notmuch-hello-recent-searches
+	(when notmuch-search-history
 	  (widget-insert "\nRecent searches: ")
 	  (widget-create 'push-button
 			 :notify (lambda (&rest ignore)
-				   (setq notmuch-hello-recent-searches nil)
+				   (setq notmuch-search-history nil)
 				   (notmuch-hello-update))
 			 "clear")
 	  (widget-insert "\n\n")
-	  (let ((start (point))
-		(nth 0))
-	    (mapc (lambda (search)
-		    (let ((widget-symbol (intern (format "notmuch-hello-search-%d" nth))))
+	  (let ((start (point)))
+	    (loop for i from 1 to notmuch-hello-recent-searches-max
+		  for search in notmuch-search-history do
+		    (let ((widget-symbol (intern (format "notmuch-hello-search-%d" i))))
 		      (set widget-symbol
 			   (widget-create 'editable-field
 					  ;; Don't let the search boxes be
@@ -551,9 +544,7 @@ Complete list of currently available key bindings:
 					       (notmuch-hello-add-saved-search widget))
 				     :notmuch-saved-search-widget widget-symbol
 				     "save"))
-		    (widget-insert "\n")
-		    (setq nth (1+ nth)))
-		  notmuch-hello-recent-searches)
+		    (widget-insert "\n"))
 	    (indent-rigidly start (point) notmuch-hello-indent)))
 
 	(when alltags-alist
@@ -582,7 +573,7 @@ Complete list of currently available key bindings:
       (let ((start (point)))
 	(widget-insert "\n\n")
 	(widget-insert "Type a search query and hit RET to view matching threads.\n")
-	(when notmuch-hello-recent-searches
+	(when notmuch-search-history
 	  (widget-insert "Hit RET to re-submit a previous search. Edit it first if you like.\n")
 	  (widget-insert "Save recent searches with the `save' button.\n"))
 	(when notmuch-saved-searches
@@ -600,7 +591,7 @@ Complete list of currently available key bindings:
 	  (widget-forward 1)))
 
       (unless (widget-at)
-	(goto-char search-bar-pos))))
+	(goto-char default-pos))))
 
   (run-hooks 'notmuch-hello-refresh-hook))
 
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 241fe8c..c906ca7 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -69,6 +69,9 @@
 
 ;;
 
+(defvar notmuch-search-history nil
+  "Variable to store notmuch searches history.")
+
 (defcustom notmuch-saved-searches nil
   "A list of saved searches to display."
   :type '(alist :key-type string :value-type string)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 6b2c252..b8b875b 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -925,21 +925,25 @@ PROMPT is the string to prompt with."
 	       (t (list string)))))))
       ;; this was simpler than convincing completing-read to accept spaces:
       (define-key keymap (kbd "<tab>") 'minibuffer-complete)
-      (read-from-minibuffer prompt nil keymap nil
-			    'notmuch-query-history nil nil))))
+      (let ((history-delete-duplicates t))
+	(read-from-minibuffer prompt nil keymap nil
+			      'notmuch-search-history nil nil)))))
 
 ;;;###autoload
-(defun notmuch-search (query &optional oldest-first target-thread target-line continuation)
-  "Run \"notmuch search\" with the given query string and display results.
+(defun notmuch-search (&optional query oldest-first target-thread target-line continuation)
+  "Run \"notmuch search\" with the given `query' and display results.
 
-The optional parameters are used as follows:
+If `query' is nil, it is read interactively from the minibuffer.
+Other optional parameters are used as follows:
 
   oldest-first: A Boolean controlling the sort order of returned threads
   target-thread: A thread ID (with the thread: prefix) that will be made
                  current if it appears in the search results.
   target-line: The line number to move to if the target thread does not
                appear in the search results."
-  (interactive (list (notmuch-read-query "Notmuch search: ")))
+  (interactive)
+  (if (null query)
+      (setq query (notmuch-read-query "Notmuch search: ")))
   (let ((buffer (get-buffer-create (notmuch-search-buffer-title query))))
     (switch-to-buffer buffer)
     (notmuch-search-mode)
-- 
1.7.8.3

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

* [PATCH v4 3/3] emacs: bind "s" to `notmuch-hello-search' in notmuch-hello buffer
  2012-01-25  1:10     ` [PATCH v4 " Dmitry Kurochkin
  2012-01-25  1:10       ` [PATCH v4 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer Dmitry Kurochkin
  2012-01-25  1:10       ` [PATCH v4 2/3] emacs: use a single history for all searches Dmitry Kurochkin
@ 2012-01-25  1:10       ` Dmitry Kurochkin
  2 siblings, 0 replies; 28+ messages in thread
From: Dmitry Kurochkin @ 2012-01-25  1:10 UTC (permalink / raw)
  To: notmuch

`notmuch-hello-search' uses `notmuch-search' function but refreshes
notmuch-hello buffer when the search buffer is closed.
---
 emacs/notmuch-hello.el |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 6970bc3..ab65e36 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -172,7 +172,8 @@ International Bureau of Weights and Measures."
       (match-string 1 search)
     search))
 
-(defun notmuch-hello-search (search)
+(defun notmuch-hello-search (&optional search)
+  (interactive)
   (unless (null search)
     (setq search (notmuch-hello-trim search))
     (let ((history-delete-duplicates t))
@@ -343,7 +344,7 @@ should be. Returns a cons cell `(tags-per-line width)'."
     (define-key map "G" 'notmuch-hello-poll-and-update)
     (define-key map (kbd "<C-tab>") 'widget-backward)
     (define-key map "m" 'notmuch-mua-new-mail)
-    (define-key map "s" 'notmuch-search)
+    (define-key map "s" 'notmuch-hello-search)
     map)
   "Keymap for \"notmuch hello\" buffers.")
 (fset 'notmuch-hello-mode-map notmuch-hello-mode-map)
-- 
1.7.8.3

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

* Re: [PATCH v4 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer
  2012-01-25  1:10       ` [PATCH v4 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer Dmitry Kurochkin
@ 2012-01-25 12:46         ` David Bremner
  0 siblings, 0 replies; 28+ messages in thread
From: David Bremner @ 2012-01-25 12:46 UTC (permalink / raw)
  To: Dmitry Kurochkin, notmuch

On Wed, 25 Jan 2012 05:10:52 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
> Before the change, "s" in notmuch-hello buffer would jump to the
> search box.  The patch changes the binding to `notmuch-search' which
> is consistent with all other notmuch buffers.

Pushed all three.

d

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

* Re: [PATCH 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer
  2012-01-17 21:22 ` [PATCH 1/3] emacs: bind "s" to `notmuch-search' " Jani Nikula
  2012-01-17 21:29   ` Dmitry Kurochkin
@ 2012-01-26 13:48   ` Pieter Praet
  2012-01-26 14:13     ` Jani Nikula
  1 sibling, 1 reply; 28+ messages in thread
From: Pieter Praet @ 2012-01-26 13:48 UTC (permalink / raw)
  To: Jani Nikula, Dmitry Kurochkin, notmuch

On Tue, 17 Jan 2012 23:22:30 +0200, Jani Nikula <jani@nikula.org> wrote:
> [...]
> 
> After this, what would the user have to do to bind some key to put the
> point in the search box? If someone wants to restore old behaviour for
> themselves.
> 

This should work:

  #+begin_src emacs-lisp
    (add-hook 'notmuch-hello-mode-hook
              (lambda ()
                 (local-set-key (kbd "s")
                  (lambda() (interactive)
                   (re-search-forward "Search: ")))))
  #+end_src


Peace

-- 
Pieter

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

* Re: [PATCH 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer
  2012-01-26 13:48   ` Pieter Praet
@ 2012-01-26 14:13     ` Jani Nikula
  0 siblings, 0 replies; 28+ messages in thread
From: Jani Nikula @ 2012-01-26 14:13 UTC (permalink / raw)
  To: Pieter Praet, Dmitry Kurochkin, notmuch

On Thu, 26 Jan 2012 14:48:44 +0100, Pieter Praet <pieter@praet.org> wrote:
> On Tue, 17 Jan 2012 23:22:30 +0200, Jani Nikula <jani@nikula.org> wrote:
> > [...]
> > 
> > After this, what would the user have to do to bind some key to put the
> > point in the search box? If someone wants to restore old behaviour for
> > themselves.
> > 
> 
> This should work:
> 
>   #+begin_src emacs-lisp
>     (add-hook 'notmuch-hello-mode-hook
>               (lambda ()
>                  (local-set-key (kbd "s")
>                   (lambda() (interactive)
>                    (re-search-forward "Search: ")))))
>   #+end_src

Thanks for the basic idea, iterated into:

(define-key notmuch-hello-mode-map "S"
  (lambda() (interactive)
    (goto-char (point-min))
    (re-search-forward "Search: ")))


BR,
Jani.

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

end of thread, other threads:[~2012-01-26 14:13 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-17 19:34 [PATCH 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer Dmitry Kurochkin
2012-01-17 19:34 ` [PATCH 2/3] emacs: use a single history for all searches Dmitry Kurochkin
2012-01-18  8:25   ` David Edmondson
2012-01-18 17:57     ` Dmitry Kurochkin
2012-01-18 18:18       ` David Edmondson
2012-01-17 19:34 ` [PATCH 3/3] emacs: bind "s" to `notmuch-hello-search' in notmuch-hello buffer Dmitry Kurochkin
2012-01-18  8:26   ` David Edmondson
2012-01-17 21:22 ` [PATCH 1/3] emacs: bind "s" to `notmuch-search' " Jani Nikula
2012-01-17 21:29   ` Dmitry Kurochkin
2012-01-26 13:48   ` Pieter Praet
2012-01-26 14:13     ` Jani Nikula
2012-01-18  8:20 ` David Edmondson
2012-01-18 20:22 ` [PATCH v2 0/3] emacs: notmuch-hello search cleanup Dmitry Kurochkin
2012-01-18 20:22   ` [PATCH v2 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer Dmitry Kurochkin
2012-01-18 20:22   ` [PATCH v2 2/3] emacs: use a single history for all searches Dmitry Kurochkin
2012-01-18 20:22   ` [PATCH v2 3/3] emacs: bind "s" to `notmuch-hello-search' in notmuch-hello buffer Dmitry Kurochkin
2012-01-19  8:12   ` [PATCH v2 0/3] emacs: notmuch-hello search cleanup David Edmondson
2012-01-23 23:48   ` [PATCH v3 " Dmitry Kurochkin
2012-01-23 23:48     ` [PATCH v3 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer Dmitry Kurochkin
2012-01-23 23:48     ` [PATCH v3 2/3] emacs: use a single history for all searches Dmitry Kurochkin
2012-01-23 23:48     ` [PATCH v3 3/3] emacs: bind "s" to `notmuch-hello-search' in notmuch-hello buffer Dmitry Kurochkin
2012-01-24 15:17     ` [PATCH v3 0/3] emacs: notmuch-hello search cleanup David Edmondson
2012-01-24 15:43     ` Austin Clements
2012-01-25  1:10     ` [PATCH v4 " Dmitry Kurochkin
2012-01-25  1:10       ` [PATCH v4 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer Dmitry Kurochkin
2012-01-25 12:46         ` David Bremner
2012-01-25  1:10       ` [PATCH v4 2/3] emacs: use a single history for all searches Dmitry Kurochkin
2012-01-25  1:10       ` [PATCH v4 3/3] emacs: bind "s" to `notmuch-hello-search' in notmuch-hello buffer Dmitry Kurochkin

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