Re: [PATCH] emacs: Fix a notmuch-print.el compiler warning.

2012-01-25 Thread David Edmondson
On Wed, 25 Jan 2012 11:19:30 +0200, Tomi Ollila tomi.oll...@iki.fi wrote:
 On Wed, 25 Jan 2012 08:52:15 +, David Edmondson d...@dme.org wrote:
  `notmuch-show-get-prop' should be declared.
  ---
 
 How 'bout 
 
 (require 'notmuch-lib)
 
 and put that declare-function there ?
 
 So that when declaration gets checked when notmuch-show defuns it 

That doesn't work, as I recall. A `declare-function' in a `require'd
file has no effect - the compiler will still complain.


pgplXhQ7y9RAS.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: Emacs: Crypto: How to get automatic encryption?

2012-01-25 Thread Jameson Graef Rollins
On Wed, 25 Jan 2012 06:23:01 +, David Edmondson d...@dme.org wrote:
 Can you explain the logic that will apply to determine whether or not a
 reply is encrypted?

My plan was to modify notmuch-reply.c to include a flag in the JSON
output if the message being replied to was encrypted.  The emacs reply
function could then look for that flag and add the ml-secure directive
to encrypt the reply.

jamie.


pgpyXy8nysrWr.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: Add `notmuch-show-stash-gmane' and `notmuch-show-stash-gmane-and-go'.

2012-01-25 Thread Tomi Ollila
On Wed, 25 Jan 2012 06:31:43 +, David Edmondson d...@dme.org wrote:
 
 Your point about Gmane not having everything applies equally to any
 service, suggesting that perhaps the user should also have an option to
 choose which service to use at stash time. Thoughts?

Completing-read which has all choice url's expanded so user may even edit
those (like fix -2- to -1- if the don't have cover letter ;)

Tomi

PS: even better this should have one level of indirection so that user
can change completing-read to something else without needing to patch
source (like I do in address completion interface)... well this is
something I need to investigate further...

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


[PATCH 2/3] emacs: Allow `notmuch-show-mode' to display only matching messages.

2012-01-25 Thread David Edmondson
The current behaviour (all messages shown, non-matching collapsed)
is retained as the default. Type '!' to switch to showing only
the matching messages - non-matching messages are not available.
'!' will switch back to showing everything.
---
 emacs/notmuch-show.el |   18 +-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index ed77474..916b941 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -134,6 +134,10 @@ indentation.
 (make-variable-buffer-local 'notmuch-show-process-crypto)
 (put 'notmuch-show-process-crypto 'permanent-local t)
 
+(defvar notmuch-show-elide-non-matching-messages nil)
+(make-variable-buffer-local 'notmuch-show-elide-non-matching-messages)
+(put 'notmuch-show-elide-non-matching-messages 'permanent-local t)
+
 (defmacro with-current-notmuch-show-message (rest body)
   Evaluate body with current buffer set to the text of current message
   `(save-excursion
@@ -890,11 +894,22 @@ current buffer, if possible.
 Not processing cryptographic MIME parts.))
   (notmuch-show-refresh-view))
 
+(defun notmuch-show-toggle-elide-non-matching ()
+  Toggle the display of non-matching messages.
+  (interactive)
+  (setq notmuch-show-elide-non-matching-messages (not 
notmuch-show-elide-non-matching-messages))
+  (message (if notmuch-show-elide-non-matching-messages
+  Showing matching messages only.
+Showing all messages.))
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-insert-tree (tree depth)
   Insert the message tree TREE at depth DEPTH in the current thread.
   (let ((msg (car tree))
(replies (cadr tree)))
-(notmuch-show-insert-msg msg depth)
+(if (or (not notmuch-show-elide-non-matching-messages)
+   (plist-get msg :match))
+   (notmuch-show-insert-msg msg depth))
 (notmuch-show-insert-thread replies (1+ depth
 
 (defun notmuch-show-insert-thread (thread depth)
@@ -1044,6 +1059,7 @@ Refreshes the current view, observing changes in 
cryptographic preferences.
(define-key map (kbd M-RET) 'notmuch-show-open-or-close-all)
(define-key map (kbd RET) 'notmuch-show-toggle-message)
(define-key map # 'notmuch-show-print-message)
+   (define-key map ! 'notmuch-show-toggle-elide-non-matching)
(define-key map $ 'notmuch-show-toggle-process-crypto)
map)
   Keymap for \notmuch show\ buffers.)
-- 
1.7.8.3

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


[PATCH 3/3] emacs: Allow the indentation of content to be toggled.

2012-01-25 Thread David Edmondson
Very deeply indented content is sometimes difficult to
read (particular for something like patches). Allow the indentation of
the content to be toggled with ''.

Indentation of the header lines is not affected, so it remains
possible to see the structure of the thread.
---
 emacs/notmuch-show.el |   23 ---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 916b941..337cd50 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -138,6 +138,10 @@ indentation.
 (make-variable-buffer-local 'notmuch-show-elide-non-matching-messages)
 (put 'notmuch-show-elide-non-matching-messages 'permanent-local t)
 
+(defvar notmuch-show-indent-content t)
+(make-variable-buffer-local 'notmuch-show-indent-content)
+(put 'notmuch-show-indent-content 'permanent-local t)
+
 (defmacro with-current-notmuch-show-message (rest body)
   Evaluate body with current buffer set to the text of current message
   `(save-excursion
@@ -244,10 +248,12 @@ operation on the contents of the current buffer.
 (all (buffer-substring (notmuch-show-message-top)
(notmuch-show-message-bottom)))
 
-(props (notmuch-show-get-message-properties)))
+(props (notmuch-show-get-message-properties))
+(indenting notmuch-show-indent-content))
 (with-temp-buffer
   (insert all)
-  (indent-rigidly (point-min) (point-max) (- depth))
+  (if indenting
+ (indent-rigidly (point-min) (point-max) (- depth)))
   ;; Remove the original header.
   (goto-char (point-min))
   (re-search-forward ^$ (point-max) nil)
@@ -856,7 +862,8 @@ current buffer, if possible.
 (setq content-end (point-marker))
 
 ;; Indent according to the depth in the thread.
-(indent-rigidly content-start content-end (* 
notmuch-show-indent-messages-width depth))
+(if notmuch-show-indent-content
+   (indent-rigidly content-start content-end (* 
notmuch-show-indent-messages-width depth)))
 
 (setq message-end (point-max-marker))
 
@@ -903,6 +910,15 @@ current buffer, if possible.
 Showing all messages.))
   (notmuch-show-refresh-view))
 
+(defun notmuch-show-toggle-thread-indentation ()
+  Toggle the indentation of threads.
+  (interactive)
+  (setq notmuch-show-indent-content (not notmuch-show-indent-content))
+  (message (if notmuch-show-indent-content
+  Content is indented.
+Content is not indented.))
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-insert-tree (tree depth)
   Insert the message tree TREE at depth DEPTH in the current thread.
   (let ((msg (car tree))
@@ -1061,6 +1077,7 @@ Refreshes the current view, observing changes in 
cryptographic preferences.
(define-key map # 'notmuch-show-print-message)
(define-key map ! 'notmuch-show-toggle-elide-non-matching)
(define-key map $ 'notmuch-show-toggle-process-crypto)
+   (define-key map  'notmuch-show-toggle-thread-indentation)
map)
   Keymap for \notmuch show\ buffers.)
 (fset 'notmuch-show-mode-map notmuch-show-mode-map)
-- 
1.7.8.3

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


[PATCH 1/3] emacs: Rework crypto switch toggle.

2012-01-25 Thread David Edmondson
Re-work the existing crypto switch toggle to be based on a persistant
buffer-local variable.

To allow this, modify `notmuch-show-refresh-view' to erase and re-draw
in the current buffer rather than killing the current buffer and
creating a new one. (This will also allow more per-buffer behaviour in
future patches.)

Add a binding ('$') to toggle crypto processing of the current buffer
and remove the prefix argument approach that achieves a similar
result.
---
 emacs/notmuch-show.el |  102 ++--
 emacs/notmuch.el  |7 +--
 2 files changed, 50 insertions(+), 59 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e6a5b31..ed77474 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -123,6 +123,17 @@ indentation.
 (const :tag View interactively
notmuch-show-interactively-view-part)))
 
+(defvar notmuch-show-thread-id nil)
+(make-variable-buffer-local 'notmuch-show-thread-id)
+(defvar notmuch-show-parent-buffer nil)
+(make-variable-buffer-local 'notmuch-show-parent-buffer)
+(defvar notmuch-show-query-context nil)
+(make-variable-buffer-local 'notmuch-show-query-context)
+
+(defvar notmuch-show-process-crypto notmuch-crypto-process-mime)
+(make-variable-buffer-local 'notmuch-show-process-crypto)
+(put 'notmuch-show-process-crypto 'permanent-local t)
+
 (defmacro with-current-notmuch-show-message (rest body)
   Evaluate body with current buffer set to the text of current message
   `(save-excursion
@@ -379,14 +390,11 @@ message at DEPTH in the current thread.
 
 (defmacro notmuch-with-temp-part-buffer (message-id nth rest body)
   (declare (indent 2))
-  (let ((process-crypto (make-symbol process-crypto)))
-`(let ((,process-crypto notmuch-show-process-crypto))
-   (with-temp-buffer
-(setq notmuch-show-process-crypto ,process-crypto)
-;; Always acquires the part via `notmuch part', even if it is
-;; available in the JSON output.
-(insert (notmuch-show-get-bodypart-internal ,message-id ,nth))
-,@body
+  `(with-temp-buffer
+ ;; Always acquires the part via `notmuch part', even if it is
+ ;; available in the JSON output.
+ (insert (notmuch-show-get-bodypart-internal ,message-id ,nth))
+ ,@body))
 
 (defun notmuch-show-save-part (message-id nth optional filename content-type)
   (notmuch-with-temp-part-buffer message-id nth
@@ -567,7 +575,7 @@ current buffer, if possible.
   (sigstatus (car (plist-get part :sigstatus
  (notmuch-crypto-insert-sigstatus-button sigstatus from))
   ;; if we're not adding sigstatus, tell the user how they can get it
-  (button-put button 'help-echo Set notmuch-crypto-process-mime to 
process cryptographic mime parts.)))
+  (button-put button 'help-echo Set notmuch-crypto-process-mime to 
process cryptographic MIME parts.)))
 
   (let ((inner-parts (plist-get part :content))
(start (point)))
@@ -593,7 +601,7 @@ current buffer, if possible.
 (sigstatus (car (plist-get part :sigstatus
(notmuch-crypto-insert-sigstatus-button sigstatus from
   ;; if we're not adding encstatus, tell the user how they can get it
-  (button-put button 'help-echo Set notmuch-crypto-process-mime to 
process cryptographic mime parts.)))
+  (button-put button 'help-echo Set notmuch-crypto-process-mime to 
process cryptographic MIME parts.)))
 
   (let ((inner-parts (plist-get part :content))
(start (point)))
@@ -720,8 +728,6 @@ current buffer, if possible.
 
 ;; Helper for parts which are generally not included in the default
 ;; JSON output.
-;; Uses the buffer-local variable notmuch-show-process-crypto to
-;; determine if parts should be decrypted first.
 (defun notmuch-show-get-bodypart-internal (message-id part-number)
   (let ((args '(show --format=raw))
(part-arg (format --part=%s part-number)))
@@ -875,6 +881,15 @@ current buffer, if possible.
 ;; criteria.
 (notmuch-show-message-visible msg (plist-get msg :match
 
+(defun notmuch-show-toggle-process-crypto ()
+  Toggle the processing of cryptographic MIME parts.
+  (interactive)
+  (setq notmuch-show-process-crypto (not notmuch-show-process-crypto))
+  (message (if notmuch-show-process-crypto
+  Processing cryptographic MIME parts.
+Not processing cryptographic MIME parts.))
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-insert-tree (tree depth)
   Insert the message tree TREE at depth DEPTH in the current thread.
   (let ((msg (car tree))
@@ -890,15 +905,6 @@ current buffer, if possible.
   Insert the forest of threads FOREST.
   (mapc (lambda (thread) (notmuch-show-insert-thread thread 0)) forest))
 
-(defvar notmuch-show-thread-id nil)
-(make-variable-buffer-local 'notmuch-show-thread-id)
-(defvar notmuch-show-parent-buffer nil)
-(make-variable-buffer-local 'notmuch-show-parent-buffer)
-(defvar 

Re: Emacs: Crypto: How to get automatic encryption?

2012-01-25 Thread David Edmondson
On Wed, 25 Jan 2012 01:26:19 -0800, Jameson Graef Rollins 
jroll...@finestructure.net wrote:
 On Wed, 25 Jan 2012 06:23:01 +, David Edmondson d...@dme.org wrote:
  Can you explain the logic that will apply to determine whether or not a
  reply is encrypted?
 
 My plan was to modify notmuch-reply.c to include a flag in the JSON
 output if the message being replied to was encrypted.  The emacs reply
 function could then look for that flag and add the ml-secure directive
 to encrypt the reply.

Isn't it still necessary to ensure that you have encryption keys
appropriate to the recipient?


pgpKMocLh0OKq.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: Add `notmuch-show-stash-gmane' and `notmuch-show-stash-gmane-and-go'.

2012-01-25 Thread David Edmondson
On Wed, 25 Jan 2012 12:18:22 +0200, Tomi Ollila tomi.oll...@iki.fi wrote:
 On Wed, 25 Jan 2012 06:31:43 +, David Edmondson d...@dme.org wrote:
  
  Your point about Gmane not having everything applies equally to any
  service, suggesting that perhaps the user should also have an option to
  choose which service to use at stash time. Thoughts?
 
 Completing-read which has all choice url's expanded so user may even edit
 those

`completing-read' on the _names_ of the services, sure. I'm not sure
that showing the URLs as a set of choices would be nice.

 (like fix -2- to -1- if the don't have cover letter ;)

Should a single patch need a cover letter?


pgpJdOhue2FOu.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v3 3/8] emacs: break out thread navigation from notmuch-show-archive-thread

2012-01-25 Thread David Edmondson
On Tue, 24 Jan 2012 16:06:18 -0800, Jameson Graef Rollins 
jroll...@finestructure.net wrote:
 This function is now just for archiving the current thread.  A new
 function is created to archive-then-next.  The 'a' key binding is
 updated accordingly.
 
 This will allow people to bind to the simple thread archiving function
 without the extra navigation.  The archive-thread function now also
 takes a prefix to unarchive the current thread (ie. put the whole
 thread back in the inbox).
 ---
  emacs/notmuch-show.el |   23 +--
  1 files changed, 17 insertions(+), 6 deletions(-)
 
 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
 index fb908b0..071e662 100644
 --- a/emacs/notmuch-show.el
 +++ b/emacs/notmuch-show.el
 @@ -1044,7 +1044,7 @@ thread id.  If a prefix is given, crypto processing is 
 toggled.
   (define-key map - 'notmuch-show-remove-tag)
   (define-key map + 'notmuch-show-add-tag)
   (define-key map x 'notmuch-show-archive-thread-then-exit)
 - (define-key map a 'notmuch-show-archive-thread)
 + (define-key map a 'notmuch-show-archive-thread-then-next)
   (define-key map N 'notmuch-show-next-message)
   (define-key map P 'notmuch-show-previous-message)
   (define-key map n 'notmuch-show-next-open-message)
 @@ -1304,7 +1304,7 @@ thread from the search from which this thread was 
 originally
  shown.
(interactive)
(if (notmuch-show-advance)
 -  (notmuch-show-archive-thread)))
 +  (notmuch-show-archive-thread-then-next)))
  
  (defun notmuch-show-rewind ()
Backup through the thread, (reverse scrolling compared to 
 \\[notmuch-show-advance-and-archive]).
 @@ -1558,8 +1558,12 @@ added.
(if show-next
 (notmuch-search-show-thread)
  
 -(defun notmuch-show-archive-thread ()
 -  Archive each message in thread, then show next thread from search.
 +(defun notmuch-show-archive-thread (optional unarchive)
 +  Archive each message in thread.
 +
 +If a prefix argument is given, the messages will be
 +\unarchived\ (ie. the \inbox\ tag will be added instead of
 +removed).

It's clearer to reference inbox directly:

 Remove the inbox tag from the messages currently shown.

 If a prefix argument is given the inbox tag will be added rather
 than removed.

  
  Archive each message currently shown by removing the \inbox\
  tag from each. Then kill this buffer and show the next thread
 @@ -1569,14 +1573,21 @@ Note: This command is safe from any race condition of 
 new messages
  being delivered to the same thread. It does not archive the
  entire thread, but only the messages shown in the current
  buffer.
 +  (interactive P)
 +  (if unarchive
 +  (notmuch-show-add-tag-thread inbox)
 +(notmuch-show-remove-tag-thread inbox)))
 +
 +(defun notmuch-show-archive-thread-then-next ()
 +  Archive each message in thread, then show next thread from search.
(interactive)
 -  (notmuch-show-remove-tag-thread inbox)
 +  (notmuch-show-archive-thread)
(notmuch-show-next-thread t))
  
  (defun notmuch-show-archive-thread-then-exit ()
Archive each message in thread, then exit back to search results.
(interactive)
 -  (notmuch-show-remove-tag-thread inbox)
 +  (notmuch-show-archive-thread)
(notmuch-show-next-thread))
  
  (defun notmuch-show-stash-cc ()
 -- 
 1.7.8.3
 
 ___
 notmuch mailing list
 notmuch@notmuchmail.org
 http://notmuchmail.org/mailman/listinfo/notmuch


pgp7C9rBVavM6.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v3 4/8] emacs: add message archiving functions

2012-01-25 Thread David Edmondson
On Tue, 24 Jan 2012 16:06:19 -0800, Jameson Graef Rollins 
jroll...@finestructure.net wrote:
 This adds two new message archiving functions that parallel the thread
 archiving functions: notmuch-show-archive-message{,-then-next}.  The
 former also takes a prefix argument to unarchive the message (ie. put
 back in inbox).
 ---
  emacs/notmuch-show.el |   17 +
  1 files changed, 17 insertions(+), 0 deletions(-)
 
 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
 index 071e662..0dc594b 100644
 --- a/emacs/notmuch-show.el
 +++ b/emacs/notmuch-show.el
 @@ -1590,6 +1590,23 @@ buffer.
(notmuch-show-archive-thread)
(notmuch-show-next-thread))
  
 +(defun notmuch-show-archive-message (optional unarchive)
 +  Archive the current message.
 +
 +If a prefix argument is given, the message will be
 +\unarchived\ (ie. the \inbox\ tag will be added instead of
 +removed).

Same comments as for the previous patch - just reference inbox
directly.

 +  (interactive P)
 +  (if unarchive
 +  (notmuch-show-add-tag inbox)
 +(notmuch-show-remove-tag inbox)))
 +
 +(defun notmuch-show-archive-message-then-next ()
 +  Archive the current message, then show the next open message in the 
 current thread.
 +  (interactive)
 +  (notmuch-show-archive-message)
 +  (notmuch-show-next-open-message))
 +
  (defun notmuch-show-stash-cc ()
Copy CC field of current message to kill-ring.
(interactive)
 -- 
 1.7.8.3
 
 ___
 notmuch mailing list
 notmuch@notmuchmail.org
 http://notmuchmail.org/mailman/listinfo/notmuch


pgpk37FSiRFGE.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v3 8/8] emacs: fix show-previous-message doc string

2012-01-25 Thread David Edmondson
Fine.


pgpKbaKgOLkD5.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v3 1/8] emacs: use search-next-thread to move to next thread in show mode

2012-01-25 Thread David Edmondson
Fine.


pgpQD2IcvndvB.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 1/3] emacs: s/buttonise/buttonize/g

2012-01-25 Thread David Bremner
On Thu, 12 Jan 2012 18:23:43 +0100, Pieter Praet pie...@praet.org wrote:
 Worldwide, -ize endings prevail in scientific writing and are commonly
 used by many international organizations, such as the ISO and the
 WHO. The European Union switched from -ize to -ise some years ago in its
 English language publications, and this resulted in the coexistence of

needs rebasing against master. 

d

P.S. Personally think it's a bit silly, but that might be because I'm
Canadian, and we are all about the inconsistent anglo/american
spelling. But if the consensus is to follow the UN black helicopter
spelling police, ok :).
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 0/4 v43] emacs test helpers

2012-01-25 Thread David Bremner
On Tue, 24 Jan 2012 16:14:03 +, David Edmondson d...@dme.org wrote:
 Small changes as per Dmitry's last comments.

Pushed.

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


Re: [PATCH] emacs: have notmuch-search-archive-thread use -next-thread function

2012-01-25 Thread David Bremner
On Tue, 17 Jan 2012 10:54:26 -0800, Jameson Graef Rollins 
jroll...@finestructure.net wrote:
 Use this standard function, to keep thread navigation in one place.

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


[PATCH 0/2] improve `notmuch-show-clean-address'

2012-01-25 Thread David Edmondson
Avoids warnings due to unicode characters and improves display.

David Edmondson (2):
  emacs: Avoid `mail-header-parse-address' in
`notmuch-show-clean-address'.
  emacs: Another special case for `notmuch-show-clean-address'.

 emacs/notmuch-show.el  |   54 +--
 test/emacs-address-cleaning.el |6 +++-
 test/emacs-address-cleaning.sh |1 -
 3 files changed, 44 insertions(+), 17 deletions(-)

-- 
1.7.8.3

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


Re: [PATCH] emacs: Add `notmuch-show-stash-gmane' and `notmuch-show-stash-gmane-and-go'.

2012-01-25 Thread Tomi Ollila
On Wed, 25 Jan 2012 10:41:26 +, David Edmondson d...@dme.org wrote:
 On Wed, 25 Jan 2012 12:18:22 +0200, Tomi Ollila tomi.oll...@iki.fi wrote:
  On Wed, 25 Jan 2012 06:31:43 +, David Edmondson d...@dme.org wrote:
   
   Your point about Gmane not having everything applies equally to any
   service, suggesting that perhaps the user should also have an option to
   choose which service to use at stash time. Thoughts?
  
  Completing-read which has all choice url's expanded so user may even edit
  those
 
 `completing-read' on the _names_ of the services, sure. I'm not sure
 that showing the URLs as a set of choices would be nice.

Hmm... yes. Editing is not important here.

 
  (like fix -2- to -1- if the don't have cover letter ;)
 
 Should a single patch need a cover letter?

Nope -- and forget this -- I thought this a bit wrong.

So, 'completing-read' -- or something that does the same thing better (ymmv).

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


Re: [PATCH] emacs: make `notmuch-show-open-or-close-all' toggle visibility

2012-01-25 Thread Tomi Ollila
On Wed, 25 Jan 2012 06:35:33 +, David Edmondson d...@dme.org wrote:
 On Wed, 25 Jan 2012 06:25:39 +0100, Pieter Praet pie...@praet.org wrote:
  * emacs/notmuch-show.el (notmuch-show-open-or-close-all):
Rename to `notmuch-show-toggle-all-messages', and make it toggle
visibility of all messages based on the visibility of the current
message, instead of setting visibility based on whether or not a
prefix arg was supplied.
  
  Same functionality, less effort (reaching for 'C-u' is a pain)...
 
 -1.
 
 The behaviour you've provided is not what I want, from two perspectives:
 - currently it's clear what will happen when I use M-RET or
   C-uM-RET without me having to think about whether the cursor
   is over an open message,
 - often I'll be reading an open message and I want to open all
   of the rest to look at some context. That's a little more
   awkward after this change.

Yes, let's just switch. c-u M-RET to expand and M-RET to collapse (!!!)

(Needless to say I've never expanded but often collapsed ;)

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


[PATCH 0/3] minor cleanup and improvements

2012-01-25 Thread David Edmondson
Three minor cleanup or small improvement patches.

David Edmondson (3):
  emacs: Stop the `truncate-string-to-width' madness.
  emacs: Don't mark messages as unsaved when printing.
  emacs: Prefer '[No Subject]' to blank subjects.

 emacs/notmuch-lib.el   |5 +
 emacs/notmuch-print.el |9 +++--
 emacs/notmuch-show.el  |5 -
 emacs/notmuch.el   |   13 -
 4 files changed, 20 insertions(+), 12 deletions(-)

-- 
1.7.8.3

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


[PATCH 2/3] emacs: Don't mark messages as unsaved when printing.

2012-01-25 Thread David Edmondson
`ps-print-buffer' notes that a buffer is unsaved unless
`buffer-modified-p' returns `nil', so ensure that it does.
---
 emacs/notmuch-print.el |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-print.el b/emacs/notmuch-print.el
index f96ccbe..83eb525 100644
--- a/emacs/notmuch-print.el
+++ b/emacs/notmuch-print.el
@@ -80,6 +80,7 @@ Optional OUTPUT allows passing a list of flags to muttprint.
 
 (defun notmuch-print-message (msg)
   Print a message using the user-selected mechanism.
+  (set-buffer-modified-p nil)
   (funcall notmuch-print-mechanism msg))
 
 (provide 'notmuch-print)
-- 
1.7.8.3

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


[PATCH 1/3] emacs: Stop the `truncate-string-to-width' madness.

2012-01-25 Thread David Edmondson
There's no need to call `truncate-string-to-width' twice in this code
path.
---
 emacs/notmuch.el |   14 ++
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 3ec0816..3f6b977 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -441,18 +441,16 @@ Complete list of currently available key bindings:
   (interactive P)
   (let ((thread-id (notmuch-search-find-thread-id))
(subject (notmuch-search-find-subject)))
+
+(if (string-match ^[ \t]*$ subject)
+   (setq subject [No Subject]))
+
 (if ( (length thread-id) 0)
(notmuch-show thread-id
  (current-buffer)
  notmuch-search-query-string
- ;; name the buffer based on notmuch-search-find-subject
- (if (string-match ^[ \t]*$ subject)
- [No Subject]
-   (truncate-string-to-width
-(concat *
-(truncate-string-to-width subject 32 nil nil t)
-*)
-32 nil nil t))
+ ;; Name the buffer based on the subject.
+ (concat * (truncate-string-to-width subject 30 nil nil 
t) *)
  crypto-switch)
   (message End of search results.
 
-- 
1.7.8.3

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


[PATCH 3/3] emacs: Prefer '[No Subject]' to blank subjects.

2012-01-25 Thread David Edmondson
---
 emacs/notmuch-lib.el   |6 ++
 emacs/notmuch-print.el |8 ++--
 emacs/notmuch-show.el  |5 -
 emacs/notmuch.el   |5 +
 4 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 241fe8c..5b8a41c 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -130,6 +130,12 @@ the user hasn't set this variable with the old or new 
value.
   (interactive)
   (kill-buffer (current-buffer)))
 
+(defun notmuch-prettify-subject (subject)
+  (if (and subject
+  (string-match ^[ \t]*$ subject))
+  (setq subject [No Subject]))
+  subject)
+
 ;;
 
 (defun notmuch-common-do-stash (text)
diff --git a/emacs/notmuch-print.el b/emacs/notmuch-print.el
index 83eb525..51bb740 100644
--- a/emacs/notmuch-print.el
+++ b/emacs/notmuch-print.el
@@ -19,6 +19,8 @@
 ;;
 ;; Authors: David Edmondson d...@dme.org
 
+(require 'notmuch-lib)
+
 (defcustom notmuch-print-mechanism 'notmuch-print-lpr
   How should printing be done?
   :group 'notmuch
@@ -56,14 +58,16 @@ Optional OUTPUT allows passing a list of flags to 
muttprint.
 
 (defun notmuch-print-ps-print (msg)
   Print a message buffer using the ps-print package.
-  (let ((subject (plist-get (notmuch-show-get-prop :headers msg) :Subject)))
+  (let ((subject (notmuch-prettify-subject
+ (plist-get (notmuch-show-get-prop :headers msg) :Subject
 (rename-buffer subject t)
 (ps-print-buffer)))
 
 (defun notmuch-print-ps-print/evince (msg)
   Preview a message buffer using ps-print and evince.
   (let ((ps-file (make-temp-file notmuch))
-   (subject (plist-get (notmuch-show-get-prop :headers msg) :Subject)))
+   (subject (notmuch-prettify-subject
+ (plist-get (notmuch-show-get-prop :headers msg) :Subject
 (rename-buffer subject t)
 (ps-print-buffer ps-file)
 (notmuch-print-run-evince ps-file)))
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e6a5b31..c602b3e 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -985,7 +985,7 @@ buffer.
   (notmuch-show-next-open-message))
 
 ;; Set the header line to the subject of the first open message.
-(setq header-line-format (notmuch-show-strip-re 
(notmuch-show-get-subject)))
+(setq header-line-format (notmuch-show-strip-re 
(notmuch-show-get-pretty-subject)))
 
 (notmuch-show-mark-read)))
 
@@ -1216,6 +1216,9 @@ Some useful entries are:
 (defun notmuch-show-get-depth ()
   (notmuch-show-get-prop :depth))
 
+(defun notmuch-show-get-pretty-subject ()
+  (notmuch-prettify-subject (notmuch-show-get-subject)))
+
 (defun notmuch-show-set-tags (tags)
   Set the tags of the current message.
   (notmuch-show-set-prop :tags tags)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 3f6b977..ce1e232 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -440,10 +440,7 @@ Complete list of currently available key bindings:
   Display the currently selected thread.
   (interactive P)
   (let ((thread-id (notmuch-search-find-thread-id))
-   (subject (notmuch-search-find-subject)))
-
-(if (string-match ^[ \t]*$ subject)
-   (setq subject [No Subject]))
+   (subject (notmuch-prettify-subject (notmuch-search-find-subject
 
 (if ( (length thread-id) 0)
(notmuch-show thread-id
-- 
1.7.8.3

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


[PATCH 0/3 v2] minor cleanup and improvements

2012-01-25 Thread David Edmondson
Three minor cleanup or small improvement patches.

v2: Fix the case where subject can be `nil' in patch 3.

David Edmondson (3):
  emacs: Stop the `truncate-string-to-width' madness.
  emacs: Don't mark messages as unsaved when printing.
  emacs: Prefer '[No Subject]' to blank subjects.

 emacs/notmuch-lib.el   |6 ++
 emacs/notmuch-print.el |9 +++--
 emacs/notmuch-show.el  |5 -
 emacs/notmuch.el   |   13 -
 4 files changed, 21 insertions(+), 12 deletions(-)

-- 
1.7.8.3

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


[PATCH 3/3] emacs: Another special case for `notmuch-show-clean-address'.

2012-01-25 Thread David Edmondson
Remove backslashes.
---
 emacs/notmuch-show.el  |   14 +-
 test/emacs-address-cleaning.el |6 --
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 1fd2524..c849e84 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -310,11 +310,15 @@ unchanged ADDRESS if parsing fails.
(t
(setq p-address address)))
 
-  ;; Remove outer double quotes. They might be required during
-  ;; transport, but we don't need to see them.
-  (when (and p-name
-(string-match ^\\\(.*\\)\$ p-name))
-   (setq p-name (match-string 1 p-name)))
+  ;; Remove elements of the mailbox part that are not relevant for
+  ;; display, even if they are required during transport.
+  (when p-name
+   ;; Outer double quotes.
+   (when (string-match ^\\\(.*\\)\$ p-name)
+ (setq p-name (match-string 1 p-name)))
+
+   ;; Backslashes.
+   (setq p-name (replace-regexp-in-string   p-name)))
 
   ;; If the address is 'f...@bar.com f...@bar.com' then show just
   ;; 'f...@bar.com'.
diff --git a/test/emacs-address-cleaning.el b/test/emacs-address-cleaning.el
index 19e9e05..3b0b109 100644
--- a/test/emacs-address-cleaning.el
+++ b/test/emacs-address-cleaning.el
@@ -20,10 +20,12 @@
   (let* ((input '(ДБ db-uk...@stop.me.uk
  foo (at home) f...@bar.com
  foo [at home] f...@bar.com
- Foo Bar))
+ Foo Bar
+ Fred Dibna \\[extraordinaire\\] f...@dibna.com))
 (expected '(ДБ db-uk...@stop.me.uk
 foo (at home) f...@bar.com
 foo [at home] f...@bar.com
-Foo Bar))
+Foo Bar
+Fred Dibna [extraordinaire] f...@dibna.com))
 (output (mapcar #'notmuch-show-clean-address input)))
 (notmuch-test-expect-equal output expected)))
-- 
1.7.8.3

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


[PATCH 2/3] test: Updated expected output for new `notmuch-show-clean-address'.

2012-01-25 Thread David Edmondson
---
 test/emacs |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/test/emacs b/test/emacs
index f150d95..8ca4c8a 100755
--- a/test/emacs
+++ b/test/emacs
@@ -78,7 +78,7 @@ thread=$(notmuch search --output=threads 
subject:message-with-invalid-from)
 test_emacs (notmuch-show \$thread\)
(test-output)
 cat EOF EXPECTED
-Invalid  From test_su...@notmuchmail.org (2001-01-05) (inbox)
+Invalid  From test_su...@notmuchmail.org (2001-01-05) (inbox)
 Subject: message-with-invalid-from
 To: Notmuch Test Suite test_su...@notmuchmail.org
 Date: Fri, 05 Jan 2001 15:43:57 +
-- 
1.7.8.3

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


Re: [PATCH 0/3 v2 ] improve `notmuch-show-clean-address'

2012-01-25 Thread Tomi Ollila
On Wed, 25 Jan 2012 13:53:57 +, David Edmondson d...@dme.org wrote:
 Avoids warnings due to unicode characters and improves display.
 
 v2: Update the existing test output accordingly.
 
 David Edmondson (3):
   emacs: Avoid `mail-header-parse-address' in
 `notmuch-show-clean-address'.
   test: Updated expected output for new `notmuch-show-clean-address'.
   emacs: Another special case for `notmuch-show-clean-address'.

+1

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


[PATCH 1/1] emacs: Take more care when hiding regions with buttons.

2012-01-25 Thread David Edmondson
If the region to be hidden with a button by
`notmuch-wash-region-to-button' starts at the beginning of the buffer,
the invisible region will include the inserted button. This is
unfortunate, as it means that it is not possible to see the button to
be pressed.

Make a little space at the start of the buffer before inserting the
button to avoid this, not forgetting to remove the inserted space upon
completion.
---

This is a hack, but I couldn't see another way around it. Can anyone
find a better solution?

 emacs/notmuch-wash.el |   57 
 1 files changed, 38 insertions(+), 19 deletions(-)

diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index 5c1e830..4afd3b3 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -147,25 +147,44 @@ insert before the button, probably for indentation.
   ;; symbols because of the way the button code works. Note that
   ;; replacing intern-soft with make-symbol will cause this to fail,
   ;; since the newly created symbol has no plist.
-
-  (let ((overlay (make-overlay beg end))
-   (message-invis-spec (plist-get msg :message-invis-spec))
-   (invis-spec (make-symbol (concat notmuch- type -region)))
-   (button-type (intern-soft (concat notmuch-wash-button-
- type -toggle-type
-(add-to-invisibility-spec invis-spec)
-(overlay-put overlay 'invisible (list invis-spec message-invis-spec))
-(overlay-put overlay 'isearch-open-invisible 
#'notmuch-wash-region-isearch-show)
-(overlay-put overlay 'priority 10)
-(overlay-put overlay 'type type)
-(goto-char (1+ end))
-(save-excursion
-  (goto-char (1- beg))
-  (insert prefix)
-  (insert-button (notmuch-wash-button-label overlay)
-'invisibility-spec invis-spec
-'overlay overlay
-:type button-type
+  (save-excursion
+;; If the beginning of the region to be converted to a button is the
+;; beginning of the buffer we must move forward a little to avoid
+;; creating an overlay that will hide the button intended to be used
+;; to reveal the hidden region.
+(let (scene-of-crime)
+  (when (eq beg (point-min))
+   (goto-char (point-min))
+   (insert \n)
+   (setq scene-of-crime (point-min)
+ beg (point)))
+
+  ;; This uses some slightly tricky conversions between strings and
+  ;; symbols because of the way the button code works. Note that
+  ;; replacing intern-soft with make-symbol will cause this to fail,
+  ;; since the newly created symbol has no plist.
+
+  (let ((overlay (make-overlay beg end))
+   (message-invis-spec (plist-get msg :message-invis-spec))
+   (invis-spec (make-symbol (concat notmuch- type -region)))
+   (button-type (intern-soft (concat notmuch-wash-button-
+ type -toggle-type
+   (add-to-invisibility-spec invis-spec)
+   (overlay-put overlay 'invisible (list invis-spec message-invis-spec))
+   (overlay-put overlay 'isearch-open-invisible 
#'notmuch-wash-region-isearch-show)
+   (overlay-put overlay 'priority 10)
+   (overlay-put overlay 'type type)
+
+   (goto-char (1- beg))
+   (insert prefix)
+   (insert-button (notmuch-wash-button-label overlay)
+  'invisibility-spec invis-spec
+  'overlay overlay
+  :type button-type))
+
+  (when scene-of-crime
+   (goto-char scene-of-crime)
+   (delete-char 1)
 
 (defun notmuch-wash-excerpt-citations (msg depth)
   Excerpt citations and up to one signature.
-- 
1.7.8.3

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


Re: [PATCH 1/1] emacs: Take more care when hiding regions with buttons.

2012-01-25 Thread Dmitry Kurochkin
On Wed, 25 Jan 2012 15:05:08 +, David Edmondson d...@dme.org wrote:
 If the region to be hidden with a button by
 `notmuch-wash-region-to-button' starts at the beginning of the buffer,
 the invisible region will include the inserted button. This is
 unfortunate, as it means that it is not possible to see the button to
 be pressed.
 
 Make a little space at the start of the buffer before inserting the
 button to avoid this, not forgetting to remove the inserted space upon
 completion.
 ---
 
 This is a hack, but I couldn't see another way around it. Can anyone
 find a better solution?
 

I think it would be much easier to understand the problem and probably
suggest a solution if there is a test :)

Regards,
  Dmitry

  emacs/notmuch-wash.el |   57 
  1 files changed, 38 insertions(+), 19 deletions(-)
 
 diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
 index 5c1e830..4afd3b3 100644
 --- a/emacs/notmuch-wash.el
 +++ b/emacs/notmuch-wash.el
 @@ -147,25 +147,44 @@ insert before the button, probably for indentation.
;; symbols because of the way the button code works. Note that
;; replacing intern-soft with make-symbol will cause this to fail,
;; since the newly created symbol has no plist.
 -
 -  (let ((overlay (make-overlay beg end))
 - (message-invis-spec (plist-get msg :message-invis-spec))
 - (invis-spec (make-symbol (concat notmuch- type -region)))
 - (button-type (intern-soft (concat notmuch-wash-button-
 -   type -toggle-type
 -(add-to-invisibility-spec invis-spec)
 -(overlay-put overlay 'invisible (list invis-spec message-invis-spec))
 -(overlay-put overlay 'isearch-open-invisible 
 #'notmuch-wash-region-isearch-show)
 -(overlay-put overlay 'priority 10)
 -(overlay-put overlay 'type type)
 -(goto-char (1+ end))
 -(save-excursion
 -  (goto-char (1- beg))
 -  (insert prefix)
 -  (insert-button (notmuch-wash-button-label overlay)
 -  'invisibility-spec invis-spec
 -  'overlay overlay
 -  :type button-type
 +  (save-excursion
 +;; If the beginning of the region to be converted to a button is the
 +;; beginning of the buffer we must move forward a little to avoid
 +;; creating an overlay that will hide the button intended to be used
 +;; to reveal the hidden region.
 +(let (scene-of-crime)
 +  (when (eq beg (point-min))
 + (goto-char (point-min))
 + (insert \n)
 + (setq scene-of-crime (point-min)
 +   beg (point)))
 +
 +  ;; This uses some slightly tricky conversions between strings and
 +  ;; symbols because of the way the button code works. Note that
 +  ;; replacing intern-soft with make-symbol will cause this to fail,
 +  ;; since the newly created symbol has no plist.
 +
 +  (let ((overlay (make-overlay beg end))
 + (message-invis-spec (plist-get msg :message-invis-spec))
 + (invis-spec (make-symbol (concat notmuch- type -region)))
 + (button-type (intern-soft (concat notmuch-wash-button-
 +   type -toggle-type
 + (add-to-invisibility-spec invis-spec)
 + (overlay-put overlay 'invisible (list invis-spec message-invis-spec))
 + (overlay-put overlay 'isearch-open-invisible 
 #'notmuch-wash-region-isearch-show)
 + (overlay-put overlay 'priority 10)
 + (overlay-put overlay 'type type)
 +
 + (goto-char (1- beg))
 + (insert prefix)
 + (insert-button (notmuch-wash-button-label overlay)
 +'invisibility-spec invis-spec
 +'overlay overlay
 +:type button-type))
 +
 +  (when scene-of-crime
 + (goto-char scene-of-crime)
 + (delete-char 1)
  
  (defun notmuch-wash-excerpt-citations (msg depth)
Excerpt citations and up to one signature.
 -- 
 1.7.8.3
 
 ___
 notmuch mailing list
 notmuch@notmuchmail.org
 http://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 1/1] emacs: Take more care when hiding regions with buttons.

2012-01-25 Thread David Edmondson
On Wed, 25 Jan 2012 19:10:35 +0400, Dmitry Kurochkin 
dmitry.kuroch...@gmail.com wrote:
 On Wed, 25 Jan 2012 15:05:08 +, David Edmondson d...@dme.org wrote:
  If the region to be hidden with a button by
  `notmuch-wash-region-to-button' starts at the beginning of the buffer,
  the invisible region will include the inserted button. This is
  unfortunate, as it means that it is not possible to see the button to
  be pressed.
  
  Make a little space at the start of the buffer before inserting the
  button to avoid this, not forgetting to remove the inserted space upon
  completion.
  ---
  
  This is a hack, but I couldn't see another way around it. Can anyone
  find a better solution?
  
 
 I think it would be much easier to understand the problem and probably
 suggest a solution if there is a test :)

Wow, and I have that new test infrastructure to use!

 
 Regards,
   Dmitry
 
   emacs/notmuch-wash.el |   57 
  
   1 files changed, 38 insertions(+), 19 deletions(-)
  
  diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
  index 5c1e830..4afd3b3 100644
  --- a/emacs/notmuch-wash.el
  +++ b/emacs/notmuch-wash.el
  @@ -147,25 +147,44 @@ insert before the button, probably for indentation.
 ;; symbols because of the way the button code works. Note that
 ;; replacing intern-soft with make-symbol will cause this to fail,
 ;; since the newly created symbol has no plist.
  -
  -  (let ((overlay (make-overlay beg end))
  -   (message-invis-spec (plist-get msg :message-invis-spec))
  -   (invis-spec (make-symbol (concat notmuch- type -region)))
  -   (button-type (intern-soft (concat notmuch-wash-button-
  - type -toggle-type
  -(add-to-invisibility-spec invis-spec)
  -(overlay-put overlay 'invisible (list invis-spec message-invis-spec))
  -(overlay-put overlay 'isearch-open-invisible 
  #'notmuch-wash-region-isearch-show)
  -(overlay-put overlay 'priority 10)
  -(overlay-put overlay 'type type)
  -(goto-char (1+ end))
  -(save-excursion
  -  (goto-char (1- beg))
  -  (insert prefix)
  -  (insert-button (notmuch-wash-button-label overlay)
  -'invisibility-spec invis-spec
  -'overlay overlay
  -:type button-type
  +  (save-excursion
  +;; If the beginning of the region to be converted to a button is the
  +;; beginning of the buffer we must move forward a little to avoid
  +;; creating an overlay that will hide the button intended to be used
  +;; to reveal the hidden region.
  +(let (scene-of-crime)
  +  (when (eq beg (point-min))
  +   (goto-char (point-min))
  +   (insert \n)
  +   (setq scene-of-crime (point-min)
  + beg (point)))
  +
  +  ;; This uses some slightly tricky conversions between strings and
  +  ;; symbols because of the way the button code works. Note that
  +  ;; replacing intern-soft with make-symbol will cause this to fail,
  +  ;; since the newly created symbol has no plist.
  +
  +  (let ((overlay (make-overlay beg end))
  +   (message-invis-spec (plist-get msg :message-invis-spec))
  +   (invis-spec (make-symbol (concat notmuch- type -region)))
  +   (button-type (intern-soft (concat notmuch-wash-button-
  + type -toggle-type
  +   (add-to-invisibility-spec invis-spec)
  +   (overlay-put overlay 'invisible (list invis-spec message-invis-spec))
  +   (overlay-put overlay 'isearch-open-invisible 
  #'notmuch-wash-region-isearch-show)
  +   (overlay-put overlay 'priority 10)
  +   (overlay-put overlay 'type type)
  +
  +   (goto-char (1- beg))
  +   (insert prefix)
  +   (insert-button (notmuch-wash-button-label overlay)
  +  'invisibility-spec invis-spec
  +  'overlay overlay
  +  :type button-type))
  +
  +  (when scene-of-crime
  +   (goto-char scene-of-crime)
  +   (delete-char 1)
   
   (defun notmuch-wash-excerpt-citations (msg depth)
 Excerpt citations and up to one signature.
  -- 
  1.7.8.3
  
  ___
  notmuch mailing list
  notmuch@notmuchmail.org
  http://notmuchmail.org/mailman/listinfo/notmuch


pgpbXZMk6Lacb.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[RFC PATCH] bikeshed uncrustify options

2012-01-25 Thread Tomi Ollila
Look or try. thoughts ?

Questions:

Is (generally) using *INDENT-(OFF|ON)*  ok ? 

Would it be ok to have
#define STRINGIFY(s) STRINGIFY_ (s)

(now such expansion disabled by INDENT-OFF)
When used, it is still thought as function call,
and whitespace added.

What about enum { } \n format_sel change below ?

After applying this patch and running:

$ uncrustify --replace -c devel/uncrustify.cfg *.[ch]

one can discuss (at least):

* should there be space after '!'
* should there be space after (cast)

---
 devel/uncrustify.cfg |3 ++-
 notmuch-client.h |5 -
 notmuch-reply.c  |2 ++
 notmuch-search.c |   13 +
 notmuch-show.c   |8 
 notmuch-time.c   |3 +++
 6 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/devel/uncrustify.cfg b/devel/uncrustify.cfg
index d8075ba..a752fae 100644
--- a/devel/uncrustify.cfg
+++ b/devel/uncrustify.cfg
@@ -58,7 +58,8 @@ nl_after_struct = 0
 # Extra types used in notmuch source.
 # (add more on demand)
 
-type GMimeObject mime_node_t
+type GMimeObject GMimeCryptoContext GMimeCipherContext
+type mime_node_t notmuch_message_t
 
 #
 # inter-character spacing options
diff --git a/notmuch-client.h b/notmuch-client.h
index e0eb594..131e453 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -59,8 +59,10 @@
 
 #define unused(x) x __attribute__ ((unused))
 
+/* *INDENT-OFF* */
 #define STRINGIFY(s) STRINGIFY_(s)
 #define STRINGIFY_(s) #s
+/* *INDENT-ON* */
 
 struct mime_node;
 struct notmuch_show_params;
@@ -377,7 +379,8 @@ mime_node_t *
 mime_node_child (mime_node_t *parent, int child);
 
 /* Return the nth child of node in a depth-first traversal.  If n is
- * 0, returns node itself.  Returns NULL if there is no such part. */
+ * 0, returns node itself.  Returns NULL if there is no such part.
+ */
 mime_node_t *
 mime_node_seek_dfs (mime_node_t *node, int n);
 
diff --git a/notmuch-reply.c b/notmuch-reply.c
index f55b1d2..57742c4 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -31,6 +31,7 @@ static void
 reply_part_content (GMimeObject *part);
 
 static const notmuch_show_format_t format_reply = {
+/* *INDENT-OFF* */
 , NULL,
, NULL,
, NULL, reply_headers_message_part, \n,
@@ -44,6 +45,7 @@ static const notmuch_show_format_t format_reply = {
,
, ,
 
+/* *INDENT-ON* */
 };
 
 static void
diff --git a/notmuch-search.c b/notmuch-search.c
index d504051..57ec603 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -65,6 +65,7 @@ format_thread_text (const void *ctx,
const char *authors,
const char *subject);
 static const search_format_t format_text = {
+/* *INDENT-OFF* */
 ,
,
format_item_id_text,
@@ -75,6 +76,7 @@ static const search_format_t format_text = {
,
 \n,
 ,
+/* *INDENT-ON* */
 };
 
 static void
@@ -91,6 +93,7 @@ format_thread_json (const void *ctx,
const char *authors,
const char *subject);
 static const search_format_t format_json = {
+/* *INDENT-OFF* */
 [,
{,
format_item_id_json,
@@ -101,6 +104,7 @@ static const search_format_t format_json = {
},
 ]\n,
 ]\n,
+/* *INDENT-ON* */
 };
 
 static void
@@ -160,7 +164,7 @@ format_item_id_json (const void *ctx,
 printf (%s, json_quote_str (ctx_quote, item_id));
 
 talloc_free (ctx_quote);
-
+
 }
 
 static void
@@ -333,7 +337,7 @@ do_search_messages (const search_format_t *format,
 
first_message = 0;
}
-   
+
notmuch_filenames_destroy( filenames );
 
} else { /* output == OUTPUT_MESSAGES */
@@ -427,8 +431,9 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
 size_t search_exclude_tags_length;
 unsigned int i;
 
-enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT }
-   format_sel = NOTMUCH_FORMAT_TEXT;
+enum { /* note: also emacs indents this wrongly if not like this. */
+   NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT
+} format_sel = NOTMUCH_FORMAT_TEXT;
 
 notmuch_opt_desc_t options[] = {
{ NOTMUCH_OPT_KEYWORD, sort, sort, 's',
diff --git a/notmuch-show.c b/notmuch-show.c
index dec799c..dfe37bc 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -42,6 +42,7 @@ static void
 format_part_end_text (GMimeObject *part);
 
 static const notmuch_show_format_t format_text = {
+/* *INDENT-OFF* */
 , NULL,
\fmessage{ , format_message_text,
\fheader{\n, format_headers_text, 
format_headers_message_part_text, \fheader}\n,
@@ -55,6 +56,7 @@ static const notmuch_show_format_t format_text = {
\fbody}\n,
\fmessage}\n, ,
 
+/* *INDENT-ON* */
 };
 
 static void
@@ -89,6 +91,7 @@ static void
 format_part_end_json (GMimeObject *part);
 
 static const notmuch_show_format_t format_json = {
+/* *INDENT-OFF* */
 [, NULL,
{, format_message_json,
\headers\: {, 

[PATCH 0/4 v2] more care when hiding regions with buttons

2012-01-25 Thread David Edmondson
Added a test, which required some improvements to the test harness.

The fix still seems awkward.

David Edmondson (4):
  test: `visible-buffer-substring' should not return text properties.
  test: `notmuch-test-run' should protect against buffer switching.
  test: Add test for Original Message hiding at point-min.
  emacs: Take more care when hiding regions with buttons.

 emacs/notmuch-wash.el |   57 ++---
 test/emacs-original-message-hiding.el |   15 +
 test/emacs-original-message-hiding.sh |   19 +++
 test/notmuch-test |1 +
 test/test-lib.el  |6 ++-
 5 files changed, 77 insertions(+), 21 deletions(-)
 create mode 100644 test/emacs-original-message-hiding.el
 create mode 100755 test/emacs-original-message-hiding.sh

-- 
1.7.8.3

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


[PATCH 3/4 v2] test: Add test for Original Message hiding at point-min.

2012-01-25 Thread David Edmondson
---
 test/emacs-original-message-hiding.el |   15 +++
 test/emacs-original-message-hiding.sh |   20 
 test/notmuch-test |1 +
 3 files changed, 36 insertions(+), 0 deletions(-)
 create mode 100644 test/emacs-original-message-hiding.el
 create mode 100755 test/emacs-original-message-hiding.sh

diff --git a/test/emacs-original-message-hiding.el 
b/test/emacs-original-message-hiding.el
new file mode 100644
index 000..bbacbeb
--- /dev/null
+++ b/test/emacs-original-message-hiding.el
@@ -0,0 +1,15 @@
+(defun notmuch-test-original-message-hiding ()
+  (let ((notmuch-show-insert-text/plain-hook '(notmuch-wash-excerpt-citations))
+   (expected \
+Sender sen...@example.com (2010-01-05) (inbox)
+Subject: hiding an Original Message
+To: mailingl...@notmuchmail.org
+Date: Tue, 05 Jan 2010 15:43:56 -
+
+[ 2-line hidden original message. Click/Enter to show. ]
+
+)
+   output)
+(notmuch-show id:\test_mess...@test.org\)
+(setq output (visible-buffer-string))
+(notmuch-test-expect-equal output expected)))
diff --git a/test/emacs-original-message-hiding.sh 
b/test/emacs-original-message-hiding.sh
new file mode 100755
index 000..01cf98d
--- /dev/null
+++ b/test/emacs-original-message-hiding.sh
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+
+test_description=emacs Original Message hiding
+. test-lib.sh
+
+test_begin_subtest Hiding an Original Message region at point-min
+add_message \
+'[id]=test_mess...@test.org' \
+'[from]=Sender sen...@example.com' \
+'[to]=mailingl...@notmuchmail.org' \
+'[subject]=hiding an Original Message' \
+'[date]=Tue, 05 Jan 2010 15:43:56 -' \
+'[body]=-Original Message-
+Text here.
+'
+test_subtest_known_broken
+test_emacs_expect_t \
+'(load emacs-original-message-hiding.el) 
(notmuch-test-original-message-hiding)'
+
+test_done
diff --git a/test/notmuch-test b/test/notmuch-test
index 3f1740c..af132fc 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -54,6 +54,7 @@ TESTS=
   argument-parsing
   emacs-test-functions.sh
   emacs-address-cleaning.sh
+  emacs-original-message-hiding.sh
 
 TESTS=${NOTMUCH_TESTS:=$TESTS}
 
-- 
1.7.8.3

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


Re: [RFC PATCH] bikeshed uncrustify options

2012-01-25 Thread Jani Nikula

Coding style bikeshedding, wonderful. :)

On Wed, 25 Jan 2012 17:21:26 +0200, Tomi Ollila tomi.oll...@iki.fi wrote:
 Is (generally) using *INDENT-(OFF|ON)*  ok ? 

Obviously I wish we could do without.

You should cook up a wrapper for uncrustify that takes a patch, applies
it, and checks if it introduces new coding style issues, but ignores the
existing ones. ;)

 Would it be ok to have
 #define STRINGIFY(s) STRINGIFY_ (s)

Why not, it's the notmuch style?

 (now such expansion disabled by INDENT-OFF)
 When used, it is still thought as function call,
 and whitespace added.
 
 What about enum { } \n format_sel change below ?

See comment inline below.

 After applying this patch and running:
 
 $ uncrustify --replace -c devel/uncrustify.cfg *.[ch]
 
 one can discuss (at least):
 
 * should there be space after '!'

That's like having space in '- foo' or '~ foo', isn't it? I'd prefer no
space after unary operators.

 * should there be space after (cast)

Yes, please.

 
 ---
  devel/uncrustify.cfg |3 ++-
  notmuch-client.h |5 -
  notmuch-reply.c  |2 ++
  notmuch-search.c |   13 +
  notmuch-show.c   |8 
  notmuch-time.c   |3 +++
  6 files changed, 28 insertions(+), 6 deletions(-)
 
 diff --git a/devel/uncrustify.cfg b/devel/uncrustify.cfg
 index d8075ba..a752fae 100644
 --- a/devel/uncrustify.cfg
 +++ b/devel/uncrustify.cfg
 @@ -58,7 +58,8 @@ nl_after_struct = 0
  # Extra types used in notmuch source.
  # (add more on demand)
  
 -type GMimeObject mime_node_t
 +type GMimeObject GMimeCryptoContext GMimeCipherContext
 +type mime_node_t notmuch_message_t
  
  #
  # inter-character spacing options
 diff --git a/notmuch-client.h b/notmuch-client.h
 index e0eb594..131e453 100644
 --- a/notmuch-client.h
 +++ b/notmuch-client.h
 @@ -59,8 +59,10 @@
  
  #define unused(x) x __attribute__ ((unused))
  
 +/* *INDENT-OFF* */
  #define STRINGIFY(s) STRINGIFY_(s)
  #define STRINGIFY_(s) #s
 +/* *INDENT-ON* */
  
  struct mime_node;
  struct notmuch_show_params;
 @@ -377,7 +379,8 @@ mime_node_t *
  mime_node_child (mime_node_t *parent, int child);
  
  /* Return the nth child of node in a depth-first traversal.  If n is
 - * 0, returns node itself.  Returns NULL if there is no such part. */
 + * 0, returns node itself.  Returns NULL if there is no such part.
 + */
  mime_node_t *
  mime_node_seek_dfs (mime_node_t *node, int n);
  
 diff --git a/notmuch-reply.c b/notmuch-reply.c
 index f55b1d2..57742c4 100644
 --- a/notmuch-reply.c
 +++ b/notmuch-reply.c
 @@ -31,6 +31,7 @@ static void
  reply_part_content (GMimeObject *part);
  
  static const notmuch_show_format_t format_reply = {
 +/* *INDENT-OFF* */

What does it do here without the comment?

  , NULL,
   , NULL,
   , NULL, reply_headers_message_part, \n,
 @@ -44,6 +45,7 @@ static const notmuch_show_format_t format_reply = {
   ,
   , ,
  
 +/* *INDENT-ON* */
  };
  
  static void
 diff --git a/notmuch-search.c b/notmuch-search.c
 index d504051..57ec603 100644
 --- a/notmuch-search.c
 +++ b/notmuch-search.c
 @@ -65,6 +65,7 @@ format_thread_text (const void *ctx,
   const char *authors,
   const char *subject);
  static const search_format_t format_text = {
 +/* *INDENT-OFF* */
  ,
   ,
   format_item_id_text,
 @@ -75,6 +76,7 @@ static const search_format_t format_text = {
   ,
  \n,
  ,
 +/* *INDENT-ON* */
  };
  
  static void
 @@ -91,6 +93,7 @@ format_thread_json (const void *ctx,
   const char *authors,
   const char *subject);
  static const search_format_t format_json = {
 +/* *INDENT-OFF* */
  [,
   {,
   format_item_id_json,
 @@ -101,6 +104,7 @@ static const search_format_t format_json = {
   },
  ]\n,
  ]\n,
 +/* *INDENT-ON* */
  };
  
  static void
 @@ -160,7 +164,7 @@ format_item_id_json (const void *ctx,
  printf (%s, json_quote_str (ctx_quote, item_id));
  
  talloc_free (ctx_quote);
 -
 +
  }
  
  static void
 @@ -333,7 +337,7 @@ do_search_messages (const search_format_t *format,
  
   first_message = 0;
   }
 - 
 +
   notmuch_filenames_destroy( filenames );
  
   } else { /* output == OUTPUT_MESSAGES */
 @@ -427,8 +431,9 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
  size_t search_exclude_tags_length;
  unsigned int i;
  
 -enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT }
 - format_sel = NOTMUCH_FORMAT_TEXT;
 +enum { /* note: also emacs indents this wrongly if not like this. */
 + NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT
 +} format_sel = NOTMUCH_FORMAT_TEXT;

I prefer this style anyway. Compare with:

struct { int foo; int bar; } baz;

which I think would be frowned upon.

  
  notmuch_opt_desc_t options[] = {
   { NOTMUCH_OPT_KEYWORD, sort, sort, 's',
 diff --git a/notmuch-show.c b/notmuch-show.c
 index dec799c..dfe37bc 100644
 --- 

Re: Emacs: Crypto: How to get automatic encryption?

2012-01-25 Thread Jameson Graef Rollins
On Wed, 25 Jan 2012 10:20:26 +, David Edmondson d...@dme.org wrote:
 Isn't it still necessary to ensure that you have encryption keys
 appropriate to the recipient?

I want to ensure that all replies to encrypted to be encrypted.  I would
rather have the reply fail outright than fall back to unencrypted.

Here's a behavior that I think would be reasonable:

 * notmuch reply outputs JSON encrypted flag

 * emacs does a quick check to see if the needed key is available

 * if key not available: give a nice mini-buffer prompt, something like:
 
'encryption key for Foo Bar f...@bar.com not found.  Retrieve?'

   * if response is yes: call gpg to retrieve the key

 * if key available: add encrypt flag

   else: I feel like this should abort, but maybe there's something to
 be done here.  Allow reply but don't quote the original?

jamie.


pgp2F9SRA2eFT.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 3/4 v2] test: Add test for Original Message hiding at point-min.

2012-01-25 Thread Dmitry Kurochkin
On Wed, 25 Jan 2012 15:45:27 +, David Edmondson d...@dme.org wrote:
 ---
  test/emacs-original-message-hiding.el |   15 +++
  test/emacs-original-message-hiding.sh |   20 
  test/notmuch-test |1 +
  3 files changed, 36 insertions(+), 0 deletions(-)
  create mode 100644 test/emacs-original-message-hiding.el
  create mode 100755 test/emacs-original-message-hiding.sh
 
 diff --git a/test/emacs-original-message-hiding.el 
 b/test/emacs-original-message-hiding.el
 new file mode 100644
 index 000..bbacbeb
 --- /dev/null
 +++ b/test/emacs-original-message-hiding.el
 @@ -0,0 +1,15 @@
 +(defun notmuch-test-original-message-hiding ()
 +  (let ((notmuch-show-insert-text/plain-hook 
 '(notmuch-wash-excerpt-citations))

Do we have to override the default value here?  I thought
notmuch-wash-excerpt-citations was enabled by default.

 + (expected \
 +Sender sen...@example.com (2010-01-05) (inbox)
 +Subject: hiding an Original Message
 +To: mailingl...@notmuchmail.org
 +Date: Tue, 05 Jan 2010 15:43:56 -
 +
 +[ 2-line hidden original message. Click/Enter to show. ]
 +
 +)
 + output)
 +(notmuch-show id:\test_mess...@test.org\)
 +(setq output (visible-buffer-string))
 +(notmuch-test-expect-equal output expected)))

IMO writing the test in lisp does not give any benefit in this case.
Quite the opposite: a simple test is split in two files and becomes more
complex.

But since we accepted this way of writing tests and you seem to prefer
it, I would not argue about changing it.

 diff --git a/test/emacs-original-message-hiding.sh 
 b/test/emacs-original-message-hiding.sh
 new file mode 100755
 index 000..01cf98d
 --- /dev/null
 +++ b/test/emacs-original-message-hiding.sh

Let's rename this file to something a bit more general, e.g.
emacs-message-hiding.  Then we can put new tests (and move all
existing!) related to hiding message parts into it.

 @@ -0,0 +1,20 @@
 +#!/usr/bin/env bash
 +
 +test_description=emacs Original Message hiding
 +. test-lib.sh
 +
 +test_begin_subtest Hiding an Original Message region at point-min
 +add_message \
 +'[id]=test_mess...@test.org' \

The message-id should be more unique to avoid collisions with other
tests.  IMO deriving message-id from the test description is a good
practice.  Also, consider assigning it to a variable and using it
instead of the string.  Since part of the test is in lisp, it is tricky
to use this variable in it.  Perhaps we should pass it as a parameter to
notmuch-test-original-message-hiding?  Or just do not bother and use
string constants :)  Your choice.

Regards,
  Dmitry

 +'[from]=Sender sen...@example.com' \
 +'[to]=mailingl...@notmuchmail.org' \
 +'[subject]=hiding an Original Message' \
 +'[date]=Tue, 05 Jan 2010 15:43:56 -' \
 +'[body]=-Original Message-
 +Text here.
 +'
 +test_subtest_known_broken
 +test_emacs_expect_t \
 +'(load emacs-original-message-hiding.el) 
 (notmuch-test-original-message-hiding)'
 +
 +test_done
 diff --git a/test/notmuch-test b/test/notmuch-test
 index 3f1740c..af132fc 100755
 --- a/test/notmuch-test
 +++ b/test/notmuch-test
 @@ -54,6 +54,7 @@ TESTS=
argument-parsing
emacs-test-functions.sh
emacs-address-cleaning.sh
 +  emacs-original-message-hiding.sh
  
  TESTS=${NOTMUCH_TESTS:=$TESTS}
  
 -- 
 1.7.8.3
 
 ___
 notmuch mailing list
 notmuch@notmuchmail.org
 http://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 4/4 v2] emacs: Take more care when hiding regions with buttons.

2012-01-25 Thread Dmitry Kurochkin
On Wed, 25 Jan 2012 15:45:28 +, David Edmondson d...@dme.org wrote:
 If the region to be hidden with a button by
 `notmuch-wash-region-to-button' starts at the beginning of the buffer,
 the invisible region will include the inserted button. This is
 unfortunate, as it means that it is not possible to see the button to
 be pressed.
 
 Make a little space at the start of the buffer before inserting the
 button to avoid this, not forgetting to remove the inserted space upon
 completion.
 
 Mark the relevant test as no longer broken.
 ---

I will try to find some time to play with the test and look for
alternative solutions.

Regards,
  Dmitry

  emacs/notmuch-wash.el |   57 
 ++---
  test/emacs-original-message-hiding.sh |1 -
  2 files changed, 38 insertions(+), 20 deletions(-)
 
 diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
 index 5c1e830..4afd3b3 100644
 --- a/emacs/notmuch-wash.el
 +++ b/emacs/notmuch-wash.el
 @@ -147,25 +147,44 @@ insert before the button, probably for indentation.
;; symbols because of the way the button code works. Note that
;; replacing intern-soft with make-symbol will cause this to fail,
;; since the newly created symbol has no plist.
 -
 -  (let ((overlay (make-overlay beg end))
 - (message-invis-spec (plist-get msg :message-invis-spec))
 - (invis-spec (make-symbol (concat notmuch- type -region)))
 - (button-type (intern-soft (concat notmuch-wash-button-
 -   type -toggle-type
 -(add-to-invisibility-spec invis-spec)
 -(overlay-put overlay 'invisible (list invis-spec message-invis-spec))
 -(overlay-put overlay 'isearch-open-invisible 
 #'notmuch-wash-region-isearch-show)
 -(overlay-put overlay 'priority 10)
 -(overlay-put overlay 'type type)
 -(goto-char (1+ end))
 -(save-excursion
 -  (goto-char (1- beg))
 -  (insert prefix)
 -  (insert-button (notmuch-wash-button-label overlay)
 -  'invisibility-spec invis-spec
 -  'overlay overlay
 -  :type button-type
 +  (save-excursion
 +;; If the beginning of the region to be converted to a button is the
 +;; beginning of the buffer we must move forward a little to avoid
 +;; creating an overlay that will hide the button intended to be used
 +;; to reveal the hidden region.
 +(let (scene-of-crime)
 +  (when (eq beg (point-min))
 + (goto-char (point-min))
 + (insert \n)
 + (setq scene-of-crime (point-min)
 +   beg (point)))
 +
 +  ;; This uses some slightly tricky conversions between strings and
 +  ;; symbols because of the way the button code works. Note that
 +  ;; replacing intern-soft with make-symbol will cause this to fail,
 +  ;; since the newly created symbol has no plist.
 +
 +  (let ((overlay (make-overlay beg end))
 + (message-invis-spec (plist-get msg :message-invis-spec))
 + (invis-spec (make-symbol (concat notmuch- type -region)))
 + (button-type (intern-soft (concat notmuch-wash-button-
 +   type -toggle-type
 + (add-to-invisibility-spec invis-spec)
 + (overlay-put overlay 'invisible (list invis-spec message-invis-spec))
 + (overlay-put overlay 'isearch-open-invisible 
 #'notmuch-wash-region-isearch-show)
 + (overlay-put overlay 'priority 10)
 + (overlay-put overlay 'type type)
 +
 + (goto-char (1- beg))
 + (insert prefix)
 + (insert-button (notmuch-wash-button-label overlay)
 +'invisibility-spec invis-spec
 +'overlay overlay
 +:type button-type))
 +
 +  (when scene-of-crime
 + (goto-char scene-of-crime)
 + (delete-char 1)
  
  (defun notmuch-wash-excerpt-citations (msg depth)
Excerpt citations and up to one signature.
 diff --git a/test/emacs-original-message-hiding.sh 
 b/test/emacs-original-message-hiding.sh
 index 01cf98d..038ef4f 100755
 --- a/test/emacs-original-message-hiding.sh
 +++ b/test/emacs-original-message-hiding.sh
 @@ -13,7 +13,6 @@ add_message \
  '[body]=-Original Message-
  Text here.
  '
 -test_subtest_known_broken
  test_emacs_expect_t \
  '(load emacs-original-message-hiding.el) 
 (notmuch-test-original-message-hiding)'
  
 -- 
 1.7.8.3
 
 ___
 notmuch mailing list
 notmuch@notmuchmail.org
 http://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [RFC PATCH] bikeshed uncrustify options

2012-01-25 Thread Tomi Ollila
On Wed, 25 Jan 2012 08:41:52 -0800, Jameson Graef Rollins 
jroll...@finestructure.net wrote:
 On Wed, 25 Jan 2012 17:21:26 +0200, Tomi Ollila tomi.oll...@iki.fi wrote:
  -type GMimeObject mime_node_t
  +type GMimeObject GMimeCryptoContext GMimeCipherContext
  +type mime_node_t notmuch_message_t
 
 This must be a mistake.  Presumably this hasn't been properly rebased
 against the latest master, which includes Austin's part 2 show rewrite.

$ git reset --hard origin/master
$ git describe
debian/0.11-1-116-ge6e10b8
$ git am foo.am
Applying: bikeshed uncrustify options
$

 jamie.

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


[PATCH] emacs: polish notmuch-hello help text

2012-01-25 Thread Dmitry Kurochkin
Make `=' binding description consistent with others.
---
 emacs/notmuch-hello.el |2 +-
 test/emacs.expected-output/notmuch-hello   |2 +-
 .../notmuch-hello-no-saved-searches|2 +-
 .../emacs.expected-output/notmuch-hello-with-empty |2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index ab65e36..d17a30f 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -580,7 +580,7 @@ Complete list of currently available key bindings:
(when notmuch-saved-searches
  (widget-insert Edit saved searches with the `edit' button.\n))
(widget-insert Hit RET or click on a saved search or tag name to view 
matching threads.\n)
-   (widget-insert `=' refreshes this screen. `s' to search messages. `q' 
to quit.\n)
+   (widget-insert `=' to refresh this screen. `s' to search messages. `q' 
to quit.\n)
(let ((fill-column (- (window-width) notmuch-hello-indent)))
  (center-region start (point
 
diff --git a/test/emacs.expected-output/notmuch-hello 
b/test/emacs.expected-output/notmuch-hello
index c43ab8c..3e59595 100644
--- a/test/emacs.expected-output/notmuch-hello
+++ b/test/emacs.expected-output/notmuch-hello
@@ -11,4 +11,4 @@ Search:   
  .
 Type a search query and hit RET to view matching threads.
Edit saved searches with the `edit' button.
   Hit RET or click on a saved search or tag name to view matching threads.
-  `=' refreshes this screen. `s' to search messages. `q' to quit.
+  `=' to refresh this screen. `s' to search messages. `q' to quit.
diff --git a/test/emacs.expected-output/notmuch-hello-no-saved-searches 
b/test/emacs.expected-output/notmuch-hello-no-saved-searches
index 080a56b..ef0e5d0 100644
--- a/test/emacs.expected-output/notmuch-hello-no-saved-searches
+++ b/test/emacs.expected-output/notmuch-hello-no-saved-searches
@@ -7,4 +7,4 @@ Search: 
.
 Type a search query and hit RET to view matching threads.
Edit saved searches with the `edit' button.
   Hit RET or click on a saved search or tag name to view matching threads.
-  `=' refreshes this screen. `s' to search messages. `q' to quit.
+  `=' to refresh this screen. `s' to search messages. `q' to quit.
diff --git a/test/emacs.expected-output/notmuch-hello-with-empty 
b/test/emacs.expected-output/notmuch-hello-with-empty
index a9e312c..71edba7 100644
--- a/test/emacs.expected-output/notmuch-hello-with-empty
+++ b/test/emacs.expected-output/notmuch-hello-with-empty
@@ -11,4 +11,4 @@ Search:   
  .
 Type a search query and hit RET to view matching threads.
Edit saved searches with the `edit' button.
   Hit RET or click on a saved search or tag name to view matching threads.
-  `=' refreshes this screen. `s' to search messages. `q' to quit.
+  `=' to refresh this screen. `s' to search messages. `q' to quit.
-- 
1.7.8.3

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


Re: [RFC PATCH] bikeshed uncrustify options

2012-01-25 Thread Jameson Graef Rollins
On Wed, 25 Jan 2012 20:24:19 +0200, Tomi Ollila tomi.oll...@iki.fi wrote:
 On Wed, 25 Jan 2012 08:41:52 -0800, Jameson Graef Rollins 
 jroll...@finestructure.net wrote:
  On Wed, 25 Jan 2012 17:21:26 +0200, Tomi Ollila tomi.oll...@iki.fi wrote:
   -type GMimeObject mime_node_t
   +type GMimeObject GMimeCryptoContext GMimeCipherContext
   +type mime_node_t notmuch_message_t
  
  This must be a mistake.  Presumably this hasn't been properly rebased
  against the latest master, which includes Austin's part 2 show rewrite.
 
 $ git reset --hard origin/master
 $ git describe
 debian/0.11-1-116-ge6e10b8
 $ git am foo.am
 Applying: bikeshed uncrustify options
 $

Ok, but obviously this patch should not be making this change.

jamie.


pgpwpldY3ksY6.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: Emacs: Crypto: How to get automatic encryption?

2012-01-25 Thread Daniel Kahn Gillmor
On 01/25/2012 12:45 PM, Jameson Graef Rollins wrote:
 Here's a behavior that I think would be reasonable:
 
  * notmuch reply outputs JSON encrypted flag
 
  * emacs does a quick check to see if the needed key is available
 
  * if key not available: give a nice mini-buffer prompt, something like:
  
 'encryption key for Foo Bar f...@bar.com not found.  Retrieve?'
 
* if response is yes: call gpg to retrieve the key
 
  * if key available: add encrypt flag
 
else: I feel like this should abort, but maybe there's something to
  be done here.  Allow reply but don't quote the original?

I note from observing my own correspondence practices that there are
some other heuristics that might be reasonable, if we're willing to be
more sophisticated here too.

For example:

 * if the entire encrypted message body was signed by key X (which we
either have or fetch), and
 * X has a User ID which matches the address to which we're replying, and
 * we don't have a technically-valid matching User ID for the e-mail
address (so we wouldn't normally want to encrypt mail to key X),

then

 we could offer (or default) to encrypt the reply to that key anyway, on
the grounds that the keyholder in question knew the contents of the
original message anyway.

Some visual indication of being in this corner-case state would be nice,
of course.

While i'm dreaming, I'd also love to be able to get some statistics
about how many messages in a given thread have this kind
encryption/signing response.  It would be interesting for some sort of
measurement of e-mail+keyholding continuity, which would be useful in a
more generalized contacts+crypto manager.

--dkg



signature.asc
Description: OpenPGP digital signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: polish notmuch-hello help text

2012-01-25 Thread David Edmondson
Obviously good, +1.


pgp9PO8Q9MCDD.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] uncrustify.cfg: comments and more types

2012-01-25 Thread Tomi Ollila
Changes to devel/uncrustify.cfg:

* Updated header comment to state this is config file for *notmuch*.
* Mentioned in header commit that uncrustify version 0.59 required.
* Use tabs to indent/align comments.
* Added comment about the reason of 'type' keyword used.
* Added some more custom types woth 'type' keyword.
* Have (every) multiline comment lines start with '*'.
---
 devel/uncrustify.cfg |   23 +++
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/devel/uncrustify.cfg b/devel/uncrustify.cfg
index d8075ba..92bb29b 100644
--- a/devel/uncrustify.cfg
+++ b/devel/uncrustify.cfg
@@ -1,13 +1,15 @@
 #
-# uncrustify config file for the linux kernel
+# Uncrustify config file for notmuch.
+# Based on uncrustify config file for the linux kernel
 #
 # $Id: linux-indent.cfg 488 2006-09-09 12:44:38Z bengardner $
 # Taken from the uncrustify distribution under license (GPL2+)
 #
-# sample usage:
+# Sample usage:
 #uncrustify --replace -c uncrustify.cfg foo.c
 #
-#
+# Note: for proper output, uncrustify version 0.59 is required.
+# (without indent_cmt_with_tabs this may work ok with 0.58 (and possibly older)
 
 indent_with_tabs   = 2 # 1=indent to level only, 2=indent with 
tabs
 align_with_tabs= TRUE  # use tabs to align
@@ -18,6 +20,8 @@ indent_columns= 4
 
 indent_label   = -2# pos: absolute col, neg: relative 
column
 
+indent_cmt_with_tabs   = true  # use tabs to indent/align comments
+
 #
 # inter-symbol newlines
 #
@@ -54,11 +58,14 @@ nl_after_struct = 0
 # mod_full_brace_do= remove# do a--; while (); vs do { a--; } 
while ();
 # mod_full_brace_while = remove# while (a) a--; vs while (a) { a--; 
}
 
-#
-# Extra types used in notmuch source.
-# (add more on demand)
 
-type GMimeObject mime_node_t
+# In case some custom types aren't detected properly by uncrustify
+# add those to this section below. For example there are cases where
+# uncrustify doesn't know whether a 'token' is part of pointer type
+# or left operand of a binary multiplication operation. 
+
+type GMimeObject GMimeCryptoContext GMimeCipherContext
+type mime_node_t notmuch_message_t
 
 #
 # inter-character spacing options
@@ -107,7 +114,6 @@ align_right_cmt_span= 8 # align 
comments span this much in func
 # align_pp_define_span = 8;
 # align_pp_define_gap  = 4;
 
-# cmt_star_cont= FALSE
+cmt_star_cont  = true
 
 # indent_brace = 0
-- 
1.7.8.2

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


[Emacs] Bug?: notmuch-search-show-thread shows several threads; only one containing matching messages

2012-01-25 Thread Gregor Zattler
[sorry for the long and meandering explanation, I do not know how
to express the issue more concise]

Dear notmuch developers,

may someone please enlighten me regarding this behaviour: 

I experienced a situation where the Emacs interface shows three
(3) different threads in one notmuch show buffer.  I thought it
should show only one.  Perhaps this is the result of notmuch show
showing messages which do not match the search pattern and do not
belong to one thread which contains messages which do so.[1]


What I did:

I remembered a thread on the Emacs-orgmode mailing list about
date ranges in various Emacs implementations/compilations and
searched for it with this search expression:

folder:orgmode date 64 bit 32

it resulted in a *notmuch-search-folder:orgmode date 64 bit 32*
buffer containing 5 lines with matching threads, one of it with 7
out of 99 matching messages and the subject [O]: dates before
1970, I selected this one with RET (notmuch-search-show-thread)
and got a notmuch show mode buffer.

The buffer begins with this thread (which is the one I
remembered: ~20 messages) but contains 2 more totally different
threads ([O] Slow movement in large buffers and [O] The
Org-ODT exporter is now in Org's core) with no matching
messages at all (at least all of the messages are
invisible/folded).  The starting messages of these two additional
threads were shown with no indentation -- because they start a
thread.

I don't know for sure if the broad search pattern really does not
apply to at least some of the messages in the 2 additional
threads.[1]  But even if: why are they part of the same 
buffer resulting from notmuch-search-show-thread?

In order to further investigate this phenomenon I run notmuch from
the command line like:
notmuch show  --entire-thread  --format=mbox   folder:orgmode date 64 bit 32 
/tmp/date64.mbox

and opened the resulting mbox with mutt.  mutt showed the thread
I was interested in and several other threads which are not part
of this one.  I isolated the thread I was interested in,
extracted the message ids of its messages and greped the rest of
the messages for this message ids: no matches.[2] Therefore no of
the rests messages are part of the thread I was interested in but
some of them were also part of the notmuch show buffer alongside
the one thread I was interested in.

My expectation was to only see one thread: the one with the
matching messages.

So this about the Emacs interface and perhaps about what a
notmuch search matches.

Can somebody please explain this to me?  Since all relevant
messages are public I am able to provide the relevant messages as
one mbox file (2.9 MB).


Ciao, Gregor
-- 
[1] I don't know how to test if messages should show up in an
notmuch serch query with date bit 64 32 being the serach
pattern.  When I did a rgrep -l -I date
/tmp/unmatched.maildir|xargs egrep -l -I bit |xargs egrep -l
-I 64|xargs egrep -l -I 32 I got many hits but this is to be
expected since every e-mail has a Date header and enough
headers to match 64 and 32 and since its a mailing list
discussion software bit is also to be expected in these
e-mails.

[2] grep -I ^Message-Id: /tmp/thread-I-m-interested-in.mbox |sed -e 
s/Message-Id: //I -e s/$// really.mid
grep -I -F really.mid rest.mbox
-- no match
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] emacs: add completion to tag all operation (* binding)

2012-01-25 Thread Dmitry Kurochkin
The patch adds tab completion to tag all operation bound to *
(`notmuch-search-operate-all' function).
---
 emacs/notmuch.el |   48 
 1 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index e02966f..71b0221 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -48,6 +48,7 @@
 ;; required, but is available from http://notmuchmail.org).
 
 (eval-when-compile (require 'cl))
+(require 'crm)
 (require 'mm-view)
 (require 'message)
 
@@ -75,12 +76,33 @@ For example:
 (defvar notmuch-query-history nil
   Variable to store minibuffer history for notmuch queries)
 
-(defun notmuch-select-tag-with-completion (prompt rest search-terms)
+(defun notmuch-tag-completions (optional search-terms prefixes)
   (let ((tag-list
 (with-output-to-string
   (with-current-buffer standard-output
 (apply 'call-process notmuch-command nil t nil search-tags 
search-terms)
-(completing-read prompt (split-string tag-list \n+ t) nil nil nil)))
+(setq tag-list (split-string tag-list \n+ t))
+(if (null prefixes)
+   tag-list
+  (apply #'append
+(mapcar (lambda (tag)
+  (mapcar (lambda (prefix)
+(concat prefix tag)) prefixes))
+tag-list)
+
+(defun notmuch-select-tag-with-completion (prompt optional search-terms 
prefixes)
+  (let ((tag-list (notmuch-tag-completions search-terms prefixes)))
+(completing-read prompt tag-list)))
+
+(defun notmuch-select-tags-with-completion (prompt optional search-terms 
prefixes)
+  (let ((tag-list (notmuch-tag-completions search-terms prefixes))
+   (crm-separator  )
+   (crm-local-completion-map (copy-keymap crm-local-completion-map)))
+;; By default, space is bound to complete word function.
+;; Re-bind it to insert a space instead.  Note that tab still
+;; does the completion.
+(define-key crm-local-completion-map   'self-insert-command)
+(completing-read-multiple prompt tag-list)))
 
 (defun notmuch-foreach-mime-part (function mm-handle)
   (cond ((stringp (car mm-handle))
@@ -860,16 +882,18 @@ will prompt for tags to be added or removed. Tags 
prefixed with
 Each character of the tag name may consist of alphanumeric
 characters as well as `_.+-'.
 
-  (interactive sOperation (+add -drop): notmuch tag )
-  (let ((action-split (split-string action  +)))
-;; Perform some validation
-(let ((words action-split))
-  (when (null words) (error No operation given))
-  (while words
-   (unless (string-match-p ^[-+][-+_.[:word:]]+$ (car words))
- (error Action must be of the form `+thistag -that_tag'))
-   (setq words (cdr words
-(apply 'notmuch-tag notmuch-search-query-string action-split)))
+  (interactive (list (notmuch-select-tags-with-completion
+ Operation (+add -drop): notmuch tag  nil
+ '(+ -
+  (setq action (delete  action))
+  ;; Perform some validation
+  (let ((words action))
+(when (null words) (error No operation given))
+(while words
+  (unless (string-match-p ^[-+][-+_.[:word:]]+$ (car words))
+   (error Action must be of the form `+thistag -that_tag'))
+  (setq words (cdr words
+  (apply 'notmuch-tag notmuch-search-query-string action))
 
 (defun notmuch-search-buffer-title (query)
   Returns the title for a buffer with notmuch search results.
-- 
1.7.8.3

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


Re: [Emacs] Bug?: notmuch-search-show-thread shows several threads; only one containing matching messages

2012-01-25 Thread Austin Clements
Quoth Gregor Zattler on Jan 26 at  1:40 am:
 [sorry for the long and meandering explanation, I do not know how
 to express the issue more concise]
 
 Dear notmuch developers,
 
 may someone please enlighten me regarding this behaviour: 
 
 I experienced a situation where the Emacs interface shows three
 (3) different threads in one notmuch show buffer.  I thought it
 should show only one.  Perhaps this is the result of notmuch show
 showing messages which do not match the search pattern and do not
 belong to one thread which contains messages which do so.[1]

It's always possible that this is a bug, but one potential legitimate
cause comes to mind.  If *any* of the messages in each of the
apparently unrelated threads contain a message ID of any of the
messages in the original thread (or one of the other unrelated
threads) in their References or In-reply-to headers, notmuch will
merge the threads and cause the exact behavior you're seeing.

One very common cause of this is someone using reply to get an
initial set of recipients, but then replacing the entire message and
subject (presumably without realizing that the mail is still tracking
what it was a reply to).  This can also happen if someone
intentionally replies to multiple messages (though few mail clients
support this), or if there was a message ID collision.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v2] emacs: add completion to tag all operation (* binding)

2012-01-25 Thread Dmitry Kurochkin
The patch adds tab completion to tag all operation bound to *
(`notmuch-search-operate-all' function).
---

Changes in v2:

* s/thistag/this_tag/ for consistency with that_tag, since we touch
  the line anyway

Regards,
  Dmitry

 emacs/notmuch.el |   48 
 1 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index e02966f..a57bf70 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -48,6 +48,7 @@
 ;; required, but is available from http://notmuchmail.org).
 
 (eval-when-compile (require 'cl))
+(require 'crm)
 (require 'mm-view)
 (require 'message)
 
@@ -75,12 +76,33 @@ For example:
 (defvar notmuch-query-history nil
   Variable to store minibuffer history for notmuch queries)
 
-(defun notmuch-select-tag-with-completion (prompt rest search-terms)
+(defun notmuch-tag-completions (optional search-terms prefixes)
   (let ((tag-list
 (with-output-to-string
   (with-current-buffer standard-output
 (apply 'call-process notmuch-command nil t nil search-tags 
search-terms)
-(completing-read prompt (split-string tag-list \n+ t) nil nil nil)))
+(setq tag-list (split-string tag-list \n+ t))
+(if (null prefixes)
+   tag-list
+  (apply #'append
+(mapcar (lambda (tag)
+  (mapcar (lambda (prefix)
+(concat prefix tag)) prefixes))
+tag-list)
+
+(defun notmuch-select-tag-with-completion (prompt optional search-terms 
prefixes)
+  (let ((tag-list (notmuch-tag-completions search-terms prefixes)))
+(completing-read prompt tag-list)))
+
+(defun notmuch-select-tags-with-completion (prompt optional search-terms 
prefixes)
+  (let ((tag-list (notmuch-tag-completions search-terms prefixes))
+   (crm-separator  )
+   (crm-local-completion-map (copy-keymap crm-local-completion-map)))
+;; By default, space is bound to complete word function.
+;; Re-bind it to insert a space instead.  Note that tab still
+;; does the completion.
+(define-key crm-local-completion-map   'self-insert-command)
+(completing-read-multiple prompt tag-list)))
 
 (defun notmuch-foreach-mime-part (function mm-handle)
   (cond ((stringp (car mm-handle))
@@ -860,16 +882,18 @@ will prompt for tags to be added or removed. Tags 
prefixed with
 Each character of the tag name may consist of alphanumeric
 characters as well as `_.+-'.
 
-  (interactive sOperation (+add -drop): notmuch tag )
-  (let ((action-split (split-string action  +)))
-;; Perform some validation
-(let ((words action-split))
-  (when (null words) (error No operation given))
-  (while words
-   (unless (string-match-p ^[-+][-+_.[:word:]]+$ (car words))
- (error Action must be of the form `+thistag -that_tag'))
-   (setq words (cdr words
-(apply 'notmuch-tag notmuch-search-query-string action-split)))
+  (interactive (list (notmuch-select-tags-with-completion
+ Operation (+add -drop): notmuch tag  nil
+ '(+ -
+  (setq action (delete  action))
+  ;; Perform some validation
+  (let ((words action))
+(when (null words) (error No operation given))
+(while words
+  (unless (string-match-p ^[-+][-+_.[:word:]]+$ (car words))
+   (error Action must be of the form `+this_tag -that_tag'))
+  (setq words (cdr words
+  (apply 'notmuch-tag notmuch-search-query-string action))
 
 (defun notmuch-search-buffer-title (query)
   Returns the title for a buffer with notmuch search results.
-- 
1.7.8.3

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


Re: [PATCH] emacs: add completion to tag all operation (* binding)

2012-01-25 Thread Austin Clements
Neat.  As an aside, I would love to see a prompt like this for + and
-, allowing multiple tags to be modified at once (and starting out
with whichever of + or - got you in to the prompt).

Quoth Dmitry Kurochkin on Jan 26 at  5:12 am:
 The patch adds tab completion to tag all operation bound to *
 (`notmuch-search-operate-all' function).
 ---
  emacs/notmuch.el |   48 
  1 files changed, 36 insertions(+), 12 deletions(-)
 
 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
 index e02966f..71b0221 100644
 --- a/emacs/notmuch.el
 +++ b/emacs/notmuch.el
 @@ -48,6 +48,7 @@
  ;; required, but is available from http://notmuchmail.org).
  
  (eval-when-compile (require 'cl))
 +(require 'crm)
  (require 'mm-view)
  (require 'message)
  
 @@ -75,12 +76,33 @@ For example:
  (defvar notmuch-query-history nil
Variable to store minibuffer history for notmuch queries)
  
 -(defun notmuch-select-tag-with-completion (prompt rest search-terms)
 +(defun notmuch-tag-completions (optional search-terms prefixes)
(let ((tag-list
(with-output-to-string
  (with-current-buffer standard-output
(apply 'call-process notmuch-command nil t nil search-tags 
 search-terms)
 -(completing-read prompt (split-string tag-list \n+ t) nil nil nil)))
 +(setq tag-list (split-string tag-list \n+ t))
 +(if (null prefixes)
 + tag-list
 +  (apply #'append
 +  (mapcar (lambda (tag)
 +(mapcar (lambda (prefix)
 +  (concat prefix tag)) prefixes))
 +  tag-list)
 +
 +(defun notmuch-select-tag-with-completion (prompt optional search-terms 
 prefixes)

This changes the API of notmuch-select-tag-with-completion in a
non-backwards-compatible way.  I'm pretty sure this breaks
notmuch-search-remove-tag and notmuch-show-remove-tag, but I haven't
tested it.

 +  (let ((tag-list (notmuch-tag-completions search-terms prefixes)))
 +(completing-read prompt tag-list)))
 +
 +(defun notmuch-select-tags-with-completion (prompt optional search-terms 
 prefixes)
 +  (let ((tag-list (notmuch-tag-completions search-terms prefixes))
 + (crm-separator  )
 + (crm-local-completion-map (copy-keymap crm-local-completion-map)))

Alternatively, you could create a child keymap.
crm-local-completion-map is small enough that it probably doesn't
matter, so whatever makes the code clearer.

 +;; By default, space is bound to complete word function.
 +;; Re-bind it to insert a space instead.  Note that tab still
 +;; does the completion.
 +(define-key crm-local-completion-map   'self-insert-command)
 +(completing-read-multiple prompt tag-list)))
  
  (defun notmuch-foreach-mime-part (function mm-handle)
(cond ((stringp (car mm-handle))
 @@ -860,16 +882,18 @@ will prompt for tags to be added or removed. Tags 
 prefixed with
  Each character of the tag name may consist of alphanumeric
  characters as well as `_.+-'.
  

Technically this changes the API of notmuch-search-operate-all, though
the new one is better.  Perhaps it should test for (stringp action)
and be backwards-compatible?

The argument should probably be called actions now and it may even
make sense to make it a rest argument (though then you can't make it
backwards-compatible).

 -  (interactive sOperation (+add -drop): notmuch tag )
 -  (let ((action-split (split-string action  +)))
 -;; Perform some validation
 -(let ((words action-split))
 -  (when (null words) (error No operation given))
 -  (while words
 - (unless (string-match-p ^[-+][-+_.[:word:]]+$ (car words))
 -   (error Action must be of the form `+thistag -that_tag'))
 - (setq words (cdr words
 -(apply 'notmuch-tag notmuch-search-query-string action-split)))
 +  (interactive (list (notmuch-select-tags-with-completion
 +   Operation (+add -drop): notmuch tag  nil
 +   '(+ -
 +  (setq action (delete  action))
 +  ;; Perform some validation
 +  (let ((words action))
 +(when (null words) (error No operation given))
 +(while words
 +  (unless (string-match-p ^[-+][-+_.[:word:]]+$ (car words))
 + (error Action must be of the form `+thistag -that_tag'))
 +  (setq words (cdr words

This should really be a mapc or a dolist, but maybe that's for another
patch.

 +  (apply 'notmuch-tag notmuch-search-query-string action))
  
  (defun notmuch-search-buffer-title (query)
Returns the title for a buffer with notmuch search results.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: add completion to tag all operation (* binding)

2012-01-25 Thread Dmitry Kurochkin
On Wed, 25 Jan 2012 20:37:27 -0500, Austin Clements amdra...@mit.edu wrote:
 Neat.  As an aside, I would love to see a prompt like this for + and
 -, allowing multiple tags to be modified at once (and starting out
 with whichever of + or - got you in to the prompt).
 

Yeah, I was thinking about making + and - accepting multiple tags
using `notmuch-select-tags-with-completion'.  But that is for another
patch.

 Quoth Dmitry Kurochkin on Jan 26 at  5:12 am:
  The patch adds tab completion to tag all operation bound to *
  (`notmuch-search-operate-all' function).
  ---
   emacs/notmuch.el |   48 
   1 files changed, 36 insertions(+), 12 deletions(-)
  
  diff --git a/emacs/notmuch.el b/emacs/notmuch.el
  index e02966f..71b0221 100644
  --- a/emacs/notmuch.el
  +++ b/emacs/notmuch.el
  @@ -48,6 +48,7 @@
   ;; required, but is available from http://notmuchmail.org).
   
   (eval-when-compile (require 'cl))
  +(require 'crm)
   (require 'mm-view)
   (require 'message)
   
  @@ -75,12 +76,33 @@ For example:
   (defvar notmuch-query-history nil
 Variable to store minibuffer history for notmuch queries)
   
  -(defun notmuch-select-tag-with-completion (prompt rest search-terms)
  +(defun notmuch-tag-completions (optional search-terms prefixes)
 (let ((tag-list
   (with-output-to-string
 (with-current-buffer standard-output
   (apply 'call-process notmuch-command nil t nil search-tags 
  search-terms)
  -(completing-read prompt (split-string tag-list \n+ t) nil nil nil)))
  +(setq tag-list (split-string tag-list \n+ t))
  +(if (null prefixes)
  +   tag-list
  +  (apply #'append
  +(mapcar (lambda (tag)
  +  (mapcar (lambda (prefix)
  +(concat prefix tag)) prefixes))
  +tag-list)
  +
  +(defun notmuch-select-tag-with-completion (prompt optional search-terms 
  prefixes)
 
 This changes the API of notmuch-select-tag-with-completion in a
 non-backwards-compatible way.  I'm pretty sure this breaks
 notmuch-search-remove-tag and notmuch-show-remove-tag, but I haven't
 tested it.
 

I tested only tag additions.  It works, and I assumed tag removal is no
different.  Will fix.

  +  (let ((tag-list (notmuch-tag-completions search-terms prefixes)))
  +(completing-read prompt tag-list)))
  +
  +(defun notmuch-select-tags-with-completion (prompt optional search-terms 
  prefixes)
  +  (let ((tag-list (notmuch-tag-completions search-terms prefixes))
  +   (crm-separator  )
  +   (crm-local-completion-map (copy-keymap crm-local-completion-map)))
 
 Alternatively, you could create a child keymap.
 crm-local-completion-map is small enough that it probably doesn't
 matter, so whatever makes the code clearer.
 

Thanks, I will look into it.

  +;; By default, space is bound to complete word function.
  +;; Re-bind it to insert a space instead.  Note that tab still
  +;; does the completion.
  +(define-key crm-local-completion-map   'self-insert-command)
  +(completing-read-multiple prompt tag-list)))
   
   (defun notmuch-foreach-mime-part (function mm-handle)
 (cond ((stringp (car mm-handle))
  @@ -860,16 +882,18 @@ will prompt for tags to be added or removed. Tags 
  prefixed with
   Each character of the tag name may consist of alphanumeric
   characters as well as `_.+-'.
   
 
 Technically this changes the API of notmuch-search-operate-all, though
 the new one is better.  Perhaps it should test for (stringp action)
 and be backwards-compatible?
 

In this case, I do not think there are many users of the function.  So I
would prefer to keep the code clean.

 The argument should probably be called actions now and it may even
 make sense to make it a rest argument (though then you can't make it
 backwards-compatible).
 

Makes sense, will do.

  -  (interactive sOperation (+add -drop): notmuch tag )
  -  (let ((action-split (split-string action  +)))
  -;; Perform some validation
  -(let ((words action-split))
  -  (when (null words) (error No operation given))
  -  (while words
  -   (unless (string-match-p ^[-+][-+_.[:word:]]+$ (car words))
  - (error Action must be of the form `+thistag -that_tag'))
  -   (setq words (cdr words
  -(apply 'notmuch-tag notmuch-search-query-string action-split)))
  +  (interactive (list (notmuch-select-tags-with-completion
  + Operation (+add -drop): notmuch tag  nil
  + '(+ -
  +  (setq action (delete  action))
  +  ;; Perform some validation
  +  (let ((words action))
  +(when (null words) (error No operation given))
  +(while words
  +  (unless (string-match-p ^[-+][-+_.[:word:]]+$ (car words))
  +   (error Action must be of the form `+thistag -that_tag'))
  +  (setq words (cdr words
 
 This should really be a mapc or a dolist, but maybe that's for another
 patch.
 

Yes, I changed this_tag spelling in v2, but would 

Re: [Emacs] Bug?: notmuch-search-show-thread shows several threads; only one containing matching messages

2012-01-25 Thread Jameson Graef Rollins
On Wed, 25 Jan 2012 20:19:03 -0500, Austin Clements amdra...@mit.edu wrote:
 One very common cause of this is someone using reply to get an
 initial set of recipients, but then replacing the entire message and
 subject (presumably without realizing that the mail is still tracking
 what it was a reply to).  This can also happen if someone
 intentionally replies to multiple messages (though few mail clients
 support this), or if there was a message ID collision.

This is a very common occurrence for me as well.  I would put money down
that this is what you're seeing.

jamie.


pgpcmeWASElmA.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v3] emacs: add completion to tag all operation (* binding)

2012-01-25 Thread Dmitry Kurochkin
The patch adds tab completion to tag all operation bound to *
(`notmuch-search-operate-all' function).
---

Changes:

v3:

* fixed comments from Austin's review [1]

v2:

* s/thistag/this_tag/ for consistency with that_tag, since we touch
  the line anyway

Regards,
  Dmitry

[1] id:20120126013727.gb1...@mit.edu

 emacs/notmuch-show.el |4 +-
 emacs/notmuch.el  |   55 
 2 files changed, 43 insertions(+), 16 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e6a5b31..b23a981 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -38,7 +38,7 @@
 
 (declare-function notmuch-call-notmuch-process notmuch (rest args))
 (declare-function notmuch-fontify-headers notmuch nil)
-(declare-function notmuch-select-tag-with-completion notmuch (prompt rest 
search-terms))
+(declare-function notmuch-select-tag-with-completion notmuch (prompt 
optional prefixes rest search-terms))
 (declare-function notmuch-search-show-thread notmuch nil)
 
 (defcustom notmuch-message-headers '(Subject To Cc Date)
@@ -1474,7 +1474,7 @@ the result.
   Remove a tag from the current message.
   (interactive
(list (notmuch-select-tag-with-completion
- Tag to remove:  (notmuch-show-get-message-id
+ Tag to remove:  nil (notmuch-show-get-message-id
 
   (let* ((current-tags (notmuch-show-get-tags))
 (new-tags (notmuch-show-del-tags-worker current-tags toremove)))
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index e02966f..ba8f8e1 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -48,6 +48,7 @@
 ;; required, but is available from http://notmuchmail.org).
 
 (eval-when-compile (require 'cl))
+(require 'crm)
 (require 'mm-view)
 (require 'message)
 
@@ -75,12 +76,36 @@ For example:
 (defvar notmuch-query-history nil
   Variable to store minibuffer history for notmuch queries)
 
-(defun notmuch-select-tag-with-completion (prompt rest search-terms)
+(defun notmuch-tag-completions (optional prefixes search-terms)
   (let ((tag-list
 (with-output-to-string
   (with-current-buffer standard-output
 (apply 'call-process notmuch-command nil t nil search-tags 
search-terms)
-(completing-read prompt (split-string tag-list \n+ t) nil nil nil)))
+(setq tag-list (split-string tag-list \n+ t))
+(if (null prefixes)
+   tag-list
+  (apply #'append
+(mapcar (lambda (tag)
+  (mapcar (lambda (prefix)
+(concat prefix tag)) prefixes))
+tag-list)
+
+(defun notmuch-select-tag-with-completion (prompt optional prefixes rest 
search-terms)
+  (let ((tag-list (notmuch-tag-completions prefixes search-terms)))
+(completing-read prompt tag-list)))
+
+(defun notmuch-select-tags-with-completion (prompt optional prefixes rest 
search-terms)
+  (let ((tag-list (notmuch-tag-completions prefixes search-terms))
+   (crm-separator  )
+   (crm-local-completion-map
+(let ((map (make-sparse-keymap)))
+  (set-keymap-parent map crm-local-completion-map)
+  map)))
+;; By default, space is bound to complete word function.
+;; Re-bind it to insert a space instead.  Note that tab still
+;; does the completion.
+(define-key crm-local-completion-map   'self-insert-command)
+(completing-read-multiple prompt tag-list)))
 
 (defun notmuch-foreach-mime-part (function mm-handle)
   (cond ((stringp (car mm-handle))
@@ -606,7 +631,7 @@ The tag is removed from all messages in the currently 
selected
 thread or threads in the current region.
   (interactive
(list (notmuch-select-tag-with-completion
- Tag to remove: 
+ Tag to remove:  nil
  (if (region-active-p)
  (mapconcat 'identity
 (notmuch-search-find-thread-id-region 
(region-beginning) (region-end))
@@ -849,7 +874,7 @@ non-authors is found, assume that all of the authors match.
  (goto-char found-target)))
   (delete-process proc
 
-(defun notmuch-search-operate-all (action)
+(defun notmuch-search-operate-all (rest actions)
   Add/remove tags from all matching messages.
 
 This command adds or removes tags from all messages matching the
@@ -860,16 +885,18 @@ will prompt for tags to be added or removed. Tags 
prefixed with
 Each character of the tag name may consist of alphanumeric
 characters as well as `_.+-'.
 
-  (interactive sOperation (+add -drop): notmuch tag )
-  (let ((action-split (split-string action  +)))
-;; Perform some validation
-(let ((words action-split))
-  (when (null words) (error No operation given))
-  (while words
-   (unless (string-match-p ^[-+][-+_.[:word:]]+$ (car words))
- (error Action must be of the form `+thistag -that_tag'))
-   (setq words (cdr words
-(apply 'notmuch-tag notmuch-search-query-string action-split)))
+  (interactive (notmuch-select-tags-with-completion

[PATCH v4] emacs: add completion to tag all operation (* binding)

2012-01-25 Thread Dmitry Kurochkin
The patch adds tab completion to tag all operation bound to *
(`notmuch-search-operate-all' function).
---

On a second thought, `notmuch-select-tag-with-completion' should never
need `prefixes' argument at all.  So I reverted the API and related
changes.

Changes:

v4:

* do not change `notmuch-select-tag-with-completion' API, revert
  related changes

v3:

* fixed comments from Austin's review [1]

v2:

* s/thistag/this_tag/ for consistency with that_tag, since we touch
  the line anyway

Regards,
  Dmitry

[1] id:20120126013727.gb1...@mit.edu

 emacs/notmuch.el |   53 -
 1 files changed, 40 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index e02966f..d2af630 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -48,6 +48,7 @@
 ;; required, but is available from http://notmuchmail.org).
 
 (eval-when-compile (require 'cl))
+(require 'crm)
 (require 'mm-view)
 (require 'message)
 
@@ -75,12 +76,36 @@ For example:
 (defvar notmuch-query-history nil
   Variable to store minibuffer history for notmuch queries)
 
-(defun notmuch-select-tag-with-completion (prompt rest search-terms)
+(defun notmuch-tag-completions (optional prefixes search-terms)
   (let ((tag-list
 (with-output-to-string
   (with-current-buffer standard-output
 (apply 'call-process notmuch-command nil t nil search-tags 
search-terms)
-(completing-read prompt (split-string tag-list \n+ t) nil nil nil)))
+(setq tag-list (split-string tag-list \n+ t))
+(if (null prefixes)
+   tag-list
+  (apply #'append
+(mapcar (lambda (tag)
+  (mapcar (lambda (prefix)
+(concat prefix tag)) prefixes))
+tag-list)
+
+(defun notmuch-select-tag-with-completion (prompt rest search-terms)
+  (let ((tag-list (notmuch-tag-completions nil search-terms)))
+(completing-read prompt tag-list)))
+
+(defun notmuch-select-tags-with-completion (prompt optional prefixes rest 
search-terms)
+  (let ((tag-list (notmuch-tag-completions prefixes search-terms))
+   (crm-separator  )
+   (crm-local-completion-map
+(let ((map (make-sparse-keymap)))
+  (set-keymap-parent map crm-local-completion-map)
+  map)))
+;; By default, space is bound to complete word function.
+;; Re-bind it to insert a space instead.  Note that tab still
+;; does the completion.
+(define-key crm-local-completion-map   'self-insert-command)
+(completing-read-multiple prompt tag-list)))
 
 (defun notmuch-foreach-mime-part (function mm-handle)
   (cond ((stringp (car mm-handle))
@@ -849,7 +874,7 @@ non-authors is found, assume that all of the authors match.
  (goto-char found-target)))
   (delete-process proc
 
-(defun notmuch-search-operate-all (action)
+(defun notmuch-search-operate-all (rest actions)
   Add/remove tags from all matching messages.
 
 This command adds or removes tags from all messages matching the
@@ -860,16 +885,18 @@ will prompt for tags to be added or removed. Tags 
prefixed with
 Each character of the tag name may consist of alphanumeric
 characters as well as `_.+-'.
 
-  (interactive sOperation (+add -drop): notmuch tag )
-  (let ((action-split (split-string action  +)))
-;; Perform some validation
-(let ((words action-split))
-  (when (null words) (error No operation given))
-  (while words
-   (unless (string-match-p ^[-+][-+_.[:word:]]+$ (car words))
- (error Action must be of the form `+thistag -that_tag'))
-   (setq words (cdr words
-(apply 'notmuch-tag notmuch-search-query-string action-split)))
+  (interactive (notmuch-select-tags-with-completion
+   Operations (+add -drop): notmuch tag 
+   '(+ -)))
+  (setq actions (delete  actions))
+  ;; Perform some validation
+  (let ((words actions))
+(when (null words) (error No operations given))
+(while words
+  (unless (string-match-p ^[-+][-+_.[:word:]]+$ (car words))
+   (error Action must be of the form `+this_tag' or `-that_tag'))
+  (setq words (cdr words
+  (apply 'notmuch-tag notmuch-search-query-string actions))
 
 (defun notmuch-search-buffer-title (query)
   Returns the title for a buffer with notmuch search results.
-- 
1.7.8.3

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


Re: [RFC PATCH 5/5] show: Simplify new text formatter code

2012-01-25 Thread Austin Clements
Quoth Dmitry Kurochkin on Jan 24 at  5:49 am:
 On Wed, 11 Jan 2012 20:49:33 -0500, Austin Clements amdra...@mit.edu wrote:
  This makes the text formatter take advantage of the new code
  structure.  The previously duplicated header logic is now unified,
  several things that we used to compute repeatedly across different
  callbacks are now computed once, and the code is generally simplified.
  
  Unifying the header logic causes this to format some dates slightly
  differently, so the two affected test cases are updated.
 
 Thanks for these patches, Austin.  They are a definite improvement for
 notmuch show code.  I hope it would soon get pushed to master.  And I
 hope more patches would follow :)
 
 Few minor comments below.
 
  ---
   notmuch-show.c |   84 
  
   test/crypto|2 +-
   test/thread-naming |   16 +-
   3 files changed, 28 insertions(+), 74 deletions(-)
  
  diff --git a/notmuch-show.c b/notmuch-show.c
  index 3241965..1689222 100644
  --- a/notmuch-show.c
  +++ b/notmuch-show.c
  @@ -175,67 +175,42 @@ format_part_text (const void *ctx, mime_node_t *node,
   GMimeObject *meta = node-envelope_part ?
  GMIME_OBJECT (node-envelope_part) : node-part;
   GMimeContentType *content_type = g_mime_object_get_content_type (meta);
  +GMimeContentDisposition *disposition =
  +   g_mime_object_get_content_disposition (meta);
  +notmuch_bool_t attachment = disposition 
  +   strcmp (disposition-disposition, GMIME_DISPOSITION_ATTACHMENT) == 0;
 
 If I did not miss anything, attachment is used only as following:
 
   attachment ? attachment : part
 
 Please make it const char[] and set to attachment or part.

Ooh, good catch.  But I'll do you one better.  I introduced a const
char *part_type that's set to attachment, part, *or* message in
the if structure below.  That eliminates the attachment variable,
moves the disposition variable back down into one of the early if
bodies, and eliminates the entire conditional the figures out what to
print to close the block.

  +notmuch_bool_t leaf = GMIME_IS_PART (node-part);
 
 Please add const where possible to local variables (e.g. attachment, leaf).

Generally I consider these overkill on local non-pointer variables,
but okay.  leaf wound up being the only one I had to add it to.

   int i;
   
   if (node-envelope_file) {
  notmuch_message_t *message = node-envelope_file;
  -   const char *headers[] = {
  -   Subject, From, To, Cc, Bcc, Date
  -   };
  -   const char *name, *value;
  -   unsigned int i;
   
  -   printf (\fmessage{ );
  -   printf (id:%s depth:%d match:%d filename:%s\n,
  +   printf (\fmessage{ id:%s depth:%d match:%d filename:%s\n,
  notmuch_message_get_message_id (message),
  indent,
  notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH),
  notmuch_message_get_filename (message));
  -
  -   printf (\fheader{\n);
  -
  -   printf (%s\n, _get_one_line_summary (ctx, message));
  -
  -   for (i = 0; i  ARRAY_SIZE (headers); i++) {
  -   name = headers[i];
  -   value = notmuch_message_get_header (message, name);
  -   if (value  strlen (value))
  -   printf (%s: %s\n, name, value);
  -   }
  -   printf (\fheader}\n);
 
 Yay!  Only one header-printing code left :)
 
   } else {
  -   GMimeContentDisposition *disposition = 
  g_mime_object_get_content_disposition (meta);
  const char *cid = g_mime_object_get_content_id (meta);
  +   const char *filename = leaf ?
  +   g_mime_part_get_filename (GMIME_PART (node-part)) : NULL;
   
  -   if (disposition 
  -   strcmp (disposition-disposition, GMIME_DISPOSITION_ATTACHMENT) == 
  0)
  -   {
  -   printf (\fattachment{ ID: %d, node-part_num);
  -
  -   } else {
  -
  -   printf (\fpart{ ID: %d, node-part_num);
  -   }
  -
  -   if (GMIME_IS_PART (node-part))
  -   {
  -   const char *filename = g_mime_part_get_filename (GMIME_PART 
  (node-part));
  -   if (filename)
  -   printf (, Filename: %s, filename);
  -   }
  -
  +   printf (\f%s{ ID: %d, attachment ? attachment : part, 
  node-part_num);
  +   if (filename)
 
 I always forget about it, can we declare variables inside if condition
 like in C++?  I.e.:
 
   if (const char *filename = leaf ? g_mime_part_get_filename (GMIME_PART 
 (node-part)) : NULL)
 
 If yes, I would prefer to use this style where possible.

You can do that in C++?  You definitely can't do that in C.

  +   printf (, Filename: %s, filename);
  if (cid)
  printf (, Content-id: %s, cid);
  -
 
 I would revert blank line changes.  But I do not insist :)

Eh.  I'm generally opposed to drive-by fixes, but this code inherited
a lot of funny formatting that just interrupts the whole flow when the
code is all in one place.

  printf (, Content-type: %s\n, g_mime_content_type_to_string 
  (content_type));
   }
   
  -if 

[PATCH 0/2] Rewrite text show format

2012-01-25 Thread Austin Clements
And now the real fun begins.  This series translates the text
formatter into the new format style in two steps: the first patch is a
big diff but just shuffles code and the second actually takes
advantage of the new structure.

This incorporates Dmitry's comments on the RFC patch series from
id:87lioxna2n@gmail.com .

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


[PATCH 1/2] show: Convert text format to the new self-recursive style

2012-01-25 Thread Austin Clements
This is all code movement and a smidgen of glue.  This moves the
existing text formatter code into one self-recursive function, but
doesn't change any of the logic.  The next patch will actually take
advantage of what the new structure has to offer.

Note that this patch retains format_headers_message_part_text because
it is also used by the raw format.
---
 notmuch-show.c |  270 +---
 1 files changed, 139 insertions(+), 131 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index dec799c..6a890b2 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -21,40 +21,17 @@
 #include notmuch-client.h
 
 static void
-format_message_text (unused (const void *ctx),
-notmuch_message_t *message,
-int indent);
-static void
-format_headers_text (const void *ctx,
-notmuch_message_t *message);
-
-static void
 format_headers_message_part_text (GMimeMessage *message);
 
 static void
-format_part_start_text (GMimeObject *part,
-   int *part_count);
-
-static void
-format_part_content_text (GMimeObject *part);
-
-static void
-format_part_end_text (GMimeObject *part);
+format_part_text (const void *ctx, mime_node_t *node,
+ int indent, const notmuch_show_params_t *params);
 
 static const notmuch_show_format_t format_text = {
-, NULL,
-   \fmessage{ , format_message_text,
-   \fheader{\n, format_headers_text, 
format_headers_message_part_text, \fheader}\n,
-   \fbody{\n,
-   format_part_start_text,
-   NULL,
-   NULL,
-   format_part_content_text,
-   format_part_end_text,
-   ,
-   \fbody}\n,
-   \fmessage}\n, ,
-
+.message_set_start = ,
+.part = format_part_text,
+.message_set_sep = ,
+.message_set_end = 
 };
 
 static void
@@ -191,16 +168,6 @@ _get_one_line_summary (const void *ctx, notmuch_message_t 
*message)
 }
 
 static void
-format_message_text (unused (const void *ctx), notmuch_message_t *message, int 
indent)
-{
-printf (id:%s depth:%d match:%d filename:%s\n,
-   notmuch_message_get_message_id (message),
-   indent,
-   notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH),
-   notmuch_message_get_filename (message));
-}
-
-static void
 format_message_json (const void *ctx, notmuch_message_t *message, unused (int 
indent))
 {
 notmuch_tags_t *tags;
@@ -338,26 +305,6 @@ format_message_mbox (const void *ctx,
 fclose (file);
 }
 
-
-static void
-format_headers_text (const void *ctx, notmuch_message_t *message)
-{
-const char *headers[] = {
-   Subject, From, To, Cc, Bcc, Date
-};
-const char *name, *value;
-unsigned int i;
-
-printf (%s\n, _get_one_line_summary (ctx, message));
-
-for (i = 0; i  ARRAY_SIZE (headers); i++) {
-   name = headers[i];
-   value = notmuch_message_get_header (message, name);
-   if (value  strlen (value))
-   printf (%s: %s\n, name, value);
-}
-}
-
 static void
 format_headers_message_part_text (GMimeMessage *message)
 {
@@ -523,78 +470,6 @@ signer_status_to_string (GMimeSignerStatus x)
 #endif
 
 static void
-format_part_start_text (GMimeObject *part, int *part_count)
-{
-GMimeContentDisposition *disposition = 
g_mime_object_get_content_disposition (part);
-
-if (disposition 
-   strcmp (disposition-disposition, GMIME_DISPOSITION_ATTACHMENT) == 0)
-{
-   printf (\fattachment{ ID: %d, *part_count);
-
-} else {
-
-   printf (\fpart{ ID: %d, *part_count);
-}
-}
-
-static void
-format_part_content_text (GMimeObject *part)
-{
-const char *cid = g_mime_object_get_content_id (part);
-GMimeContentType *content_type = g_mime_object_get_content_type 
(GMIME_OBJECT (part));
-
-if (GMIME_IS_PART (part))
-{
-   const char *filename = g_mime_part_get_filename (GMIME_PART (part));
-   if (filename)
-   printf (, Filename: %s, filename);
-}
-
-if (cid)
-   printf (, Content-id: %s, cid);
-
-printf (, Content-type: %s\n, g_mime_content_type_to_string 
(content_type));
-
-if (g_mime_content_type_is_type (content_type, text, *) 
-   !g_mime_content_type_is_type (content_type, text, html))
-{
-   GMimeStream *stream_stdout = g_mime_stream_file_new (stdout);
-   g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream_stdout), FALSE);
-   show_text_part_content (part, stream_stdout);
-   g_object_unref(stream_stdout);
-}
-else if (g_mime_content_type_is_type (content_type, multipart, *) ||
-g_mime_content_type_is_type (content_type, message, rfc822))
-{
-   /* Do nothing for multipart since its content will be printed
-* when recursing. */
-}
-else
-{
-   printf (Non-text part: %s\n,
-   g_mime_content_type_to_string (content_type));
-}
-}
-
-static void

[PATCH 2/2] show: Simplify new text formatter code

2012-01-25 Thread Austin Clements
This makes the text formatter take advantage of the new code
structure.  The previously duplicated header logic is now unified,
several things that we used to compute repeatedly across different
callbacks are now computed once, and the code is simpler overall and
32% shorter.

Unifying the header logic causes this to format some dates slightly
differently, so the two affected test cases are updated.
---
 notmuch-show.c |   88 +--
 test/crypto|2 +-
 test/thread-naming |   16 +-
 3 files changed, 32 insertions(+), 74 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index 6a890b2..30f6501 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -727,67 +727,48 @@ format_part_text (const void *ctx, mime_node_t *node,
 GMimeObject *meta = node-envelope_part ?
GMIME_OBJECT (node-envelope_part) : node-part;
 GMimeContentType *content_type = g_mime_object_get_content_type (meta);
+const notmuch_bool_t leaf = GMIME_IS_PART (node-part);
+const char *part_type;
 int i;
 
 if (node-envelope_file) {
notmuch_message_t *message = node-envelope_file;
-   const char *headers[] = {
-   Subject, From, To, Cc, Bcc, Date
-   };
-   const char *name, *value;
-   unsigned int i;
 
-   printf (\fmessage{ );
-   printf (id:%s depth:%d match:%d filename:%s\n,
+   part_type = message;
+   printf (\f%s{ id:%s depth:%d match:%d filename:%s\n,
+   part_type,
notmuch_message_get_message_id (message),
indent,
notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH),
notmuch_message_get_filename (message));
-
-   printf (\fheader{\n);
-
-   printf (%s\n, _get_one_line_summary (ctx, message));
-
-   for (i = 0; i  ARRAY_SIZE (headers); i++) {
-   name = headers[i];
-   value = notmuch_message_get_header (message, name);
-   if (value  strlen (value))
-   printf (%s: %s\n, name, value);
-   }
-   printf (\fheader}\n);
 } else {
GMimeContentDisposition *disposition = 
g_mime_object_get_content_disposition (meta);
const char *cid = g_mime_object_get_content_id (meta);
+   const char *filename = leaf ?
+   g_mime_part_get_filename (GMIME_PART (node-part)) : NULL;
 
if (disposition 
strcmp (disposition-disposition, GMIME_DISPOSITION_ATTACHMENT) == 
0)
-   {
-   printf (\fattachment{ ID: %d, node-part_num);
-
-   } else {
-
-   printf (\fpart{ ID: %d, node-part_num);
-   }
-
-   if (GMIME_IS_PART (node-part))
-   {
-   const char *filename = g_mime_part_get_filename (GMIME_PART 
(node-part));
-   if (filename)
-   printf (, Filename: %s, filename);
-   }
+   part_type = attachment;
+   else
+   part_type = part;
 
+   printf (\f%s{ ID: %d, part_type, node-part_num);
+   if (filename)
+   printf (, Filename: %s, filename);
if (cid)
printf (, Content-id: %s, cid);
-
printf (, Content-type: %s\n, g_mime_content_type_to_string 
(content_type));
 }
 
-if (node-envelope_part) {
+if (GMIME_IS_MESSAGE (node-part)) {
GMimeMessage *message = GMIME_MESSAGE (node-part);
InternetAddressList *recipients;
const char *recipients_string;
 
printf (\fheader{\n);
+   if (node-envelope_file)
+   printf (%s\n, _get_one_line_summary (ctx, node-envelope_file));
printf (Subject: %s\n, g_mime_message_get_subject (message));
printf (From: %s\n, g_mime_message_get_sender (message));
recipients = g_mime_message_get_recipients (message, 
GMIME_RECIPIENT_TYPE_TO);
@@ -800,9 +781,11 @@ format_part_text (const void *ctx, mime_node_t *node,
printf (Cc: %s\n, recipients_string);
printf (Date: %s\n, g_mime_message_get_date_as_string (message));
printf (\fheader}\n);
+
+   printf (\fbody{\n);
 }
 
-if (!node-envelope_file) {
+if (leaf) {
if (g_mime_content_type_is_type (content_type, text, *) 
!g_mime_content_type_is_type (content_type, text, html))
{
@@ -810,45 +793,20 @@ format_part_text (const void *ctx, mime_node_t *node,
g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream_stdout), 
FALSE);
show_text_part_content (node-part, stream_stdout);
g_object_unref(stream_stdout);
-   }
-   else if (g_mime_content_type_is_type (content_type, multipart, *) ||
-g_mime_content_type_is_type (content_type, message, 
rfc822))
-   {
-   /* Do nothing for multipart since its content will be printed
-* when recursing. */
-   }
-   else
-   {
+   } else {
printf (Non-text part: %s\n,
g_mime_content_type_to_string (content_type));
}

Re: [PATCH v4] emacs: add completion to tag all operation (* binding)

2012-01-25 Thread Austin Clements
Quoth Dmitry Kurochkin on Jan 26 at  9:06 am:
 The patch adds tab completion to tag all operation bound to *
 (`notmuch-search-operate-all' function).
 ---
 
 On a second thought, `notmuch-select-tag-with-completion' should never
 need `prefixes' argument at all.  So I reverted the API and related
 changes.
 
 Changes:
 
 v4:
 
 * do not change `notmuch-select-tag-with-completion' API, revert
   related changes
 
 v3:
 
 * fixed comments from Austin's review [1]
 
 v2:
 
 * s/thistag/this_tag/ for consistency with that_tag, since we touch
   the line anyway
 
 Regards,
   Dmitry
 
 [1] id:20120126013727.gb1...@mit.edu
 
  emacs/notmuch.el |   53 -
  1 files changed, 40 insertions(+), 13 deletions(-)
 
 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
 index e02966f..d2af630 100644
 --- a/emacs/notmuch.el
 +++ b/emacs/notmuch.el
 @@ -48,6 +48,7 @@
  ;; required, but is available from http://notmuchmail.org).
  
  (eval-when-compile (require 'cl))
 +(require 'crm)
  (require 'mm-view)
  (require 'message)
  
 @@ -75,12 +76,36 @@ For example:
  (defvar notmuch-query-history nil
Variable to store minibuffer history for notmuch queries)
  
 -(defun notmuch-select-tag-with-completion (prompt rest search-terms)
 +(defun notmuch-tag-completions (optional prefixes search-terms)
(let ((tag-list
(with-output-to-string
  (with-current-buffer standard-output
(apply 'call-process notmuch-command nil t nil search-tags 
 search-terms)
 -(completing-read prompt (split-string tag-list \n+ t) nil nil nil)))
 +(setq tag-list (split-string tag-list \n+ t))

Since this setq is unconditional, you can do the split-string right in
the let binding, around the with-output-to-string.

 +(if (null prefixes)
 + tag-list
 +  (apply #'append
 +  (mapcar (lambda (tag)
 +(mapcar (lambda (prefix)
 +  (concat prefix tag)) prefixes))
 +  tag-list)
 +
 +(defun notmuch-select-tag-with-completion (prompt rest search-terms)
 +  (let ((tag-list (notmuch-tag-completions nil search-terms)))
 +(completing-read prompt tag-list)))
 +
 +(defun notmuch-select-tags-with-completion (prompt optional prefixes rest 
 search-terms)
 +  (let ((tag-list (notmuch-tag-completions prefixes search-terms))
 + (crm-separator  )
 + (crm-local-completion-map
 +  (let ((map (make-sparse-keymap)))
 +(set-keymap-parent map crm-local-completion-map)
 +map)))
 +;; By default, space is bound to complete word function.
 +;; Re-bind it to insert a space instead.  Note that tab still
 +;; does the completion.
 +(define-key crm-local-completion-map   'self-insert-command)

You could do the define-key inside the (let ((map ..)) ..) so you get
back the fully formed keymap.  Your call.

 +(completing-read-multiple prompt tag-list)))
  
  (defun notmuch-foreach-mime-part (function mm-handle)
(cond ((stringp (car mm-handle))
 @@ -849,7 +874,7 @@ non-authors is found, assume that all of the authors 
 match.
 (goto-char found-target)))
(delete-process proc
  
 -(defun notmuch-search-operate-all (action)
 +(defun notmuch-search-operate-all (rest actions)
Add/remove tags from all matching messages.
  
  This command adds or removes tags from all messages matching the
 @@ -860,16 +885,18 @@ will prompt for tags to be added or removed. Tags 
 prefixed with
  Each character of the tag name may consist of alphanumeric
  characters as well as `_.+-'.
  
 -  (interactive sOperation (+add -drop): notmuch tag )
 -  (let ((action-split (split-string action  +)))
 -;; Perform some validation
 -(let ((words action-split))
 -  (when (null words) (error No operation given))
 -  (while words
 - (unless (string-match-p ^[-+][-+_.[:word:]]+$ (car words))
 -   (error Action must be of the form `+thistag -that_tag'))
 - (setq words (cdr words
 -(apply 'notmuch-tag notmuch-search-query-string action-split)))
 +  (interactive (notmuch-select-tags-with-completion
 + Operations (+add -drop): notmuch tag 
 + '(+ -)))
 +  (setq actions (delete  actions))

Either this line isn't necessary or
notmuch-select-tags-with-completion can do something funny that it
should take care of internally.

 +  ;; Perform some validation
 +  (let ((words actions))
 +(when (null words) (error No operations given))
 +(while words
 +  (unless (string-match-p ^[-+][-+_.[:word:]]+$ (car words))
 + (error Action must be of the form `+this_tag' or `-that_tag'))
 +  (setq words (cdr words
 +  (apply 'notmuch-tag notmuch-search-query-string actions))
  
  (defun notmuch-search-buffer-title (query)
Returns the title for a buffer with notmuch search results.
___
notmuch mailing list
notmuch@notmuchmail.org

[PATCH 0/4 v3] more care when hiding regions with buttons

2012-01-25 Thread David Edmondson
Address Dmitry's comments.

David Edmondson (4):
  test: `visible-buffer-substring' should not return text properties.
  test: `notmuch-test-run' should protect against buffer switching.
  test: Add test for Original Message hiding at point-min.
  emacs: Take more care when hiding regions with buttons.

 emacs/notmuch-wash.el|   57 --
 test/emacs-message-hiding.sh |   36 ++
 test/notmuch-test|1 +
 test/test-lib.el |   13 ++---
 4 files changed, 84 insertions(+), 23 deletions(-)
 create mode 100755 test/emacs-message-hiding.sh

-- 
1.7.8.3

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


[PATCH 1/4 v3] test: `visible-buffer-substring' should not return text properties.

2012-01-25 Thread David Edmondson
When using `visible-buffer-substring' to examine a buffer, the text
properties are not useful, so don't include them.
---
 test/test-lib.el |9 ++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/test/test-lib.el b/test/test-lib.el
index bc75f06..5b32e0a 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -51,16 +51,19 @@ FILENAME is OUTPUT.
 (with-temp-file (or filename OUTPUT) (insert text
 
 (defun visible-buffer-string ()
-  Same as `buffer-string', but excludes invisible text.
+  Same as `buffer-string', but excludes invisible text and
+removes any text properties.
   (visible-buffer-substring (point-min) (point-max)))
 
 (defun visible-buffer-substring (start end)
-  Same as `buffer-substring', but excludes invisible text.
+  Same as `buffer-substring-no-properties', but excludes
+invisible text.
   (let (str)
 (while ( start end)
   (let ((next-pos (next-char-property-change start end)))
(when (not (invisible-p start))
- (setq str (concat str (buffer-substring start next-pos
+ (setq str (concat str (buffer-substring-no-properties
+start next-pos
(setq start next-pos)))
 str))
 
-- 
1.7.8.3

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


[PATCH 2/4 v3] test: `notmuch-test-run' should protect against buffer switching.

2012-01-25 Thread David Edmondson
The body of the test may cause the current buffer to change. Ensure
that the output goes to the correct buffer by switching back before
inserting it.
---
 test/test-lib.el |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/test/test-lib.el b/test/test-lib.el
index 5b32e0a..6271da2 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -92,7 +92,9 @@ nothing.
 (defmacro notmuch-test-run (rest body)
   Evaluate a BODY of test expressions and output the result.
   `(with-temp-buffer
- (let ((result (progn ,@body)))
+ (let ((buffer (current-buffer))
+  (result (progn ,@body)))
+   (switch-to-buffer buffer)
(insert (if (stringp result)
   result
 (prin1-to-string result)))
-- 
1.7.8.3

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


[PATCH 3/4 v3] test: Add test for Original Message hiding at point-min.

2012-01-25 Thread David Edmondson
---
 test/emacs-message-hiding.sh |   37 +
 test/notmuch-test|1 +
 2 files changed, 38 insertions(+), 0 deletions(-)
 create mode 100755 test/emacs-message-hiding.sh

diff --git a/test/emacs-message-hiding.sh b/test/emacs-message-hiding.sh
new file mode 100755
index 000..70bc66d
--- /dev/null
+++ b/test/emacs-message-hiding.sh
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+
+test_description=emacs Original Message hiding
+. test-lib.sh
+
+test_begin_subtest Hiding an Original Message region at point-min
+add_message \
+'[id]=originalmessagehidin...@notmuchmail.org' \
+'[from]=Sender sen...@example.com' \
+'[to]=mailingl...@notmuchmail.org' \
+'[subject]=hiding an Original Message' \
+'[date]=Tue, 05 Jan 2010 15:43:56 -' \
+'[body]=-Original Message-
+Text here.
+'
+
+cat  EXPECTED EOF
+Sender sen...@example.com (2010-01-05) (inbox)
+Subject: hiding an Original Message
+To: mailingl...@notmuchmail.org
+Date: Tue, 05 Jan 2010 15:43:56 -
+
+[ 2-line hidden original message. Click/Enter to show. ]
+
+EOF
+
+test_emacs '
+(notmuch-test-run
+ (let ((notmuch-show-insert-text/plain-hook (quote 
notmuch-wash-excerpt-citations)))
+   (notmuch-show id:\originalmessagehidin...@notmuchmail.org\)
+   (visible-buffer-string)))
+'
+
+test_subtest_known_broken
+test_expect_equal_file EXPECTED OUTPUT
+
+test_done
diff --git a/test/notmuch-test b/test/notmuch-test
index 3f1740c..6631f87 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -54,6 +54,7 @@ TESTS=
   argument-parsing
   emacs-test-functions.sh
   emacs-address-cleaning.sh
+  emacs-message-hiding.sh
 
 TESTS=${NOTMUCH_TESTS:=$TESTS}
 
-- 
1.7.8.3

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


Re: [PATCH 3/4 v2] test: Add test for Original Message hiding at point-min.

2012-01-25 Thread David Edmondson
I've applied changes in accordance with all of the feedback in this mail
and the others, except for...

On Wed, 25 Jan 2012 21:53:08 +0400, Dmitry Kurochkin 
dmitry.kuroch...@gmail.com wrote:
  +  (let ((notmuch-show-insert-text/plain-hook 
  '(notmuch-wash-excerpt-citations))
 
 Do we have to override the default value here?  I thought
 notmuch-wash-excerpt-citations was enabled by default.

It avoids potential confusion over where the problem lies.

 [...]
 
 IMO writing the test in lisp does not give any benefit in this case.
 Quite the opposite: a simple test is split in two files and becomes more
 complex.
 
 But since we accepted this way of writing tests and you seem to prefer
 it, I would not argue about changing it.

You're right - it's simpler in the original style here, so v3 switches
to that.


pgpdSXNRYDzIH.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


gmime2.6 packaging for debian

2012-01-25 Thread Daniel Kahn Gillmor
hey notmuch folks--

those of you who run debian might be interested in the gmime2.6
packaging which i cobbled together for debian from the existing gmime2.4
packaging:

 http://bugs.debian.org/657426

Those of you developing notmuch with the gmime 2.6 patchsets might be
interested in trying it out.  Please let me know of any problems you
might have with the experimental packaging.

It would be good if we could change the build-deps to

 libgmime2.6-dev | libgmime2.4-dev

Regards,

--dkg


pgpWdMGIl709c.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v4 2/3] emacs: `notmuch-show-buttonize-links' only `notmuch-show's a message if it exists

2012-01-25 Thread Pieter Praet
On Sun, 22 Jan 2012 11:10:02 +, Mark Walters  
wrote:
> 
> > * emacs/notmuch-show.el (notmuch-show-if-found): new function that only 
> > shows
> >   a message/thread if present in the database and otherwise returns an 
> > error.
> 
> I like this in principle but it interacts awkwardly with the automatic tag
> exclusion. If the id: matches a message with an excluded tag
> then notmuch-show-if-found will not let you view it, but if you typed the
> same search in a search field it would show you the message. 
> 
> Note notmuch show currently does not currently respect excluded tags (see
> id:"871uqvgrnm.fsf at qmul.ac.uk"), and this is not completely trivial to
> fix since it is not clear quite what its behaviour should be in some
> corner cases.
> 
> Perhaps we could have an option like "--include-all" to notmuch
> search/count to tell it not to apply the exclusions. On the other hand
> that might also be useful as something the user can type in a search box
> so a special search term (eg include:all) might be better.
> 

Hmm, interesting...

Sorry I haven't taken the time to have a look at your patch series yet.
(I probably wouldn't have anything useful to contribute anyway...)

I'll be taking a stab at fixing this when the exclusion-dust settles.

Thanks for pointing it out!


> Best wishes
> 
> Mark
> 
> 


Peace

-- 
Pieter


[PATCH 3/4] config: only set search.exclude_tags to "deleted; spam; " during setup

2012-01-25 Thread Pieter Praet
On Mon, 23 Jan 2012 08:31:23 +, Jani Nikula  wrote:
> On Mon, 23 Jan 2012 09:03:42 +0100, Pieter Praet  wrote:
> > On Mon, 23 Jan 2012 07:22:25 +, Jani Nikula  wrote:
> > > On Mon, 23 Jan 2012 06:05:27 +0100, Pieter Praet  
> > > wrote:
> > > > On Sun, 22 Jan 2012 14:53:41 -0800, Jameson Graef Rollins  > > > finestructure.net> wrote:
> > > > > On Sun, 22 Jan 2012 23:14:13 +0100, Xavier Maillard  > > > > maillard.im> wrote:
> > > > > > 
> > > > > > On Thu, 19 Jan 2012 20:19:03 +0100, Pieter Praet  > > > > > praet.org> wrote:
> > > > > > > If the 'search.exclude_tags' option is missing from the config 
> > > > > > > file,
> > > > > > > its value is automatically set to "deleted;spam;".  Taking 
> > > > > > > PoLS/DWIM
> > > > > > > into account, this should probably only happen during setup.
> > > > > > > 
> > > > > > > This patch is actually Austin Clements' work:
> > > > > > >   id:"20120117203211.GQ16740 at mit.edu"
> > > > > > 
> > > > > > I do not think this is a sane default. As I told it in another 
> > > > > > post. I
> > > > > > do not expect notmuch to skew my search queries not that I 
> > > > > > specifically
> > > > > > asked.
> > > > > 
> > > > > Hi, Xavier.  Do you currently mark things as "deleted" or "spam"?  If
> > > > > not, this would have no affect on your search results.  If you do, do
> > > > > you currently expect those messages to show up in searches?  If so, 
> > > > > why
> > > > > did you mark them as "deleted" or "spam" to begin with?
> > > > > 
> > > > > I agree with your point in principle (ie. I don't generally want my
> > > > > searches tampered with behind the scenes) but the issue here is about
> > > > > messages that have been explicitly tagged as a form of "trash".  Trash
> > > > > is by it's nature something you're trying to get rid of.  If you 
> > > > > wanted
> > > > > to find something in the future, why would you put it in the trash in
> > > > > the first place?
> > > > > 
> > > > 
> > > > You definitely have a point, but then again, who are we to assume that
> > > > the terms "deleted" and "spam" have the *exact* same meaning for
> > > > everyone?  (also see id:"8739bbo0br.fsf at praet.org")
> > > 
> > > "deleted" used to be a tag recognized by notmuch, and it used to sync to
> > > the T (trashed) maildir flag. Even if notmuch won't delete any of your
> > > mails now, I don't think you should use "deleted" on messages you want
> > > to see again. Please let's not split hairs about this.
> > > 
> > 
> > Agreed, but it might be nice to make a clear distinction between
> > concepts and the actual tags mapped to them.  I'm not suggestion we
> > redefine the term "deleted", but from an internationalization
> > standpoint, we shouldn't prevent users from mapping e.g. "verwijderd",
> > "supprim?", "gel?scht", ... to the concept "deleted".
> > 
> > > There really should be a definitive list of tags that are special to
> > > lib/cli/emacs (like "inbox", "unread", "deleted", ...), or are
> > > recommended for specific purposes (like "new" as an intermediate tag
> > > before more sophisticated tagging), to avoid prolonged discussions like
> > > this.
> > > 
> > 
> > A list of recommended tags would definitely be nice, as long as they
> > remain recommendations (as opposed to obligations), especially since
> > there's really no reason to designate certain tags as being "special".
> 
> Whether there's reason or not, certain tags are special, for a fact, and
> they are not just recommendations. [...]

My mistake.  Thanks for the correction!


> [...] Perhaps one day someone will
> contribute patches to make them configurable, and separate the concepts
> from the actual tags, but in the mean time it will be easier to just
> document them for what they are.
> 

Agreed.


> BR,
> Jani.


Peace

-- 
Pieter


[PATCH 3/4] config: only set search.exclude_tags to "deleted; spam; " during setup

2012-01-25 Thread Pieter Praet
On Mon, 23 Jan 2012 08:24:44 +, Jani Nikula  wrote:
> On Sun, 22 Jan 2012 23:38:40 -0800, Jameson Graef Rollins  finestructure.net> wrote:
> > On Mon, 23 Jan 2012 07:22:25 +, Jani Nikula  wrote:
> > > There really should be a definitive list of tags that are special to
> > > lib/cli/emacs (like "inbox", "unread", "deleted", ...), or are
> > > recommended for specific purposes (like "new" as an intermediate tag
> > > before more sophisticated tagging), to avoid prolonged discussions like
> > > this.
> > 
> > Just to be clear: the lib doesn't assign any special meaning to any tag
> > (as it shouldn't).  The cli does, but only in the sense that it creates
> > config files that designate certain tags for certain operations by
> > default.  It's really in emacs where certain tags currently have
> > unconfigurable meanings ("inbox").
> 
> The lib *does* assign special meaning to the tags it syncs to maildir
> flags: draft, flagged, passed, replied, unread. (deleted used to be part
> of the list.) The cli does have to request the syncing, but the mapping
> is in the lib (flag2tag array in lib/message.cc).
> 

Hmmm, right.

And seeing as how we can't simply replace the hardcoded tag names in
the flag2tag array with calls to the `notmuch_config_get_*' functions
(or move the Maildir sync stuff out of the lib altogether), custom
tag-to-concept mapping probably won't become a reality anytime soon.

Too bad...


> BR,
> Jani.


Peace

-- 
Pieter


[PATCH] emacs: have notmuch-search-archive-thread use -next-thread function

2012-01-25 Thread Pieter Praet
On Tue, 17 Jan 2012 10:54:26 -0800, Jameson Graef Rollins  wrote:
> Use this standard function, to keep thread navigation in one place.
> ---

+1


Peace

-- 
Pieter


[PATCH 0/3] Configuration file option to exclude files/directories

2012-01-25 Thread Pieter Praet
On Thu, 08 Dec 2011 11:05:50 +0200, Tomi Ollila  wrote:
> On Wed, 07 Dec 2011 19:51:32 -0400, David Bremner  
> wrote:
> > On Wed, 14 Sep 2011 00:32:01 +0300, tomi.ollila at iki.fi wrote:
> > > This patch set adds a configuration option 'database.exclude'; a list of
> > > files/directories to be excluded when doing 'notmuch new' operation.
> > 
> > Hi All;
> > 
> > I could see idea of excluding spam and trash folders from indexing being
> > useful, but this has been sitting in the list for a few months without
> > comment. Does that mean no-one but Tomi thinks the functionality is
> > interesting? Or it just slipped by?
> 
> Well, basically due to my comments in 
> id:"1315949524-4948-1-git-send-email-tomi.ollila at iki.fi" (and so far little
> interest to this patch series) I have 'drafts' and 'spam' directories
> elsewhere. 
> 
> If there is renewed interests with real use cases I'm interested to make
> this work more complete (now that there is change to get patches in ;) 
> -- and then move my drafts and spam under database.path too.
> 

Please do!  The desire to be able to exclude certain files/folders has been
expressed many times in the past [1], and once again a mere 2 days ago [2].

I'm currently kicking myself for somehow having missed this thread...

Many thanks in advance!


> I'll mark the current patches as 'notmuch::wip' for the time being.
> 
> > 
> > d
> > 
> 
> Tomi
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


Peace

-- 
Pieter

[1] id:"AANLkTikddX=fYiDmnN2Jx3ERcJndw=80+5_07=M45MQ=@mail.gmail.com"
[2] id:"20120122113212.GA7084 at X200"


[PATCH 10/10] test: use emacsclient(1) for Emacs tests

2012-01-25 Thread Pieter Praet
On Mon, 23 Jan 2012 20:08:59 +0100, Xavier Maillard  
wrote:
> On Tue, 28 Jun 2011 08:45:11 +0400, Dmitry Kurochkin  gmail.com> wrote:
> > Before the change, every Emacs test ran in a separate Emacs
> > instance.  Starting Emacs many times wastes considerable time and
> > it gets worse as the test suite grows.  The patch solves this by
> > using a single Emacs server and emacsclient(1) to run multiple
> > tests.  Emacs server is started on the first test_emacs call and
> > stopped when test_done is called.  We take care not to leave
> > orphan Emacs processes behind when test is terminated by whatever
> > reason: Emacs server runs a watchdog that periodically checks
> > that the test is still running.
> > 
> > Some tests need to provide user input.  Before the change, this
> > was done using echo(1) to Emacs stdin.  This no longer works and
> > instead `standard-input' variable is set accordingly to make
> > `read' return the appropriate string.
> 
> I really like this too. 
> 
> +1
> 

Actually, these have all been pushed already, around June 2011.
See commits e4fc21e8..a854d06e.

I necrobumped this thread to keep my typo fix [1] in proper context.

Which leaves me to ponder: should these kinds of fixes be sent in reply
to the original patch (and potentially cause confusion), or would it be
better to just start a new thread?


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


Peace

-- 
Pieter

[1] id:"1327292770-9528-1-git-send-email-pieter at praet.org"


[PATCH] emacs: Add `notmuch-show-stash-gmane' and `notmuch-show-stash-gmane-and-go'.

2012-01-25 Thread Pieter Praet
In a perfect world, everyone would be using Notmuch and have a local
copy of every message ever sent to any ML.  While we're waiting for
Atlantis to resurface, we'll need an interim solution.

+1 for the idea, but Gmane doesn't archive *all* MLs, so we should leave
the user some legroom.  Since I've already made the necessary changes,
I'll just send the patch instead of wasting your time with suggestions.
Feel free to merge it into yours.

Peace

---
 emacs/notmuch-show.el |   40 ++--
 test/emacs|2 +-
 2 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index c4d45e7..7f209cd 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -123,6 +123,24 @@ indentation."
 (const :tag "View interactively"
notmuch-show-interactively-view-part)))

+(defcustom notmuch-show-stash-mlarchive-link-pref "http://mid.gmane.org/;
+  "Default Mailing List Archive to use when stashing links."
+  :group 'notmuch-show
+  ;; TODO: find a working `Message-Id' search arg for all options.
+  :type '(choice (const :tag "Gmane"
+   "http://mid.gmane.org/;)
+;; (const :tag "MARC"
+;; "http://marc.info/;)
+(const :tag "Mail Archive, The"
+   "http://www.mail-archive.com/search?l=mid=;)
+;; (const :tag "MarkMail"
+;; "http://markmail.org/;)
+;; (const :tag "opensubscriber"
+;; "http://opensubscriber.com/;)
+;; (const :tag "Nabble"
+;; "http://nabble.com/;)
+(string :tag "Custom URI")))
+
 (defmacro with-current-notmuch-show-message ( body)
   "Evaluate body with current buffer set to the text of current message"
   `(save-excursion
@@ -1016,8 +1034,8 @@ thread id.  If a prefix is given, crypto processing is 
toggled."
 (define-key map "s" 'notmuch-show-stash-subject)
 (define-key map "T" 'notmuch-show-stash-tags)
 (define-key map "t" 'notmuch-show-stash-to)
-(define-key map "g" 'notmuch-show-stash-gmane)
-(define-key map "G" 'notmuch-show-stash-gmane-and-go)
+(define-key map "l" 'notmuch-show-stash-mlarchive-link)
+(define-key map "L" 'notmuch-show-stash-mlarchive-link-and-go)
 map)
   "Submap for stash commands")
 (fset 'notmuch-show-stash-map notmuch-show-stash-map)
@@ -1605,20 +1623,22 @@ buffer."
   (interactive)
   (notmuch-common-do-stash (notmuch-show-get-to)))

-(defun notmuch-show-stash-gmane ()
-  "Copy a Gmane URI for the current message to the kill-ring.
+(defun notmuch-show-stash-mlarchive-link ()
+  "Copy an ML Archive URI for the current message to the kill-ring.

-This presumes that the message is available at Gmane."
+This presumes that the message is available at the Mailing List Archive
+configured in `notmuch-show-stash-mlarchive-link-pref'."
   (interactive)
-  (notmuch-common-do-stash (concat "http://mid.gmane.org/;
+  (notmuch-common-do-stash (concat notmuch-show-stash-mlarchive-link-pref
   (substring (notmuch-show-get-message-id) 4 
-1

-(defun notmuch-show-stash-gmane-and-go ()
-  "Copy a Gmane URI for the current message to the kill-ring and visit it.
+(defun notmuch-show-stash-mlarchive-link-and-go ()
+  "Copy an ML Archive URI for the current message to the kill-ring and visit 
it.

-This presumes that the message is available at Gmane."
+This presumes that the message is available at the Mailing List Archive
+configured in `notmuch-show-stash-mlarchive-link-pref'."
   (interactive)
-  (let ((uri (concat "http://mid.gmane.org/;
+  (let ((uri (concat notmuch-show-stash-mlarchive-link-pref
 (substring (notmuch-show-get-message-id) 4 -1
 (notmuch-common-do-stash uri)
 (browse-url uri)))
diff --git a/test/emacs b/test/emacs
index 5f7467d..4e08726 100755
--- a/test/emacs
+++ b/test/emacs
@@ -382,7 +382,7 @@ test_emacs '(notmuch-show "id:\"bought\"")
(notmuch-show-stash-message-id-stripped)
(notmuch-show-stash-tags)
(notmuch-show-stash-filename)
-   (notmuch-show-stash-gmane)
+   (notmuch-show-stash-mlarchive-link)
(switch-to-buffer
  (generate-new-buffer "*test-stashing*"))
(dotimes (i 10)
-- 
1.7.8.1



[PATCH v4 0/3] emacs: notmuch-hello search cleanup

2012-01-25 Thread Dmitry Kurochkin
Changes:

v4:

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

v3:

* rebased on current master

v2:

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

Regards,
  Dmitry


[PATCH v4 1/3] emacs: bind "s" to `notmuch-search' in notmuch-hello buffer

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

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 63f2e07..d88a870 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -29,9 +29,6 @@
 (declare-function notmuch-search "notmuch" (query  oldest-first 
target-thread target-line continuation))
 (declare-function notmuch-poll "notmuch" ())

-(defvar notmuch-hello-search-bar-marker nil
-  "The position of the search bar within the notmuch-hello buffer.")
-
 (defcustom notmuch-recent-searches-max 10
   "The number of recent searches to store and display."
   :type 'integer
@@ -324,11 +321,6 @@ should be. Returns a cons cell `(tags-per-line width)'."
   (widget-insert "\n"))
 found-target-pos))

-(defun notmuch-hello-goto-search ()
-  "Put point inside the `search' widget."
-  (interactive)
-  (goto-char notmuch-hello-search-bar-marker))
-
 (defimage notmuch-hello-logo ((:type png :file "notmuch-logo.png")))

 (defun notmuch-hello-search-continuation()
@@ -358,7 +350,7 @@ should be. Returns a cons cell `(tags-per-line width)'."
 (define-key map "G" 'notmuch-hello-poll-and-update)
 (define-key map (kbd "") 'widget-backward)
 (define-key map "m" 'notmuch-mua-new-mail)
-(define-key map "s" 'notmuch-hello-goto-search)
+(define-key map "s" 'notmuch-search)
 map)
   "Keymap for \"notmuch hello\" buffers.")
 (fset 'notmuch-hello-mode-map notmuch-hello-mode-map)
@@ -471,7 +463,8 @@ Complete list of currently available key bindings:
   (widget-insert " messages.\n"))

 (let ((found-target-pos nil)
- (final-target-pos nil))
+ (final-target-pos nil)
+ (search-bar-pos))
   (let* ((saved-alist
  ;; Filter out empty saved searches if required.
  (if notmuch-show-empty-saved-searches
@@ -503,7 +496,7 @@ Complete list of currently available key bindings:
(indent-rigidly start (point) notmuch-hello-indent)))

(widget-insert "\nSearch: ")
-   (setq notmuch-hello-search-bar-marker (point-marker))
+   (setq search-bar-pos (point-marker))
(widget-create 'editable-field
   ;; Leave some space at the start and end of the
   ;; search boxes.
@@ -595,7 +588,7 @@ Complete list of currently available key bindings:
(when notmuch-saved-searches
  (widget-insert "Edit saved searches with the `edit' button.\n"))
(widget-insert "Hit RET or click on a saved search or tag name to view 
matching threads.\n")
-   (widget-insert "`=' refreshes this screen. `s' jumps to the search box. 
`q' to quit.\n")
+   (widget-insert "`=' refreshes this screen. `s' to search messages. `q' 
to quit.\n")
(let ((fill-column (- (window-width) notmuch-hello-indent)))
  (center-region start (point

@@ -607,7 +600,7 @@ Complete list of currently available key bindings:
  (widget-forward 1)))

   (unless (widget-at)
-   (notmuch-hello-goto-search
+   (goto-char search-bar-pos

   (run-hooks 'notmuch-hello-refresh-hook))

diff --git a/test/emacs.expected-output/notmuch-hello 
b/test/emacs.expected-output/notmuch-hello
index 196112e..c43ab8c 100644
--- a/test/emacs.expected-output/notmuch-hello
+++ b/test/emacs.expected-output/notmuch-hello
@@ -11,4 +11,4 @@ Search:   
  .
 Type a search query and hit RET to view matching threads.
Edit saved searches with the `edit' button.
   Hit RET or click on a saved search or tag name to view matching threads.
-`=' refreshes this screen. `s' jumps to the search box. `q' to quit.
+  `=' refreshes this screen. `s' to search messages. `q' to quit.
diff --git a/test/emacs.expected-output/notmuch-hello-no-saved-searches 
b/test/emacs.expected-output/notmuch-hello-no-saved-searches
index f4cfe49..080a56b 100644
--- a/test/emacs.expected-output/notmuch-hello-no-saved-searches
+++ b/test/emacs.expected-output/notmuch-hello-no-saved-searches
@@ -7,4 +7,4 @@ Search: 
.
 Type a search query and hit RET to view matching threads.
Edit saved searches with the `edit' button.
   Hit RET or click on a saved search or tag name to view matching threads.
-`=' refreshes this screen. `s' jumps to the search box. `q' to quit.
+  `=' refreshes this screen. `s' to search messages. `q' to quit.
diff --git 

[PATCH v4 3/3] emacs: bind "s" to `notmuch-hello-search' in notmuch-hello buffer

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

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 6970bc3..ab65e36 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -172,7 +172,8 @@ International Bureau of Weights and Measures."
   (match-string 1 search)
 search))

-(defun notmuch-hello-search (search)
+(defun notmuch-hello-search ( search)
+  (interactive)
   (unless (null search)
 (setq search (notmuch-hello-trim search))
 (let ((history-delete-duplicates t))
@@ -343,7 +344,7 @@ should be. Returns a cons cell `(tags-per-line width)'."
 (define-key map "G" 'notmuch-hello-poll-and-update)
 (define-key map (kbd "") 'widget-backward)
 (define-key map "m" 'notmuch-mua-new-mail)
-(define-key map "s" 'notmuch-search)
+(define-key map "s" 'notmuch-hello-search)
 map)
   "Keymap for \"notmuch hello\" buffers.")
 (fset 'notmuch-hello-mode-map notmuch-hello-mode-map)
-- 
1.7.8.3



[PATCH v4 2/3] emacs: use a single history for all searches

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

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index d88a870..6970bc3 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -29,8 +29,8 @@
 (declare-function notmuch-search "notmuch" (query  oldest-first 
target-thread target-line continuation))
 (declare-function notmuch-poll "notmuch" ())

-(defcustom notmuch-recent-searches-max 10
-  "The number of recent searches to store and display."
+(defcustom notmuch-hello-recent-searches-max 10
+  "The number of recent searches to display."
   :type 'integer
   :group 'notmuch-hello)

@@ -154,16 +154,6 @@ International Bureau of Weights and Measures."
 (defvar notmuch-hello-url "http://notmuchmail.org;
   "The `notmuch' web site.")

-(defvar notmuch-hello-recent-searches nil)
-
-(defun notmuch-hello-remember-search (search)
-  (setq notmuch-hello-recent-searches
-   (delete search notmuch-hello-recent-searches))
-  (push search notmuch-hello-recent-searches)
-  (if (> (length notmuch-hello-recent-searches)
-notmuch-recent-searches-max)
-  (setq notmuch-hello-recent-searches (butlast 
notmuch-hello-recent-searches
-
 (defun notmuch-hello-nice-number (n)
   (let (result)
 (while (> n 0)
@@ -183,9 +173,12 @@ International Bureau of Weights and Measures."
 search))

 (defun notmuch-hello-search (search)
-  (let ((search (notmuch-hello-trim search)))
-(notmuch-hello-remember-search search)
-(notmuch-search search notmuch-search-oldest-first nil nil 
#'notmuch-hello-search-continuation)))
+  (unless (null search)
+(setq search (notmuch-hello-trim search))
+(let ((history-delete-duplicates t))
+  (add-to-history 'notmuch-search-history search)))
+  (notmuch-search search notmuch-search-oldest-first nil nil
+ #'notmuch-hello-search-continuation))

 (defun notmuch-hello-add-saved-search (widget)
   (interactive)
@@ -464,7 +457,7 @@ Complete list of currently available key bindings:

 (let ((found-target-pos nil)
  (final-target-pos nil)
- (search-bar-pos))
+ (default-pos))
   (let* ((saved-alist
  ;; Filter out empty saved searches if required.
  (if notmuch-show-empty-saved-searches
@@ -496,7 +489,7 @@ Complete list of currently available key bindings:
(indent-rigidly start (point) notmuch-hello-indent)))

(widget-insert "\nSearch: ")
-   (setq search-bar-pos (point-marker))
+   (setq default-pos (point-marker))
(widget-create 'editable-field
   ;; Leave some space at the start and end of the
   ;; search boxes.
@@ -513,18 +506,18 @@ Complete list of currently available key bindings:
(put-text-property (1- (point)) (point) 'invisible t)
(widget-insert "\n")

-   (when notmuch-hello-recent-searches
+   (when notmuch-search-history
  (widget-insert "\nRecent searches: ")
  (widget-create 'push-button
 :notify (lambda ( ignore)
-  (setq notmuch-hello-recent-searches nil)
+  (setq notmuch-search-history nil)
   (notmuch-hello-update))
 "clear")
  (widget-insert "\n\n")
- (let ((start (point))
-   (nth 0))
-   (mapc (lambda (search)
-   (let ((widget-symbol (intern (format 
"notmuch-hello-search-%d" nth
+ (let ((start (point)))
+   (loop for i from 1 to notmuch-hello-recent-searches-max
+ for search in notmuch-search-history do
+   (let ((widget-symbol (intern (format 
"notmuch-hello-search-%d" i
  (set widget-symbol
   (widget-create 'editable-field
  ;; Don't let the search boxes be
@@ -551,9 +544,7 @@ Complete list of currently available key bindings:
   (notmuch-hello-add-saved-search 
widget))
 :notmuch-saved-search-widget widget-symbol
 "save"))
-   (widget-insert "\n")
-   (setq nth (1+ nth)))
- notmuch-hello-recent-searches)
+   (widget-insert "\n"))
(indent-rigidly start (point) notmuch-hello-indent)))

(when alltags-alist
@@ -582,7 +573,7 @@ Complete list of currently available 

[PATCH] emacs: make `notmuch-show-open-or-close-all' toggle visibility

2012-01-25 Thread Pieter Praet
* emacs/notmuch-show.el (notmuch-show-open-or-close-all):
  Rename to `notmuch-show-toggle-all-messages', and make it toggle
  visibility of all messages based on the visibility of the current
  message, instead of setting visibility based on whether or not a
  prefix arg was supplied.

Same functionality, less effort (reaching for 'C-u' is a pain)...

---
 emacs/notmuch-show.el |   22 --
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e6a5b31..2d17f74 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1050,8 +1050,8 @@ thread id.  If a prefix is given, crypto processing is 
toggled."
(define-key map "p" 'notmuch-show-previous-open-message)
(define-key map (kbd "DEL") 'notmuch-show-rewind)
(define-key map " " 'notmuch-show-advance-and-archive)
-   (define-key map (kbd "M-RET") 'notmuch-show-open-or-close-all)
(define-key map (kbd "RET") 'notmuch-show-toggle-message)
+   (define-key map (kbd "M-RET") 'notmuch-show-toggle-all-messages)
(define-key map "#" 'notmuch-show-print-message)
map)
   "Keymap for \"notmuch show\" buffers.")
@@ -1502,16 +1502,18 @@ the result."
  (not (plist-get props :message-visible
   (force-window-update))

-(defun notmuch-show-open-or-close-all ()
-  "Set the visibility all of the messages in the current thread.
-By default make all of the messages visible. With a prefix
-argument, hide all of the messages."
+(defun notmuch-show-toggle-all-messages ()
+  "Toggle the visibility of all messages in the current thread.
+If the current message is visible, hide all messages -- and vice versa."
   (interactive)
-  (save-excursion
-(goto-char (point-min))
-(loop do (notmuch-show-message-visible 
(notmuch-show-get-message-properties)
-  (not current-prefix-arg))
- until (not (notmuch-show-goto-message-next
+  (let ((toggle (notmuch-show-message-visible-p)))
+(save-excursion
+  (goto-char (point-min))
+  (loop do (notmuch-show-message-visible
+   (notmuch-show-get-message-properties)
+   (not toggle))
+   until (not (notmuch-show-goto-message-next)
+  (recenter-top-bottom 1)
   (force-window-update))

 (defun notmuch-show-next-button ()
-- 
1.7.8.1



[PATCH 1/3] emacs: Don't return the button from `notmuch-show-insert-part-header'.

2012-01-25 Thread David Edmondson
On Tue, 24 Jan 2012 11:52:09 -0800, Jameson Graef Rollins  wrote:
> On Tue, 24 Jan 2012 19:25:19 +, David Edmondson  wrote:
> > On Tue, 24 Jan 2012 10:46:57 -0800, Jameson Graef Rollins  > finestructure.net> wrote:
> > > Is there a reason it's really necessary to make this change?  Can't
> > > callers just ignore the returned button if they don't care about it
> > > further?  I can see that maybe it's nice to be able to specify
> > > parameters at creation time, but I'm not sure why that requires throwing
> > > out the returned object as well.
> > 
> > Patches 2 and 3 in that series can result in the button not being
> > inserted.
> 
> Can patches 2 and 3 be rewritten so they are compatible with the button
> being returned by the button creation function?

No. The whole purpose of 2 and 3 is that they don't insert a button in
some circumstances. If no button is inserted then there is no button to
return.

The changes to `notmuch-show-insert-part-multipart/signed' and
`notmuch-show-insert-part-multipart/encrypted' in patch 1 could be
re-written to anticipate that a button might not be returned, but the
resulting code was more complex that that I sent.

> > > I can see that maybe it's nice to be able to specify parameters at
> > > creation time, but I'm not sure why that requires throwing out the
> > > returned object as well.

Do you have a specific use case for this?
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120125/8cfaa274/attachment-0001.pgp>


Emacs: Crypto: How to get automatic encryption?

2012-01-25 Thread David Edmondson
On Tue, 24 Jan 2012 16:10:47 -0800, Jameson Graef Rollins  wrote:
> On Tue, 24 Jan 2012 16:34:32 -0500, micah anderson  
> wrote:
> > David replied to it because it was sent to him, but the list email
> > hasn't come through yet (I want this functionality, so I'm dying to see
> > the patch!)
> 
> Hey, Micah.  There an outstanding patch series that add a new JSON reply
> format, and then uses that in emacs [0].  Once that's in, it will be
> relatively easy to implement auto-reply-to-encrypted.  I'm going to work
> on implementing that as soon as the above patch gets pushed to master.

Can you explain the logic that will apply to determine whether or not a
reply is encrypted?
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120125/cd6cc8c4/attachment.pgp>


[PATCH 0/3] Configuration file option to exclude files/directories

2012-01-25 Thread David Edmondson
On Thu, 08 Dec 2011 11:05:50 +0200, Tomi Ollila  wrote:
> On Wed, 07 Dec 2011 19:51:32 -0400, David Bremner  
> wrote:
> > On Wed, 14 Sep 2011 00:32:01 +0300, tomi.ollila at iki.fi wrote:
> > > This patch set adds a configuration option 'database.exclude'; a list of
> > > files/directories to be excluded when doing 'notmuch new' operation.
> > 
> > Hi All;
> > 
> > I could see idea of excluding spam and trash folders from indexing being
> > useful, but this has been sitting in the list for a few months without
> > comment. Does that mean no-one but Tomi thinks the functionality is
> > interesting? Or it just slipped by?
> 
> Well, basically due to my comments in 
> id:"1315949524-4948-1-git-send-email-tomi.ollila at iki.fi" (and so far little
> interest to this patch series) I have 'drafts' and 'spam' directories
> elsewhere. 
> 
> If there is renewed interests with real use cases I'm interested to make
> this work more complete (now that there is change to get patches in ;) 
> -- and then move my drafts and spam under database.path too.

I'd be interested in these changes (I'd like to ignore .git). It would
help if a test case or two was include.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120125/da2724c8/attachment.pgp>


[PATCH] emacs: Add `notmuch-show-stash-gmane' and `notmuch-show-stash-gmane-and-go'.

2012-01-25 Thread David Edmondson
))
> diff --git a/test/emacs b/test/emacs
> index 5f7467d..4e08726 100755
> --- a/test/emacs
> +++ b/test/emacs
> @@ -382,7 +382,7 @@ test_emacs '(notmuch-show "id:\"bought\"")
>   (notmuch-show-stash-message-id-stripped)
>   (notmuch-show-stash-tags)
>   (notmuch-show-stash-filename)
> - (notmuch-show-stash-gmane)
> + (notmuch-show-stash-mlarchive-link)
>   (switch-to-buffer
> (generate-new-buffer "*test-stashing*"))
>   (dotimes (i 10)
> -- 
> 1.7.8.1
> 
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120125/a8d9cc55/attachment.pgp>


[PATCH] emacs: make `notmuch-show-open-or-close-all' toggle visibility

2012-01-25 Thread David Edmondson
On Wed, 25 Jan 2012 06:25:39 +0100, Pieter Praet  wrote:
> * emacs/notmuch-show.el (notmuch-show-open-or-close-all):
>   Rename to `notmuch-show-toggle-all-messages', and make it toggle
>   visibility of all messages based on the visibility of the current
>   message, instead of setting visibility based on whether or not a
>   prefix arg was supplied.
> 
> Same functionality, less effort (reaching for 'C-u' is a pain)...

-1.

The behaviour you've provided is not what I want, from two perspectives:
- currently it's clear what will happen when I use M-RET or
  C-uM-RET without me having to think about whether the cursor
  is over an open message,
- often I'll be reading an open message and I want to open all
  of the rest to look at some context. That's a little more
  awkward after this change.
> 
> ---
>  emacs/notmuch-show.el |   22 --
>  1 files changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index e6a5b31..2d17f74 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1050,8 +1050,8 @@ thread id.  If a prefix is given, crypto processing is 
> toggled."
>   (define-key map "p" 'notmuch-show-previous-open-message)
>   (define-key map (kbd "DEL") 'notmuch-show-rewind)
>   (define-key map " " 'notmuch-show-advance-and-archive)
> - (define-key map (kbd "M-RET") 'notmuch-show-open-or-close-all)
>   (define-key map (kbd "RET") 'notmuch-show-toggle-message)
> + (define-key map (kbd "M-RET") 'notmuch-show-toggle-all-messages)
>   (define-key map "#" 'notmuch-show-print-message)
>   map)
>"Keymap for \"notmuch show\" buffers.")
> @@ -1502,16 +1502,18 @@ the result."
>   (not (plist-get props :message-visible
>(force-window-update))
>  
> -(defun notmuch-show-open-or-close-all ()
> -  "Set the visibility all of the messages in the current thread.
> -By default make all of the messages visible. With a prefix
> -argument, hide all of the messages."
> +(defun notmuch-show-toggle-all-messages ()
> +  "Toggle the visibility of all messages in the current thread.
> +If the current message is visible, hide all messages -- and vice versa."
>(interactive)
> -  (save-excursion
> -(goto-char (point-min))
> -(loop do (notmuch-show-message-visible 
> (notmuch-show-get-message-properties)
> -(not current-prefix-arg))
> -   until (not (notmuch-show-goto-message-next
> +  (let ((toggle (notmuch-show-message-visible-p)))
> +(save-excursion
> +  (goto-char (point-min))
> +  (loop do (notmuch-show-message-visible
> + (notmuch-show-get-message-properties)
> + (not toggle))
> + until (not (notmuch-show-goto-message-next)
> +  (recenter-top-bottom 1)
>(force-window-update))
>  
>  (defun notmuch-show-next-button ()
> -- 
> 1.7.8.1
> 
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120125/87cba7da/attachment.pgp>


[PATCH] emacs: Fix a notmuch-print.el compiler warning.

2012-01-25 Thread David Edmondson
`notmuch-show-get-prop' should be declared.
---
 emacs/notmuch-print.el |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-print.el b/emacs/notmuch-print.el
index f96ccbe..fd86288 100644
--- a/emacs/notmuch-print.el
+++ b/emacs/notmuch-print.el
@@ -19,6 +19,8 @@
 ;;
 ;; Authors: David Edmondson 

+(declare-function notmuch-show-get-prop "notmuch-show" (prop  props))
+
 (defcustom notmuch-print-mechanism 'notmuch-print-lpr
   "How should printing be done?"
   :group 'notmuch
-- 
1.7.8.3



[PATCH] emacs: Fix a notmuch-print.el compiler warning.

2012-01-25 Thread Tomi Ollila
On Wed, 25 Jan 2012 08:52:15 +, David Edmondson  wrote:
> `notmuch-show-get-prop' should be declared.
> ---

How 'bout 

(require 'notmuch-lib)

and put that declare-function there ?

So that when declaration gets checked when notmuch-show defuns it 


Tomi


[PATCH] emacs: Fix a notmuch-print.el compiler warning.

2012-01-25 Thread David Edmondson
On Wed, 25 Jan 2012 11:19:30 +0200, Tomi Ollila  wrote:
> On Wed, 25 Jan 2012 08:52:15 +, David Edmondson  wrote:
> > `notmuch-show-get-prop' should be declared.
> > ---
> 
> How 'bout 
> 
> (require 'notmuch-lib)
> 
> and put that declare-function there ?
> 
> So that when declaration gets checked when notmuch-show defuns it 

That doesn't work, as I recall. A `declare-function' in a `require'd
file has no effect - the compiler will still complain.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120125/7732edfb/attachment-0001.pgp>


Emacs: Crypto: How to get automatic encryption?

2012-01-25 Thread Jameson Graef Rollins
On Wed, 25 Jan 2012 06:23:01 +, David Edmondson  wrote:
> Can you explain the logic that will apply to determine whether or not a
> reply is encrypted?

My plan was to modify notmuch-reply.c to include a flag in the JSON
output if the message being replied to was encrypted.  The emacs reply
function could then look for that flag and add the ml-secure directive
to encrypt the reply.

jamie.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120125/1336519f/attachment.pgp>


[PATCH] emacs: Add `notmuch-show-stash-gmane' and `notmuch-show-stash-gmane-and-go'.

2012-01-25 Thread Tomi Ollila
On Wed, 25 Jan 2012 06:31:43 +, David Edmondson  wrote:
> 
> Your point about Gmane not having everything applies equally to any
> service, suggesting that perhaps the user should also have an option to
> choose which service to use at stash time. Thoughts?

Completing-read which has all choice url's expanded so user may even edit
those (like fix -2- to -1- if the don't have cover letter ;)

Tomi

PS: even better this should have one level of indirection so that user
can change completing-read to something else without needing to patch
source (like I do in address completion interface)... well this is
something I need to investigate further...



[PATCH 2/3] emacs: Allow `notmuch-show-mode' to display only matching messages.

2012-01-25 Thread David Edmondson
The current behaviour (all messages shown, non-matching collapsed)
is retained as the default. Type '!' to switch to showing only
the matching messages - non-matching messages are not available.
'!' will switch back to showing everything.
---
 emacs/notmuch-show.el |   18 +-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index ed77474..916b941 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -134,6 +134,10 @@ indentation."
 (make-variable-buffer-local 'notmuch-show-process-crypto)
 (put 'notmuch-show-process-crypto 'permanent-local t)

+(defvar notmuch-show-elide-non-matching-messages nil)
+(make-variable-buffer-local 'notmuch-show-elide-non-matching-messages)
+(put 'notmuch-show-elide-non-matching-messages 'permanent-local t)
+
 (defmacro with-current-notmuch-show-message ( body)
   "Evaluate body with current buffer set to the text of current message"
   `(save-excursion
@@ -890,11 +894,22 @@ current buffer, if possible."
 "Not processing cryptographic MIME parts."))
   (notmuch-show-refresh-view))

+(defun notmuch-show-toggle-elide-non-matching ()
+  "Toggle the display of non-matching messages."
+  (interactive)
+  (setq notmuch-show-elide-non-matching-messages (not 
notmuch-show-elide-non-matching-messages))
+  (message (if notmuch-show-elide-non-matching-messages
+  "Showing matching messages only."
+"Showing all messages."))
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-insert-tree (tree depth)
   "Insert the message tree TREE at depth DEPTH in the current thread."
   (let ((msg (car tree))
(replies (cadr tree)))
-(notmuch-show-insert-msg msg depth)
+(if (or (not notmuch-show-elide-non-matching-messages)
+   (plist-get msg :match))
+   (notmuch-show-insert-msg msg depth))
 (notmuch-show-insert-thread replies (1+ depth

 (defun notmuch-show-insert-thread (thread depth)
@@ -1044,6 +1059,7 @@ Refreshes the current view, observing changes in 
cryptographic preferences."
(define-key map (kbd "M-RET") 'notmuch-show-open-or-close-all)
(define-key map (kbd "RET") 'notmuch-show-toggle-message)
(define-key map "#" 'notmuch-show-print-message)
+   (define-key map "!" 'notmuch-show-toggle-elide-non-matching)
(define-key map "$" 'notmuch-show-toggle-process-crypto)
map)
   "Keymap for \"notmuch show\" buffers.")
-- 
1.7.8.3



[PATCH 3/3] emacs: Allow the indentation of content to be toggled.

2012-01-25 Thread David Edmondson
Very deeply indented content is sometimes difficult to
read (particular for something like patches). Allow the indentation of
the content to be toggled with '<'.

Indentation of the header lines is not affected, so it remains
possible to see the structure of the thread.
---
 emacs/notmuch-show.el |   23 ---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 916b941..337cd50 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -138,6 +138,10 @@ indentation."
 (make-variable-buffer-local 'notmuch-show-elide-non-matching-messages)
 (put 'notmuch-show-elide-non-matching-messages 'permanent-local t)

+(defvar notmuch-show-indent-content t)
+(make-variable-buffer-local 'notmuch-show-indent-content)
+(put 'notmuch-show-indent-content 'permanent-local t)
+
 (defmacro with-current-notmuch-show-message ( body)
   "Evaluate body with current buffer set to the text of current message"
   `(save-excursion
@@ -244,10 +248,12 @@ operation on the contents of the current buffer."
 (all (buffer-substring (notmuch-show-message-top)
(notmuch-show-message-bottom)))

-(props (notmuch-show-get-message-properties)))
+(props (notmuch-show-get-message-properties))
+(indenting notmuch-show-indent-content))
 (with-temp-buffer
   (insert all)
-  (indent-rigidly (point-min) (point-max) (- depth))
+  (if indenting
+ (indent-rigidly (point-min) (point-max) (- depth)))
   ;; Remove the original header.
   (goto-char (point-min))
   (re-search-forward "^$" (point-max) nil)
@@ -856,7 +862,8 @@ current buffer, if possible."
 (setq content-end (point-marker))

 ;; Indent according to the depth in the thread.
-(indent-rigidly content-start content-end (* 
notmuch-show-indent-messages-width depth))
+(if notmuch-show-indent-content
+   (indent-rigidly content-start content-end (* 
notmuch-show-indent-messages-width depth)))

 (setq message-end (point-max-marker))

@@ -903,6 +910,15 @@ current buffer, if possible."
 "Showing all messages."))
   (notmuch-show-refresh-view))

+(defun notmuch-show-toggle-thread-indentation ()
+  "Toggle the indentation of threads."
+  (interactive)
+  (setq notmuch-show-indent-content (not notmuch-show-indent-content))
+  (message (if notmuch-show-indent-content
+  "Content is indented."
+"Content is not indented."))
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-insert-tree (tree depth)
   "Insert the message tree TREE at depth DEPTH in the current thread."
   (let ((msg (car tree))
@@ -1061,6 +1077,7 @@ Refreshes the current view, observing changes in 
cryptographic preferences."
(define-key map "#" 'notmuch-show-print-message)
(define-key map "!" 'notmuch-show-toggle-elide-non-matching)
(define-key map "$" 'notmuch-show-toggle-process-crypto)
+   (define-key map "<" 'notmuch-show-toggle-thread-indentation)
map)
   "Keymap for \"notmuch show\" buffers.")
 (fset 'notmuch-show-mode-map notmuch-show-mode-map)
-- 
1.7.8.3



[PATCH 0/3] reworked crypto toggle, plus a couple of other toggles

2012-01-25 Thread David Edmondson
The crypto toggle previously worked using an argument to
`notmuch-show' and various other functions and relied on killing and
re-creating the notmuch-show-mode buffer. Various other
pseudo-buffer-local variables were present based on an ad-hoc scheme.

Replace the ad-hoc scheme with real buffer-local variables and then
update `notmuch-show-refresh-view' to erase and re-paint rather than
kill and re-create. Update the crypto switch accordingly.

Add two other toggles:
- whether non-matching messages are available,
- the indentation of message contents.
Both of these default to the current behaviour.

A wart in the first patch is the handling of the
`notmuch-show-process-crypto' default. It is set based on
`notmuch-crypto-process-mime', but the users choice of setting for
that variable may not have been applied at the point where
`notmuch-show-process-crypto' inherits it.

My inclination is to remove `notmuch-crypto-process-mime' altogether
(declared it an obsolete variable) and allow users to set a default
for `notmuch-show-process-crypto' directly, but that is not done in
this patchset while awaiting feedback.

`notmuch-crypto-process-mime' is used only in notmuch-show.el, so the
setting really belongs there with an appropriate name.

David Edmondson (3):
  emacs: Rework crypto switch toggle.
  emacs: Allow `notmuch-show-mode' to display only matching messages.
  emacs: Allow the indentation of content to be toggled.

 emacs/notmuch-show.el |  143 +
 emacs/notmuch.el  |7 +--
 2 files changed, 87 insertions(+), 63 deletions(-)

-- 
1.7.8.3



[PATCH 1/3] emacs: Rework crypto switch toggle.

2012-01-25 Thread David Edmondson
Re-work the existing crypto switch toggle to be based on a persistant
buffer-local variable.

To allow this, modify `notmuch-show-refresh-view' to erase and re-draw
in the current buffer rather than killing the current buffer and
creating a new one. (This will also allow more per-buffer behaviour in
future patches.)

Add a binding ('$') to toggle crypto processing of the current buffer
and remove the prefix argument approach that achieves a similar
result.
---
 emacs/notmuch-show.el |  102 ++--
 emacs/notmuch.el  |7 +--
 2 files changed, 50 insertions(+), 59 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e6a5b31..ed77474 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -123,6 +123,17 @@ indentation."
 (const :tag "View interactively"
notmuch-show-interactively-view-part)))

+(defvar notmuch-show-thread-id nil)
+(make-variable-buffer-local 'notmuch-show-thread-id)
+(defvar notmuch-show-parent-buffer nil)
+(make-variable-buffer-local 'notmuch-show-parent-buffer)
+(defvar notmuch-show-query-context nil)
+(make-variable-buffer-local 'notmuch-show-query-context)
+
+(defvar notmuch-show-process-crypto notmuch-crypto-process-mime)
+(make-variable-buffer-local 'notmuch-show-process-crypto)
+(put 'notmuch-show-process-crypto 'permanent-local t)
+
 (defmacro with-current-notmuch-show-message ( body)
   "Evaluate body with current buffer set to the text of current message"
   `(save-excursion
@@ -379,14 +390,11 @@ message at DEPTH in the current thread."

 (defmacro notmuch-with-temp-part-buffer (message-id nth  body)
   (declare (indent 2))
-  (let ((process-crypto (make-symbol "process-crypto")))
-`(let ((,process-crypto notmuch-show-process-crypto))
-   (with-temp-buffer
-(setq notmuch-show-process-crypto ,process-crypto)
-;; Always acquires the part via `notmuch part', even if it is
-;; available in the JSON output.
-(insert (notmuch-show-get-bodypart-internal ,message-id ,nth))
-, at body
+  `(with-temp-buffer
+ ;; Always acquires the part via `notmuch part', even if it is
+ ;; available in the JSON output.
+ (insert (notmuch-show-get-bodypart-internal ,message-id ,nth))
+ , at body))

 (defun notmuch-show-save-part (message-id nth  filename content-type)
   (notmuch-with-temp-part-buffer message-id nth
@@ -567,7 +575,7 @@ current buffer, if possible."
   (sigstatus (car (plist-get part :sigstatus
  (notmuch-crypto-insert-sigstatus-button sigstatus from))
   ;; if we're not adding sigstatus, tell the user how they can get it
-  (button-put button 'help-echo "Set notmuch-crypto-process-mime to 
process cryptographic mime parts.")))
+  (button-put button 'help-echo "Set notmuch-crypto-process-mime to 
process cryptographic MIME parts.")))

   (let ((inner-parts (plist-get part :content))
(start (point)))
@@ -593,7 +601,7 @@ current buffer, if possible."
 (sigstatus (car (plist-get part :sigstatus
(notmuch-crypto-insert-sigstatus-button sigstatus from
   ;; if we're not adding encstatus, tell the user how they can get it
-  (button-put button 'help-echo "Set notmuch-crypto-process-mime to 
process cryptographic mime parts.")))
+  (button-put button 'help-echo "Set notmuch-crypto-process-mime to 
process cryptographic MIME parts.")))

   (let ((inner-parts (plist-get part :content))
(start (point)))
@@ -720,8 +728,6 @@ current buffer, if possible."

 ;; Helper for parts which are generally not included in the default
 ;; JSON output.
-;; Uses the buffer-local variable notmuch-show-process-crypto to
-;; determine if parts should be decrypted first.
 (defun notmuch-show-get-bodypart-internal (message-id part-number)
   (let ((args '("show" "--format=raw"))
(part-arg (format "--part=%s" part-number)))
@@ -875,6 +881,15 @@ current buffer, if possible."
 ;; criteria.
 (notmuch-show-message-visible msg (plist-get msg :match

+(defun notmuch-show-toggle-process-crypto ()
+  "Toggle the processing of cryptographic MIME parts."
+  (interactive)
+  (setq notmuch-show-process-crypto (not notmuch-show-process-crypto))
+  (message (if notmuch-show-process-crypto
+  "Processing cryptographic MIME parts."
+"Not processing cryptographic MIME parts."))
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-insert-tree (tree depth)
   "Insert the message tree TREE at depth DEPTH in the current thread."
   (let ((msg (car tree))
@@ -890,15 +905,6 @@ current buffer, if possible."
   "Insert the forest of threads FOREST."
   (mapc (lambda (thread) (notmuch-show-insert-thread thread 0)) forest))

-(defvar notmuch-show-thread-id nil)
-(make-variable-buffer-local 'notmuch-show-thread-id)
-(defvar notmuch-show-parent-buffer nil)
-(make-variable-buffer-local 'notmuch-show-parent-buffer)

Emacs: Crypto: How to get automatic encryption?

2012-01-25 Thread David Edmondson
On Wed, 25 Jan 2012 01:26:19 -0800, Jameson Graef Rollins  wrote:
> On Wed, 25 Jan 2012 06:23:01 +, David Edmondson  wrote:
> > Can you explain the logic that will apply to determine whether or not a
> > reply is encrypted?
> 
> My plan was to modify notmuch-reply.c to include a flag in the JSON
> output if the message being replied to was encrypted.  The emacs reply
> function could then look for that flag and add the ml-secure directive
> to encrypt the reply.

Isn't it still necessary to ensure that you have encryption keys
appropriate to the recipient?
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120125/f6e19de6/attachment.pgp>


[PATCH] emacs: Add `notmuch-show-stash-gmane' and `notmuch-show-stash-gmane-and-go'.

2012-01-25 Thread David Edmondson
On Wed, 25 Jan 2012 12:18:22 +0200, Tomi Ollila  wrote:
> On Wed, 25 Jan 2012 06:31:43 +, David Edmondson  wrote:
> > 
> > Your point about Gmane not having everything applies equally to any
> > service, suggesting that perhaps the user should also have an option to
> > choose which service to use at stash time. Thoughts?
> 
> Completing-read which has all choice url's expanded so user may even edit
> those

`completing-read' on the _names_ of the services, sure. I'm not sure
that showing the URLs as a set of choices would be nice.

> (like fix -2- to -1- if the don't have cover letter ;)

Should a single patch need a cover letter?
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120125/8f6a0b1c/attachment.pgp>


[PATCH v3 2/8] emacs: break up notmuch-show-archive-thread-internal into two more generally useful functions

2012-01-25 Thread David Edmondson
On Tue, 24 Jan 2012 16:06:17 -0800, Jameson Graef Rollins  wrote:
> notmuch-show-tag-thread-internal: applies a tag to all messages in
> thread.  If option remove flag is t, tags will be removed instead of
> added.

If it's non-nil, but yes.

> notmuch-show-next-thread: moves to the next thread in the search
> result.  If given a prefix, will show the next result, otherwise will
> just move to it in the search view.
> 
> Two new interactive functions, notmuch-show-{add,remove}-tag-thread,
> are also added.  Together, these provide a better suit of thread
> tagging and navigation tools.
> 
> The higher level thread archiving functions are modified to use these
> new function.
> ---
>  emacs/notmuch-show.el |   46 +-
>  1 files changed, 33 insertions(+), 13 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index a0045fc..fb908b0 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1525,20 +1525,38 @@ argument, hide all of the messages."
>(interactive)
>(backward-button 1))
>  
> -(defun notmuch-show-archive-thread-internal (show-next)
> -  ;; Remove the tag from the current set of messages.
> +(defun notmuch-show-tag-thread-internal (tag  remove)
> +  "Add tag to the current set of messages.

"Add TAG to all messages in the current buffer."

> +
> +If the remove switch is given, tags will be removed instead of
> +added."

"If the REMOVE argument is non-nil, ..."

>(goto-char (point-min))
> -  (loop do (notmuch-show-remove-tag "inbox")
> - until (not (notmuch-show-goto-message-next)))
> -  ;; Move to the next item in the search results, if any.
> +  (let ((tag-function (if remove
> +   'notmuch-show-remove-tag
> + 'notmuch-show-add-tag)))
> +(loop do (funcall tag-function tag)
> +   until (not (notmuch-show-goto-message-next)

I wonder if we shouldn't have a macro for "do something to all messages
in the current buffer" that could be used more widely.

> +
> +(defun notmuch-show-add-tag-thread (tag)
> +  "Add tag to all messages in the current thread."
> +  (interactive)
> +  (notmuch-show-tag-thread-internal tag))
> +
> +(defun notmuch-show-remove-tag-thread (tag)
> +  "Remove tag from all messages in the current thread."
> +  (interactive)
> +  (notmuch-show-tag-thread-internal tag t))
> +
> +(defun notmuch-show-next-thread ( show-next)
> +  "Move to the next item in the search results, if any."

Describe the meaning of SHOW-NEXT.

> +  (interactive "P")
>(let ((parent-buffer notmuch-show-parent-buffer))
>  (notmuch-kill-this-buffer)
> -(if parent-buffer
> - (progn
> -   (switch-to-buffer parent-buffer)
> -   (notmuch-search-next-thread)
> -   (if show-next
> -   (notmuch-search-show-thread))
> +(when parent-buffer
> +  (switch-to-buffer parent-buffer)
> +  (notmuch-search-next-thread)
> +  (if show-next
> +   (notmuch-search-show-thread)
>  
>  (defun notmuch-show-archive-thread ()
>"Archive each message in thread, then show next thread from search.
> @@ -1552,12 +1570,14 @@ being delivered to the same thread. It does not 
> archive the
>  entire thread, but only the messages shown in the current
>  buffer."
>(interactive)
> -  (notmuch-show-archive-thread-internal t))
> +  (notmuch-show-remove-tag-thread "inbox")
> +  (notmuch-show-next-thread t))
>  
>  (defun notmuch-show-archive-thread-then-exit ()
>"Archive each message in thread, then exit back to search results."
>(interactive)
> -  (notmuch-show-archive-thread-internal nil))
> +  (notmuch-show-remove-tag-thread "inbox")
> +  (notmuch-show-next-thread))
>  
>  (defun notmuch-show-stash-cc ()
>"Copy CC field of current message to kill-ring."
> -- 
> 1.7.8.3
> 
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120125/2ab4f34b/attachment.pgp>


[PATCH v3 3/8] emacs: break out thread navigation from notmuch-show-archive-thread

2012-01-25 Thread David Edmondson
On Tue, 24 Jan 2012 16:06:18 -0800, Jameson Graef Rollins  wrote:
> This function is now just for archiving the current thread.  A new
> function is created to archive-then-next.  The 'a' key binding is
> updated accordingly.
> 
> This will allow people to bind to the simple thread archiving function
> without the extra navigation.  The archive-thread function now also
> takes a prefix to unarchive the current thread (ie. put the whole
> thread back in the inbox).
> ---
>  emacs/notmuch-show.el |   23 +--
>  1 files changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index fb908b0..071e662 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1044,7 +1044,7 @@ thread id.  If a prefix is given, crypto processing is 
> toggled."
>   (define-key map "-" 'notmuch-show-remove-tag)
>   (define-key map "+" 'notmuch-show-add-tag)
>   (define-key map "x" 'notmuch-show-archive-thread-then-exit)
> - (define-key map "a" 'notmuch-show-archive-thread)
> + (define-key map "a" 'notmuch-show-archive-thread-then-next)
>   (define-key map "N" 'notmuch-show-next-message)
>   (define-key map "P" 'notmuch-show-previous-message)
>   (define-key map "n" 'notmuch-show-next-open-message)
> @@ -1304,7 +1304,7 @@ thread from the search from which this thread was 
> originally
>  shown."
>(interactive)
>(if (notmuch-show-advance)
> -  (notmuch-show-archive-thread)))
> +  (notmuch-show-archive-thread-then-next)))
>  
>  (defun notmuch-show-rewind ()
>"Backup through the thread, (reverse scrolling compared to 
> \\[notmuch-show-advance-and-archive]).
> @@ -1558,8 +1558,12 @@ added."
>(if show-next
> (notmuch-search-show-thread)
>  
> -(defun notmuch-show-archive-thread ()
> -  "Archive each message in thread, then show next thread from search.
> +(defun notmuch-show-archive-thread ( unarchive)
> +  "Archive each message in thread.
> +
> +If a prefix argument is given, the messages will be
> +\"unarchived\" (ie. the \"inbox\" tag will be added instead of
> +removed).

It's clearer to reference "inbox" directly:

 Remove the "inbox" tag from the messages currently shown.

 If a prefix argument is given the "inbox" tag will be added rather
 than removed.

>  
>  Archive each message currently shown by removing the \"inbox\"
>  tag from each. Then kill this buffer and show the next thread
> @@ -1569,14 +1573,21 @@ Note: This command is safe from any race condition of 
> new messages
>  being delivered to the same thread. It does not archive the
>  entire thread, but only the messages shown in the current
>  buffer."
> +  (interactive "P")
> +  (if unarchive
> +  (notmuch-show-add-tag-thread "inbox")
> +(notmuch-show-remove-tag-thread "inbox")))
> +
> +(defun notmuch-show-archive-thread-then-next ()
> +  "Archive each message in thread, then show next thread from search."
>(interactive)
> -  (notmuch-show-remove-tag-thread "inbox")
> +  (notmuch-show-archive-thread)
>(notmuch-show-next-thread t))
>  
>  (defun notmuch-show-archive-thread-then-exit ()
>"Archive each message in thread, then exit back to search results."
>(interactive)
> -  (notmuch-show-remove-tag-thread "inbox")
> +  (notmuch-show-archive-thread)
>(notmuch-show-next-thread))
>  
>  (defun notmuch-show-stash-cc ()
> -- 
> 1.7.8.3
> 
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120125/41f6e70f/attachment.pgp>


[PATCH v3 4/8] emacs: add message archiving functions

2012-01-25 Thread David Edmondson
On Tue, 24 Jan 2012 16:06:19 -0800, Jameson Graef Rollins  wrote:
> This adds two new message archiving functions that parallel the thread
> archiving functions: notmuch-show-archive-message{,-then-next}.  The
> former also takes a prefix argument to unarchive the message (ie. put
> back in inbox).
> ---
>  emacs/notmuch-show.el |   17 +
>  1 files changed, 17 insertions(+), 0 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 071e662..0dc594b 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1590,6 +1590,23 @@ buffer."
>(notmuch-show-archive-thread)
>(notmuch-show-next-thread))
>  
> +(defun notmuch-show-archive-message ( unarchive)
> +  "Archive the current message.
> +
> +If a prefix argument is given, the message will be
> +\"unarchived\" (ie. the \"inbox\" tag will be added instead of
> +removed)."

Same comments as for the previous patch - just reference "inbox"
directly.

> +  (interactive "P")
> +  (if unarchive
> +  (notmuch-show-add-tag "inbox")
> +(notmuch-show-remove-tag "inbox")))
> +
> +(defun notmuch-show-archive-message-then-next ()
> +  "Archive the current message, then show the next open message in the 
> current thread."
> +  (interactive)
> +  (notmuch-show-archive-message)
> +  (notmuch-show-next-open-message))
> +
>  (defun notmuch-show-stash-cc ()
>"Copy CC field of current message to kill-ring."
>(interactive)
> -- 
> 1.7.8.3
> 
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
------ next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120125/1d3a3549/attachment.pgp>


[PATCH v3 5/8] emacs: add option to show-next-{, open-}message functions to pop out to parent buffer if at end

2012-01-25 Thread David Edmondson
Fine.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120125/84d0ac7e/attachment-0001.pgp>


[PATCH v3 7/8] emacs: modify the default show-mode key bindings for archiving

2012-01-25 Thread David Edmondson
Fine.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120125/cee23b2e/attachment.pgp>


[PATCH v3 8/8] emacs: fix show-previous-message doc string

2012-01-25 Thread David Edmondson
Fine.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120125/79245318/attachment.pgp>


[PATCH v3 1/8] emacs: use search-next-thread to move to next thread in show mode

2012-01-25 Thread David Edmondson
Fine.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120125/f9baaa5e/attachment.pgp>


[PATCH 1/3] emacs: s/buttonise/buttonize/g

2012-01-25 Thread David Bremner
On Thu, 12 Jan 2012 18:23:43 +0100, Pieter Praet  wrote:
> "Worldwide, -ize endings prevail in scientific writing and are commonly
> used by many international organizations, such as the ISO and the
> WHO. The European Union switched from -ize to -ise some years ago in its
> English language publications, and this resulted in the coexistence of

needs rebasing against master. 

d

P.S. Personally think it's a bit silly, but that might be because I'm
Canadian, and we are all about the inconsistent anglo/american
spelling. But if the consensus is to follow the UN black helicopter
spelling police, ok :).


[PATCH 0/4 v43] emacs test helpers

2012-01-25 Thread David Bremner
On Tue, 24 Jan 2012 16:14:03 +, David Edmondson  wrote:
> Small changes as per Dmitry's last comments.

Pushed.

d


[PATCH v5 0/2] Second step of 'show' rewrite

2012-01-25 Thread David Bremner
On Mon, 23 Jan 2012 18:33:08 -0500, Austin Clements  wrote:
> Arrg, sorry for the spam.  I grabbed the wrong commit ID when sending
> v4.
> 
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

v5 pushed


  1   2   >