[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
> 

Multiple sender identities (composing)

2011-05-29 Thread Stewart Smith
On Tue, 24 May 2011 14:54:37 -0700, Carl Worth  wrote:
> I've wanted something like this, but I'm extremely reluctant to put
> fancy things like this in my .emacs file. The problem I have is that I
> don't want to restrict nice features to the people who manage to
> configure their emacs "just so".

I completely agree - and am rather glad that there's a proper solution now.

> I'll reply with a patch I just wrote attempting to implement that. By
> default, it generates the list of addresses by looking in your notmuch
> configuration file. It also provides a customizable list of addresses
> that the user can provide (notmuch-identities).

I'll try trunk with the patches as soon as I get home from travel and am
somewhat remotely close to not being a zombie.

> I don't know what trouble you had with ido on Ubuntu, but hopefully you
> can work that out.

I hope so too... it could just be how I was trying to use it or user
ignorance or something like that.

-- 
Stewart Smith


[PATCH 2/2] emacs: add notmuch-show-worker function for specifying crypto processing directly

2011-05-29 Thread Jameson Graef Rollins
The main reason to introduce this new unexposed function is to allow
the buffer redisplay crypto switch to behaving in a more expected way.
The prefix to notmuch-show-redisplay buffer now switches the crypto
processing of the current show buffer, as opposed to switching the
logic of the notmuch-crypto-process-mime customization variable.  This
behavior is more intuitive.
---
 emacs/notmuch-show.el |   20 
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 6e0d454..3a075a4 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -811,13 +811,16 @@ The optional CRYPTO-SWITCH toggles the value of the
 notmuch-crypto-process-mime customization variable for this show
 buffer."
   (interactive "sNotmuch show: ")
+  (let* ((process-crypto (if crypto-switch
+(not notmuch-crypto-process-mime)
+  notmuch-crypto-process-mime)))
+(notmuch-show-worker thread-id parent-buffer query-context buffer-name 
process-crypto)))
+
+(defun notmuch-show-worker (thread-id parent-buffer query-context buffer-name 
process-crypto)
   (let* ((buffer-name (generate-new-buffer-name
   (or buffer-name
   (concat "*notmuch-" thread-id "*"
 (buffer (get-buffer-create buffer-name))
-(process-crypto (if crypto-switch
-(not notmuch-crypto-process-mime)
-  notmuch-crypto-process-mime))
 (inhibit-read-only t))
 (switch-to-buffer buffer)
 (notmuch-show-mode)
@@ -864,16 +867,17 @@ buffer."
   "Refresh the current view (with crypto switch if prefix given).

 Kills the current buffer and reruns notmuch show with the same
-thread id.  If a prefix is given, the current thread is
-redisplayed with the crypto switch activated, which switch the
-logic of the notmuch-crypto-process-mime customization variable."
+thread id.  If a prefix is given, crypto processing is toggled."
   (interactive "P")
   (let ((thread-id notmuch-show-thread-id)
(parent-buffer notmuch-show-parent-buffer)
(query-context notmuch-show-query-context)
-   (buffer-name notmuch-show-buffer-name))
+   (buffer-name notmuch-show-buffer-name)
+   (process-crypto (if crypto-switch
+   (not notmuch-show-process-crypto)
+ notmuch-show-process-crypto)))
 (notmuch-kill-this-buffer)
-(notmuch-show thread-id parent-buffer query-context buffer-name 
crypto-switch)))
+(notmuch-show-worker thread-id parent-buffer query-context buffer-name 
process-crypto)))

 (defvar notmuch-show-stash-map
   (let ((map (make-sparse-keymap)))
-- 
1.7.4.4



[PATCH 1/2] emacs: add documentation for notmuch-show crypto-switch option

2011-05-29 Thread Jameson Graef Rollins
---
 emacs/notmuch-show.el |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 3b35b81..6e0d454 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -805,7 +805,11 @@ non-nil.
 The optional BUFFER-NAME provides the neame of the buffer in
 which the message thread is shown. If it is nil (which occurs
 when the command is called interactively) the argument to the
-function is used. "
+function is used.
+
+The optional CRYPTO-SWITCH toggles the value of the
+notmuch-crypto-process-mime customization variable for this show
+buffer."
   (interactive "sNotmuch show: ")
   (let* ((buffer-name (generate-new-buffer-name
   (or buffer-name
-- 
1.7.4.4



compile error of current git on F15

2011-05-29 Thread Dirk Hohndel

CC -O2 notmuch-reply.o
notmuch-reply.c: In function ?notmuch_reply_command?:
notmuch-reply.c:658:3: error: unknown type name ?GMimeSession?
notmuch-reply.c:659:3: warning: passing argument 1 of ?g_mime_gpg_context_new? 
from incompatible pointer type [enabled by default]
/usr/include/gmime-2.6/gmime/gmime-gpg-context.h:64:21: note: expected 
?GMimePasswordRequestFunc? but argument is of type ?int *?
make: *** [notmuch-reply.o] Error 1

This seems to have been introduced in Jameson's crypto patch series...

./configure shows:

Checking for Xapian development files... Yes (1.2.4).
Checking for GMime development files... Yes (gmime-2.6).
Checking for Glib development files (>= 2.14)... Yes.

/D

-- 
Dirk Hohndel
Intel Open Source Technology Center


[PATCH 2/2] test: fix tests after notmuch show output changes related to filenames

2011-05-29 Thread Dmitry Kurochkin
---
 test/crypto|3 +--
 test/multipart |   12 
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/test/crypto b/test/crypto
index 8e92016..796c4ca 100755
--- a/test/crypto
+++ b/test/crypto
@@ -168,8 +168,7 @@ Non-text part: application/pgp-encrypted
 part{ ID: 4, Content-type: text/plain
 This is a test encrypted message.
 part}
-attachment{ ID: 5, Content-type: application/octet-stream
-Attachment: TESTATTACHMENT (application/octet-stream)
+attachment{ ID: 5, Filename: TESTATTACHMENT, Content-type: 
application/octet-stream
 Non-text part: application/octet-stream
 attachment}
 part}
diff --git a/test/multipart b/test/multipart
index 62efd84..9348fb6 100755
--- a/test/multipart
+++ b/test/multipart
@@ -77,8 +77,7 @@ Date: Tue, 05 Jan 2001 15:43:57 -
 Non-text part: text/html
 part}
 part}
-attachment{ ID: 5, Content-type: text/plain
-Attachment: attachment (text/plain)
+attachment{ ID: 5, Filename: attachment, Content-type: text/plain
 This is a text attachment.
 attachment}
 part{ ID: 6, Content-type: text/plain
@@ -104,8 +103,7 @@ test_expect_equal "$output" \
 Non-text part: text/html
 part}
 part}
-attachment{ ID: 5, Content-type: text/plain
-Attachment: attachment (text/plain)
+attachment{ ID: 5, Filename: attachment, Content-type: text/plain
 This is a text attachment.
 attachment}
 part{ ID: 6, Content-type: text/plain
@@ -128,8 +126,7 @@ test_expect_equal "$output" \
 Non-text part: text/html
 part}
 part}
-attachment{ ID: 5, Content-type: text/plain
-Attachment: attachment (text/plain)
+attachment{ ID: 5, Filename: attachment, Content-type: text/plain
 This is a text attachment.
 attachment}
 part{ ID: 6, Content-type: text/plain
@@ -158,8 +155,7 @@ Non-text part: text/html
 test_begin_subtest "--format=text --part=5, inline attachement"
 output=$(notmuch show --format=text --part=5 'id:87liy5ap00.fsf at 
yoom.home.cworth.org')
 test_expect_equal "$output" \
-"attachment{ ID: 5, Content-type: text/plain
-Attachment: attachment (text/plain)
+"attachment{ ID: 5, Filename: attachment, Content-type: text/plain
 This is a text attachment.
 attachment}"

-- 
1.7.5.3



[PATCH 1/2] Add part filename and content-id in notmuch show output if available.

2011-05-29 Thread Dmitry Kurochkin
Before the change, notmuch show output had filename only for
parts with "Content-Disposition: attachment".  But parts with
inline disposition may have filename as well.

The patch makes notmuch show always output filename if available,
independent of Content-Disposition.  Both JSON and text output
formats are changed.

Also, the patch adds Content-id to text output format of notmuch
show.

The main goal of these changes is to have filenames on Emacs
buttons for inline attachments.  In particular, this is very
helpful for inline patches.

Note: text format changes may require updates in clients that use
it.  The changes are:

* text part header format changed from:

^Lpart{ ID: 2, Content-type: text/x-diff

  to:

^Lpart{ ID: 2, Filename: cool-feature.patch, Content-type: text/x-diff

* attachment format changed from:

^Lattachment{ ID: 4, Content-type: application/octet-stream
Attachment: data.tar.bz2 (application/octet-stream)
Non-text part: application/octet-stream
^Lattachment}

  to:

^Lattachment{ ID: 4, Filename: data.tar.bz2, Content-type: 
application/octet-stream
Non-text part: application/octet-stream
^Lattachment}
---
 notmuch-show.c |   24 
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index e90f07e..8f275d7 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -445,20 +445,22 @@ format_part_start_text (GMimeObject *part, int 
*part_count)
 static void
 format_part_content_text (GMimeObject *part)
 {
-GMimeContentDisposition *disposition = 
g_mime_object_get_content_disposition (part);
+const char *cid = g_mime_object_get_content_id (part);
 GMimeContentType *content_type = g_mime_object_get_content_type 
(GMIME_OBJECT (part));
 GMimeStream *stream_stdout = g_mime_stream_file_new (stdout);

-printf (", Content-type: %s\n", g_mime_content_type_to_string 
(content_type));
-
-if (disposition &&
-   strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0)
+if (GMIME_IS_PART (part))
 {
const char *filename = g_mime_part_get_filename (GMIME_PART (part));
-   printf ("Attachment: %s (%s)\n", filename,
-   g_mime_content_type_to_string (content_type));
+   if (filename)
+   printf (", Filename: %s", filename);
 }

+if (cid)
+   printf (", Content-id: %s", cid);
+
+printf (", Content-type: %s\n", g_mime_content_type_to_string 
(content_type));
+
 if (g_mime_content_type_is_type (content_type, "text", "*") &&
!g_mime_content_type_is_type (content_type, "text", "html"))
 {
@@ -580,7 +582,6 @@ format_part_content_json (GMimeObject *part)
 GMimeStream *stream_memory = g_mime_stream_mem_new ();
 const char *cid = g_mime_object_get_content_id (part);
 void *ctx = talloc_new (NULL);
-GMimeContentDisposition *disposition = 
g_mime_object_get_content_disposition (part);
 GByteArray *part_content;

 printf (", \"content-type\": %s",
@@ -589,12 +590,11 @@ format_part_content_json (GMimeObject *part)
 if (cid != NULL)
printf(", \"content-id\": %s", json_quote_str (ctx, cid));

-if (disposition &&
-   strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0)
+if (GMIME_IS_PART (part))
 {
const char *filename = g_mime_part_get_filename (GMIME_PART (part));
-
-   printf (", \"filename\": %s", json_quote_str (ctx, filename));
+   if (filename)
+   printf (", \"filename\": %s", json_quote_str (ctx, filename));
 }

 if (g_mime_content_type_is_type (content_type, "text", "*") &&
-- 
1.7.5.3



[PATCH] fixed typo in a comment

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

---

 This patch corrects a typo

 test/Makefile |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/test/Makefile b/test/Makefile
index b6859ea..de492a7 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,4 +1,4 @@
-# See Makfefile.local for the list of files to be compiled in this
+# See Makefile.local for the list of files to be compiled in this
 # directory.
 all:
$(MAKE) -C .. all
-- 
1.7.4.4



[PATCH] added keys to hide/show a portion of the thread

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

---

 Here's another improvement. In the notmuch-show display this binds '[' to
 expand all the children messages (replies). Analogously ']' collapses all the
 children messages.

 dima

 emacs/notmuch-show.el |   34 ++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 2ba151e..600f3ec 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -813,6 +813,8 @@ function is used. "
(define-key map " " 'notmuch-show-advance-and-archive)
(define-key map (kbd "M-RET") 'notmuch-show-open-or-close-all)
(define-key map (kbd "RET") 'notmuch-show-toggle-message)
+   (define-key map "]" 'notmuch-show-hide-hierarchy)
+   (define-key map "[" 'notmuch-show-show-hierarchy)
map)
   "Keymap for \"notmuch show\" buffers.")
 (fset 'notmuch-show-mode-map notmuch-show-mode-map)
@@ -1266,6 +1268,38 @@ argument, hide all of the messages."
  until (not (notmuch-show-goto-message-next
   (force-window-update))

+; get the depth, assuming the point is at the start of the header line
+(defun notmuch-show-get-depth ()
+  (save-excursion
+(let ((start (point)))
+  (- (re-search-forward "^ *") start
+
+(defun notmuch-show-hideshow-hierarchy (doshow)
+  "Hides or shows this message and all its replies"
+  (interactive)
+  (save-excursion
+(notmuch-show-move-to-message-top)
+
+(let ((depth0 (notmuch-show-get-depth)))
+  (loop do (notmuch-show-message-visible 
(notmuch-show-get-message-properties)
+ doshow)
+until (or (not (notmuch-show-goto-message-next))
+  (<= (notmuch-show-get-depth) depth0
+  (force-window-update))
+)
+
+(defun notmuch-show-show-hierarchy ()
+  "Show this message and all its replies"
+  (interactive)
+  (notmuch-show-hideshow-hierarchy 1)
+)
+
+(defun notmuch-show-hide-hierarchy ()
+  "Hide this message and all its replies"
+  (interactive)
+  (notmuch-show-hideshow-hierarchy nil)
+)
+
 (defun notmuch-show-next-button ()
   "Advance point to the next button in the buffer."
   (interactive)
-- 
1.7.4.4



[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] fixed typo in a comment

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

---

 This patch corrects a typo

 test/Makefile |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/test/Makefile b/test/Makefile
index b6859ea..de492a7 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,4 +1,4 @@
-# See Makfefile.local for the list of files to be compiled in this
+# See Makefile.local for the list of files to be compiled in this
 # directory.
 all:
$(MAKE) -C .. all
-- 
1.7.4.4

___
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-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