[PATCH] Added C-up and C-down to cycle through previous searches

2011-06-07 Thread Dima Kogan
> Notmuch uses a mix of 8 char width tabs and spaces.  First go tabs,
> then, if you need indenting with more precision, spaces.  Look at the
> lines your patch removes for an example.
> 
> Also, .dir-locals.el sets some variables to configure Emacs for
> Notmuch coding style but only for c-mode.  You may set it by hand for
> lisp.

Hi again. Here's the new patch, with M-n/M-p and tabbed indentation

dima
-- next part --
A non-text attachment was scrubbed...
Name: 0001-Added-M-n-and-M-p-to-cycle-through-previous-searches.patch
Type: text/x-patch
Size: 3698 bytes
Desc: not available
URL: 



Re: [PATCH] Added C-up and C-down to cycle through previous searches

2011-06-07 Thread Dima Kogan
 Notmuch uses a mix of 8 char width tabs and spaces.  First go tabs,
 then, if you need indenting with more precision, spaces.  Look at the
 lines your patch removes for an example.
 
 Also, .dir-locals.el sets some variables to configure Emacs for
 Notmuch coding style but only for c-mode.  You may set it by hand for
 lisp.

Hi again. Here's the new patch, with M-n/M-p and tabbed indentation

dimaFrom 70193e0a9f7451033fd0843d46ac40e5524b000b Mon Sep 17 00:00:00 2001
From: Dima Kogan d...@secretsauce.net
Date: Mon, 6 Jun 2011 23:15:26 -0700
Subject: [PATCH] Added M-n and M-p to cycle through previous searches

---
 emacs/notmuch-hello.el |   47 ---
 1 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 916cda1..035e551 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -123,6 +123,12 @@ Typically \,\ in the US and UK and \.\ in Europe.
 
 (defvar notmuch-hello-recent-searches nil)
 
+(defvar notmuch-hello-cyclerecent-index 0
+  The current index of the most-recent searches )
+
+(defvar notmuch-hello-search-widget nil
+  The search widget)
+
 (defun notmuch-hello-remember-search (search)
   (if (not (member search notmuch-hello-recent-searches))
   (push search notmuch-hello-recent-searches))
@@ -148,6 +154,26 @@ Typically \,\ in the US and UK and \.\ in Europe.
   (match-string 1 search)
 search))
 
+(defun notmuch-hello-cyclerecent-next ()
+  Cycle through the most recently-searched queries, going forwards
+  (interactive)
+  (notmuch-hello-cyclerecent 1))
+
+(defun notmuch-hello-cyclerecent-prev ()
+  Cycle through the most recently-searched queries, going backwards
+  (interactive)
+  (notmuch-hello-cyclerecent -1))
+
+(defun notmuch-hello-cyclerecent (d) ()
+  (when notmuch-hello-recent-searches ; if no recent searches, do nothing
+(let ((N (length notmuch-hello-recent-searches)))
+  (setq notmuch-hello-cyclerecent-index
+	(% (+ notmuch-hello-cyclerecent-index d N) N))) ; update the index
+
+(widget-value-set notmuch-hello-search-widget
+		  (nth notmuch-hello-cyclerecent-index notmuch-hello-recent-searches))
+(widget-setup)))
+
 (defun notmuch-hello-search (search)
   (let ((search (notmuch-hello-trim search)))
 (notmuch-hello-remember-search search)
@@ -455,13 +481,19 @@ Complete list of currently available key bindings:
 
 	(widget-insert \nSearch: )
 	(setq notmuch-hello-search-bar-marker (point-marker))
-	(widget-create 'editable-field
-		   ;; Leave some space at the start and end of the
-		   ;; search boxes.
-		   :size (max 8 (- (window-width) notmuch-hello-indent
-   (length Search: )))
-		   :action (lambda (widget rest ignore)
- (notmuch-hello-search (widget-value widget
+	(setq notmuch-hello-search-widget
+	  (widget-create 'editable-field
+			 ;; Leave some space at the start and end of the
+			 ;; search boxes.
+			 :size (max 8 (- (window-width) notmuch-hello-indent
+	 (length Search: )))
+			 :action (lambda (widget rest ignore)
+   (notmuch-hello-search (widget-value widget)))
+			 :keymap (let ((map (make-sparse-keymap)))
+   (set-keymap-parent map widget-field-keymap)
+   (define-key map (kbd M-p) 'notmuch-hello-cyclerecent-prev)
+   (define-key map (kbd M-n) 'notmuch-hello-cyclerecent-next)
+   map)))
 	(widget-insert \n)
 
 	(when notmuch-hello-recent-searches
@@ -535,6 +567,7 @@ Complete list of currently available key bindings:
 	(widget-insert Type a search query and hit RET to view matching threads.\n)
 	(when notmuch-hello-recent-searches
 	  (widget-insert Hit RET to re-submit a previous search. Edit it first if you like.\n)
+	  (widget-insert In the search box, M-n/M-p cycles through the recent searches.\n)
 	  (widget-insert Save recent searches with the `save' button.\n))
 	(when notmuch-saved-searches
 	  (widget-insert Edit saved searches with the `edit' button.\n))
-- 
1.7.5.3

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] Added C-up and C-down to cycle through previous searches

2011-06-05 Thread Dmitry Kurochkin
Hi Dima.

On Sat, 4 Jun 2011 13:07:32 -0700, Dima Kogan  
wrote:
> > On Sun, 29 May 2011 20:04:00 +0400
> > Dmitry Kurochkin  wrote:
> >
> > Hi Dima.
> > 
> > On Sun, 29 May 2011 01:56:28 -0700, notmuch at dima.secretsauce.net
> > wrote:
> > > From: Dima Kogan 
> > > 
> > > ---
> > > 
> > >  Hi.
> > > 
> > >  I made a few improvements to the emacs UI. This patch allows the
> > > user to scroll through the most recent searches with C-up and
> > > C-down while in the search box.
> > > 
> > 
> > This sounds like a very nice improvement to me!  I just have one
> > concern: Why C-up and C-down?  I believe M-p and M-n would be more
> > natural for Emacs users (at least for me :)).
> > 
> > Also, I did not read the code and can not comment on it.  But notmuch
> > coding style is to use tabs for indentation.  I guess .dir-locals.el
> > should be improved to set coding style variables for all modes, not
> > just C.
> > 
> > Regards,
> >   Dmitry
> 
> Hi. I have a mild preference to C-up/down, but M-n/p is just fine also.
> As for the coding style, I've looked through that file
> (notmuch-hello.el), and it doesn't seem to have a consistent style as
> far as tabs/spaces go. I'm happy to change my patch to conform, but I
> don't know what I should be conforming to. Should I be tab-ing all
> indents, or just some?
> 

Notmuch uses a mix of 8 char width tabs and spaces.  First go tabs, then,
if you need indenting with more precision, spaces.  Look at the lines
your patch removes for an example.

Also, .dir-locals.el sets some variables to configure Emacs for Notmuch
coding style but only for c-mode.  You may set it by hand for lisp.

Regards,
  Dmitry


[PATCH] Added C-up and C-down to cycle through previous searches

2011-06-05 Thread Xavier Maillard
Hi,

On Sun, 29 May 2011 20:04:00 +0400, Dmitry Kurochkin  wrote:
> Hi Dima.
> 
> On Sun, 29 May 2011 01:56:28 -0700, notmuch at dima.secretsauce.net wrote:
> > From: Dima Kogan 
> > 
> > ---
> > 
> >  Hi.
> > 
> >  I made a few improvements to the emacs UI. This patch allows the user to 
> > scroll
> >  through the most recent searches with C-up and C-down while in the search 
> > box.
> > 
> 
> This sounds like a very nice improvement to me!  I just have one
> concern: Why C-up and C-down?  I believe M-p and M-n would be more
> natural for Emacs users (at least for me :)).

+1. M-p/M-n is way simpler to remember for me too. IMO, that should be
setq'able at the user level to suit best users preferences.

/Xavier


Re: [PATCH] Added C-up and C-down to cycle through previous searches

2011-06-05 Thread Xavier Maillard
Hi,

On Sun, 29 May 2011 20:04:00 +0400, Dmitry Kurochkin 
dmitry.kuroch...@gmail.com wrote:
 Hi Dima.
 
 On Sun, 29 May 2011 01:56:28 -0700, notm...@dima.secretsauce.net wrote:
  From: Dima Kogan d...@secretsauce.net
  
  ---
  
   Hi.
  
   I made a few improvements to the emacs UI. This patch allows the user to 
  scroll
   through the most recent searches with C-up and C-down while in the search 
  box.
  
 
 This sounds like a very nice improvement to me!  I just have one
 concern: Why C-up and C-down?  I believe M-p and M-n would be more
 natural for Emacs users (at least for me :)).

+1. M-p/M-n is way simpler to remember for me too. IMO, that should be
setq'able at the user level to suit best users preferences.

/Xavier
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] Added C-up and C-down to cycle through previous searches

2011-06-04 Thread Dima Kogan
> On Sun, 29 May 2011 20:04:00 +0400
> Dmitry Kurochkin  wrote:
>
> Hi Dima.
> 
> On Sun, 29 May 2011 01:56:28 -0700, notmuch at dima.secretsauce.net
> wrote:
> > From: Dima Kogan 
> > 
> > ---
> > 
> >  Hi.
> > 
> >  I made a few improvements to the emacs UI. This patch allows the
> > user to scroll through the most recent searches with C-up and
> > C-down while in the search box.
> > 
> 
> This sounds like a very nice improvement to me!  I just have one
> concern: Why C-up and C-down?  I believe M-p and M-n would be more
> natural for Emacs users (at least for me :)).
> 
> Also, I did not read the code and can not comment on it.  But notmuch
> coding style is to use tabs for indentation.  I guess .dir-locals.el
> should be improved to set coding style variables for all modes, not
> just C.
> 
> Regards,
>   Dmitry

Hi. I have a mild preference to C-up/down, but M-n/p is just fine also.
As for the coding style, I've looked through that file
(notmuch-hello.el), and it doesn't seem to have a consistent style as
far as tabs/spaces go. I'm happy to change my patch to conform, but I
don't know what I should be conforming to. Should I be tab-ing all
indents, or just some?



Re: [PATCH] Added C-up and C-down to cycle through previous searches

2011-06-04 Thread Dima Kogan
 On Sun, 29 May 2011 20:04:00 +0400
 Dmitry Kurochkin dmitry.kuroch...@gmail.com wrote:

 Hi Dima.
 
 On Sun, 29 May 2011 01:56:28 -0700, notm...@dima.secretsauce.net
 wrote:
  From: Dima Kogan d...@secretsauce.net
  
  ---
  
   Hi.
  
   I made a few improvements to the emacs UI. This patch allows the
  user to scroll through the most recent searches with C-up and
  C-down while in the search box.
  
 
 This sounds like a very nice improvement to me!  I just have one
 concern: Why C-up and C-down?  I believe M-p and M-n would be more
 natural for Emacs users (at least for me :)).
 
 Also, I did not read the code and can not comment on it.  But notmuch
 coding style is to use tabs for indentation.  I guess .dir-locals.el
 should be improved to set coding style variables for all modes, not
 just C.
 
 Regards,
   Dmitry

Hi. I have a mild preference to C-up/down, but M-n/p is just fine also.
As for the coding style, I've looked through that file
(notmuch-hello.el), and it doesn't seem to have a consistent style as
far as tabs/spaces go. I'm happy to change my patch to conform, but I
don't know what I should be conforming to. Should I be tab-ing all
indents, or just some?

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] Added C-up and C-down to cycle through previous searches

2011-05-30 Thread Dmitry Kurochkin
Hi Dima.

On Sun, 29 May 2011 01:56:28 -0700, notm...@dima.secretsauce.net wrote:
 From: Dima Kogan d...@secretsauce.net
 
 ---
 
  Hi.
 
  I made a few improvements to the emacs UI. This patch allows the user to 
 scroll
  through the most recent searches with C-up and C-down while in the search 
 box.
 

This sounds like a very nice improvement to me!  I just have one
concern: Why C-up and C-down?  I believe M-p and M-n would be more
natural for Emacs users (at least for me :)).

Also, I did not read the code and can not comment on it.  But notmuch
coding style is to use tabs for indentation.  I guess .dir-locals.el
should be improved to set coding style variables for all modes, not just
C.

Regards,
  Dmitry

  dima
 
  emacs/notmuch-hello.el |   49 +--
  1 files changed, 42 insertions(+), 7 deletions(-)
 
 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
 index 916cda1..56f853f 100644
 --- a/emacs/notmuch-hello.el
 +++ b/emacs/notmuch-hello.el
 @@ -123,6 +123,12 @@ Typically \,\ in the US and UK and \.\ in Europe.
  
  (defvar notmuch-hello-recent-searches nil)
  
 +(defvar notmuch-hello-cyclerecent-index 0
 +  The current index of the most-recent searches )
 +
 +(defvar notmuch-hello-search-widget nil
 +  The search widget)
 +
  (defun notmuch-hello-remember-search (search)
(if (not (member search notmuch-hello-recent-searches))
(push search notmuch-hello-recent-searches))
 @@ -148,6 +154,28 @@ Typically \,\ in the US and UK and \.\ in Europe.
(match-string 1 search)
  search))
  
 +(defun notmuch-hello-cyclerecent-next ()
 +  Cycle through the most recently-searched queries, going forwards
 +  (interactive)
 +  (notmuch-hello-cyclerecent 1))
 +
 +(defun notmuch-hello-cyclerecent-prev ()
 +  Cycle through the most recently-searched queries, going backwards
 +  (interactive)
 +  (notmuch-hello-cyclerecent -1))
 +
 +(defun notmuch-hello-cyclerecent (d) ()
 +
 +  (when notmuch-hello-recent-searches ; if no recent searches, do nothing
 +(let ((N (length notmuch-hello-recent-searches)))
 +  (setq notmuch-hello-cyclerecent-index
 +(% (+ notmuch-hello-cyclerecent-index d N) N))) ; update the 
 index
 +
 +(widget-value-set notmuch-hello-search-widget
 +  (nth notmuch-hello-cyclerecent-index 
 notmuch-hello-recent-searches))
 +(widget-setup))
 +)
 +
  (defun notmuch-hello-search (search)
(let ((search (notmuch-hello-trim search)))
  (notmuch-hello-remember-search search)
 @@ -455,13 +483,19 @@ Complete list of currently available key bindings:
  
   (widget-insert \nSearch: )
   (setq notmuch-hello-search-bar-marker (point-marker))
 - (widget-create 'editable-field
 -;; Leave some space at the start and end of the
 -;; search boxes.
 -:size (max 8 (- (window-width) notmuch-hello-indent
 -(length Search: )))
 -:action (lambda (widget rest ignore)
 -  (notmuch-hello-search (widget-value widget
 + (setq notmuch-hello-search-widget
 +  (widget-create 'editable-field
 + ;; Leave some space at the start and end of the
 + ;; search boxes.
 + :size (max 8 (- (window-width) 
 notmuch-hello-indent
 + (length Search: )))
 + :action (lambda (widget rest ignore)
 +   (notmuch-hello-search (widget-value 
 widget)))
 + :keymap (let ((map (make-sparse-keymap)))
 +   (set-keymap-parent map 
 widget-field-keymap)
 +   (define-key map (kbd C-up)   
 'notmuch-hello-cyclerecent-prev)
 +   (define-key map (kbd C-down) 
 'notmuch-hello-cyclerecent-next)
 +   map)))
   (widget-insert \n)
  
   (when notmuch-hello-recent-searches
 @@ -535,6 +569,7 @@ Complete list of currently available key bindings:
   (widget-insert Type a search query and hit RET to view matching 
 threads.\n)
   (when notmuch-hello-recent-searches
 (widget-insert Hit RET to re-submit a previous search. Edit it first 
 if you like.\n)
 +   (widget-insert In the search box, C-up/C-down cycles through the 
 recent searches.\n)
 (widget-insert Save recent searches with the `save' button.\n))
   (when notmuch-saved-searches
 (widget-insert Edit saved searches with the `edit' button.\n))
 -- 
 1.7.4.4
 
 ___
 notmuch mailing list
 notmuch@notmuchmail.org
 http://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org

[PATCH] Added C-up and C-down to cycle through previous searches

2011-05-29 Thread Dmitry Kurochkin
Hi Dima.

On Sun, 29 May 2011 01:56:28 -0700, notmuch at dima.secretsauce.net wrote:
> From: Dima Kogan 
> 
> ---
> 
>  Hi.
> 
>  I made a few improvements to the emacs UI. This patch allows the user to 
> scroll
>  through the most recent searches with C-up and C-down while in the search 
> box.
> 

This sounds like a very nice improvement to me!  I just have one
concern: Why C-up and C-down?  I believe M-p and M-n would be more
natural for Emacs users (at least for me :)).

Also, I did not read the code and can not comment on it.  But notmuch
coding style is to use tabs for indentation.  I guess .dir-locals.el
should be improved to set coding style variables for all modes, not just
C.

Regards,
  Dmitry

>  dima
> 
>  emacs/notmuch-hello.el |   49 +--
>  1 files changed, 42 insertions(+), 7 deletions(-)
> 
> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> index 916cda1..56f853f 100644
> --- a/emacs/notmuch-hello.el
> +++ b/emacs/notmuch-hello.el
> @@ -123,6 +123,12 @@ Typically \",\" in the US and UK and \".\" in Europe."
>  
>  (defvar notmuch-hello-recent-searches nil)
>  
> +(defvar notmuch-hello-cyclerecent-index 0
> +  "The current index of the most-recent searches" )
> +
> +(defvar notmuch-hello-search-widget nil
> +  "The search widget")
> +
>  (defun notmuch-hello-remember-search (search)
>(if (not (member search notmuch-hello-recent-searches))
>(push search notmuch-hello-recent-searches))
> @@ -148,6 +154,28 @@ Typically \",\" in the US and UK and \".\" in Europe."
>(match-string 1 search)
>  search))
>  
> +(defun notmuch-hello-cyclerecent-next ()
> +  "Cycle through the most recently-searched queries, going forwards"
> +  (interactive)
> +  (notmuch-hello-cyclerecent 1))
> +
> +(defun notmuch-hello-cyclerecent-prev ()
> +  "Cycle through the most recently-searched queries, going backwards"
> +  (interactive)
> +  (notmuch-hello-cyclerecent -1))
> +
> +(defun notmuch-hello-cyclerecent (d) ()
> +
> +  (when notmuch-hello-recent-searches ; if no recent searches, do nothing
> +(let ((N (length notmuch-hello-recent-searches)))
> +  (setq notmuch-hello-cyclerecent-index
> +(% (+ notmuch-hello-cyclerecent-index d N) N))) ; update the 
> index
> +
> +(widget-value-set notmuch-hello-search-widget
> +  (nth notmuch-hello-cyclerecent-index 
> notmuch-hello-recent-searches))
> +(widget-setup))
> +)
> +
>  (defun notmuch-hello-search (search)
>(let ((search (notmuch-hello-trim search)))
>  (notmuch-hello-remember-search search)
> @@ -455,13 +483,19 @@ Complete list of currently available key bindings:
>  
>   (widget-insert "\nSearch: ")
>   (setq notmuch-hello-search-bar-marker (point-marker))
> - (widget-create 'editable-field
> -;; Leave some space at the start and end of the
> -;; search boxes.
> -:size (max 8 (- (window-width) notmuch-hello-indent
> -(length "Search: ")))
> -:action (lambda (widget  ignore)
> -  (notmuch-hello-search (widget-value widget
> + (setq notmuch-hello-search-widget
> +  (widget-create 'editable-field
> + ;; Leave some space at the start and end of the
> + ;; search boxes.
> + :size (max 8 (- (window-width) 
> notmuch-hello-indent
> + (length "Search: ")))
> + :action (lambda (widget  ignore)
> +   (notmuch-hello-search (widget-value 
> widget)))
> + :keymap (let ((map (make-sparse-keymap)))
> +   (set-keymap-parent map 
> widget-field-keymap)
> +   (define-key map (kbd "")   
> 'notmuch-hello-cyclerecent-prev)
> +   (define-key map (kbd "") 
> 'notmuch-hello-cyclerecent-next)
> +   map)))
>   (widget-insert "\n")
>  
>   (when notmuch-hello-recent-searches
> @@ -535,6 +569,7 @@ Complete list of currently available key bindings:
>   (widget-insert "Type a search query and hit RET to view matching 
> threads.\n")
>   (when notmuch-hello-recent-searches
> (widget-insert "Hit RET to re-submit a previous search. Edit it first 
> if you like.\n")
> +   (widget-insert "In the search box, C-up/C-down cycles through the 
> recent searches.\n")
> (widget-insert "Save recent searches with the `save' button.\n"))
>   (when notmuch-saved-searches
> (widget-insert "Edit saved searches with the `edit' button.\n"))
> -- 
> 1.7.4.4
> 
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> 

[PATCH] Added C-up and C-down to cycle through previous searches

2011-05-29 Thread notm...@dima.secretsauce.net
From: Dima Kogan 

---

 Hi.

 I made a few improvements to the emacs UI. This patch allows the user to scroll
 through the most recent searches with C-up and C-down while in the search box.

 dima

 emacs/notmuch-hello.el |   49 +--
 1 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 916cda1..56f853f 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -123,6 +123,12 @@ Typically \",\" in the US and UK and \".\" in Europe."

 (defvar notmuch-hello-recent-searches nil)

+(defvar notmuch-hello-cyclerecent-index 0
+  "The current index of the most-recent searches" )
+
+(defvar notmuch-hello-search-widget nil
+  "The search widget")
+
 (defun notmuch-hello-remember-search (search)
   (if (not (member search notmuch-hello-recent-searches))
   (push search notmuch-hello-recent-searches))
@@ -148,6 +154,28 @@ Typically \",\" in the US and UK and \".\" in Europe."
   (match-string 1 search)
 search))

+(defun notmuch-hello-cyclerecent-next ()
+  "Cycle through the most recently-searched queries, going forwards"
+  (interactive)
+  (notmuch-hello-cyclerecent 1))
+
+(defun notmuch-hello-cyclerecent-prev ()
+  "Cycle through the most recently-searched queries, going backwards"
+  (interactive)
+  (notmuch-hello-cyclerecent -1))
+
+(defun notmuch-hello-cyclerecent (d) ()
+
+  (when notmuch-hello-recent-searches ; if no recent searches, do nothing
+(let ((N (length notmuch-hello-recent-searches)))
+  (setq notmuch-hello-cyclerecent-index
+(% (+ notmuch-hello-cyclerecent-index d N) N))) ; update the index
+
+(widget-value-set notmuch-hello-search-widget
+  (nth notmuch-hello-cyclerecent-index 
notmuch-hello-recent-searches))
+(widget-setup))
+)
+
 (defun notmuch-hello-search (search)
   (let ((search (notmuch-hello-trim search)))
 (notmuch-hello-remember-search search)
@@ -455,13 +483,19 @@ Complete list of currently available key bindings:

(widget-insert "\nSearch: ")
(setq notmuch-hello-search-bar-marker (point-marker))
-   (widget-create 'editable-field
-  ;; Leave some space at the start and end of the
-  ;; search boxes.
-  :size (max 8 (- (window-width) notmuch-hello-indent
-  (length "Search: ")))
-  :action (lambda (widget  ignore)
-(notmuch-hello-search (widget-value widget
+   (setq notmuch-hello-search-widget
+  (widget-create 'editable-field
+ ;; Leave some space at the start and end of the
+ ;; search boxes.
+ :size (max 8 (- (window-width) 
notmuch-hello-indent
+ (length "Search: ")))
+ :action (lambda (widget  ignore)
+   (notmuch-hello-search (widget-value 
widget)))
+ :keymap (let ((map (make-sparse-keymap)))
+   (set-keymap-parent map 
widget-field-keymap)
+   (define-key map (kbd "")   
'notmuch-hello-cyclerecent-prev)
+   (define-key map (kbd "") 
'notmuch-hello-cyclerecent-next)
+   map)))
(widget-insert "\n")

(when notmuch-hello-recent-searches
@@ -535,6 +569,7 @@ Complete list of currently available key bindings:
(widget-insert "Type a search query and hit RET to view matching 
threads.\n")
(when notmuch-hello-recent-searches
  (widget-insert "Hit RET to re-submit a previous search. Edit it first 
if you like.\n")
+ (widget-insert "In the search box, C-up/C-down cycles through the 
recent searches.\n")
  (widget-insert "Save recent searches with the `save' button.\n"))
(when notmuch-saved-searches
  (widget-insert "Edit saved searches with the `edit' button.\n"))
-- 
1.7.4.4



[PATCH] Added C-up and C-down to cycle through previous searches

2011-05-29 Thread notmuch
From: Dima Kogan d...@secretsauce.net

---

 Hi.

 I made a few improvements to the emacs UI. This patch allows the user to scroll
 through the most recent searches with C-up and C-down while in the search box.

 dima

 emacs/notmuch-hello.el |   49 +--
 1 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 916cda1..56f853f 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -123,6 +123,12 @@ Typically \,\ in the US and UK and \.\ in Europe.
 
 (defvar notmuch-hello-recent-searches nil)
 
+(defvar notmuch-hello-cyclerecent-index 0
+  The current index of the most-recent searches )
+
+(defvar notmuch-hello-search-widget nil
+  The search widget)
+
 (defun notmuch-hello-remember-search (search)
   (if (not (member search notmuch-hello-recent-searches))
   (push search notmuch-hello-recent-searches))
@@ -148,6 +154,28 @@ Typically \,\ in the US and UK and \.\ in Europe.
   (match-string 1 search)
 search))
 
+(defun notmuch-hello-cyclerecent-next ()
+  Cycle through the most recently-searched queries, going forwards
+  (interactive)
+  (notmuch-hello-cyclerecent 1))
+
+(defun notmuch-hello-cyclerecent-prev ()
+  Cycle through the most recently-searched queries, going backwards
+  (interactive)
+  (notmuch-hello-cyclerecent -1))
+
+(defun notmuch-hello-cyclerecent (d) ()
+
+  (when notmuch-hello-recent-searches ; if no recent searches, do nothing
+(let ((N (length notmuch-hello-recent-searches)))
+  (setq notmuch-hello-cyclerecent-index
+(% (+ notmuch-hello-cyclerecent-index d N) N))) ; update the index
+
+(widget-value-set notmuch-hello-search-widget
+  (nth notmuch-hello-cyclerecent-index 
notmuch-hello-recent-searches))
+(widget-setup))
+)
+
 (defun notmuch-hello-search (search)
   (let ((search (notmuch-hello-trim search)))
 (notmuch-hello-remember-search search)
@@ -455,13 +483,19 @@ Complete list of currently available key bindings:
 
(widget-insert \nSearch: )
(setq notmuch-hello-search-bar-marker (point-marker))
-   (widget-create 'editable-field
-  ;; Leave some space at the start and end of the
-  ;; search boxes.
-  :size (max 8 (- (window-width) notmuch-hello-indent
-  (length Search: )))
-  :action (lambda (widget rest ignore)
-(notmuch-hello-search (widget-value widget
+   (setq notmuch-hello-search-widget
+  (widget-create 'editable-field
+ ;; Leave some space at the start and end of the
+ ;; search boxes.
+ :size (max 8 (- (window-width) 
notmuch-hello-indent
+ (length Search: )))
+ :action (lambda (widget rest ignore)
+   (notmuch-hello-search (widget-value 
widget)))
+ :keymap (let ((map (make-sparse-keymap)))
+   (set-keymap-parent map 
widget-field-keymap)
+   (define-key map (kbd C-up)   
'notmuch-hello-cyclerecent-prev)
+   (define-key map (kbd C-down) 
'notmuch-hello-cyclerecent-next)
+   map)))
(widget-insert \n)
 
(when notmuch-hello-recent-searches
@@ -535,6 +569,7 @@ Complete list of currently available key bindings:
(widget-insert Type a search query and hit RET to view matching 
threads.\n)
(when notmuch-hello-recent-searches
  (widget-insert Hit RET to re-submit a previous search. Edit it first 
if you like.\n)
+ (widget-insert In the search box, C-up/C-down cycles through the 
recent searches.\n)
  (widget-insert Save recent searches with the `save' button.\n))
(when notmuch-saved-searches
  (widget-insert Edit saved searches with the `edit' button.\n))
-- 
1.7.4.4

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch