[PATCH 1/3] test: Adding non-maildir tags does not move message from new to cur

2013-09-03 Thread David Bremner
Michal Sojka  writes:

> From: Michal Sojka 
>
> Some MUA's like mutt show the difference between "new" emails living in 
> maildir
> directory new/, and "old" emails living in maildir directory cur/. However
> notmuch tag unconditionally moves selected messages from new/ to cur/, even if
> no maildir synchronized tag is changed.

I pushed these three, and the three followup patches from Jani and I
(mine squashed in to avoid a commit with broken tests).

d


[PATCH 0/2] emacs: simplify and cleanup notmuch-mua-reply

2013-09-03 Thread Tomi Ollila
On Wed, Aug 28 2013, Jani Nikula  wrote:

> This is an alternative to [1]. I tried to dig through history, and I
> couldn't find a decent reason for having the backwards regexp in place.

I played a bit with this and this works fine. Looks good & tests pass. +1

>
> BR,
> Jani.

Tomi

>
>
> [1] id:1375961732-14327-1-git-send-email-geoffrey.ferrari at oriel.oxon.org
>
>
> Jani Nikula (2):
>   emacs: simplify point placement for inserting message body on reply
>   emacs: slightly cleanup the reply code
>
>  emacs/notmuch-mua.el |   45 -
>  1 file changed, 20 insertions(+), 25 deletions(-)
>
> -- 
> 1.7.10.4
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
>

-- 
"kaik on m?nt!"


[PATCH 0/4] contrib: pick: extra tests

2013-09-03 Thread Tomi Ollila
On Tue, Sep 03 2013, Mark Walters  wrote:

> This series adds some tests for various existing and recently added
> functionality.
>
> The only thing to note is that the xapian tag database and the
> displayed tags are update separately so we need to test both.

Looks good (afaiu), tests pass

> Best wishes
>
> Mark

Tomi

>
> Mark Walters (4):
>   contrib: pick: test: tag/untag single message
>   contrib: pick: test: tag/untag whole thread
>   contrib: pick: test: stash message id
>   contrib: pick: test: buffer movement
>
>  contrib/notmuch-pick/test/emacs-pick   |  121 
> 
>  .../notmuch-pick-tag-inbox-tagged  |   53 +
>  .../notmuch-pick-tag-inbox-thread-tagged   |   53 +
>  3 files changed, 227 insertions(+), 0 deletions(-)
>  create mode 100644 
> contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-tagged
>  create mode 100644 
> contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-thread-tagged
>
> -- 
> 1.7.9.1
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
>

-- 
"kaik on m?nt!"


[PATCH v2 9/9] emacs: Move ?, q, s, m, =, and G to the common keymap

2013-09-03 Thread Austin Clements
The only user-visible effect of this should be that "G" now works in
show mode (previously it was unbound for no apparent reason).

This shared keymap gives us one place to put global commands, which
both forces us to think about what commands should be global, and
ensures their bindings can't diverge (like the missing "G" in show).
---
 emacs/notmuch-hello.el |6 --
 emacs/notmuch-lib.el   |6 ++
 emacs/notmuch-show.el  |5 -
 emacs/notmuch.el   |6 --
 4 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 46baf55..55c416a 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -525,13 +525,7 @@ Such a list can be computed with 
`notmuch-hello-query-counts'."
 (set-keymap-parent map notmuch-common-keymap)
 (define-key map "v" (lambda () "Display the notmuch version" (interactive)
  (message "notmuch version %s" (notmuch-version
-(define-key map "?" 'notmuch-help)
-(define-key map "q" 'notmuch-kill-this-buffer)
-(define-key map "=" 'notmuch-refresh-this-buffer)
-(define-key map "G" 'notmuch-poll-and-refresh-this-buffer)
 (define-key map (kbd "") 'widget-backward)
-(define-key map "m" 'notmuch-mua-new-mail)
-(define-key map "s" 'notmuch-search)
 map)
   "Keymap for \"notmuch hello\" buffers.")
 (fset 'notmuch-hello-mode-map notmuch-hello-mode-map)
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 2bf1d2f..58f3313 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -130,6 +130,12 @@ For example, if you wanted to remove an \"inbox\" tag and 
add an

 (defvar notmuch-common-keymap
   (let ((map (make-sparse-keymap)))
+(define-key map "?" 'notmuch-help)
+(define-key map "q" 'notmuch-kill-this-buffer)
+(define-key map "s" 'notmuch-search)
+(define-key map "m" 'notmuch-mua-new-mail)
+(define-key map "=" 'notmuch-refresh-this-buffer)
+(define-key map "G" 'notmuch-poll-and-refresh-this-buffer)
 map)
   "Keymap shared by all notmuch modes.")

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 9f67340..9d8b785 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1265,14 +1265,10 @@ reset based on the original query."
 (defvar notmuch-show-mode-map
   (let ((map (make-sparse-keymap)))
(set-keymap-parent map notmuch-common-keymap)
-   (define-key map "?" 'notmuch-help)
-   (define-key map "q" 'notmuch-kill-this-buffer)
(define-key map (kbd "") 'widget-backward)
(define-key map (kbd "M-TAB") 'notmuch-show-previous-button)
(define-key map (kbd "") 'notmuch-show-previous-button)
(define-key map (kbd "TAB") 'notmuch-show-next-button)
-   (define-key map "s" 'notmuch-search)
-   (define-key map "m" 'notmuch-mua-new-mail)
(define-key map "f" 'notmuch-show-forward-message)
(define-key map "r" 'notmuch-show-reply-sender)
(define-key map "R" 'notmuch-show-reply)
@@ -1280,7 +1276,6 @@ reset based on the original query."
(define-key map "w" 'notmuch-show-save-attachments)
(define-key map "V" 'notmuch-show-view-raw-message)
(define-key map "c" 'notmuch-show-stash-map)
-   (define-key map "=" 'notmuch-refresh-this-buffer)
(define-key map "h" 'notmuch-show-toggle-visibility-headers)
(define-key map "*" 'notmuch-show-tag-all)
(define-key map "-" 'notmuch-show-remove-tag)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index e098bd7..4de6229 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -199,8 +199,6 @@ first line of documentation for the bound function."
 (defvar notmuch-search-mode-map
   (let ((map (make-sparse-keymap)))
 (set-keymap-parent map notmuch-common-keymap)
-(define-key map "?" 'notmuch-help)
-(define-key map "q" 'notmuch-kill-this-buffer)
 (define-key map "x" 'notmuch-kill-this-buffer)
 (define-key map (kbd "") 'notmuch-search-scroll-down)
 (define-key map "b" 'notmuch-search-scroll-down)
@@ -211,12 +209,8 @@ first line of documentation for the bound function."
 (define-key map "n" 'notmuch-search-next-thread)
 (define-key map "r" 'notmuch-search-reply-to-thread-sender)
 (define-key map "R" 'notmuch-search-reply-to-thread)
-(define-key map "m" 'notmuch-mua-new-mail)
-(define-key map "s" 'notmuch-search)
 (define-key map "o" 'notmuch-search-toggle-order)
 (define-key map "c" 'notmuch-search-stash-map)
-(define-key map "=" 'notmuch-refresh-this-buffer)
-(define-key map "G" 'notmuch-poll-and-refresh-this-buffer)
 (define-key map "t" 'notmuch-search-filter-by-tag)
 (define-key map "f" 'notmuch-search-filter)
 (define-key map [mouse-1] 'notmuch-search-show-thread)
-- 
1.7.10.4



[PATCH v2 8/9] emacs: Define a common shared keymap for all of notmuch

2013-09-03 Thread Austin Clements
This defines a single, currently empty keymap that all other notmuch
mode maps inherit from.
---
 emacs/notmuch-hello.el |   10 --
 emacs/notmuch-lib.el   |5 +
 emacs/notmuch-show.el  |1 +
 emacs/notmuch.el   |1 +
 4 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 6a7b884..46baf55 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -515,8 +515,14 @@ Such a list can be computed with 
`notmuch-hello-query-counts'."


 (defvar notmuch-hello-mode-map
-  (let ((map (make-sparse-keymap)))
-(set-keymap-parent map widget-keymap)
+  (let ((map (if (fboundp 'make-composed-keymap)
+;; Inherit both widget-keymap and notmuch-common-keymap
+(make-composed-keymap widget-keymap)
+  ;; Before Emacs 24, keymaps didn't support multiple
+  ;; inheritance,, so just copy the widget keymap since
+  ;; it's unlikely to change.
+  (copy-keymap widget-keymap
+(set-keymap-parent map notmuch-common-keymap)
 (define-key map "v" (lambda () "Display the notmuch version" (interactive)
  (message "notmuch version %s" (notmuch-version
 (define-key map "?" 'notmuch-help)
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 782badb..2bf1d2f 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -128,6 +128,11 @@ For example, if you wanted to remove an \"inbox\" tag and 
add an
   :group 'notmuch-search
   :group 'notmuch-show)

+(defvar notmuch-common-keymap
+  (let ((map (make-sparse-keymap)))
+map)
+  "Keymap shared by all notmuch modes.")
+
 ;; By default clicking on a button does not select the window
 ;; containing the button (as opposed to clicking on a widget which
 ;; does). This means that the button action is then executed in the
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 380df66..9f67340 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1264,6 +1264,7 @@ reset based on the original query."

 (defvar notmuch-show-mode-map
   (let ((map (make-sparse-keymap)))
+   (set-keymap-parent map notmuch-common-keymap)
(define-key map "?" 'notmuch-help)
(define-key map "q" 'notmuch-kill-this-buffer)
(define-key map (kbd "") 'widget-backward)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 0304096..e098bd7 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -198,6 +198,7 @@ first line of documentation for the bound function."

 (defvar notmuch-search-mode-map
   (let ((map (make-sparse-keymap)))
+(set-keymap-parent map notmuch-common-keymap)
 (define-key map "?" 'notmuch-help)
 (define-key map "q" 'notmuch-kill-this-buffer)
 (define-key map "x" 'notmuch-kill-this-buffer)
-- 
1.7.10.4



[PATCH v2 7/9] emacs: Make notmuch-help work with arbitrary keymaps

2013-09-03 Thread Austin Clements
This converts notmuch-help to use map-keymap for all keymap traversal.
This generally cleans up and simplifies construction of keymap
documentation, and also makes notmuch-help support anything that can
be in a keymap, including more esoteric stuff like multiple
inheritance.
---
 emacs/notmuch.el |   58 +-
 1 file changed, 22 insertions(+), 36 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 80446be..0304096 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -140,48 +140,34 @@ This is basically just `format-kbd-macro' but we also 
convert ESC to M-."
"M-"
   (concat desc " "

-;; I would think that emacs would have code handy for walking a keymap
-;; and generating strings for each key, and I would prefer to just call
-;; that. But I couldn't find any (could be all implemented in C I
-;; suppose), so I wrote my own here.
-(defun notmuch-substitute-one-command-key-with-prefix (prefix binding)
-  "For a key binding, return a string showing a human-readable
-representation of the prefixed key as well as the first line of
-documentation from the bound function.
-
-For a mouse binding, return nil."
-  (let ((key (car binding))
-   (action (cdr binding)))
-(if (mouse-event-p key)
-   nil
-  (if (keymapp action)
- (let ((substitute (apply-partially 
'notmuch-substitute-one-command-key-with-prefix (notmuch-prefix-key-description 
key)))
-   (as-list))
-   (map-keymap (lambda (a b)
- (push (cons a b) as-list))
-   action)
-   (mapconcat substitute as-list "\n"))
-   (concat prefix (format-kbd-macro (vector key))
-   "\t"
-   (notmuch-documentation-first-line action))
-
-(defun notmuch-substitute-command-keys-one (key)
-  ;; A `keymap' key indicates inheritance from a parent keymap - the
-  ;; inherited mappings follow, so there is nothing to print for
-  ;; `keymap' itself.
-  (when (not (eq key 'keymap))
-(notmuch-substitute-one-command-key-with-prefix nil key)))
+(defun notmuch-describe-keymap (keymap  prefix tail)
+  "Return a list of strings, each describing one key in KEYMAP.
+
+Each string gives a human-readable description of the key and the
+first line of documentation for the bound function."
+  (map-keymap
+   (lambda (key binding)
+ (cond ((mouse-event-p key) nil)
+  ((keymapp binding)
+   (setq tail
+ (notmuch-describe-keymap
+  binding (notmuch-prefix-key-description key) tail)))
+  (t
+   (push (concat prefix (format-kbd-macro (vector key)) "\t"
+ (notmuch-documentation-first-line binding))
+ tail
+   keymap)
+  tail)

 (defun notmuch-substitute-command-keys (doc)
   "Like `substitute-command-keys' but with documentation, not function names."
   (let ((beg 0))
 (while (string-match "{\\([^}[:space:]]*\\)}" doc beg)
   (let* ((keymap-name (substring doc (match-beginning 1) (match-end 1)))
-(keymap (symbol-value (intern keymap-name
-   (setq doc (replace-match
-  (mapconcat #'notmuch-substitute-command-keys-one
- (cdr keymap) "\n")
-  1 1 doc)))
+(keymap (symbol-value (intern keymap-name)))
+(desc-list (notmuch-describe-keymap keymap))
+(desc (mapconcat #'identity desc-list "\n")))
+   (setq doc (replace-match desc 1 1 doc)))
   (setq beg (match-end 0)))
 doc))

-- 
1.7.10.4



[PATCH v2 6/9] emacs: Add unified refresh-this-buffer function

2013-09-03 Thread Austin Clements
This unifies the various refresh and poll-and-refresh functions we
have for different modes.  Now all modes bind "=" and "G" (except
show, which doesn't bind "G" for some reason) to
`notmuch-refresh-this-buffer' and
`notmuch-poll-and-refresh-this-buffer', respectively.
---
 emacs/notmuch-hello.el |   12 +++-
 emacs/notmuch-lib.el   |   20 +++-
 emacs/notmuch-show.el  |3 ++-
 emacs/notmuch.el   |   12 +++-
 4 files changed, 27 insertions(+), 20 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 94cc4b5..6a7b884 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -481,15 +481,8 @@ Such a list can be computed with 
`notmuch-hello-query-counts'."
 (defun notmuch-hello-update ( no-display)
   "Update the current notmuch view."
   ;; Lazy - rebuild everything.
-  (interactive)
   (notmuch-hello no-display))

-(defun notmuch-hello-poll-and-update ()
-  "Invoke `notmuch-poll' to import mail, then refresh the current view."
-  (interactive)
-  (notmuch-poll)
-  (notmuch-hello-update))
-
 (defun notmuch-hello-window-configuration-change ()
   "Hook function to update the hello buffer when it is switched to."
   (let ((hello-buf (get-buffer "*notmuch-hello*"))
@@ -528,8 +521,8 @@ Such a list can be computed with 
`notmuch-hello-query-counts'."
  (message "notmuch version %s" (notmuch-version
 (define-key map "?" 'notmuch-help)
 (define-key map "q" 'notmuch-kill-this-buffer)
-(define-key map "=" 'notmuch-hello-update)
-(define-key map "G" 'notmuch-hello-poll-and-update)
+(define-key map "=" 'notmuch-refresh-this-buffer)
+(define-key map "G" 'notmuch-poll-and-refresh-this-buffer)
 (define-key map (kbd "") 'widget-backward)
 (define-key map "m" 'notmuch-mua-new-mail)
 (define-key map "s" 'notmuch-search)
@@ -545,6 +538,7 @@ Complete list of currently available key bindings:
 \\{notmuch-hello-mode-map}"
  (interactive)
  (kill-all-local-variables)
+ (setq notmuch-buffer-refresh-function #'notmuch-hello-update)
  (use-local-map notmuch-hello-mode-map)
  (setq major-mode 'notmuch-hello-mode
mode-name "notmuch-hello")
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 9754e16..782badb 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -204,6 +204,25 @@ depending on the value of `notmuch-poll-script'."
   (interactive)
   (kill-buffer (current-buffer)))

+(defvar notmuch-buffer-refresh-function nil
+  "Function to call to refresh the current buffer.")
+(make-variable-buffer-local 'notmuch-buffer-refresh-function)
+
+(defun notmuch-refresh-this-buffer ()
+  "Refresh the current buffer."
+  (interactive)
+  (when notmuch-buffer-refresh-function
+(if (commandp notmuch-buffer-refresh-function)
+   ;; Pass prefix argument, etc.
+   (call-interactively notmuch-buffer-refresh-function)
+  (funcall notmuch-buffer-refresh-function
+
+(defun notmuch-poll-and-refresh-this-buffer ()
+  "Invoke `notmuch-poll' to import mail, then refresh the current buffer."
+  (interactive)
+  (notmuch-poll)
+  (notmuch-refresh-this-buffer))
+
 (defun notmuch-prettify-subject (subject)
   ;; This function is used by `notmuch-search-process-filter' which
   ;; requires that we not disrupt its' matching state.
@@ -596,7 +615,6 @@ status."
 (defvar notmuch-show-process-crypto nil)
 (make-variable-buffer-local 'notmuch-show-process-crypto)

-
 (provide 'notmuch-lib)

 ;; Local Variables:
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 82b70ba..380df66 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1279,7 +1279,7 @@ reset based on the original query."
(define-key map "w" 'notmuch-show-save-attachments)
(define-key map "V" 'notmuch-show-view-raw-message)
(define-key map "c" 'notmuch-show-stash-map)
-   (define-key map "=" 'notmuch-show-refresh-view)
+   (define-key map "=" 'notmuch-refresh-this-buffer)
(define-key map "h" 'notmuch-show-toggle-visibility-headers)
(define-key map "*" 'notmuch-show-tag-all)
(define-key map "-" 'notmuch-show-remove-tag)
@@ -1338,6 +1338,7 @@ All currently available key bindings:
 \\{notmuch-show-mode-map}"
   (interactive)
   (kill-all-local-variables)
+  (setq notmuch-buffer-refresh-function #'notmuch-show-refresh-view)
   (use-local-map notmuch-show-mode-map)
   (setq major-mode 'notmuch-show-mode
mode-name "notmuch-show")
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 82cece8..80446be 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -228,8 +228,8 @@ For a mouse binding, return nil."
 (define-key map "s" 'notmuch-search)
 (define-key map "o" 'notmuch-search-toggle-order)
 (define-key map "c" 'notmuch-search-stash-map)
-(define-key map "=" 'notmuch-search-refresh-view)
-(define-key map "G" 'notmuch-search-poll-and-refresh-view)
+(define-key map "=" 'notmuch-refresh-this-buffer)
+

[PATCH v2 5/9] emacs: Move `notmuch-poll' to notmuch-lib

2013-09-03 Thread Austin Clements
---
 emacs/notmuch-lib.el |   38 ++
 emacs/notmuch.el |   38 --
 2 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 4796f17..9754e16 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -76,6 +76,33 @@ search."
   :type 'boolean
   :group 'notmuch-search)

+(defcustom notmuch-poll-script nil
+  "An external script to incorporate new mail into the notmuch database.
+
+This variable controls the action invoked by
+`notmuch-search-poll-and-refresh-view' and
+`notmuch-hello-poll-and-update' (each have a default keybinding
+of 'G') to incorporate new mail into the notmuch database.
+
+If set to nil (the default), new mail is processed by invoking
+\"notmuch new\". Otherwise, this should be set to a string that
+gives the name of an external script that processes new mail. If
+set to the empty string, no command will be run.
+
+The external script could do any of the following depending on
+the user's needs:
+
+1. Invoke a program to transfer mail to the local mail store
+2. Invoke \"notmuch new\" to incorporate the new mail
+3. Invoke one or more \"notmuch tag\" commands to classify the mail
+
+Note that the recommended way of achieving the same is using
+\"notmuch new\" hooks."
+  :type '(choice (const :tag "notmuch new" nil)
+(const :tag "Disabled" "")
+(string :tag "Custom script"))
+  :group 'notmuch-external)
+
 ;;

 (defvar notmuch-search-history nil
@@ -161,6 +188,17 @@ Otherwise the output will be returned"
   "Return the user.other_email value (as a list) from the notmuch 
configuration."
   (split-string (notmuch-config-get "user.other_email") "\n"))

+(defun notmuch-poll ()
+  "Run \"notmuch new\" or an external script to import mail.
+
+Invokes `notmuch-poll-script', \"notmuch new\", or does nothing
+depending on the value of `notmuch-poll-script'."
+  (interactive)
+  (if (stringp notmuch-poll-script)
+  (unless (string= notmuch-poll-script "")
+   (call-process notmuch-poll-script nil nil))
+(call-process notmuch-command nil nil nil "new")))
+
 (defun notmuch-kill-this-buffer ()
   "Kill the current buffer."
   (interactive)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 00cf271..82cece8 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -959,44 +959,6 @@ same relative position within the new buffer."
 (notmuch-search query oldest-first target-thread target-line)
 (goto-char (point-min

-(defcustom notmuch-poll-script nil
-  "An external script to incorporate new mail into the notmuch database.
-
-This variable controls the action invoked by
-`notmuch-search-poll-and-refresh-view' and
-`notmuch-hello-poll-and-update' (each have a default keybinding
-of 'G') to incorporate new mail into the notmuch database.
-
-If set to nil (the default), new mail is processed by invoking
-\"notmuch new\". Otherwise, this should be set to a string that
-gives the name of an external script that processes new mail. If
-set to the empty string, no command will be run.
-
-The external script could do any of the following depending on
-the user's needs:
-
-1. Invoke a program to transfer mail to the local mail store
-2. Invoke \"notmuch new\" to incorporate the new mail
-3. Invoke one or more \"notmuch tag\" commands to classify the mail
-
-Note that the recommended way of achieving the same is using
-\"notmuch new\" hooks."
-  :type '(choice (const :tag "notmuch new" nil)
-(const :tag "Disabled" "")
-(string :tag "Custom script"))
-  :group 'notmuch-external)
-
-(defun notmuch-poll ()
-  "Run \"notmuch new\" or an external script to import mail.
-
-Invokes `notmuch-poll-script', \"notmuch new\", or does nothing
-depending on the value of `notmuch-poll-script'."
-  (interactive)
-  (if (stringp notmuch-poll-script)
-  (unless (string= notmuch-poll-script "")
-   (call-process notmuch-poll-script nil nil))
-(call-process notmuch-command nil nil nil "new")))
-
 (defun notmuch-search-poll-and-refresh-view ()
   "Invoke `notmuch-poll' to import mail, then refresh the current view."
   (interactive)
-- 
1.7.10.4



[PATCH v2 4/9] emacs: Remove notmuch-search quit continuation

2013-09-03 Thread Austin Clements
Since notmuch-hello doesn't need this any more, we can remove this
hack.  This also eliminates `notmuch-search-quit', so now all modes
bind "q" to `notmuch-kill-this-buffer'.
---
 emacs/notmuch.el |   22 +-
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index c964186..00cf271 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -213,8 +213,8 @@ For a mouse binding, return nil."
 (defvar notmuch-search-mode-map
   (let ((map (make-sparse-keymap)))
 (define-key map "?" 'notmuch-help)
-(define-key map "q" 'notmuch-search-quit)
-(define-key map "x" 'notmuch-search-quit)
+(define-key map "q" 'notmuch-kill-this-buffer)
+(define-key map "x" 'notmuch-kill-this-buffer)
 (define-key map (kbd "") 'notmuch-search-scroll-down)
 (define-key map "b" 'notmuch-search-scroll-down)
 (define-key map " " 'notmuch-search-scroll-up)
@@ -257,18 +257,9 @@ For a mouse binding, return nil."
 (defvar notmuch-search-query-string)
 (defvar notmuch-search-target-thread)
 (defvar notmuch-search-target-line)
-(defvar notmuch-search-continuation)

 (defvar notmuch-search-disjunctive-regexp  "\\<[oO][rR]\\>")

-(defun notmuch-search-quit ()
-  "Exit the search buffer, calling any defined continuation function."
-  (interactive)
-  (let ((continuation notmuch-search-continuation))
-(notmuch-kill-this-buffer)
-(when continuation
-  (funcall continuation
-
 (defun notmuch-search-scroll-up ()
   "Move forward through search results by one window's worth."
   (interactive)
@@ -412,7 +403,6 @@ Complete list of currently available key bindings:
   (make-local-variable 'notmuch-search-oldest-first)
   (make-local-variable 'notmuch-search-target-thread)
   (make-local-variable 'notmuch-search-target-line)
-  (set (make-local-variable 'notmuch-search-continuation) nil)
   (set (make-local-variable 'scroll-preserve-screen-position) t)
   (add-to-invisibility-spec (cons 'ellipsis t))
   (use-local-map notmuch-search-mode-map)
@@ -896,7 +886,7 @@ PROMPT is the string to prompt with."
  'notmuch-search-history nil nil)

 ;;;###autoload
-(defun notmuch-search ( query oldest-first target-thread target-line 
continuation)
+(defun notmuch-search ( query oldest-first target-thread target-line)
   "Run \"notmuch search\" with the given `query' and display results.

 If `query' is nil, it is read interactively from the minibuffer.
@@ -928,7 +918,6 @@ the configured default sort order."
 (set 'notmuch-search-oldest-first oldest-first)
 (set 'notmuch-search-target-thread target-thread)
 (set 'notmuch-search-target-line target-line)
-(set 'notmuch-search-continuation continuation)
 (let ((proc (get-buffer-process (current-buffer)))
  (inhibit-read-only t))
   (if proc
@@ -965,10 +954,9 @@ same relative position within the new buffer."
   (let ((target-line (line-number-at-pos))
(oldest-first notmuch-search-oldest-first)
(target-thread (notmuch-search-find-thread-id 'bare))
-   (query notmuch-search-query-string)
-   (continuation notmuch-search-continuation))
+   (query notmuch-search-query-string))
 (notmuch-kill-this-buffer)
-(notmuch-search query oldest-first target-thread target-line continuation)
+(notmuch-search query oldest-first target-thread target-line)
 (goto-char (point-min

 (defcustom notmuch-poll-script nil
-- 
1.7.10.4



[PATCH v2 3/9] emacs: Bind "s" to notmuch-search in hello-mode

2013-09-03 Thread Austin Clements
Since there is now no difference between notmuch-hello-search and
notmuch-search when called interactively, bind "s" to notmuch-search
in notmuch-hello-mode-map.  Now all modes bind "s" this way.
---
 emacs/notmuch-hello.el |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 24ac1c6..94cc4b5 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -263,7 +263,6 @@ afterwards.")
 search))

 (defun notmuch-hello-search ( search)
-  (interactive)
   (unless (null search)
 (setq search (notmuch-hello-trim search))
 (let ((history-delete-duplicates t))
@@ -533,7 +532,7 @@ Such a list can be computed with 
`notmuch-hello-query-counts'."
 (define-key map "G" 'notmuch-hello-poll-and-update)
 (define-key map (kbd "") 'widget-backward)
 (define-key map "m" 'notmuch-mua-new-mail)
-(define-key map "s" 'notmuch-hello-search)
+(define-key map "s" 'notmuch-search)
 map)
   "Keymap for \"notmuch hello\" buffers.")
 (fset 'notmuch-hello-mode-map notmuch-hello-mode-map)
-- 
1.7.10.4



[PATCH v2 2/9] emacs: Refresh hello whenever the user switches to the buffer

2013-09-03 Thread Austin Clements
Previously, we refreshed hello when the user quit a search that was
started from hello.  This is fine assuming purely stack-oriented
buffer use, but is quite fragile and requires hacks to search.

This replaces that logic with a new approach that refreshes hello
whenever the user switches to the hello buffer, regardless of how this
happens.
---
 emacs/notmuch-hello.el |   58 +++-
 1 file changed, 48 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 9db8c99..24ac1c6 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -232,6 +232,11 @@ supported for \"Customized queries section\" items."
notmuch-hello-query-section
(function :tag "Custom section"

+(defcustom notmuch-hello-auto-refresh t
+  "Automatically refresh when returning to the notmuch-hello buffer."
+  :group 'notmuch-hello
+  :type 'boolean)
+
 (defvar notmuch-hello-hidden-sections nil
   "List of sections titles whose contents are hidden")

@@ -263,8 +268,7 @@ afterwards.")
 (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))
+  (notmuch-search search notmuch-search-oldest-first))

 (defun notmuch-hello-add-saved-search (widget)
   (interactive)
@@ -322,8 +326,7 @@ diagonal."
 (defun notmuch-hello-widget-search (widget  ignore)
   (notmuch-search (widget-get widget
  :notmuch-search-terms)
- notmuch-search-oldest-first
- nil nil #'notmuch-hello-search-continuation))
+ notmuch-search-oldest-first))

 (defun notmuch-saved-search-count (search)
   (car (process-lines notmuch-command "count" search)))
@@ -476,9 +479,6 @@ Such a list can be computed with 
`notmuch-hello-query-counts'."

 (defimage notmuch-hello-logo ((:type png :file "notmuch-logo.png")))

-(defun notmuch-hello-search-continuation()
-  (notmuch-hello-update t))
-
 (defun notmuch-hello-update ( no-display)
   "Update the current notmuch view."
   ;; Lazy - rebuild everything.
@@ -491,6 +491,36 @@ Such a list can be computed with 
`notmuch-hello-query-counts'."
   (notmuch-poll)
   (notmuch-hello-update))

+(defun notmuch-hello-window-configuration-change ()
+  "Hook function to update the hello buffer when it is switched to."
+  (let ((hello-buf (get-buffer "*notmuch-hello*"))
+   (do-refresh nil))
+;; Consider all windows in the currently selected frame, since
+;; that's where the configuration change happened.  This also
+;; refreshes our snapshot of all windows, so we have to do this
+;; even if we know we won't refresh (e.g., hello-buf is null).
+(dolist (window (window-list))
+  (let ((last-buf (window-parameter window 'notmuch-hello-last-buffer))
+   (cur-buf (window-buffer window)))
+   (when (not (eq last-buf cur-buf))
+ ;; This window changed or is new.  Update recorded buffer
+ ;; for next time.
+ (set-window-parameter window 'notmuch-hello-last-buffer cur-buf)
+ (when (and (eq cur-buf hello-buf) last-buf)
+   ;; The user just switched to hello in this window (hello
+   ;; is currently visible, was not visible on the last
+   ;; configuration change, and this is not a new window)
+   (setq do-refresh t)
+(when (and do-refresh notmuch-hello-auto-refresh)
+  ;; Refresh hello as soon as we get back to redisplay.  On Emacs
+  ;; 24, we can't do it right here because something in this
+  ;; hook's call stack overrides hello's point placement.
+  (run-at-time nil nil #'notmuch-hello t))
+(when (null hello-buf)
+  ;; Clean up hook
+  (remove-hook 'window-configuration-change-hook
+  #'notmuch-hello-window-configuration-change
+

 (defvar notmuch-hello-mode-map
   (let ((map (make-sparse-keymap)))
@@ -765,9 +795,17 @@ following:
   "Run notmuch and display saved searches, known tags, etc."
   (interactive)

-  (if no-display
-  (set-buffer "*notmuch-hello*")
-(switch-to-buffer "*notmuch-hello*"))
+  ;; This may cause a window configuration change, so if the
+  ;; auto-refresh hook is already installed, avoid recursive refresh.
+  (let ((notmuch-hello-auto-refresh nil))
+(if no-display
+   (set-buffer "*notmuch-hello*")
+  (switch-to-buffer "*notmuch-hello*")))
+
+  ;; Install auto-refresh hook
+  (when notmuch-hello-auto-refresh
+(add-hook 'window-configuration-change-hook
+ #'notmuch-hello-window-configuration-change))

   (let ((target-line (line-number-at-pos))
(target-column (current-column))
-- 
1.7.10.4



[PATCH v2 1/9] emacs: Consistently use configured sort order

2013-09-03 Thread Austin Clements
Previously, if `notmuch-search' was called interactively (bound to "s"
in search and show, but not hello), it would always use newest-first.
However, `notmuch-hello-search' (bound to "s" in hello) and
`notmuch-hello-widget-search` would call it with the user-configured
sort order.  This inconsistency seems unintentional, so change
`notmuch-search' to use the user-configured sort order when called
interactively.
---
 emacs/notmuch.el |   14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f3ce840..c964186 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -906,8 +906,18 @@ Other optional parameters are used as follows:
   target-thread: A thread ID (without 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)
+   appear in the search results.
+
+When called interactively, this will prompt for a query and use
+the configured default sort order."
+  (interactive
+   (list
+;; Prompt for a query
+nil
+;; Use the default search order (if we're doing a search from a
+;; search buffer, ignore any buffer-local overrides)
+(default-value notmuch-search-oldest-first)))
+
   (let* ((query (or query (notmuch-read-query "Notmuch search: ")))
 (buffer (get-buffer-create (notmuch-search-buffer-title query
 (switch-to-buffer buffer)
-- 
1.7.10.4



[PATCH v2 0/9] emacs: Unify common key bindings and lots more

2013-09-03 Thread Austin Clements
This is v2 of id:1377793557-28878-1-git-send-email-amdragon at mit.edu.
This fixes a problem found by Jani where notmuch-hello would reset
point placement when refreshing in Emacs 24.  It also inverts the
sense of notmuch-hello-auto-refresh and makes it a defcustom
(originally I'd intended notmuch-hello-inhibit-auto-refresh for
internal use only, but both Mark and Jani expressed interest in
setting it).

The diff from v1 follows

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 1d6c3a2..55c416a 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -232,6 +232,11 @@ supported for \"Customized queries section\" items."
notmuch-hello-query-section
(function :tag "Custom section"

+(defcustom notmuch-hello-auto-refresh t
+  "Automatically refresh when returning to the notmuch-hello buffer."
+  :group 'notmuch-hello
+  :type 'boolean)
+
 (defvar notmuch-hello-hidden-sections nil
   "List of sections titles whose contents are hidden")

@@ -478,9 +483,6 @@ Such a list can be computed with 
`notmuch-hello-query-counts'."
   ;; Lazy - rebuild everything.
   (notmuch-hello no-display))

-(defvar notmuch-hello-inhibit-auto-refresh nil
-  "Don't refresh notmuch-hello on window configuration changes.")
-
 (defun notmuch-hello-window-configuration-change ()
   "Hook function to update the hello buffer when it is switched to."
   (let ((hello-buf (get-buffer "*notmuch-hello*"))
@@ -501,8 +503,11 @@ Such a list can be computed with 
`notmuch-hello-query-counts'."
;; is currently visible, was not visible on the last
;; configuration change, and this is not a new window)
(setq do-refresh t)
-(when (and do-refresh (not notmuch-hello-inhibit-auto-refresh))
-  (notmuch-hello t))
+(when (and do-refresh notmuch-hello-auto-refresh)
+  ;; Refresh hello as soon as we get back to redisplay.  On Emacs
+  ;; 24, we can't do it right here because something in this
+  ;; hook's call stack overrides hello's point placement.
+  (run-at-time nil nil #'notmuch-hello t))
 (when (null hello-buf)
   ;; Clean up hook
   (remove-hook 'window-configuration-change-hook
@@ -785,14 +790,15 @@ following:

   ;; This may cause a window configuration change, so if the
   ;; auto-refresh hook is already installed, avoid recursive refresh.
-  (let ((notmuch-hello-inhibit-auto-refresh t))
+  (let ((notmuch-hello-auto-refresh nil))
 (if no-display
(set-buffer "*notmuch-hello*")
   (switch-to-buffer "*notmuch-hello*")))

   ;; Install auto-refresh hook
-  (add-hook 'window-configuration-change-hook
-   #'notmuch-hello-window-configuration-change)
+  (when notmuch-hello-auto-refresh
+(add-hook 'window-configuration-change-hook
+ #'notmuch-hello-window-configuration-change))

   (let ((target-line (line-number-at-pos))
(target-column (current-column))



[PATCH 4/4] contrib: pick: test: buffer movement

2013-09-03 Thread Mark Walters
---
 contrib/notmuch-pick/test/emacs-pick |   40 ++
 1 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/contrib/notmuch-pick/test/emacs-pick 
b/contrib/notmuch-pick/test/emacs-pick
index 6834998..a802d0e 100755
--- a/contrib/notmuch-pick/test/emacs-pick
+++ b/contrib/notmuch-pick/test/emacs-pick
@@ -167,4 +167,44 @@ output=$(test_emacs '(add-to-list (quote load-path) 
"'$PICK_DIR'")
 (notmuch-show-stash-message-id)')
 test_expect_equal "$output" "\"Stashed: id:1258498485-sup-142 at elly\""

+test_begin_subtest "Move to next matching message"
+output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
+(require (quote notmuch-pick))
+(notmuch-pick "from:cworth")
+(notmuch-test-wait)
+(notmuch-pick-next-matching-message)
+(notmuch-show-stash-message-id)')
+test_expect_equal "$output" "\"Stashed: id:878we4qdqf.fsf at 
yoom.home.cworth.org\""
+
+test_begin_subtest "Move to next thread"
+output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
+(require (quote notmuch-pick))
+(notmuch-pick "tag:inbox")
+(notmuch-test-wait)
+(forward-line 26)
+(notmuch-pick-next-thread)
+(notmuch-show-stash-message-id)')
+test_expect_equal "$output" "\"Stashed: 
id:1258471718-6781-1-git-send-email-dottedmag at dottedmag.net\""
+
+test_begin_subtest "Move to previous thread"
+output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
+(require (quote notmuch-pick))
+(notmuch-pick "tag:inbox")
+(notmuch-test-wait)
+(forward-line 26)
+(notmuch-pick-prev-thread)
+(notmuch-show-stash-message-id)')
+test_expect_equal "$output" "\"Stashed: id:20091117190054.GU3165 at 
dottiness.seas.harvard.edu\""
+
+test_begin_subtest "Move to previous previous thread"
+output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
+(require (quote notmuch-pick))
+(notmuch-pick "tag:inbox")
+(notmuch-test-wait)
+(forward-line 26)
+(notmuch-pick-prev-thread)
+(notmuch-pick-prev-thread)
+(notmuch-show-stash-message-id)')
+test_expect_equal "$output" "\"Stashed: 
id:1258493565-13508-1-git-send-email-keithp at keithp.com\""
+
 test_done
-- 
1.7.9.1



[PATCH 3/4] contrib: pick: test: stash message id

2013-09-03 Thread Mark Walters
This is important to test as lots of subsequent tests will fail if this fails.
---
 contrib/notmuch-pick/test/emacs-pick |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/contrib/notmuch-pick/test/emacs-pick 
b/contrib/notmuch-pick/test/emacs-pick
index 91edcac..6834998 100755
--- a/contrib/notmuch-pick/test/emacs-pick
+++ b/contrib/notmuch-pick/test/emacs-pick
@@ -159,4 +159,12 @@ test_emacs '(notmuch-hello)
 cp OUTPUT /tmp/mjwout
 test_expect_equal_file OUTPUT $EXPECTED/notmuch-pick-show-window

+test_begin_subtest "Stash id"
+output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
+(require (quote notmuch-pick))
+(notmuch-pick "id:1258498485-sup-142 at elly")
+(notmuch-test-wait)
+(notmuch-show-stash-message-id)')
+test_expect_equal "$output" "\"Stashed: id:1258498485-sup-142 at elly\""
+
 test_done
-- 
1.7.9.1



[PATCH 2/4] contrib: pick: test: tag/untag whole thread

2013-09-03 Thread Mark Walters
---
 contrib/notmuch-pick/test/emacs-pick   |   39 ++
 .../notmuch-pick-tag-inbox-thread-tagged   |   53 
 2 files changed, 92 insertions(+), 0 deletions(-)
 create mode 100644 
contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-thread-tagged

diff --git a/contrib/notmuch-pick/test/emacs-pick 
b/contrib/notmuch-pick/test/emacs-pick
index 909f76a..91edcac 100755
--- a/contrib/notmuch-pick/test/emacs-pick
+++ b/contrib/notmuch-pick/test/emacs-pick
@@ -68,6 +68,45 @@ test_begin_subtest "Untag message in notmuch pick view 
(database)"
 output=$(notmuch search --output=messages 'tag:test_tag')
 test_expect_equal "$output" ""

+test_begin_subtest "Tag thread in notmuch pick view"
+test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
+   (require (quote notmuch-pick))
+   (notmuch-pick "tag:inbox")
+   (notmuch-test-wait)
+   ;; move to a sizable thread
+   (forward-line 26)
+   (notmuch-pick-tag-thread "+test_thread_tag")
+   (test-output)
+   (delete-other-windows)'
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-pick-tag-inbox-thread-tagged
+
+test_begin_subtest "Tag message in notmuch pick view (database)"
+output=$(notmuch search --output=messages 'tag:test_thread_tag')
+test_expect_equal "$output" \
+"id:87ocn0qh6d.fsf at yoom.home.cworth.org
+id:20091118005040.GA25380 at dottiness.seas.harvard.edu
+id:yunaayketfm.fsf at aiko.keithp.com
+id:87fx8can9z.fsf at vertex.dottedmag
+id:20091117203301.GV3165 at dottiness.seas.harvard.edu
+id:87iqd9rn3l.fsf at vertex.dottedmag
+id:20091117190054.GU3165 at dottiness.seas.harvard.edu"
+
+test_begin_subtest "Untag thread in notmuch pick view"
+test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
+   (require (quote notmuch-pick))
+   (notmuch-pick "tag:inbox")
+   (notmuch-test-wait)
+   ;; move to the same sizable thread as above
+   (forward-line 26)
+   (notmuch-pick-tag-thread "-test_thread_tag")
+   (test-output)
+   (delete-other-windows)'
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-pick-tag-inbox
+
+test_begin_subtest "Untag message in notmuch pick view (database)"
+output=$(notmuch search --output=messages 'tag:test_thread_tag')
+test_expect_equal "$output" ""
+
 test_begin_subtest "Navigation of notmuch-hello to search results"
 test_emacs '(notmuch-hello)
(goto-char (point-min))
diff --git 
a/contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-thread-tagged
 
b/contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-thread-tagged
new file mode 100644
index 000..a7aba6e
--- /dev/null
+++ 
b/contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-thread-tagged
@@ -0,0 +1,53 @@
+  2010-12-29  Fran?ois Boulogne ??[aur-general] Guidelines: cp, mkdir vs 
install  (inbox, unread)
+  2010-12-16  Olivier Berger??Essai accentu?   
   (inbox, unread)
+  2009-11-18  Chris Wilson  ??[notmuch] [PATCH 1/2] Makefile: evaluate 
pkg-config once (inbox, unread)
+  2009-11-18  Alex Botero-Lowry ??[notmuch] [PATCH] Error out if no query 
is supplied to searchinstead of going into an infinite loop (attachment, 
inbox, unread)
+  2009-11-18  Carl Worth???[notmuch] [PATCH] Error out if no query 
is supplied to search instead of going into an infinite loop (inbox, unread)
+  2009-11-17  Ingmar Vanhassel  ??[notmuch] [PATCH] Typsos 
   (inbox, unread)
+  2009-11-18  Carl Worth??? ...
   (inbox, unread)
+  2009-11-17  Adrian Perez de Cast  ??[notmuch] Introducing myself 
   (inbox, signed, unread)
+  2009-11-18  Keith Packard ??? ...
   (inbox, unread)
+  2009-11-18  Carl Worth??? ...
   (inbox, unread)
+  2009-11-17  Israel Herraiz??[notmuch] New to the list
   (inbox, unread)
+  2009-11-18  Keith Packard ??? ...
   (inbox, unread)
+  2009-11-18  Carl Worth??? ...
   (inbox, unread)
+  2009-11-17  Jan Janak ??[notmuch] What a great idea! 
   (inbox, unread)
+  2009-11-17  Jan Janak ??? ...
   (inbox, unread)
+  2009-11-18  Carl Worth??? ...
   (inbox, unread)
+  2009-11-17  Jan Janak ??[notmuch] [PATCH] Older versions of 
install do not support -C. (inbox, unread)
+  2009-11-18  Carl Worth??? ...
   (inbox, unread)
+  2009-11-17  Aron Griffis  ??[notmuch] archive   

[PATCH 1/4] contrib: pick: test: tag/untag single message

2013-09-03 Thread Mark Walters
---
 contrib/notmuch-pick/test/emacs-pick   |   34 +
 .../notmuch-pick-tag-inbox-tagged  |   53 
 2 files changed, 87 insertions(+), 0 deletions(-)
 create mode 100644 
contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-tagged

diff --git a/contrib/notmuch-pick/test/emacs-pick 
b/contrib/notmuch-pick/test/emacs-pick
index 37f974a..909f76a 100755
--- a/contrib/notmuch-pick/test/emacs-pick
+++ b/contrib/notmuch-pick/test/emacs-pick
@@ -34,6 +34,40 @@ test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
(delete-other-windows)'
 test_expect_equal_file OUTPUT $EXPECTED/notmuch-pick-tag-inbox

+# In the following tag tests we make sure the display is updated
+# correctly and, in a separate test, that the database is updated
+# correctly.
+
+test_begin_subtest "Tag message in notmuch pick view (display)"
+test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
+   (require (quote notmuch-pick))
+   (notmuch-pick "tag:inbox")
+   (notmuch-test-wait)
+   (forward-line)
+   (notmuch-pick-tag "+test_tag")
+   (test-output)
+   (delete-other-windows)'
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-pick-tag-inbox-tagged
+
+test_begin_subtest "Tag message in notmuch pick view (database)"
+output=$(notmuch search --output=messages 'tag:test_tag')
+test_expect_equal "$output" "id:877h1wv7mg.fsf at inf-8657.int-evry.fr"
+
+test_begin_subtest "Untag message in notmuch pick view"
+test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
+   (require (quote notmuch-pick))
+   (notmuch-pick "tag:inbox")
+   (notmuch-test-wait)
+   (forward-line)
+   (notmuch-pick-tag "-test_tag")
+   (test-output)
+   (delete-other-windows)'
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-pick-tag-inbox
+
+test_begin_subtest "Untag message in notmuch pick view (database)"
+output=$(notmuch search --output=messages 'tag:test_tag')
+test_expect_equal "$output" ""
+
 test_begin_subtest "Navigation of notmuch-hello to search results"
 test_emacs '(notmuch-hello)
(goto-char (point-min))
diff --git 
a/contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-tagged 
b/contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-tagged
new file mode 100644
index 000..1f75a34
--- /dev/null
+++ 
b/contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-tagged
@@ -0,0 +1,53 @@
+  2010-12-29  Fran?ois Boulogne ??[aur-general] Guidelines: cp, mkdir vs 
install  (inbox, unread)
+  2010-12-16  Olivier Berger??Essai accentu?   
   (inbox, test_tag, unread)
+  2009-11-18  Chris Wilson  ??[notmuch] [PATCH 1/2] Makefile: evaluate 
pkg-config once (inbox, unread)
+  2009-11-18  Alex Botero-Lowry ??[notmuch] [PATCH] Error out if no query 
is supplied to searchinstead of going into an infinite loop (attachment, 
inbox, unread)
+  2009-11-18  Carl Worth???[notmuch] [PATCH] Error out if no query 
is supplied to search instead of going into an infinite loop (inbox, unread)
+  2009-11-17  Ingmar Vanhassel  ??[notmuch] [PATCH] Typsos 
   (inbox, unread)
+  2009-11-18  Carl Worth??? ...
   (inbox, unread)
+  2009-11-17  Adrian Perez de Cast  ??[notmuch] Introducing myself 
   (inbox, signed, unread)
+  2009-11-18  Keith Packard ??? ...
   (inbox, unread)
+  2009-11-18  Carl Worth??? ...
   (inbox, unread)
+  2009-11-17  Israel Herraiz??[notmuch] New to the list
   (inbox, unread)
+  2009-11-18  Keith Packard ??? ...
   (inbox, unread)
+  2009-11-18  Carl Worth??? ...
   (inbox, unread)
+  2009-11-17  Jan Janak ??[notmuch] What a great idea! 
   (inbox, unread)
+  2009-11-17  Jan Janak ??? ...
   (inbox, unread)
+  2009-11-18  Carl Worth??? ...
   (inbox, unread)
+  2009-11-17  Jan Janak ??[notmuch] [PATCH] Older versions of 
install do not support -C. (inbox, unread)
+  2009-11-18  Carl Worth??? ...
   (inbox, unread)
+  2009-11-17  Aron Griffis  ??[notmuch] archive
   (inbox, unread)
+  2009-11-18  Keith Packard ??? ...
   (inbox, unread)
+  2009-11-18  Carl Worth ??? ...   
   (inbox, unread)
+  2009-11-17  Keith Packard 

[PATCH 0/4] contrib: pick: extra tests

2013-09-03 Thread Mark Walters
This series adds some tests for various existing and recently added
functionality.

The only thing to note is that the xapian tag database and the
displayed tags are update separately so we need to test both.

Best wishes

Mark

Mark Walters (4):
  contrib: pick: test: tag/untag single message
  contrib: pick: test: tag/untag whole thread
  contrib: pick: test: stash message id
  contrib: pick: test: buffer movement

 contrib/notmuch-pick/test/emacs-pick   |  121 
 .../notmuch-pick-tag-inbox-tagged  |   53 +
 .../notmuch-pick-tag-inbox-thread-tagged   |   53 +
 3 files changed, 227 insertions(+), 0 deletions(-)
 create mode 100644 
contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-tagged
 create mode 100644 
contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-thread-tagged

-- 
1.7.9.1



[PATCH 1/2] test: add more maildir flag syncing related tests to insert

2013-09-03 Thread Jani Nikula
On Tue, 03 Sep 2013, David Bremner  wrote:
> Jani Nikula  writes:
>>  
>> +test_begin_subtest "Insert message with default tags stays in new/"
>> +gen_insert_msg
>> +notmuch insert < "$gen_msg_filename"
>> +output=$(notmuch search --output=files id:$gen_msg_id)
>> +dirname=$(dirname "$output")
>> +test_expect_equal "$dirname" "$MAIL_DIR/new"
>
> I'm not sure if this is a bug or a feature, but this enforces a
> constraint on the default tags that notmuch ships enabled. Is that what
> we want, or would it be better to set unread explicitely here?

We already pretty heavily depend on those default tags, so I'd say just
leave it like this. If we want to fix it later, there's some other
fixing to do too. Try this patch and 'make test':

diff --git a/notmuch-config.c b/notmuch-config.c
index 6845e3c..8362c13 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -365,8 +365,8 @@ notmuch_config_open (void *ctx,
 }

 if (notmuch_config_get_new_tags (config, ) == NULL) {
-const char *tags[] = { "unread", "inbox" };
-notmuch_config_set_new_tags (config, tags, 2);
+const char *tags[] = { "flagged" };
+notmuch_config_set_new_tags (config, tags, 1);
 }

 if (notmuch_config_get_new_ignore (config, ) == NULL) {

I get:

Notmuch test suite complete.
396/579 tests passed.
183 tests failed.


BR,
Jani.


[PATCH 1/3] database: Add notmuch_database_compact_close

2013-09-03 Thread Ben Gamari
>>  void
>>  notmuch_database_destroy (notmuch_database_t *notmuch)
>>  {
>> diff --git a/lib/notmuch.h b/lib/notmuch.h
>> index 998a4ae..e9abd90 100644
>> --- a/lib/notmuch.h
>> +++ b/lib/notmuch.h
>> @@ -101,6 +101,7 @@ typedef enum _notmuch_status {
>>  NOTMUCH_STATUS_TAG_TOO_LONG,
>>  NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW,
>>  NOTMUCH_STATUS_UNBALANCED_ATOMIC,
>> +NOTMUCH_STATUS_UNSUPPORTED_OPERATION,
>>  
>>  NOTMUCH_STATUS_LAST_STATUS
>>  } notmuch_status_t;
>> @@ -215,6 +216,20 @@ notmuch_database_open (const char *path,
>>  void
>>  notmuch_database_close (notmuch_database_t *database);
>>  
>> +/* Close the given notmuch database and then compact it.
>
> The implementation first compacts then closes.
>

>> + * After notmuch_database_close_compact has been called, calls to
>> + * other functions on objects derived from this database may either
>> + * behave as if the database had not been closed (e.g., if the
>> + * required data has been cached) or may fail with a
>> + * NOTMUCH_STATUS_XAPIAN_EXCEPTION.
>> + *
>> + * notmuch_database_close_compact can be called multiple times.  Later
>> + * calls have no effect.
>
> This is not true. The Xapian compactor does not require the database to
> be open. It will happily open the database read-only and compact the
> database again if database has been closed.
>
>> + */
>> +notmuch_status_t
>> +notmuch_database_compact_close (notmuch_database_t *notmuch);
>
> I'm afraid we really need to re-think the API.
>
It seems you are right. When writing this interface it was clear that
there would be a number of opportunities for misuse. I was hoping by
combining compact and close some of these would be eliminated but
clearly this isn't enough.

> I see that your CLI 'notmuch compact' command opens the database
> read-write, I assume to ensure there are no other writers, so that stuff
> doesn't get lost. However if you pass a read-write database that has
> been modified, I believe the changes will get lost (as Xapian opens the
> database read-only). We shouldn't let the API users shoot themselves in
> the foot so easily.
>
That is correct; the read-write database was an attempt to force the
user to exclusively lock the database they are trying to compact. It
seems that things can go quite wrong[1] when a database is modified
during compaction.  There was a suggestion in that thread to add an
option to lock the database during compaction. Perhaps it might be worth
bringing this up again with Xapian upstream. I think we agree that it
would be a poor idea to merge compaction functionality without having a
mechanism for ensuring data integrity, especially since many users
invoke notmuch in a cron job.

> I think I'd go for something like:
>
> notmuch_status_t
> notmuch_database_compact (const char *path);
>
> or
>
> notmuch_status_t
> notmuch_database_compact (const char *path, const char *backup);
>
> which would internally open the database as read-write to ensure no
> modifications, compact, and close. If backup != NULL, it would save the
> old database there (same mounted file system as the database is a fine
> limitation), otherwise remove.
>
This sounds fine to me.

> Even then I'm not completely sure what Xapian WritableDatabase will do
> on close when the database has been switched underneath it. But moving
> the database after it has been closed has a race condition too.
>
Good points. Not sure what the least evil way about this is. Hopefully
Xapian's close operation really does just close file handles.

Cheers,

- Ben


[1] http://lists.xapian.org/pipermail/xapian-discuss/2011-July/008310.html
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20130903/522f0d4a/attachment-0001.pgp>


[PATCH] test: update insert tests for new maildir synchronization rules

2013-09-03 Thread Jani Nikula
On Tue, 03 Sep 2013, david at tethera.net wrote:
> From: David Bremner 
>
> As of id:1355952747-27350-4-git-send-email-sojkam1 at fel.cvut.cz
> we are more conservative about moving messages from ./new to ./cur.
> This updates the insert tests to match
> ---
>
> Hopefully this makes sense, and is not just papering over a real
> problem that should be fixed.

LGTM. I sent some additional tests on top.

Jani.



>
>  test/insert | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/test/insert b/test/insert
> index 021edb6..1718120 100755
> --- a/test/insert
> +++ b/test/insert
> @@ -82,7 +82,7 @@ gen_insert_msg
>  notmuch insert --folder=Drafts < "$gen_msg_filename"
>  output=$(notmuch search --output=files folder:Drafts)
>  dirname=$(dirname "$output")
> -test_expect_equal "$dirname" "$MAIL_DIR/Drafts/cur"
> +test_expect_equal "$dirname" "$MAIL_DIR/Drafts/new"
>  
>  test_begin_subtest "Insert message into folder, add/remove tags"
>  gen_insert_msg
> @@ -99,14 +99,14 @@ gen_insert_msg
>  notmuch insert --folder=F --create-folder +folder < "$gen_msg_filename"
>  output=$(notmuch search --output=files folder:F tag:folder)
>  basename=$(basename "$output")
> -test_expect_equal_file "$gen_msg_filename" "$MAIL_DIR/F/cur/${basename}"
> +test_expect_equal_file "$gen_msg_filename" "$MAIL_DIR/F/new/${basename}"
>  
>  test_begin_subtest "Insert message, create subfolder"
>  gen_insert_msg
>  notmuch insert --folder=F/G/H/I/J --create-folder +folder < 
> "$gen_msg_filename"
>  output=$(notmuch search --output=files folder:F/G/H/I/J tag:folder)
>  basename=$(basename "$output")
> -test_expect_equal_file "$gen_msg_filename" 
> "${MAIL_DIR}/F/G/H/I/J/cur/${basename}"
> +test_expect_equal_file "$gen_msg_filename" 
> "${MAIL_DIR}/F/G/H/I/J/new/${basename}"
>  
>  test_begin_subtest "Insert message, create existing subfolder"
>  gen_insert_msg
> -- 
> 1.8.3.2
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

-- 
Jani


[PATCH 2/2] test: improve insert test reliability by checking message-id instead of count

2013-09-03 Thread Jani Nikula
There isn't a reported issue this would fix. Spotted by reading the
test.
---
 test/insert | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/test/insert b/test/insert
index 9b448e5..550b413 100755
--- a/test/insert
+++ b/test/insert
@@ -68,14 +68,14 @@ test_expect_equal_json "$output" '["inbox", "unread"]'
 test_begin_subtest "Insert message, add tag"
 gen_insert_msg
 notmuch insert +custom < "$gen_msg_filename"
-output=$(notmuch count tag:custom)
-test_expect_equal "$output" "1"
+output=$(notmuch search --output=messages tag:custom)
+test_expect_equal "$output" "id:$gen_msg_id"

 test_begin_subtest "Insert message, add/remove tags"
 gen_insert_msg
 notmuch insert +custom -unread < "$gen_msg_filename"
-output=$(notmuch count tag:custom NOT tag:unread)
-test_expect_equal "$output" "1"
+output=$(notmuch search --output=messages tag:custom NOT tag:unread)
+test_expect_equal "$output" "id:$gen_msg_id"

 test_begin_subtest "Insert message with default tags stays in new/"
 gen_insert_msg
@@ -123,8 +123,8 @@ test_expect_equal "$dirname" "$MAIL_DIR/Drafts/new"
 test_begin_subtest "Insert message into folder, add/remove tags"
 gen_insert_msg
 notmuch insert --folder=Drafts +draft -unread < "$gen_msg_filename"
-output=$(notmuch count folder:Drafts tag:draft NOT tag:unread)
-test_expect_equal "$output" "1"
+output=$(notmuch search --output=messages folder:Drafts tag:draft NOT 
tag:unread)
+test_expect_equal "$output" "id:$gen_msg_id"

 gen_insert_msg
 test_expect_code 1 "Insert message into non-existent folder" \
-- 
1.8.4.rc3



[PATCH 1/2] test: add more maildir flag syncing related tests to insert

2013-09-03 Thread Jani Nikula
Specifically test maildir flag syncing with insert.

---

These are additional tests on top of David's fix.
---
 test/insert | 36 
 1 file changed, 36 insertions(+)

diff --git a/test/insert b/test/insert
index 1718120..9b448e5 100755
--- a/test/insert
+++ b/test/insert
@@ -77,6 +77,42 @@ notmuch insert +custom -unread < "$gen_msg_filename"
 output=$(notmuch count tag:custom NOT tag:unread)
 test_expect_equal "$output" "1"

+test_begin_subtest "Insert message with default tags stays in new/"
+gen_insert_msg
+notmuch insert < "$gen_msg_filename"
+output=$(notmuch search --output=files id:$gen_msg_id)
+dirname=$(dirname "$output")
+test_expect_equal "$dirname" "$MAIL_DIR/new"
+
+test_begin_subtest "Insert message with non-maildir synced tags stays in new/"
+gen_insert_msg
+notmuch insert +custom -inbox < "$gen_msg_filename"
+output=$(notmuch search --output=files id:$gen_msg_id)
+dirname=$(dirname "$output")
+test_expect_equal "$dirname" "$MAIL_DIR/new"
+
+test_begin_subtest "Insert message with custom new.tags goes to cur/"
+OLDCONFIG=$(notmuch config get new.tags)
+notmuch config set new.tags test
+gen_insert_msg
+notmuch insert < "$gen_msg_filename"
+output=$(notmuch search --output=files id:$gen_msg_id)
+dirname=$(dirname "$output")
+notmuch config set new.tags $OLDCONFIG
+test_expect_equal "$dirname" "$MAIL_DIR/cur"
+
+# additional check on the previous message
+test_begin_subtest "Insert message with custom new.tags actually gets the tags"
+output=$(notmuch search --output=tags id:$gen_msg_id)
+test_expect_equal "$output" "test"
+
+test_begin_subtest "Insert message with maildir synced tags goes to cur/"
+gen_insert_msg
+notmuch insert +flagged < "$gen_msg_filename"
+output=$(notmuch search --output=files id:$gen_msg_id)
+dirname=$(dirname "$output")
+test_expect_equal "$dirname" "$MAIL_DIR/cur"
+
 test_begin_subtest "Insert message into folder"
 gen_insert_msg
 notmuch insert --folder=Drafts < "$gen_msg_filename"
-- 
1.8.4.rc3



[PATCH 1/2] test: add more maildir flag syncing related tests to insert

2013-09-03 Thread David Bremner
Jani Nikula  writes:
>  
> +test_begin_subtest "Insert message with default tags stays in new/"
> +gen_insert_msg
> +notmuch insert < "$gen_msg_filename"
> +output=$(notmuch search --output=files id:$gen_msg_id)
> +dirname=$(dirname "$output")
> +test_expect_equal "$dirname" "$MAIL_DIR/new"

I'm not sure if this is a bug or a feature, but this enforces a
constraint on the default tags that notmuch ships enabled. Is that what
we want, or would it be better to set unread explicitely here?

d


[Patch v3 0/3] contrib: pick: remove an unused variable

2013-09-03 Thread David Bremner
Mark Walters  writes:

> v2 of this is at id:1377551345-27147-1-git-send-email-markwalters1009 at 
> gmail.com
>
> This is unchanged except it is rebased on top of the series
> id:1377460534-6022-1-git-send-email-markwalters1009 at gmail.com so that
> should be applied first.

pushed

d


[Patch v4 0/3] Add some thread based actions to pick

2013-09-03 Thread David Bremner
Mark Walters  writes:

> This is a rebased version of 
> id:1371195472-441-1-git-send-email-markwalters1009 at gmail.com
>
> The only other change is a new patch 3 adding previous/next thread
> commands: they are both very simple functions based on the first two
> patches.
>

I pushed this. Does it need some new tests for the new functionality?

d


Re: [Patch v4 0/3] Add some thread based actions to pick

2013-09-03 Thread David Bremner
Mark Walters markwalters1...@gmail.com writes:

 This is a rebased version of 
 id:1371195472-441-1-git-send-email-markwalters1...@gmail.com

 The only other change is a new patch 3 adding previous/next thread
 commands: they are both very simple functions based on the first two
 patches.


I pushed this. Does it need some new tests for the new functionality?

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


Re: [Patch v3 0/3] contrib: pick: remove an unused variable

2013-09-03 Thread David Bremner
Mark Walters markwalters1...@gmail.com writes:

 v2 of this is at 
 id:1377551345-27147-1-git-send-email-markwalters1...@gmail.com

 This is unchanged except it is rebased on top of the series
 id:1377460534-6022-1-git-send-email-markwalters1...@gmail.com so that
 should be applied first.

pushed

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


Re: [PATCH 1/2] test: add more maildir flag syncing related tests to insert

2013-09-03 Thread David Bremner
Jani Nikula j...@nikula.org writes:
  
 +test_begin_subtest Insert message with default tags stays in new/
 +gen_insert_msg
 +notmuch insert  $gen_msg_filename
 +output=$(notmuch search --output=files id:$gen_msg_id)
 +dirname=$(dirname $output)
 +test_expect_equal $dirname $MAIL_DIR/new

I'm not sure if this is a bug or a feature, but this enforces a
constraint on the default tags that notmuch ships enabled. Is that what
we want, or would it be better to set unread explicitely here?

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


Re: [PATCH 1/2] test: add more maildir flag syncing related tests to insert

2013-09-03 Thread Jani Nikula
On Tue, 03 Sep 2013, David Bremner da...@tethera.net wrote:
 Jani Nikula j...@nikula.org writes:
  
 +test_begin_subtest Insert message with default tags stays in new/
 +gen_insert_msg
 +notmuch insert  $gen_msg_filename
 +output=$(notmuch search --output=files id:$gen_msg_id)
 +dirname=$(dirname $output)
 +test_expect_equal $dirname $MAIL_DIR/new

 I'm not sure if this is a bug or a feature, but this enforces a
 constraint on the default tags that notmuch ships enabled. Is that what
 we want, or would it be better to set unread explicitely here?

We already pretty heavily depend on those default tags, so I'd say just
leave it like this. If we want to fix it later, there's some other
fixing to do too. Try this patch and 'make test':

diff --git a/notmuch-config.c b/notmuch-config.c
index 6845e3c..8362c13 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -365,8 +365,8 @@ notmuch_config_open (void *ctx,
 }
 
 if (notmuch_config_get_new_tags (config, tmp) == NULL) {
-const char *tags[] = { unread, inbox };
-notmuch_config_set_new_tags (config, tags, 2);
+const char *tags[] = { flagged };
+notmuch_config_set_new_tags (config, tags, 1);
 }
 
 if (notmuch_config_get_new_ignore (config, tmp) == NULL) {

I get:

Notmuch test suite complete.
396/579 tests passed.
183 tests failed.


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


[PATCH 1/4] contrib: pick: test: tag/untag single message

2013-09-03 Thread Mark Walters
---
 contrib/notmuch-pick/test/emacs-pick   |   34 +
 .../notmuch-pick-tag-inbox-tagged  |   53 
 2 files changed, 87 insertions(+), 0 deletions(-)
 create mode 100644 
contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-tagged

diff --git a/contrib/notmuch-pick/test/emacs-pick 
b/contrib/notmuch-pick/test/emacs-pick
index 37f974a..909f76a 100755
--- a/contrib/notmuch-pick/test/emacs-pick
+++ b/contrib/notmuch-pick/test/emacs-pick
@@ -34,6 +34,40 @@ test_emacs '(add-to-list (quote load-path) '$PICK_DIR')
(delete-other-windows)'
 test_expect_equal_file OUTPUT $EXPECTED/notmuch-pick-tag-inbox
 
+# In the following tag tests we make sure the display is updated
+# correctly and, in a separate test, that the database is updated
+# correctly.
+
+test_begin_subtest Tag message in notmuch pick view (display)
+test_emacs '(add-to-list (quote load-path) '$PICK_DIR')
+   (require (quote notmuch-pick))
+   (notmuch-pick tag:inbox)
+   (notmuch-test-wait)
+   (forward-line)
+   (notmuch-pick-tag +test_tag)
+   (test-output)
+   (delete-other-windows)'
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-pick-tag-inbox-tagged
+
+test_begin_subtest Tag message in notmuch pick view (database)
+output=$(notmuch search --output=messages 'tag:test_tag')
+test_expect_equal $output id:877h1wv7mg@inf-8657.int-evry.fr
+
+test_begin_subtest Untag message in notmuch pick view
+test_emacs '(add-to-list (quote load-path) '$PICK_DIR')
+   (require (quote notmuch-pick))
+   (notmuch-pick tag:inbox)
+   (notmuch-test-wait)
+   (forward-line)
+   (notmuch-pick-tag -test_tag)
+   (test-output)
+   (delete-other-windows)'
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-pick-tag-inbox
+
+test_begin_subtest Untag message in notmuch pick view (database)
+output=$(notmuch search --output=messages 'tag:test_tag')
+test_expect_equal $output 
+
 test_begin_subtest Navigation of notmuch-hello to search results
 test_emacs '(notmuch-hello)
(goto-char (point-min))
diff --git 
a/contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-tagged 
b/contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-tagged
new file mode 100644
index 000..1f75a34
--- /dev/null
+++ 
b/contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-tagged
@@ -0,0 +1,53 @@
+  2010-12-29  François Boulogne ─►[aur-general] Guidelines: cp, mkdir vs 
install  (inbox, unread)
+  2010-12-16  Olivier Berger─►Essai accentué   
   (inbox, test_tag, unread)
+  2009-11-18  Chris Wilson  ─►[notmuch] [PATCH 1/2] Makefile: evaluate 
pkg-config once (inbox, unread)
+  2009-11-18  Alex Botero-Lowry ┬►[notmuch] [PATCH] Error out if no query 
is supplied to searchinstead of going into an infinite loop (attachment, 
inbox, unread)
+  2009-11-18  Carl Worth╰─►[notmuch] [PATCH] Error out if no query 
is supplied to search instead of going into an infinite loop (inbox, unread)
+  2009-11-17  Ingmar Vanhassel  ┬►[notmuch] [PATCH] Typsos 
   (inbox, unread)
+  2009-11-18  Carl Worth╰─► ...
   (inbox, unread)
+  2009-11-17  Adrian Perez de Cast  ┬►[notmuch] Introducing myself 
   (inbox, signed, unread)
+  2009-11-18  Keith Packard ├─► ...
   (inbox, unread)
+  2009-11-18  Carl Worth╰─► ...
   (inbox, unread)
+  2009-11-17  Israel Herraiz┬►[notmuch] New to the list
   (inbox, unread)
+  2009-11-18  Keith Packard ├─► ...
   (inbox, unread)
+  2009-11-18  Carl Worth╰─► ...
   (inbox, unread)
+  2009-11-17  Jan Janak ┬►[notmuch] What a great idea! 
   (inbox, unread)
+  2009-11-17  Jan Janak ├─► ...
   (inbox, unread)
+  2009-11-18  Carl Worth╰─► ...
   (inbox, unread)
+  2009-11-17  Jan Janak ┬►[notmuch] [PATCH] Older versions of 
install do not support -C. (inbox, unread)
+  2009-11-18  Carl Worth╰─► ...
   (inbox, unread)
+  2009-11-17  Aron Griffis  ┬►[notmuch] archive
   (inbox, unread)
+  2009-11-18  Keith Packard ╰┬► ...
   (inbox, unread)
+  2009-11-18  Carl Worth ╰─► ...   
   (inbox, unread)
+  2009-11-17  Keith Packard ┬►[notmuch] [PATCH] Make notmuch-show 'X' 

[PATCH 3/4] contrib: pick: test: stash message id

2013-09-03 Thread Mark Walters
This is important to test as lots of subsequent tests will fail if this fails.
---
 contrib/notmuch-pick/test/emacs-pick |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/contrib/notmuch-pick/test/emacs-pick 
b/contrib/notmuch-pick/test/emacs-pick
index 91edcac..6834998 100755
--- a/contrib/notmuch-pick/test/emacs-pick
+++ b/contrib/notmuch-pick/test/emacs-pick
@@ -159,4 +159,12 @@ test_emacs '(notmuch-hello)
 cp OUTPUT /tmp/mjwout
 test_expect_equal_file OUTPUT $EXPECTED/notmuch-pick-show-window
 
+test_begin_subtest Stash id
+output=$(test_emacs '(add-to-list (quote load-path) '$PICK_DIR')
+(require (quote notmuch-pick))
+(notmuch-pick id:1258498485-sup-142@elly)
+(notmuch-test-wait)
+(notmuch-show-stash-message-id)')
+test_expect_equal $output \Stashed: id:1258498485-sup-142@elly\
+
 test_done
-- 
1.7.9.1

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


[PATCH 0/4] contrib: pick: extra tests

2013-09-03 Thread Mark Walters
This series adds some tests for various existing and recently added
functionality.

The only thing to note is that the xapian tag database and the
displayed tags are update separately so we need to test both.

Best wishes

Mark

Mark Walters (4):
  contrib: pick: test: tag/untag single message
  contrib: pick: test: tag/untag whole thread
  contrib: pick: test: stash message id
  contrib: pick: test: buffer movement

 contrib/notmuch-pick/test/emacs-pick   |  121 
 .../notmuch-pick-tag-inbox-tagged  |   53 +
 .../notmuch-pick-tag-inbox-thread-tagged   |   53 +
 3 files changed, 227 insertions(+), 0 deletions(-)
 create mode 100644 
contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-tagged
 create mode 100644 
contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-thread-tagged

-- 
1.7.9.1

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


[PATCH 2/4] contrib: pick: test: tag/untag whole thread

2013-09-03 Thread Mark Walters
---
 contrib/notmuch-pick/test/emacs-pick   |   39 ++
 .../notmuch-pick-tag-inbox-thread-tagged   |   53 
 2 files changed, 92 insertions(+), 0 deletions(-)
 create mode 100644 
contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-thread-tagged

diff --git a/contrib/notmuch-pick/test/emacs-pick 
b/contrib/notmuch-pick/test/emacs-pick
index 909f76a..91edcac 100755
--- a/contrib/notmuch-pick/test/emacs-pick
+++ b/contrib/notmuch-pick/test/emacs-pick
@@ -68,6 +68,45 @@ test_begin_subtest Untag message in notmuch pick view 
(database)
 output=$(notmuch search --output=messages 'tag:test_tag')
 test_expect_equal $output 
 
+test_begin_subtest Tag thread in notmuch pick view
+test_emacs '(add-to-list (quote load-path) '$PICK_DIR')
+   (require (quote notmuch-pick))
+   (notmuch-pick tag:inbox)
+   (notmuch-test-wait)
+   ;; move to a sizable thread
+   (forward-line 26)
+   (notmuch-pick-tag-thread +test_thread_tag)
+   (test-output)
+   (delete-other-windows)'
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-pick-tag-inbox-thread-tagged
+
+test_begin_subtest Tag message in notmuch pick view (database)
+output=$(notmuch search --output=messages 'tag:test_thread_tag')
+test_expect_equal $output \
+id:87ocn0qh6d@yoom.home.cworth.org
+id:20091118005040.ga25...@dottiness.seas.harvard.edu
+id:yunaayketfm@aiko.keithp.com
+id:87fx8can9z.fsf@vertex.dottedmag
+id:20091117203301.gv3...@dottiness.seas.harvard.edu
+id:87iqd9rn3l.fsf@vertex.dottedmag
+id:20091117190054.gu3...@dottiness.seas.harvard.edu
+
+test_begin_subtest Untag thread in notmuch pick view
+test_emacs '(add-to-list (quote load-path) '$PICK_DIR')
+   (require (quote notmuch-pick))
+   (notmuch-pick tag:inbox)
+   (notmuch-test-wait)
+   ;; move to the same sizable thread as above
+   (forward-line 26)
+   (notmuch-pick-tag-thread -test_thread_tag)
+   (test-output)
+   (delete-other-windows)'
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-pick-tag-inbox
+
+test_begin_subtest Untag message in notmuch pick view (database)
+output=$(notmuch search --output=messages 'tag:test_thread_tag')
+test_expect_equal $output 
+
 test_begin_subtest Navigation of notmuch-hello to search results
 test_emacs '(notmuch-hello)
(goto-char (point-min))
diff --git 
a/contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-thread-tagged
 
b/contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-thread-tagged
new file mode 100644
index 000..a7aba6e
--- /dev/null
+++ 
b/contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-thread-tagged
@@ -0,0 +1,53 @@
+  2010-12-29  François Boulogne ─►[aur-general] Guidelines: cp, mkdir vs 
install  (inbox, unread)
+  2010-12-16  Olivier Berger─►Essai accentué   
   (inbox, unread)
+  2009-11-18  Chris Wilson  ─►[notmuch] [PATCH 1/2] Makefile: evaluate 
pkg-config once (inbox, unread)
+  2009-11-18  Alex Botero-Lowry ┬►[notmuch] [PATCH] Error out if no query 
is supplied to searchinstead of going into an infinite loop (attachment, 
inbox, unread)
+  2009-11-18  Carl Worth╰─►[notmuch] [PATCH] Error out if no query 
is supplied to search instead of going into an infinite loop (inbox, unread)
+  2009-11-17  Ingmar Vanhassel  ┬►[notmuch] [PATCH] Typsos 
   (inbox, unread)
+  2009-11-18  Carl Worth╰─► ...
   (inbox, unread)
+  2009-11-17  Adrian Perez de Cast  ┬►[notmuch] Introducing myself 
   (inbox, signed, unread)
+  2009-11-18  Keith Packard ├─► ...
   (inbox, unread)
+  2009-11-18  Carl Worth╰─► ...
   (inbox, unread)
+  2009-11-17  Israel Herraiz┬►[notmuch] New to the list
   (inbox, unread)
+  2009-11-18  Keith Packard ├─► ...
   (inbox, unread)
+  2009-11-18  Carl Worth╰─► ...
   (inbox, unread)
+  2009-11-17  Jan Janak ┬►[notmuch] What a great idea! 
   (inbox, unread)
+  2009-11-17  Jan Janak ├─► ...
   (inbox, unread)
+  2009-11-18  Carl Worth╰─► ...
   (inbox, unread)
+  2009-11-17  Jan Janak ┬►[notmuch] [PATCH] Older versions of 
install do not support -C. (inbox, unread)
+  2009-11-18  Carl Worth╰─► ...
   (inbox, unread)
+  2009-11-17  Aron Griffis  ┬►[notmuch] archive
   (inbox, unread)
+  2009-11-18  

[PATCH 4/4] contrib: pick: test: buffer movement

2013-09-03 Thread Mark Walters
---
 contrib/notmuch-pick/test/emacs-pick |   40 ++
 1 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/contrib/notmuch-pick/test/emacs-pick 
b/contrib/notmuch-pick/test/emacs-pick
index 6834998..a802d0e 100755
--- a/contrib/notmuch-pick/test/emacs-pick
+++ b/contrib/notmuch-pick/test/emacs-pick
@@ -167,4 +167,44 @@ output=$(test_emacs '(add-to-list (quote load-path) 
'$PICK_DIR')
 (notmuch-show-stash-message-id)')
 test_expect_equal $output \Stashed: id:1258498485-sup-142@elly\
 
+test_begin_subtest Move to next matching message
+output=$(test_emacs '(add-to-list (quote load-path) '$PICK_DIR')
+(require (quote notmuch-pick))
+(notmuch-pick from:cworth)
+(notmuch-test-wait)
+(notmuch-pick-next-matching-message)
+(notmuch-show-stash-message-id)')
+test_expect_equal $output \Stashed: 
id:878we4qdqf@yoom.home.cworth.org\
+
+test_begin_subtest Move to next thread
+output=$(test_emacs '(add-to-list (quote load-path) '$PICK_DIR')
+(require (quote notmuch-pick))
+(notmuch-pick tag:inbox)
+(notmuch-test-wait)
+(forward-line 26)
+(notmuch-pick-next-thread)
+(notmuch-show-stash-message-id)')
+test_expect_equal $output \Stashed: 
id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net\
+
+test_begin_subtest Move to previous thread
+output=$(test_emacs '(add-to-list (quote load-path) '$PICK_DIR')
+(require (quote notmuch-pick))
+(notmuch-pick tag:inbox)
+(notmuch-test-wait)
+(forward-line 26)
+(notmuch-pick-prev-thread)
+(notmuch-show-stash-message-id)')
+test_expect_equal $output \Stashed: 
id:20091117190054.gu3...@dottiness.seas.harvard.edu\
+
+test_begin_subtest Move to previous previous thread
+output=$(test_emacs '(add-to-list (quote load-path) '$PICK_DIR')
+(require (quote notmuch-pick))
+(notmuch-pick tag:inbox)
+(notmuch-test-wait)
+(forward-line 26)
+(notmuch-pick-prev-thread)
+(notmuch-pick-prev-thread)
+(notmuch-show-stash-message-id)')
+test_expect_equal $output \Stashed: 
id:1258493565-13508-1-git-send-email-kei...@keithp.com\
+
 test_done
-- 
1.7.9.1

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


Re: [PATCH 1/3] database: Add notmuch_database_compact_close

2013-09-03 Thread Ben Gamari
Jani Nikula j...@nikula.org writes:

 On Sat, 24 Aug 2013, Ben Gamari bgamari.f...@gmail.com wrote:
 This function uses Xapian's Compactor machinery to compact the notmuch
 database. The compacted database is built in a temporary directory and
 later moved into place while the original uncompacted database is
 preserved.


snip

  
 +class NotmuchCompactor : public Xapian::Compactor
 +{
 +public:
 +virtual void
 +set_status (const std::string table, const std::string status)
 +{
 +if (status.length() == 0)
 +printf (compacting table %s:\n, table.c_str());
 +else
 +printf ( %s\n, status.c_str());
 +}

 We're trying to reduce the amount of prints directly from libnotmuch,
 not increase. This applies here as well as below.

Fair enough. That being said, I think that status updates are fairly
important given that the compaction process can be rather long.  Would
the preferred interface be to provide notmuch_database_compact_close
with a progress callback?

 +};
 +
 +#if HAVE_XAPIAN_COMPACT
 +notmuch_status_t
 +notmuch_database_compact_close (notmuch_database_t *notmuch)
 +{
 +void *local = talloc_new (NULL);
 +NotmuchCompactor compactor;
 +char *notmuch_path, *xapian_path, *compact_xapian_path, 
 *old_xapian_path;
 +notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
 +
 +if (! (notmuch_path = talloc_asprintf (local, %s/%s, notmuch-path, 
 .notmuch))) {
 +ret = NOTMUCH_STATUS_OUT_OF_MEMORY;
 +goto DONE;
 +}
 +
 +if (! (xapian_path = talloc_asprintf (local, %s/%s, notmuch_path, 
 xapian))) {
 +ret = NOTMUCH_STATUS_OUT_OF_MEMORY;
 +goto DONE;
 +}
 +
 +if (! (compact_xapian_path = talloc_asprintf (local, %s.compact, 
 xapian_path))) {
 +ret = NOTMUCH_STATUS_OUT_OF_MEMORY;
 +goto DONE;
 +}
 +
 +if (! (old_xapian_path = talloc_asprintf (local, %s.old, 
 xapian_path))) {
 +ret = NOTMUCH_STATUS_OUT_OF_MEMORY;
 +goto DONE;
 +}
 +
 +try {
 +compactor.set_renumber(false);
 +compactor.add_source(xapian_path);
 +compactor.set_destdir(compact_xapian_path);
 +compactor.compact();
 +
 +if (rename(xapian_path, old_xapian_path)) {
 +fprintf (stderr, Error moving old database out of the way\n);
 +ret = NOTMUCH_STATUS_FILE_ERROR;
 +goto DONE;
 +}

 This fails if old_xapian_path exists.

Ouch, yes, you are right. I suspect the right way forward here will be
to check whether old_xapian_path exists before beginning compaction,
allowing the user to fix the situation before it fails after finishing
what might be a pretty long process.

 +
 +if (rename(compact_xapian_path, xapian_path)) {
 +fprintf (stderr, Error moving compacted database\n);
 +ret = NOTMUCH_STATUS_FILE_ERROR;
 +goto DONE;
 +}
 +} catch (Xapian::InvalidArgumentError e) {
 +fprintf (stderr, Error while compacting: %s, e.get_msg().c_str());
 +ret = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
 +goto DONE;
 +}
 +
 +fprintf (stderr, \n);
 +fprintf (stderr, \n);
 +fprintf (stderr, Old database has been moved to %s, old_xapian_path);
 +fprintf (stderr, \n);
 +fprintf (stderr, To delete run,\n);
 +fprintf (stderr, \n);
 +fprintf (stderr, rm -R %s\n, old_xapian_path);
 +fprintf (stderr, \n);
 +
 +notmuch_database_close(notmuch);
 +
 +DONE:
 +talloc_free(local);

 The database does not get closed on errors. If that's intentional, it
 should be documented.

I had reasons for this but they have long fled my memory. Regardless of
what it does, this behavior should be documented. I'll take care of this.

 +return ret;
 +}
 +#else
 +notmuch_status_t
 +notmuch_database_compact_close (unused (notmuch_database_t *notmuch))
 +{
 +fprintf (stderr, notmuch was compiled against a xapian version lacking 
 compaction support.\n);
 +return NOTMUCH_STATUS_UNSUPPORTED_OPERATION;
 +}
 +#endif
 +
  void
  notmuch_database_destroy (notmuch_database_t *notmuch)
  {
 diff --git a/lib/notmuch.h b/lib/notmuch.h
 index 998a4ae..e9abd90 100644
 --- a/lib/notmuch.h
 +++ b/lib/notmuch.h
 @@ -101,6 +101,7 @@ typedef enum _notmuch_status {
  NOTMUCH_STATUS_TAG_TOO_LONG,
  NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW,
  NOTMUCH_STATUS_UNBALANCED_ATOMIC,
 +NOTMUCH_STATUS_UNSUPPORTED_OPERATION,
  
  NOTMUCH_STATUS_LAST_STATUS
  } notmuch_status_t;
 @@ -215,6 +216,20 @@ notmuch_database_open (const char *path,
  void
  notmuch_database_close (notmuch_database_t *database);
  
 +/* Close the given notmuch database and then compact it.

 The implementation first compacts then closes.


 + * After notmuch_database_close_compact has been called, calls to
 + * other functions on objects derived from this database may either
 + * behave as if the database had not been closed (e.g., if the
 + * required data has been cached) or may fail with a
 + * NOTMUCH_STATUS_XAPIAN_EXCEPTION.
 + *
 + * notmuch_database_close_compact can be called 

Re: [PATCH 0/4] contrib: pick: extra tests

2013-09-03 Thread Tomi Ollila
On Tue, Sep 03 2013, Mark Walters markwalters1...@gmail.com wrote:

 This series adds some tests for various existing and recently added
 functionality.

 The only thing to note is that the xapian tag database and the
 displayed tags are update separately so we need to test both.

Looks good (afaiu), tests pass

 Best wishes

 Mark

Tomi


 Mark Walters (4):
   contrib: pick: test: tag/untag single message
   contrib: pick: test: tag/untag whole thread
   contrib: pick: test: stash message id
   contrib: pick: test: buffer movement

  contrib/notmuch-pick/test/emacs-pick   |  121 
 
  .../notmuch-pick-tag-inbox-tagged  |   53 +
  .../notmuch-pick-tag-inbox-thread-tagged   |   53 +
  3 files changed, 227 insertions(+), 0 deletions(-)
  create mode 100644 
 contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-tagged
  create mode 100644 
 contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox-thread-tagged

 -- 
 1.7.9.1

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


-- 
kaik on mänt!
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 0/2] emacs: simplify and cleanup notmuch-mua-reply

2013-09-03 Thread Tomi Ollila
On Wed, Aug 28 2013, Jani Nikula j...@nikula.org wrote:

 This is an alternative to [1]. I tried to dig through history, and I
 couldn't find a decent reason for having the backwards regexp in place.

I played a bit with this and this works fine. Looks good  tests pass. +1


 BR,
 Jani.

Tomi



 [1] id:1375961732-14327-1-git-send-email-geoffrey.ferr...@oriel.oxon.org


 Jani Nikula (2):
   emacs: simplify point placement for inserting message body on reply
   emacs: slightly cleanup the reply code

  emacs/notmuch-mua.el |   45 -
  1 file changed, 20 insertions(+), 25 deletions(-)

 -- 
 1.7.10.4

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


-- 
kaik on mänt!
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v2 4/9] emacs: Remove notmuch-search quit continuation

2013-09-03 Thread Austin Clements
Since notmuch-hello doesn't need this any more, we can remove this
hack.  This also eliminates `notmuch-search-quit', so now all modes
bind q to `notmuch-kill-this-buffer'.
---
 emacs/notmuch.el |   22 +-
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index c964186..00cf271 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -213,8 +213,8 @@ For a mouse binding, return nil.
 (defvar notmuch-search-mode-map
   (let ((map (make-sparse-keymap)))
 (define-key map ? 'notmuch-help)
-(define-key map q 'notmuch-search-quit)
-(define-key map x 'notmuch-search-quit)
+(define-key map q 'notmuch-kill-this-buffer)
+(define-key map x 'notmuch-kill-this-buffer)
 (define-key map (kbd DEL) 'notmuch-search-scroll-down)
 (define-key map b 'notmuch-search-scroll-down)
 (define-key map   'notmuch-search-scroll-up)
@@ -257,18 +257,9 @@ For a mouse binding, return nil.
 (defvar notmuch-search-query-string)
 (defvar notmuch-search-target-thread)
 (defvar notmuch-search-target-line)
-(defvar notmuch-search-continuation)
 
 (defvar notmuch-search-disjunctive-regexp  \\[oO][rR]\\)
 
-(defun notmuch-search-quit ()
-  Exit the search buffer, calling any defined continuation function.
-  (interactive)
-  (let ((continuation notmuch-search-continuation))
-(notmuch-kill-this-buffer)
-(when continuation
-  (funcall continuation
-
 (defun notmuch-search-scroll-up ()
   Move forward through search results by one window's worth.
   (interactive)
@@ -412,7 +403,6 @@ Complete list of currently available key bindings:
   (make-local-variable 'notmuch-search-oldest-first)
   (make-local-variable 'notmuch-search-target-thread)
   (make-local-variable 'notmuch-search-target-line)
-  (set (make-local-variable 'notmuch-search-continuation) nil)
   (set (make-local-variable 'scroll-preserve-screen-position) t)
   (add-to-invisibility-spec (cons 'ellipsis t))
   (use-local-map notmuch-search-mode-map)
@@ -896,7 +886,7 @@ PROMPT is the string to prompt with.
  'notmuch-search-history nil nil)
 
 ;;;###autoload
-(defun notmuch-search (optional query oldest-first target-thread target-line 
continuation)
+(defun notmuch-search (optional query oldest-first target-thread target-line)
   Run \notmuch search\ with the given `query' and display results.
 
 If `query' is nil, it is read interactively from the minibuffer.
@@ -928,7 +918,6 @@ the configured default sort order.
 (set 'notmuch-search-oldest-first oldest-first)
 (set 'notmuch-search-target-thread target-thread)
 (set 'notmuch-search-target-line target-line)
-(set 'notmuch-search-continuation continuation)
 (let ((proc (get-buffer-process (current-buffer)))
  (inhibit-read-only t))
   (if proc
@@ -965,10 +954,9 @@ same relative position within the new buffer.
   (let ((target-line (line-number-at-pos))
(oldest-first notmuch-search-oldest-first)
(target-thread (notmuch-search-find-thread-id 'bare))
-   (query notmuch-search-query-string)
-   (continuation notmuch-search-continuation))
+   (query notmuch-search-query-string))
 (notmuch-kill-this-buffer)
-(notmuch-search query oldest-first target-thread target-line continuation)
+(notmuch-search query oldest-first target-thread target-line)
 (goto-char (point-min
 
 (defcustom notmuch-poll-script nil
-- 
1.7.10.4

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


[PATCH v2 2/9] emacs: Refresh hello whenever the user switches to the buffer

2013-09-03 Thread Austin Clements
Previously, we refreshed hello when the user quit a search that was
started from hello.  This is fine assuming purely stack-oriented
buffer use, but is quite fragile and requires hacks to search.

This replaces that logic with a new approach that refreshes hello
whenever the user switches to the hello buffer, regardless of how this
happens.
---
 emacs/notmuch-hello.el |   58 +++-
 1 file changed, 48 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 9db8c99..24ac1c6 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -232,6 +232,11 @@ supported for \Customized queries section\ items.
notmuch-hello-query-section
(function :tag Custom section
 
+(defcustom notmuch-hello-auto-refresh t
+  Automatically refresh when returning to the notmuch-hello buffer.
+  :group 'notmuch-hello
+  :type 'boolean)
+
 (defvar notmuch-hello-hidden-sections nil
   List of sections titles whose contents are hidden)
 
@@ -263,8 +268,7 @@ afterwards.)
 (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))
+  (notmuch-search search notmuch-search-oldest-first))
 
 (defun notmuch-hello-add-saved-search (widget)
   (interactive)
@@ -322,8 +326,7 @@ diagonal.
 (defun notmuch-hello-widget-search (widget rest ignore)
   (notmuch-search (widget-get widget
  :notmuch-search-terms)
- notmuch-search-oldest-first
- nil nil #'notmuch-hello-search-continuation))
+ notmuch-search-oldest-first))
 
 (defun notmuch-saved-search-count (search)
   (car (process-lines notmuch-command count search)))
@@ -476,9 +479,6 @@ Such a list can be computed with 
`notmuch-hello-query-counts'.
 
 (defimage notmuch-hello-logo ((:type png :file notmuch-logo.png)))
 
-(defun notmuch-hello-search-continuation()
-  (notmuch-hello-update t))
-
 (defun notmuch-hello-update (optional no-display)
   Update the current notmuch view.
   ;; Lazy - rebuild everything.
@@ -491,6 +491,36 @@ Such a list can be computed with 
`notmuch-hello-query-counts'.
   (notmuch-poll)
   (notmuch-hello-update))
 
+(defun notmuch-hello-window-configuration-change ()
+  Hook function to update the hello buffer when it is switched to.
+  (let ((hello-buf (get-buffer *notmuch-hello*))
+   (do-refresh nil))
+;; Consider all windows in the currently selected frame, since
+;; that's where the configuration change happened.  This also
+;; refreshes our snapshot of all windows, so we have to do this
+;; even if we know we won't refresh (e.g., hello-buf is null).
+(dolist (window (window-list))
+  (let ((last-buf (window-parameter window 'notmuch-hello-last-buffer))
+   (cur-buf (window-buffer window)))
+   (when (not (eq last-buf cur-buf))
+ ;; This window changed or is new.  Update recorded buffer
+ ;; for next time.
+ (set-window-parameter window 'notmuch-hello-last-buffer cur-buf)
+ (when (and (eq cur-buf hello-buf) last-buf)
+   ;; The user just switched to hello in this window (hello
+   ;; is currently visible, was not visible on the last
+   ;; configuration change, and this is not a new window)
+   (setq do-refresh t)
+(when (and do-refresh notmuch-hello-auto-refresh)
+  ;; Refresh hello as soon as we get back to redisplay.  On Emacs
+  ;; 24, we can't do it right here because something in this
+  ;; hook's call stack overrides hello's point placement.
+  (run-at-time nil nil #'notmuch-hello t))
+(when (null hello-buf)
+  ;; Clean up hook
+  (remove-hook 'window-configuration-change-hook
+  #'notmuch-hello-window-configuration-change
+
 
 (defvar notmuch-hello-mode-map
   (let ((map (make-sparse-keymap)))
@@ -765,9 +795,17 @@ following:
   Run notmuch and display saved searches, known tags, etc.
   (interactive)
 
-  (if no-display
-  (set-buffer *notmuch-hello*)
-(switch-to-buffer *notmuch-hello*))
+  ;; This may cause a window configuration change, so if the
+  ;; auto-refresh hook is already installed, avoid recursive refresh.
+  (let ((notmuch-hello-auto-refresh nil))
+(if no-display
+   (set-buffer *notmuch-hello*)
+  (switch-to-buffer *notmuch-hello*)))
+
+  ;; Install auto-refresh hook
+  (when notmuch-hello-auto-refresh
+(add-hook 'window-configuration-change-hook
+ #'notmuch-hello-window-configuration-change))
 
   (let ((target-line (line-number-at-pos))
(target-column (current-column))
-- 
1.7.10.4

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


[PATCH v2 3/9] emacs: Bind s to notmuch-search in hello-mode

2013-09-03 Thread Austin Clements
Since there is now no difference between notmuch-hello-search and
notmuch-search when called interactively, bind s to notmuch-search
in notmuch-hello-mode-map.  Now all modes bind s this way.
---
 emacs/notmuch-hello.el |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 24ac1c6..94cc4b5 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -263,7 +263,6 @@ afterwards.)
 search))
 
 (defun notmuch-hello-search (optional search)
-  (interactive)
   (unless (null search)
 (setq search (notmuch-hello-trim search))
 (let ((history-delete-duplicates t))
@@ -533,7 +532,7 @@ Such a list can be computed with 
`notmuch-hello-query-counts'.
 (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-search)
+(define-key map s 'notmuch-search)
 map)
   Keymap for \notmuch hello\ buffers.)
 (fset 'notmuch-hello-mode-map notmuch-hello-mode-map)
-- 
1.7.10.4

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


[PATCH v2 6/9] emacs: Add unified refresh-this-buffer function

2013-09-03 Thread Austin Clements
This unifies the various refresh and poll-and-refresh functions we
have for different modes.  Now all modes bind = and G (except
show, which doesn't bind G for some reason) to
`notmuch-refresh-this-buffer' and
`notmuch-poll-and-refresh-this-buffer', respectively.
---
 emacs/notmuch-hello.el |   12 +++-
 emacs/notmuch-lib.el   |   20 +++-
 emacs/notmuch-show.el  |3 ++-
 emacs/notmuch.el   |   12 +++-
 4 files changed, 27 insertions(+), 20 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 94cc4b5..6a7b884 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -481,15 +481,8 @@ Such a list can be computed with 
`notmuch-hello-query-counts'.
 (defun notmuch-hello-update (optional no-display)
   Update the current notmuch view.
   ;; Lazy - rebuild everything.
-  (interactive)
   (notmuch-hello no-display))
 
-(defun notmuch-hello-poll-and-update ()
-  Invoke `notmuch-poll' to import mail, then refresh the current view.
-  (interactive)
-  (notmuch-poll)
-  (notmuch-hello-update))
-
 (defun notmuch-hello-window-configuration-change ()
   Hook function to update the hello buffer when it is switched to.
   (let ((hello-buf (get-buffer *notmuch-hello*))
@@ -528,8 +521,8 @@ Such a list can be computed with 
`notmuch-hello-query-counts'.
  (message notmuch version %s (notmuch-version
 (define-key map ? 'notmuch-help)
 (define-key map q 'notmuch-kill-this-buffer)
-(define-key map = 'notmuch-hello-update)
-(define-key map G 'notmuch-hello-poll-and-update)
+(define-key map = 'notmuch-refresh-this-buffer)
+(define-key map G 'notmuch-poll-and-refresh-this-buffer)
 (define-key map (kbd C-tab) 'widget-backward)
 (define-key map m 'notmuch-mua-new-mail)
 (define-key map s 'notmuch-search)
@@ -545,6 +538,7 @@ Complete list of currently available key bindings:
 \\{notmuch-hello-mode-map}
  (interactive)
  (kill-all-local-variables)
+ (setq notmuch-buffer-refresh-function #'notmuch-hello-update)
  (use-local-map notmuch-hello-mode-map)
  (setq major-mode 'notmuch-hello-mode
mode-name notmuch-hello)
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 9754e16..782badb 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -204,6 +204,25 @@ depending on the value of `notmuch-poll-script'.
   (interactive)
   (kill-buffer (current-buffer)))
 
+(defvar notmuch-buffer-refresh-function nil
+  Function to call to refresh the current buffer.)
+(make-variable-buffer-local 'notmuch-buffer-refresh-function)
+
+(defun notmuch-refresh-this-buffer ()
+  Refresh the current buffer.
+  (interactive)
+  (when notmuch-buffer-refresh-function
+(if (commandp notmuch-buffer-refresh-function)
+   ;; Pass prefix argument, etc.
+   (call-interactively notmuch-buffer-refresh-function)
+  (funcall notmuch-buffer-refresh-function
+
+(defun notmuch-poll-and-refresh-this-buffer ()
+  Invoke `notmuch-poll' to import mail, then refresh the current buffer.
+  (interactive)
+  (notmuch-poll)
+  (notmuch-refresh-this-buffer))
+
 (defun notmuch-prettify-subject (subject)
   ;; This function is used by `notmuch-search-process-filter' which
   ;; requires that we not disrupt its' matching state.
@@ -596,7 +615,6 @@ status.
 (defvar notmuch-show-process-crypto nil)
 (make-variable-buffer-local 'notmuch-show-process-crypto)
 
-
 (provide 'notmuch-lib)
 
 ;; Local Variables:
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 82b70ba..380df66 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1279,7 +1279,7 @@ reset based on the original query.
(define-key map w 'notmuch-show-save-attachments)
(define-key map V 'notmuch-show-view-raw-message)
(define-key map c 'notmuch-show-stash-map)
-   (define-key map = 'notmuch-show-refresh-view)
+   (define-key map = 'notmuch-refresh-this-buffer)
(define-key map h 'notmuch-show-toggle-visibility-headers)
(define-key map * 'notmuch-show-tag-all)
(define-key map - 'notmuch-show-remove-tag)
@@ -1338,6 +1338,7 @@ All currently available key bindings:
 \\{notmuch-show-mode-map}
   (interactive)
   (kill-all-local-variables)
+  (setq notmuch-buffer-refresh-function #'notmuch-show-refresh-view)
   (use-local-map notmuch-show-mode-map)
   (setq major-mode 'notmuch-show-mode
mode-name notmuch-show)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 82cece8..80446be 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -228,8 +228,8 @@ For a mouse binding, return nil.
 (define-key map s 'notmuch-search)
 (define-key map o 'notmuch-search-toggle-order)
 (define-key map c 'notmuch-search-stash-map)
-(define-key map = 'notmuch-search-refresh-view)
-(define-key map G 'notmuch-search-poll-and-refresh-view)
+(define-key map = 'notmuch-refresh-this-buffer)
+(define-key map G 'notmuch-poll-and-refresh-this-buffer)
 

[PATCH v2 5/9] emacs: Move `notmuch-poll' to notmuch-lib

2013-09-03 Thread Austin Clements
---
 emacs/notmuch-lib.el |   38 ++
 emacs/notmuch.el |   38 --
 2 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 4796f17..9754e16 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -76,6 +76,33 @@ search.
   :type 'boolean
   :group 'notmuch-search)
 
+(defcustom notmuch-poll-script nil
+  An external script to incorporate new mail into the notmuch database.
+
+This variable controls the action invoked by
+`notmuch-search-poll-and-refresh-view' and
+`notmuch-hello-poll-and-update' (each have a default keybinding
+of 'G') to incorporate new mail into the notmuch database.
+
+If set to nil (the default), new mail is processed by invoking
+\notmuch new\. Otherwise, this should be set to a string that
+gives the name of an external script that processes new mail. If
+set to the empty string, no command will be run.
+
+The external script could do any of the following depending on
+the user's needs:
+
+1. Invoke a program to transfer mail to the local mail store
+2. Invoke \notmuch new\ to incorporate the new mail
+3. Invoke one or more \notmuch tag\ commands to classify the mail
+
+Note that the recommended way of achieving the same is using
+\notmuch new\ hooks.
+  :type '(choice (const :tag notmuch new nil)
+(const :tag Disabled )
+(string :tag Custom script))
+  :group 'notmuch-external)
+
 ;;
 
 (defvar notmuch-search-history nil
@@ -161,6 +188,17 @@ Otherwise the output will be returned
   Return the user.other_email value (as a list) from the notmuch 
configuration.
   (split-string (notmuch-config-get user.other_email) \n))
 
+(defun notmuch-poll ()
+  Run \notmuch new\ or an external script to import mail.
+
+Invokes `notmuch-poll-script', \notmuch new\, or does nothing
+depending on the value of `notmuch-poll-script'.
+  (interactive)
+  (if (stringp notmuch-poll-script)
+  (unless (string= notmuch-poll-script )
+   (call-process notmuch-poll-script nil nil))
+(call-process notmuch-command nil nil nil new)))
+
 (defun notmuch-kill-this-buffer ()
   Kill the current buffer.
   (interactive)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 00cf271..82cece8 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -959,44 +959,6 @@ same relative position within the new buffer.
 (notmuch-search query oldest-first target-thread target-line)
 (goto-char (point-min
 
-(defcustom notmuch-poll-script nil
-  An external script to incorporate new mail into the notmuch database.
-
-This variable controls the action invoked by
-`notmuch-search-poll-and-refresh-view' and
-`notmuch-hello-poll-and-update' (each have a default keybinding
-of 'G') to incorporate new mail into the notmuch database.
-
-If set to nil (the default), new mail is processed by invoking
-\notmuch new\. Otherwise, this should be set to a string that
-gives the name of an external script that processes new mail. If
-set to the empty string, no command will be run.
-
-The external script could do any of the following depending on
-the user's needs:
-
-1. Invoke a program to transfer mail to the local mail store
-2. Invoke \notmuch new\ to incorporate the new mail
-3. Invoke one or more \notmuch tag\ commands to classify the mail
-
-Note that the recommended way of achieving the same is using
-\notmuch new\ hooks.
-  :type '(choice (const :tag notmuch new nil)
-(const :tag Disabled )
-(string :tag Custom script))
-  :group 'notmuch-external)
-
-(defun notmuch-poll ()
-  Run \notmuch new\ or an external script to import mail.
-
-Invokes `notmuch-poll-script', \notmuch new\, or does nothing
-depending on the value of `notmuch-poll-script'.
-  (interactive)
-  (if (stringp notmuch-poll-script)
-  (unless (string= notmuch-poll-script )
-   (call-process notmuch-poll-script nil nil))
-(call-process notmuch-command nil nil nil new)))
-
 (defun notmuch-search-poll-and-refresh-view ()
   Invoke `notmuch-poll' to import mail, then refresh the current view.
   (interactive)
-- 
1.7.10.4

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


[PATCH v2 8/9] emacs: Define a common shared keymap for all of notmuch

2013-09-03 Thread Austin Clements
This defines a single, currently empty keymap that all other notmuch
mode maps inherit from.
---
 emacs/notmuch-hello.el |   10 --
 emacs/notmuch-lib.el   |5 +
 emacs/notmuch-show.el  |1 +
 emacs/notmuch.el   |1 +
 4 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 6a7b884..46baf55 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -515,8 +515,14 @@ Such a list can be computed with 
`notmuch-hello-query-counts'.
 
 
 (defvar notmuch-hello-mode-map
-  (let ((map (make-sparse-keymap)))
-(set-keymap-parent map widget-keymap)
+  (let ((map (if (fboundp 'make-composed-keymap)
+;; Inherit both widget-keymap and notmuch-common-keymap
+(make-composed-keymap widget-keymap)
+  ;; Before Emacs 24, keymaps didn't support multiple
+  ;; inheritance,, so just copy the widget keymap since
+  ;; it's unlikely to change.
+  (copy-keymap widget-keymap
+(set-keymap-parent map notmuch-common-keymap)
 (define-key map v (lambda () Display the notmuch version (interactive)
  (message notmuch version %s (notmuch-version
 (define-key map ? 'notmuch-help)
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 782badb..2bf1d2f 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -128,6 +128,11 @@ For example, if you wanted to remove an \inbox\ tag and 
add an
   :group 'notmuch-search
   :group 'notmuch-show)
 
+(defvar notmuch-common-keymap
+  (let ((map (make-sparse-keymap)))
+map)
+  Keymap shared by all notmuch modes.)
+
 ;; By default clicking on a button does not select the window
 ;; containing the button (as opposed to clicking on a widget which
 ;; does). This means that the button action is then executed in the
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 380df66..9f67340 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1264,6 +1264,7 @@ reset based on the original query.
 
 (defvar notmuch-show-mode-map
   (let ((map (make-sparse-keymap)))
+   (set-keymap-parent map notmuch-common-keymap)
(define-key map ? 'notmuch-help)
(define-key map q 'notmuch-kill-this-buffer)
(define-key map (kbd C-tab) 'widget-backward)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 0304096..e098bd7 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -198,6 +198,7 @@ first line of documentation for the bound function.
 
 (defvar notmuch-search-mode-map
   (let ((map (make-sparse-keymap)))
+(set-keymap-parent map notmuch-common-keymap)
 (define-key map ? 'notmuch-help)
 (define-key map q 'notmuch-kill-this-buffer)
 (define-key map x 'notmuch-kill-this-buffer)
-- 
1.7.10.4

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


[PATCH v2 7/9] emacs: Make notmuch-help work with arbitrary keymaps

2013-09-03 Thread Austin Clements
This converts notmuch-help to use map-keymap for all keymap traversal.
This generally cleans up and simplifies construction of keymap
documentation, and also makes notmuch-help support anything that can
be in a keymap, including more esoteric stuff like multiple
inheritance.
---
 emacs/notmuch.el |   58 +-
 1 file changed, 22 insertions(+), 36 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 80446be..0304096 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -140,48 +140,34 @@ This is basically just `format-kbd-macro' but we also 
convert ESC to M-.
M-
   (concat desc  
 
-;; I would think that emacs would have code handy for walking a keymap
-;; and generating strings for each key, and I would prefer to just call
-;; that. But I couldn't find any (could be all implemented in C I
-;; suppose), so I wrote my own here.
-(defun notmuch-substitute-one-command-key-with-prefix (prefix binding)
-  For a key binding, return a string showing a human-readable
-representation of the prefixed key as well as the first line of
-documentation from the bound function.
-
-For a mouse binding, return nil.
-  (let ((key (car binding))
-   (action (cdr binding)))
-(if (mouse-event-p key)
-   nil
-  (if (keymapp action)
- (let ((substitute (apply-partially 
'notmuch-substitute-one-command-key-with-prefix (notmuch-prefix-key-description 
key)))
-   (as-list))
-   (map-keymap (lambda (a b)
- (push (cons a b) as-list))
-   action)
-   (mapconcat substitute as-list \n))
-   (concat prefix (format-kbd-macro (vector key))
-   \t
-   (notmuch-documentation-first-line action))
-
-(defun notmuch-substitute-command-keys-one (key)
-  ;; A `keymap' key indicates inheritance from a parent keymap - the
-  ;; inherited mappings follow, so there is nothing to print for
-  ;; `keymap' itself.
-  (when (not (eq key 'keymap))
-(notmuch-substitute-one-command-key-with-prefix nil key)))
+(defun notmuch-describe-keymap (keymap optional prefix tail)
+  Return a list of strings, each describing one key in KEYMAP.
+
+Each string gives a human-readable description of the key and the
+first line of documentation for the bound function.
+  (map-keymap
+   (lambda (key binding)
+ (cond ((mouse-event-p key) nil)
+  ((keymapp binding)
+   (setq tail
+ (notmuch-describe-keymap
+  binding (notmuch-prefix-key-description key) tail)))
+  (t
+   (push (concat prefix (format-kbd-macro (vector key)) \t
+ (notmuch-documentation-first-line binding))
+ tail
+   keymap)
+  tail)
 
 (defun notmuch-substitute-command-keys (doc)
   Like `substitute-command-keys' but with documentation, not function names.
   (let ((beg 0))
 (while (string-match {\\([^}[:space:]]*\\)} doc beg)
   (let* ((keymap-name (substring doc (match-beginning 1) (match-end 1)))
-(keymap (symbol-value (intern keymap-name
-   (setq doc (replace-match
-  (mapconcat #'notmuch-substitute-command-keys-one
- (cdr keymap) \n)
-  1 1 doc)))
+(keymap (symbol-value (intern keymap-name)))
+(desc-list (notmuch-describe-keymap keymap))
+(desc (mapconcat #'identity desc-list \n)))
+   (setq doc (replace-match desc 1 1 doc)))
   (setq beg (match-end 0)))
 doc))
 
-- 
1.7.10.4

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


[PATCH v2 0/9] emacs: Unify common key bindings and lots more

2013-09-03 Thread Austin Clements
This is v2 of id:1377793557-28878-1-git-send-email-amdra...@mit.edu.
This fixes a problem found by Jani where notmuch-hello would reset
point placement when refreshing in Emacs 24.  It also inverts the
sense of notmuch-hello-auto-refresh and makes it a defcustom
(originally I'd intended notmuch-hello-inhibit-auto-refresh for
internal use only, but both Mark and Jani expressed interest in
setting it).

The diff from v1 follows

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 1d6c3a2..55c416a 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -232,6 +232,11 @@ supported for \Customized queries section\ items.
notmuch-hello-query-section
(function :tag Custom section
 
+(defcustom notmuch-hello-auto-refresh t
+  Automatically refresh when returning to the notmuch-hello buffer.
+  :group 'notmuch-hello
+  :type 'boolean)
+
 (defvar notmuch-hello-hidden-sections nil
   List of sections titles whose contents are hidden)
 
@@ -478,9 +483,6 @@ Such a list can be computed with 
`notmuch-hello-query-counts'.
   ;; Lazy - rebuild everything.
   (notmuch-hello no-display))
 
-(defvar notmuch-hello-inhibit-auto-refresh nil
-  Don't refresh notmuch-hello on window configuration changes.)
-
 (defun notmuch-hello-window-configuration-change ()
   Hook function to update the hello buffer when it is switched to.
   (let ((hello-buf (get-buffer *notmuch-hello*))
@@ -501,8 +503,11 @@ Such a list can be computed with 
`notmuch-hello-query-counts'.
;; is currently visible, was not visible on the last
;; configuration change, and this is not a new window)
(setq do-refresh t)
-(when (and do-refresh (not notmuch-hello-inhibit-auto-refresh))
-  (notmuch-hello t))
+(when (and do-refresh notmuch-hello-auto-refresh)
+  ;; Refresh hello as soon as we get back to redisplay.  On Emacs
+  ;; 24, we can't do it right here because something in this
+  ;; hook's call stack overrides hello's point placement.
+  (run-at-time nil nil #'notmuch-hello t))
 (when (null hello-buf)
   ;; Clean up hook
   (remove-hook 'window-configuration-change-hook
@@ -785,14 +790,15 @@ following:
 
   ;; This may cause a window configuration change, so if the
   ;; auto-refresh hook is already installed, avoid recursive refresh.
-  (let ((notmuch-hello-inhibit-auto-refresh t))
+  (let ((notmuch-hello-auto-refresh nil))
 (if no-display
(set-buffer *notmuch-hello*)
   (switch-to-buffer *notmuch-hello*)))
 
   ;; Install auto-refresh hook
-  (add-hook 'window-configuration-change-hook
-   #'notmuch-hello-window-configuration-change)
+  (when notmuch-hello-auto-refresh
+(add-hook 'window-configuration-change-hook
+ #'notmuch-hello-window-configuration-change))
 
   (let ((target-line (line-number-at-pos))
(target-column (current-column))

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


[PATCH v2 9/9] emacs: Move ?, q, s, m, =, and G to the common keymap

2013-09-03 Thread Austin Clements
The only user-visible effect of this should be that G now works in
show mode (previously it was unbound for no apparent reason).

This shared keymap gives us one place to put global commands, which
both forces us to think about what commands should be global, and
ensures their bindings can't diverge (like the missing G in show).
---
 emacs/notmuch-hello.el |6 --
 emacs/notmuch-lib.el   |6 ++
 emacs/notmuch-show.el  |5 -
 emacs/notmuch.el   |6 --
 4 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 46baf55..55c416a 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -525,13 +525,7 @@ Such a list can be computed with 
`notmuch-hello-query-counts'.
 (set-keymap-parent map notmuch-common-keymap)
 (define-key map v (lambda () Display the notmuch version (interactive)
  (message notmuch version %s (notmuch-version
-(define-key map ? 'notmuch-help)
-(define-key map q 'notmuch-kill-this-buffer)
-(define-key map = 'notmuch-refresh-this-buffer)
-(define-key map G 'notmuch-poll-and-refresh-this-buffer)
 (define-key map (kbd C-tab) 'widget-backward)
-(define-key map m 'notmuch-mua-new-mail)
-(define-key map s 'notmuch-search)
 map)
   Keymap for \notmuch hello\ buffers.)
 (fset 'notmuch-hello-mode-map notmuch-hello-mode-map)
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 2bf1d2f..58f3313 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -130,6 +130,12 @@ For example, if you wanted to remove an \inbox\ tag and 
add an
 
 (defvar notmuch-common-keymap
   (let ((map (make-sparse-keymap)))
+(define-key map ? 'notmuch-help)
+(define-key map q 'notmuch-kill-this-buffer)
+(define-key map s 'notmuch-search)
+(define-key map m 'notmuch-mua-new-mail)
+(define-key map = 'notmuch-refresh-this-buffer)
+(define-key map G 'notmuch-poll-and-refresh-this-buffer)
 map)
   Keymap shared by all notmuch modes.)
 
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 9f67340..9d8b785 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1265,14 +1265,10 @@ reset based on the original query.
 (defvar notmuch-show-mode-map
   (let ((map (make-sparse-keymap)))
(set-keymap-parent map notmuch-common-keymap)
-   (define-key map ? 'notmuch-help)
-   (define-key map q 'notmuch-kill-this-buffer)
(define-key map (kbd C-tab) 'widget-backward)
(define-key map (kbd M-TAB) 'notmuch-show-previous-button)
(define-key map (kbd backtab) 'notmuch-show-previous-button)
(define-key map (kbd TAB) 'notmuch-show-next-button)
-   (define-key map s 'notmuch-search)
-   (define-key map m 'notmuch-mua-new-mail)
(define-key map f 'notmuch-show-forward-message)
(define-key map r 'notmuch-show-reply-sender)
(define-key map R 'notmuch-show-reply)
@@ -1280,7 +1276,6 @@ reset based on the original query.
(define-key map w 'notmuch-show-save-attachments)
(define-key map V 'notmuch-show-view-raw-message)
(define-key map c 'notmuch-show-stash-map)
-   (define-key map = 'notmuch-refresh-this-buffer)
(define-key map h 'notmuch-show-toggle-visibility-headers)
(define-key map * 'notmuch-show-tag-all)
(define-key map - 'notmuch-show-remove-tag)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index e098bd7..4de6229 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -199,8 +199,6 @@ first line of documentation for the bound function.
 (defvar notmuch-search-mode-map
   (let ((map (make-sparse-keymap)))
 (set-keymap-parent map notmuch-common-keymap)
-(define-key map ? 'notmuch-help)
-(define-key map q 'notmuch-kill-this-buffer)
 (define-key map x 'notmuch-kill-this-buffer)
 (define-key map (kbd DEL) 'notmuch-search-scroll-down)
 (define-key map b 'notmuch-search-scroll-down)
@@ -211,12 +209,8 @@ first line of documentation for the bound function.
 (define-key map n 'notmuch-search-next-thread)
 (define-key map r 'notmuch-search-reply-to-thread-sender)
 (define-key map R 'notmuch-search-reply-to-thread)
-(define-key map m 'notmuch-mua-new-mail)
-(define-key map s 'notmuch-search)
 (define-key map o 'notmuch-search-toggle-order)
 (define-key map c 'notmuch-search-stash-map)
-(define-key map = 'notmuch-refresh-this-buffer)
-(define-key map G 'notmuch-poll-and-refresh-this-buffer)
 (define-key map t 'notmuch-search-filter-by-tag)
 (define-key map f 'notmuch-search-filter)
 (define-key map [mouse-1] 'notmuch-search-show-thread)
-- 
1.7.10.4

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


[PATCH v2 1/9] emacs: Consistently use configured sort order

2013-09-03 Thread Austin Clements
Previously, if `notmuch-search' was called interactively (bound to s
in search and show, but not hello), it would always use newest-first.
However, `notmuch-hello-search' (bound to s in hello) and
`notmuch-hello-widget-search` would call it with the user-configured
sort order.  This inconsistency seems unintentional, so change
`notmuch-search' to use the user-configured sort order when called
interactively.
---
 emacs/notmuch.el |   14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f3ce840..c964186 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -906,8 +906,18 @@ Other optional parameters are used as follows:
   target-thread: A thread ID (without 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)
+   appear in the search results.
+
+When called interactively, this will prompt for a query and use
+the configured default sort order.
+  (interactive
+   (list
+;; Prompt for a query
+nil
+;; Use the default search order (if we're doing a search from a
+;; search buffer, ignore any buffer-local overrides)
+(default-value notmuch-search-oldest-first)))
+
   (let* ((query (or query (notmuch-read-query Notmuch search: )))
 (buffer (get-buffer-create (notmuch-search-buffer-title query
 (switch-to-buffer buffer)
-- 
1.7.10.4

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


Re: [PATCH 1/3] test: Adding non-maildir tags does not move message from new to cur

2013-09-03 Thread David Bremner
Michal Sojka sojk...@fel.cvut.cz writes:

 From: Michal Sojka so...@os.inf.tu-dresden.de

 Some MUA's like mutt show the difference between new emails living in 
 maildir
 directory new/, and old emails living in maildir directory cur/. However
 notmuch tag unconditionally moves selected messages from new/ to cur/, even if
 no maildir synchronized tag is changed.

I pushed these three, and the three followup patches from Jani and I
(mine squashed in to avoid a commit with broken tests).

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