Re: [PATCH v2] notmuch/emacs: Observe the charset of text/html parts, where known.

2012-01-12 Thread David Edmondson
On Thu, 12 Jan 2012 13:49:59 -0500, Austin Clements  wrote:
> Quoth David Edmondson on Jan 12 at  1:31 pm:
> > Add the charset of text/html parts to the JSON output of 'notmuch
> > -show' when it is known. Observe the encoding when rendering such
> > parts in emacs.
> 
> This seems like a fine interim solution to me, though I'd like to see
> a comment above the change in format_part_content_json explaining why
> we include the content charset for text/html and not for anything
> else.

Okay, thanks. New patch tomorrow.


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


Re: [PATCH] emacs: whitespace-cleanup for emacs/*.el files

2012-01-13 Thread David Edmondson
On Thu, 12 Jan 2012 23:07:03 +0100, Xavier Maillard  wrote:
> On Wed, 11 Jan 2012 17:13:35 +0200, Tomi Ollila  wrote:
> > Executed
> > for f in emacs/*.el
> > do emacs -q --batch --eval \
> > "(progn (find-file \"$f\") (whitespace-cleanup) (save-buffer))"
> > done
> > 
> > which
> > removed trailing whitespace and empty lines at the end of file
> > removed spaces before tab (if any)
> > converted 8 spaces to tabs in the beginning of line
> 
> +1
> 
> Maybe we should note something about this as a /coding style/ rule ?

How about "Running `indent-region' over the file should produce no
changes" as well?


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


Re: [PATCH] emacs: globally replace non-branching "(if (not ..." with "(unless ..."

2012-01-13 Thread David Edmondson
On Thu, 12 Jan 2012 18:33:06 +0100, Pieter Praet  wrote:
> Less code, same results, without sacrificing readability.

+1, but why not replace non-branching `if' with `when' as well?


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


[PATCH v3] notmuch/emacs: Observe the charset of text/html parts, where known.

2012-01-13 Thread David Edmondson
Add the charset of text/html parts to the JSON output of 'notmuch
-show' when it is known. Observe the encoding when rendering such
parts in emacs.
---

Commentary added.

 emacs/notmuch-show.el |3 ++-
 notmuch-show.c|   28 +++-
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5502efd..0354a8e 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -328,7 +328,8 @@ message at DEPTH in the current thread."
 current buffer, if possible."
   (let ((display-buffer (current-buffer)))
 (with-temp-buffer
-  (let ((handle (mm-make-handle (current-buffer) (list content-type
+  (let* ((charset (plist-get part :content-charset))
+(handle (mm-make-handle (current-buffer) `(,content-type (charset 
. ,charset)
(if (and (mm-inlinable-p handle)
 (mm-inlined-p handle))
(let ((content (notmuch-show-get-bodypart-content msg part nth)))
diff --git a/notmuch-show.c b/notmuch-show.c
index 0200b9c..87a1c90 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -675,13 +675,31 @@ format_part_content_json (GMimeObject *part)
printf (", \"filename\": %s", json_quote_str (ctx, filename));
 }
 
-if (g_mime_content_type_is_type (content_type, "text", "*") &&
-   !g_mime_content_type_is_type (content_type, "text", "html"))
+if (g_mime_content_type_is_type (content_type, "text", "*"))
 {
-   show_text_part_content (part, stream_memory);
-   part_content = g_mime_stream_mem_get_byte_array (GMIME_STREAM_MEM 
(stream_memory));
+   /* For non-HTML text/* parts, we include the content in the
+* JSON. Since JSON must be Unicode, we handle charset
+* decoding here and do not report a charset to the caller.
+* For text/html parts, we do not include the content. If a
+* caller is interested in text/html parts, it should retrieve
+* them separately and they will not be decoded. Since this
+* makes charset decoding the responsibility on the caller, we
+* report the charset for text/html parts.
+*/
+   if (g_mime_content_type_is_type (content_type, "text", "html"))
+   {
+   const char *content_charset = 
g_mime_object_get_content_type_parameter (GMIME_OBJECT (part), "charset");
+
+   if (content_charset != NULL)
+   printf (", \"content-charset\": %s", json_quote_str (ctx, 
content_charset));
+   }
+   else
+   {
+   show_text_part_content (part, stream_memory);
+   part_content = g_mime_stream_mem_get_byte_array (GMIME_STREAM_MEM 
(stream_memory));
 
-   printf (", \"content\": %s", json_quote_chararray (ctx, (char *) 
part_content->data, part_content->len));
+   printf (", \"content\": %s", json_quote_chararray (ctx, (char *) 
part_content->data, part_content->len));
+   }
 }
 else if (g_mime_content_type_is_type (content_type, "multipart", "*"))
 {
-- 
1.7.7.3

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


Re: [PATCH] Set fill column to 70 in .dir-locals.el.

2012-01-13 Thread David Edmondson
On Thu, 12 Jan 2012 18:17:23 -0500, Austin Clements  wrote:
> This controls where comments and other text wraps.  70 is the default
> value, so this simply returns it to the default for people who have
> overridden it.  Most notmuch code already adheres to this.

Makes sense.


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


[PATCH] notmuch-dev: Forcibly delete branches.

2012-01-13 Thread David Edmondson
`magit-delete-branch' runs "git branch -d ", which refuses to
delete branches that are not fully merged. Given that we don't care
and don't want to be stalled, use "git branch -D " directly.
---

This should address the problems removing un-merged branches.

 emacs/notmuch-dev.el |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-dev.el b/emacs/notmuch-dev.el
index ac427ec..871ce3b 100644
--- a/emacs/notmuch-dev.el
+++ b/emacs/notmuch-dev.el
@@ -64,7 +64,9 @@
   (magit-checkout "master"))
 
 (defun notmuch-dev-delete-branch (name)
-  (magit-delete-branch name))
+  ;; `magit-delete-branch' uses "-d", which is not sufficiently
+  ;; aggressive for us.
+  (magit-run-git "branch" "-D" name))
 
 (defun notmuch-dev-create-branch (name)
   ;; Switches to the new branch automatically.
-- 
1.7.7.3

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


Re: [PATCH] emacs: globally replace non-branching "(if (not ..." with "(unless ..."

2012-01-13 Thread David Edmondson
On Fri, 13 Jan 2012 13:42:55 +0100, Xavier Maillard  wrote:
> On Fri, 13 Jan 2012 08:23:55 +0000, David Edmondson  wrote:
> > On Thu, 12 Jan 2012 18:33:06 +0100, Pieter Praet  wrote:
> > > Less code, same results, without sacrificing readability.
> > 
> > +1, but why not replace non-branching `if' with `when' as well?
> 
> I tend to use WHEN for case I need to execute multiple
> statements. For the rest, IF is ok.

Understood.


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


[PATCH 1/2] notmuch-dev: Remove more characters from branch names.

2012-01-13 Thread David Edmondson
Remove {, } and ,.
---
 emacs/notmuch-dev.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-dev.el b/emacs/notmuch-dev.el
index 871ce3b..465846f 100644
--- a/emacs/notmuch-dev.el
+++ b/emacs/notmuch-dev.el
@@ -75,7 +75,7 @@
 (defun notmuch-dev-flatten-title (title)
   (let* ((s (downcase title))
 (s (replace-regexp-in-string "[ \t/]+" "-" s))
-(s (replace-regexp-in-string "[\]\[\":]" "" s))
+(s (replace-regexp-in-string "[\]\[\"{}:,]" "" s))
 (s (replace-regexp-in-string "\\.$" "" s))
 )
 s))
-- 
1.7.7.3

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


[PATCH 2/2] notmuch-dev: Update the master branch when requested.

2012-01-13 Thread David Edmondson
If `notmuch-dev-show-review-patch' is called with a prefix argument,
pull updates for the 'master' branch of the temporary repository.
---
 emacs/notmuch-dev.el |8 +++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-dev.el b/emacs/notmuch-dev.el
index 465846f..3a15bf4 100644
--- a/emacs/notmuch-dev.el
+++ b/emacs/notmuch-dev.el
@@ -61,7 +61,12 @@
   (error "git clone failed."
 
 (defun notmuch-dev-checkout-master ()
-  (magit-checkout "master"))
+  (magit-checkout "master")
+  (when current-prefix-arg
+(message "Updating master...")
+;; Don't use `magit-pull' because it runs asynchronously.
+(magit-run-git "pull" "-v")
+(message "Updating master...done.")))
 
 (defun notmuch-dev-delete-branch (name)
   ;; `magit-delete-branch' uses "-d", which is not sufficiently
@@ -108,6 +113,7 @@
 (let ((default-directory notmuch-dev-temporary-repository-path))
 
   (notmuch-dev-checkout-master)
+
   ;; Delete the branch if it exists.
   (condition-case nil
  (notmuch-dev-delete-branch patch-name)
-- 
1.7.7.3

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


Re: [PATCH] emacs: globally replace non-branching "(if (not ..." with "(unless ..."

2012-01-13 Thread David Edmondson
On Thu, 12 Jan 2012 18:33:06 +0100, Pieter Praet  wrote:
> Less code, same results, without sacrificing readability.

Does this change correctly re-indent the line following the if/unless?


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


Re: [PATCH v2] emacs: logically group def{custom,face}s

2012-01-13 Thread David Edmondson
On Thu, 12 Jan 2012 23:31:34 -0400, David Bremner  wrote:
> On Thu, 12 Jan 2012 18:12:16 +0100, Pieter Praet  wrote:
> > To allow for expansion whilst keeping everything tidy and organized,
> > move all defcustom/defface variables to the following subgroups,
> > defined in notmuch-lib.el:
> > 
> > - Hello
> > - Search
> > - Show
> > - Send
> > - Crypto
> > - Hooks
> > - Appearance
> > - External Commands
> 
> I didn't investigate too closely, but I noticed when I customize-group
> emacs, each subgroup has some explanatory text beside it. Did you omit
> that on purpose?

That should be a requirement, I think.


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


Re: [PATCH] emacs: whitespace-cleanup for emacs/*.el files

2012-01-13 Thread David Edmondson
On Fri, 13 Jan 2012 11:50:52 +0200, Tomi Ollila  wrote:
> So, In addition to 'uncrustify.cfg' we need emacs reformatter along lines:
> 
> (defun reformat-elisp-buffer ()
>   (interactice)
>   (emacs-lisp-mode)
>   (whitespace-cleanup)
>   (indent-region (point-min) (point-max)))
> 
> And this located in same directory as 'uncrustify.cfg', wherever
> that ends up.

I'd be happy with that. Note that doing it initially will require a
bunch of fixes - using a single ';' as a comment leader doesn't produce
the desired result, and notmuch.el is full of it...


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


Re: [PATCH 0/4] Quoting HTML-only emails in replies redux

2012-01-15 Thread David Edmondson
Given that we're now doing a bunch of work in emacs as part of the reply
setup, why not just grab the content of the original message from the
show buffer and quote that?

The last time that approach was discussed Carl was against it because it
moved the emacs UI away from the behaviour of the CLI, but it seems that
we're already heading in that direction.


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


Re: [PATCH] Output unmodified Content-Type header value for JSON format.

2012-01-15 Thread David Edmondson
> Technically the IRC discussion was about not including *any* part
> content in the JSON output, and always using show --format=raw or
> similar to retrieve desired parts.  Currently, notmuch includes part
> content in the JSON only for text/*, *except* when it's text/html.  I
> assume non-text parts are omitted because binary data is hard to
> represent in JSON and text/html is omitted because some people don't
> need it.  However, this leads to some peculiar asymmetry in the Emacs
> code where sometimes it pulls part content out of the JSON and
> sometimes it retrieves it using show --format=raw.  This in turn leads
> to asymmetry in content encoding handling, since notmuch handles
> content encoding for parts included in the JSON (and there's no good
> way around that since JSON is Unicode), but not for parts retrieved as
> raw.

Including the text output in the JSON results in significantly fewer
calls to 'notmuch' during the building of a typical `notmuch-show-mode'
buffer. Someone with one of those older, crankier computers could easily
test how much effect this has by changing
`notmuch-show-get-bodypart-content' slightly.

> The idea discussed on IRC was to remove all part content from the JSON
> output and to always use show to retrieve it, possibly beefing up
> show's support for content decoding (and possibly introducing a way to
> retrieve multiple raw parts at once to avoid re-parsing).  This would
> get the JSON format out of the business of guessing what consumers
> need, simplify the Emacs code, and normalize content encoding
> handling.

Is there a real problem being solved here? Having a clean structure is
nice, except when it's not.


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


Re: [PATCH] emacs: globally replace non-branching "(if (not ..." with "(unless ..."

2012-01-15 Thread David Edmondson
On Sat, 14 Jan 2012 10:18:46 +0100, Pieter Praet  wrote:
> Does this really warrant a v2, or might we simply leave it as yet
> another victim for Tomi's uncrustify-for-elisp [1] ?

Pushing incorrectly indented code should be banned, in my opinion[1]. I'd
be tempted to have some pre-commit hooks to detect it.

Footnotes: 
[1]  Though I've done it myself.


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


Re: [PATCH v2] emacs: Cycle through notmuch buffers rather than jumping to the last.

2012-01-15 Thread David Edmondson
On Sat, 14 Jan 2012 10:29:31 +0100, Pieter Praet  wrote:
> Might I ask, to what key(chord) have you bound this ?  Due to its
> usefulness, I'm inclined to bind it to [SPC], but on second though,
> that might be a bit on the intense side...

C-c= globally. That's clobbered in a couple of major modes, but not
enough to bother me so far.


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


Re: [PATCH 0/4] Quoting HTML-only emails in replies redux

2012-01-16 Thread David Edmondson
On Mon, 16 Jan 2012 02:38:38 -0500, Aaron Ecay  wrote:
> On Sun, 15 Jan 2012 09:26:59 +0000, David Edmondson  wrote:
> > Given that we're now doing a bunch of work in emacs as part of the reply
> > setup, why not just grab the content of the original message from the
> > show buffer and quote that?
> > 
> > The last time that approach was discussed Carl was against it because it
> > moved the emacs UI away from the behaviour of the CLI, but it seems that
> > we're already heading in that direction.
> 
> I have been watching this patch series with interest, because it seemed
> that when it landed it would be a good time for me to begin work on a
> patch to allow notmuch to function like other emacs MUAs in constructing
> the reply buffer internally to emacs, rather than through notmuch.  This
> allows (at least) three things:
> - Greater flexibility in the construction of address lists.  For example,
>   there are some email lists where I want replies to list mail to go only
>   to the list, not also to the original sender.

Is there a mechanistic way to determine the correct behaviour in this
respect? I suspect that it's exactly the kind of thing that Carl wanted
to be included in 'notmuch' itself, so that other UIs can benefit.

>   Additionally, I like to
>   reply from my university address if colleagues write to my Gmail one.
>   If a lisp function is generating the replies, it can be made to run a
>   hook allowing users to insert these or other custom behaviors.
> - The same reasoning as above, applied to signatures.  (different ones
>   for different recipients)

You can do both of these things today using `message-send-hook' (I do).

> - There exists at least one emacs package (supercite) which allows
>   customization of the quoting of email replies.  This automates the
>   “Firstname>” style quotes one sometimes sees, as well as many other
>   possiblities.  It defines a way for emacs MUAs to construct reply
>   buffers to cooperate with it, which many of the big emacs MUAs obey
>   (Gnus and Wanderlust certainly do).  This is explained in the “hints
>   to MUA authors” section of the supercite manual (distributed with
>   Emacs).

I dislike supercite, so no support from me in that direction :-)


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


Re: [PATCH v2] emacs: Cycle through notmuch buffers rather than jumping to the last.

2012-01-16 Thread David Edmondson
On Sun, 15 Jan 2012 22:01:05 -0500, Austin Clements  wrote:
> Quoth David Edmondson on Jan 15 at 11:55 am:
> > On Sat, 14 Jan 2012 10:29:31 +0100, Pieter Praet  wrote:
> > > Might I ask, to what key(chord) have you bound this ?  Due to its
> > > usefulness, I'm inclined to bind it to [SPC], but on second though,
> > > that might be a bit on the intense side...
> > 
> > C-c= globally. That's clobbered in a couple of major modes, but not
> > enough to bother me so far.
> 
> Might it make sense to bind this across the notmuch mode maps by
> default?  This would at least make this feature more visible as well
> as quite useful to people who dedicate an Emacs instance to notmuch.

The elisp manual says:

   * Don't define `C-c LETTER' as a key in Lisp programs.  Sequences
 consisting of `C-c' and a letter (either upper or lower case) are
 reserved for users; they are the *only* sequences reserved for
 users, so do not block them.

...

   * Sequences consisting of `C-c' followed by a control character or a
 digit are reserved for major modes.

   * Sequences consisting of `C-c' followed by `{', `}', `<', `>', `:'
 or `;' are also reserved for major modes.

   * Sequences consisting of `C-c' followed by any other punctuation
 character are allocated for minor modes.  Using them in a major
 mode is not absolutely prohibited, but if you do that, the major
 mode binding may be shadowed from time to time by minor modes.

which I read to mean that C-c= is allocated for use by minor modes. I
could easily be persuaded to change to C-c; and have that bound in our
major modes (and personally bind it globally).


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


Re: [PATCH] Output unmodified Content-Type header value for JSON format.

2012-01-16 Thread David Edmondson
On Sun, 15 Jan 2012 12:58:40 -0500, Austin Clements  wrote:
> Yes.  I was mostly reiterating the IRC discussion for Pieter.  Since
> this discussion, I've stabilized on the pre-fetching notion I described
> in id:"20120115003617.gh1...@mit.edu",

Will read when I get there.

> though I do think we should make this clear in the code: that the rule
> for whether the JSON includes a "content" key for a leaf part is
> internal to the CLI and that consumers should be prepared to use it if
> it's there and to retrieve the content separately if it's not.  This
> is exactly how the Emacs code happens to work, it just hasn't been
> codified anywhere.

It's a bit more than 'happens to work' :-)

> Looking at it this way gives us more flexibility than the current code
> takes advantage of; for example we could omit content from the JSON if
> it's over some size threshold since the cost of sending that to a
> client that doesn't need it is high while the cost of having the
> client retrieve it for itself is relatively low.

This, I suspect, brings us back to what may have been Dmitry's original
concern. If we codify the current behaviour then we're actually
_forcing_ clients to use inline content if it's present, because
otherwise they have no way to discover the charset/encoding used for the
raw part.

That seems as though it could be a problem for some clients.

> OTOH, I don't understand the encoding story for HTML, since the encoding
> can come from either a header or from the body of the HTML.  Does this
> make it strictly necessary for the client to handle the encoding?

If it can be specified by the content of a part rather than the part
headers, then I think that the client will have to be prepared to handle
it.

Even if not, it might still be more effective to choose that approach -
it would remove the need to add arbitrary encoding support to the CLI
application.


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


Re: [PATCH 2/2] notmuch-dev: Update the master branch when requested.

2012-01-16 Thread David Edmondson
On Fri, 13 Jan 2012 22:03:17 +0100, Xavier Maillard  wrote:
> Have you planned to cook something about this in notmuch wiki ?
> That sounds like something I could use to test patches more easily than
> I do currently.

I'll do so.

> Note: I am totally a dummy when I have to use git :/

Me too, hence the wrapper!


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


Re: [PATCH v2 3/3] search: Support automatic tag exclusions

2012-01-16 Thread David Edmondson
On Sat, 14 Jan 2012 15:40:26 -0800, Jameson Graef Rollins 
 wrote:
> This patch looks fine.  Philosophical UI discussion to follow:
> 
> On Fri, 13 Jan 2012 18:07:04 -0500, Austin Clements  wrote:
> > +if (notmuch_config_get_auto_exclude_tags (config, &tmp) == NULL) {
> > +   const char *tags[] = { "deleted", "spam" };
> > +   notmuch_config_set_auto_exclude_tags (config, tags, 2);
> > +}
> 
> This creates the config section with the exclude list pre-set to
> "deleted;spam".

I don't think that anything should be excluded from the search results
by default, at least not as a default behaviour of the 'notmuch'
binary.

Having "deleted" and "spam" as default settings in the configuration
file might be more reasonable.


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


Re: [PATCH 0/1] emacs: allow viewing as well saving individual attachments

2012-01-16 Thread David Edmondson
On Sun, 15 Jan 2012 12:16:35 +, Mark Walters  
wrote:
> Mark Walters (1):
>   Make buttons for attachments allow viewing as well as saving
> 
>  emacs/notmuch-show.el |   81 ++--
>  1 files changed, 64 insertions(+), 17 deletions(-)

Nice changes.


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


Re: [PATCH 1/3] emacs/*.el: changed one-char comment prefix '; ' to two: '; ; '

2012-01-16 Thread David Edmondson
+2 for the whole set :-)


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


Re: [PATCH] add `tag:' prefix to `--output=tags' results

2012-01-16 Thread David Edmondson
Given the discussion that followed this patch I'd like to mark it as
'obsolete'.

Any objections?


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


Re: [PATCH v6 0/2] emacs: User-defined sections in notmuch-hello

2012-01-16 Thread David Edmondson
Daniel, there was a bunch of feedback from Dmitry about the patch and a
couple of other comments.

Do you plan to produce a new version?

It would be good to get this applied - it allows us to address various
comments that have been made about unifying the different search
mechanisms and looks generally useful.


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


Re: [PATCH v4] emacs: logically group def{custom,face}s

2012-01-16 Thread David Edmondson
Nice work. +1 for me.


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


Re: [PATCH] [RFC] emacs: merge overhauled `notmuch-cycle-notmuch-buffers' into `notmuch'

2012-01-16 Thread David Edmondson
On Mon, 16 Jan 2012 11:42:31 +0100, Pieter Praet  wrote:
> CLisp'ier version of `notmuch-cycle-notmuch-buffers', merged into `notmuch',
> eliminating the need to hog yet another keybind.

The lisp-ier-ness changes are good.

I'm less sure about the functional change. Sometimes I want to go back
to where I was, other times I want to go to `notmuch-hello'. I suppose
that I can replace my binding for `notmuch' with one for
`notmuch-hello'.

Hmm, yes, that seems reasonable.

> FYI: causes 2 compile warnings due to requiring the cl package at runtime.

`cl' is still `eval-when-compile' though - won't that break?


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


Re: [PATCH v2] emacs: globally replace non-branching "(if (not ..." with "(unless ..."

2012-01-16 Thread David Edmondson
On Mon, 16 Jan 2012 11:56:40 +0100, Pieter Praet  wrote:
> Less code, same results, without sacrificing readability.

+1.


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


Re: [PATCH] emacs: Don't attempt to colour tags in `notmuch-show-mode'.

2012-01-16 Thread David Edmondson
On Mon, 16 Jan 2012 12:17:03 +0100, Pieter Praet  wrote:
> Alas, those text properties actually *were* effective (and I liked them :)

Well, not in emacs 24. My reading of the source was that overlays were
intended to stomp on text properties, but that could have been wrong.

Do they look correct when you add/remove tags?


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


Re: [PATCH] emacs: Improved printing support.

2012-01-16 Thread David Edmondson
On Tue,  3 Jan 2012 14:12:26 +, David Edmondson  wrote:
> Add various functions to print notmuch messages and tie them together
> with a simple frontend. No keybinding is currently made to encourage
> paper saving.

Could someone review my lisp please?

bremner suggested that a default keybinding to print messages would be
appropriate. I'd like to propose '#' (for which I'll send another patch
if agreed).


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


Re: [PATCH] emacs-hello: Do not calculate the count of the messages in

2012-01-16 Thread David Edmondson
On Thu, 13 Oct 2011 16:09:23 +0200, Michal Sojka  wrote:
> On Mon, 10 Oct 2011, Daniel Schoepe wrote:
> > Fixed that and rebased against master.
> 
> Hi Daniel,
> 
> I've an improvement for your patches. Recently, I decided to speed up
> notmuch hello startup times and I found that hiding a section does not
> eliminate the execution of "notmuch count" commands for buttons in the
> hidden section. The following patch (applies on top of v5) should fix
> it. Now I can enjoy blazingly fast notmuch startup, because I have only
> one section shown. :-)
> 
> Another improvement could be the addition of [hide] button for saved
> searches sections.

Daniel, will you include this in your next version? (I'd like to mark it
'obsolete'.)


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


Re: [PATCH 1/4] emacs: unify search mechanisms

2012-01-16 Thread David Edmondson
On Sun, 25 Dec 2011 08:14:52 +0400, Dmitry Kurochkin 
 wrote:
> Before the change, there were two ways to do search in Emacs UI:
> search widget in notmuch-hello buffer and `notmuch-search'
> function bound to "s".  Internally, notmuch-hello search widget
> uses `notmuch-search' function.  But it uses widget field input
> instead of minibuffer.  Such duplication is a major issue for
> notmuch-hello usability: search interface is inconsistent and
> lacks features that are available in minibuffer (e.g. history and
> auto completion).  Some of these features may be relatively easy
> to implement for notmuch-hello search, others would be much more
> tricky.  So to avoid duplication, make UI more consistent, bring
> notmuch-hello search to feature parity with the minibuffer
> search, the patch replaces notmuch-hello search widget and with a
> button that works the same way as "s" key binding.

Dmitry, if Daniel re-submits his patches to allow the construction of
`notmuch-hello' buffers to be configured, it seems that this patchset
would become unnecessary. Is that correct?


pgpd0bjPiNU3a.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-16 Thread David Edmondson
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
> the -ize spelling in older legislative acts and the -ise spelling in
> more recent ones." ... and other convincing reasons [1].
> 
> Let's follow the good example of academic and standards bodies,
> instead of the errors of a non-democratic pseudo-authority [2].
> 
> [1] 
> http://en.wikipedia.org/wiki/American_and_British_English_spelling_differences#Greek-derived_spellings
> [2] http://en.wikipedia.org/wiki/Democratic_deficit_in_the_European_Union

Reluctantly, +1.


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


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

2012-01-16 Thread David Edmondson
On Thu, 12 Jan 2012 18:23:44 +0100, Pieter Praet  wrote:
> +  (make-text-button string-start string-end
>   'action `(lambda (arg)
> -(notmuch-show ,(match-string-no-properties 
> 0)))
> +(notmuch-show-if-found ,message-id))

I like this, but wonder idly about the performance impact (not enough to
suggest denying it, though).

> +(defun notmuch-show-found-target-p (target)
> +  (let ((args `("count" ,target)))
> +(> (string-to-number (substring
> +  (with-output-to-string
> +(apply 'call-process notmuch-command nil standard-output nil args))
> +  0 -1)) 0)))

`substring' seems unnecessary, presuming that it's to get rid of the
carriage return.

> +(defun notmuch-show-if-found (target &rest args)
> +  (if (notmuch-show-found-target-p target nil)
> +  (notmuch-show target args)
> +(error (format "Can't find target: %s" target

`error' will format strings without help.


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


Re: [PATCH 3/3] emacs: colorize buttonized 'id:' links depending on the target message's state

2012-01-16 Thread David Edmondson
On Thu, 12 Jan 2012 18:23:45 +0100, Pieter Praet  wrote:
> + 'face (cond
> +((notmuch-show-found-target-p message-id t)
> + 
> 'notmuch-show-buttonized-link-present-and-unread)
> +((notmuch-show-found-target-p message-id)
> + 'notmuch-show-buttonized-link-present)
> +(t 'notmuch-show-buttonized-link-missing)))

I like it, but worry a bit more about the performance (we're up to two
'notmuch' invocations for a missing or read message).


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


Re: [PATCH] [RFC] emacs: merge overhauled `notmuch-cycle-notmuch-buffers' into `notmuch'

2012-01-16 Thread David Edmondson
On Mon, 16 Jan 2012 12:28:06 +0100, Pieter Praet  wrote:
> Perhaps we could use `ido-completion-help', like Org-mode does with
> `org-iswitchb' ?  OTOH, that would require an extra [RET].  Bah...

I'm a no-ido person.

> > Hmm, yes, that seems reasonable.
> > 
> > > FYI: causes 2 compile warnings due to requiring the cl package at runtime.
> > 
> > `cl' is still `eval-when-compile' though - won't that break?
> 
> Haven't noticed any issues here, apart from the complaints @ compilation.

If you load the compiled lisp into 'emacs -Q' and then attempt to call
the function, it doesn't complain? (I haven't tested.)


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


Re: [PATCH 1/4] emacs: unify search mechanisms

2012-01-16 Thread David Edmondson
On Mon, 16 Jan 2012 15:39:14 +0400, Dmitry Kurochkin 
 wrote:
> > Dmitry, if Daniel re-submits his patches to allow the construction of
> > `notmuch-hello' buffers to be configured, it seems that this patchset
> > would become unnecessary. Is that correct?
> 
> Right.  We will just need to fix the 's' key binding.  Looking forward
> for that.

Can I mark this set 'obsolete' then? (I'd be relying on you to remember
to post a patch to fix the keybinding later.)


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


Re: The overloading of show (was Re: [PATCH] Output unmodified Content-Type header value for JSON format.)

2012-01-16 Thread David Edmondson
On Sat, 14 Jan 2012 19:36:17 -0500, Austin Clements  wrote:
> ...there are several levels of structure here:
> 
> 1. Threads (query results)
> 2. Thread structure
> 3. Message structure (MIME)
> 4. Part content
> 
> Currently, search returns 1; show --format=json returns 2, 3, and
> sometimes 4 (but sometimes not); and show --format=raw returns 4.
> Notably, 1 does not require opening message files (neither does 2),
> which I consider an important distinction between search and show.
> 
> Some of the discussion has been about putting 4 squarely in the realm
> of show --format=raw.  One counterargument (which has grown on me
> since this discussion) is that the part content included in
> --format=json can be thought of as pre-fetching content that clients
> are likely to need in order to avoid re-parsing the message in most
> circumstances.  I believe this is not the *intent* of the current
> code, though without a specification of the JSON format it's hard to
> tell.

The JSON output included what was considered useful (mostly for the
Emacs UI), but how much deep thought went into 'useful' I couldn't say.

> Other discussion (more interesting, in my mind) has been about
> separating retrieving thread structure, 2, from retrieving message
> structure, 3.  To me, splitting these feels much more natural than
> what we do now, which seems to be inflexibly bound to the specific way
> the Emacs show mode currently works.  The thread structure is readily
> available from the database, so I think separating these would open up
> some new UI opportunities, particularly easy and fast thread outlining
> and navigation.

Given that the current output already includes both 2 and 3, anything
that could be done with 2 can be done with the current output, so
there's no block on the kind of innovation that you describe other than
possibly some performance problems.

notmuch-lkml.el[1] was a quick prototype of an alternative way to find
messages to read based on suggestions from Aneesh. It could have used
the proposed 'thread structure only' output.

The changes you allude to make sense. My only concern would be any
potential impact on the current Emacs UI's use of JSON output. Switching
to a model where a typical 'notmuch-show' buffer requires many calls to
notmuch (and commensurate JSON parsing) may perform significantly worse
than the current approach.

> I believe it would also simplify the code and address some irritating
> asymmetries in the way notmuch show handles the --part argument.

Footnotes: 
[1]  http://dme.org/data/emacs/notmuch-lkml.el



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


[PATCH] emacs: Truncate lines and do not enable visual-line-mode in notmuch-show buffers.

2012-01-16 Thread David Edmondson
Enable the truncation of lines in `notmuch-show-mode' to avoid visual
noise caused by the wrapping of the header lines.

Don't enable `visual-line-mode' because it disables line truncation.

The benefits of `visual-line-mode' were that it wrapped long lines
in received messages. With `notmuch-wash-wrap-long-lines' now default
behaviour, this is no longer required.
---
 emacs/notmuch-show.el |6 ++
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 1a250a3..797f94b 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -873,9 +873,6 @@ buffer."
 
   (jit-lock-register #'notmuch-show-buttonise-links)
 
-  ;; Act on visual lines rather than logical lines.
-  (visual-line-mode t)
-
   (run-hooks 'notmuch-show-hook))
 
 ;; Move straight to the first open message
@@ -987,7 +984,8 @@ All currently available key bindings:
   (use-local-map notmuch-show-mode-map)
   (setq major-mode 'notmuch-show-mode
mode-name "notmuch-show")
-  (setq buffer-read-only t))
+  (setq buffer-read-only t
+   truncate-lines t))
 
 (defun notmuch-show-move-to-message-top ()
   (goto-char (notmuch-show-message-top)))
-- 
1.7.7.3

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


Re: [PATCH] debian: add a recommends for w3m-el or w3m-el-snapshot to notmuch-emacs

2012-01-16 Thread David Edmondson
On Wed,  7 Dec 2011 22:13:06 -0400, David Bremner  wrote:
> From: David Bremner 
> 
> Installing w3m-el provides a nicer out of the box experience for
> viewing html in notmuch, and the overhead is not too bad (about 5M
> diskspace).

Given the discussion, should this be 'obsolete'?


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


[PATCH 1/2] test: Add "test_expect_emacs_t" to assist with emacs testing.

2012-01-16 Thread David Edmondson
"test_expect_emacs_t" expects a single argument. If this is `t' then
the test passes. Otherwise the argument provides the details of the
test failure to be reported.
---

For use in the following set of tests and later for other emacs related tests.

 test/test-lib.sh |   20 
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index d1fbc05..0ffe9a6 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -503,6 +503,26 @@ test_expect_equal_file ()
 fi
 }
 
+# Pass test if the result is `t', else report the results.
+test_expect_emacs_t ()
+{
+   exec 1>&6 2>&7  # Restore stdout and stderr
+   inside_subtest=
+   test "$#" = 1 ||
+   error "bug in the test script: not 1 parameter to test_expect_emacs_t"
+
+   result="$1"
+   if ! test_skip "$test_subtest_name"
+   then
+   if [ "${result}" == "t" ] ; then
+   test_ok_ "$test_subtest_name"
+   else
+   testname=$this_test.$test_count
+   test_failure_ "$test_subtest_name" "$(eval printf 
${result})"
+   fi
+fi
+}
+
 NOTMUCH_NEW ()
 {
 notmuch new | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* 
total file'
-- 
1.7.7.3

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


[PATCH 2/2] test: Add tests for `notmuch-show-test-clean-address'.

2012-01-16 Thread David Edmondson
---

Add three tests. The third one currently fails.

 emacs/notmuch-test.el |   87 +
 test/emacs|6 +++
 2 files changed, 93 insertions(+), 0 deletions(-)
 create mode 100644 emacs/notmuch-test.el

diff --git a/emacs/notmuch-test.el b/emacs/notmuch-test.el
new file mode 100644
index 000..d6cf318
--- /dev/null
+++ b/emacs/notmuch-test.el
@@ -0,0 +1,87 @@
+;; notmuch-test.el --- testing the emacs interface
+;;
+;; Copyright © David Edmondson
+;;
+;; This file is part of Notmuch.
+;;
+;; Notmuch is free software: you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; Notmuch is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with Notmuch.  If not, see <http://www.gnu.org/licenses/>.
+;;
+;; Authors: David Edmondson 
+
+(require 'cl)  ;; This code is often used uncompiled.
+
+;;
+
+(defun notmuch-test-reporter (output expected)
+  "Report that the `output' does not match the `expected' result."
+  (concat "Expect:\t" (prin1-to-string expected) "\n"
+ "Output:\t" (prin1-to-string output) "\n"))
+
+(defun notmuch-test-unsimilar (output expected)
+  "`output' and `expected' are dissimilar. Show a summary of
+the differences, ignoring similarities."
+  (cond ((and (listp output)
+ (listp expected))
+(apply #'concat (loop for o in output
+  for e in expected
+  if (not (equal o e))
+  collect (notmuch-test-reporter o e
+
+   (t
+;; Catch all case.
+(notmuch-test-reporter output expected
+
+(defun notmuch-test-compare (output expected)
+  "Compare `output' with `expected'. Report any discrepencies."
+  (if (equal output expected)
+  t
+(notmuch-test-unsimilar output expected)))
+
+;;
+
+;; Tests:
+
+(defun notmuch-test-clean-address-1 ()
+  (notmuch-test-compare (notmuch-show-clean-address "d...@dme.org")
+   "d...@dme.org"))
+
+(defun notmuch-test-clean-address-2 ()
+  (let* ((input '("f...@bar.com"
+ ""
+ "Foo Bar "
+ "f...@bar.com "
+ "\"Foo Bar\" "))
+(expected '("f...@bar.com"
+"f...@bar.com"
+"Foo Bar "
+"f...@bar.com"
+"Foo Bar "))
+(output (mapcar #'notmuch-show-clean-address input)))
+(notmuch-test-compare output expected)))
+
+(defun notmuch-test-clean-address-3 ()
+  (let* ((input '("ДБ "
+ "foo (at home) "
+ "foo [at home] "
+ "Foo Bar"))
+(expected '("ДБ "
+"foo (at home) "
+"foo [at home] "
+"Foo Bar"))
+(output (mapcar #'notmuch-show-clean-address input)))
+(notmuch-test-compare output expected)))
+
+;;
+
+(provide 'notmuch-test)
diff --git a/test/emacs b/test/emacs
index ac47b16..3a536fb 100755
--- a/test/emacs
+++ b/test/emacs
@@ -514,4 +514,10 @@ counter=$(test_emacs \
 )
 test_expect_equal "$counter" 2
 
+for i in 1 2 3; do
+test_begin_subtest "notmuch-show-clean-address $i"
+result=$(test_emacs '(load "notmuch-test.el") 
(notmuch-test-clean-address-'$i')')
+test_expect_emacs_t "$result"
+done
+
 test_done
-- 
1.7.7.3

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


Re: [PATCH] v2 [RFC] emacs: merge overhauled `notmuch-cycle-notmuch-buffers' into `notmuch'

2012-01-16 Thread David Edmondson
On Mon, 16 Jan 2012 17:46:55 +0100, Pieter Praet  wrote:
> Make `notmuch-cycle-notmuch-buffers' more Lispy and merge into `notmuch',
> eliminating the need to hog yet another keybind.
...
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index ef4dcc7..539b3a0 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -1067,7 +1067,20 @@ current search results AND that are tagged with the 
> given tag."
>  (defun notmuch ()
>"Run notmuch and display saved searches, known tags, etc."
>(interactive)
> -  (notmuch-hello))
> +  (let* ((old-buffer (current-buffer))
> +  (interesting-buffers
> +   (delq nil (mapcar (lambda (b)
> +   (if (notmuch-interesting-buffer b) b))
> + (buffer-list
> +  (next-buffer (first
> +   (delq nil (mapcar (lambda (b)
> +   (unless (eq old-buffer b) b))
> + interesting-buffers)

This feels _less_ lispy. Any occurrences of '(delq nil ...)' strike me
as odd. What's wrong with '(loop ... collect ...)'?

> +(if next-buffer
> + (progn
> +   (switch-to-buffer next-buffer)
> +   (bury-buffer old-buffer))
> +  (notmuch-hello

Integrating with `notmuch' is fine with me.


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


Re: [PATCH] v2 emacs: colorize buttonized 'id:' links depending on the target message's state

2012-01-16 Thread David Edmondson
Nice. +1.


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


Re: [PATCH v2] emacs: `notmuch-show-buttonize-links' only `notmuch-show's a message if it exists

2012-01-16 Thread David Edmondson
+1.


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


[PATCH 1/2] emacs: Avoid `mail-header-parse-address' in `notmuch-show-clean-address'.

2012-01-16 Thread David Edmondson
`mail-header-parse-address' expects un-decoded mailbox parts, which is
not what we have at this point. Replace it with simple string
deconstruction.
---

Fix the failing test in the previous set.

 emacs/notmuch-show.el |   48 +++-
 1 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 1a250a3..02819f3 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -227,21 +227,43 @@ indentation."
   "Try to clean a single email ADDRESS for display.  Return
 unchanged ADDRESS if parsing fails."
   (condition-case nil
-(let* ((parsed (mail-header-parse-address address))
-  (address (car parsed))
-  (name (cdr parsed)))
-  ;; Remove double quotes. They might be required during transport,
-  ;; but we don't need to see them.
-  (when name
-(setq name (replace-regexp-in-string "\"" "" name)))
+(let (p-name p-address)
+  ;; It would be convenient to use `mail-header-parse-address',
+  ;; but that expects un-decoded mailbox parts, whereas our
+  ;; mailbox parts are already decoded (and hence may contain
+  ;; UTF-8). Given that notmuch should handle most of the awkward
+  ;; cases, some simple string deconstruction should be sufficient
+  ;; here.
+  (cond
+   ;; "User " style.
+   ((string-match "\\(.*\\) <\\(.*\\)>" address)
+   (setq p-name (match-string 1 address)
+ p-address (match-string 2 address)))
+
+   ;; "" style.
+   ((string-match "<\\(.*\\)>" address)
+   (setq p-address (match-string 1 address)))
+
+   ;; Everything else.
+   (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)))
+
   ;; If the address is 'f...@bar.com ' then show just
   ;; 'f...@bar.com'.
-  (when (string= name address)
-(setq name nil))
-
-  (if (not name)
-address
-(concat name " <" address ">")))
+  (when (string= p-name p-address)
+(setq p-name nil))
+
+  ;; If no name results, return just the address.
+  (if (not p-name)
+ p-address
+   ;; Otherwise format the name and address together.
+   (concat p-name " <" p-address ">")))
 (error address)))
 
 (defun notmuch-show-insert-headerline (headers date tags depth)
-- 
1.7.7.3

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


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

2012-01-16 Thread David Edmondson
Remove backslashes.
---

Including a new test case.

 emacs/notmuch-show.el |   14 +-
 emacs/notmuch-test.el |6 --
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 02819f3..6b9d1b8 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -248,11 +248,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 ' then show just
   ;; 'f...@bar.com'.
diff --git a/emacs/notmuch-test.el b/emacs/notmuch-test.el
index d6cf318..0637818 100644
--- a/emacs/notmuch-test.el
+++ b/emacs/notmuch-test.el
@@ -74,11 +74,13 @@ the differences, ignoring similarities."
   (let* ((input '("ДБ "
  "foo (at home) "
  "foo [at home] "
- "Foo Bar"))
+ "Foo Bar"
+ "Fred Dibna \\[extraordinaire\\] "))
 (expected '("ДБ "
 "foo (at home) "
 "foo [at home] "
-"Foo Bar"))
+"Foo Bar"
+"Fred Dibna [extraordinaire] "))
 (output (mapcar #'notmuch-show-clean-address input)))
 (notmuch-test-compare output expected)))
 
-- 
1.7.7.3

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


Re: [PATCH 1/2] test: Add "test_expect_emacs_t" to assist with emacs testing.

2012-01-16 Thread David Edmondson
I asked for feedback on the approach of implementing tests in .el[1] and
got only positive feedback (well, only one bit of feedback at all).

Here are some simpler tests implemented using this approach, trying to
address the concerns about seeing what failed. The test output is now
something like:

 PASS   notmuch-show-clean-address 1
 PASS   notmuch-show-clean-address 2
 FAIL   notmuch-show-clean-address 3
Expect: "ДБ "
Output: "db-uk...@stop.me.uk"
Expect: "foo (at home) "
Output: "foo "
Expect: "foo [at home] "
Output: "foo at home "
Expect: "Foo Bar"
Output: nil

Obviously the first two tests passed and the third failed.

Footnotes: 
[1]  id:"cunmxabqs6k@hotblack-desiato.hh.sledj.net"



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


Re: [PATCH 2/2] test: Add tests for `notmuch-show-test-clean-address'.

2012-01-16 Thread David Edmondson
On Mon, 16 Jan 2012 21:41:09 +0400, Dmitry Kurochkin 
 wrote:
> On Mon, 16 Jan 2012 16:47:33 +0000, David Edmondson  wrote:
> > ---
> > 
> > Add three tests. The third one currently fails.
> > 
> 
> I do not like that we add testing code to emacs/ folder.  My
> understanding is that files in emacs/ are all intended to be installed
> on the system.  But tests should not be.  Can we move this file to
> tests/?
> 
> Also, one file for all tests is a mess.  Let's write more smaller files
> that test different features instead of putting everything to one
> bloated file.  Like we do for other tests now.
> 
> I like the idea of putting elisp testing code into .el files and calling
> functions from regular tests (that is why I added test-lib.el).  For
> tests implemented in elisp, I propose adding a pair of files, e.g.:
> 
>   tests/emacs-address.sh - tests that call elisp functions
>   tests/emacs-address.el - elisp code that actually implements the tests
> 
> What do you think?

All good suggestions - I'll re-whack it.


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


Re: [PATCH 1/2] test: Add "test_expect_emacs_t" to assist with emacs testing.

2012-01-16 Thread David Edmondson
On Mon, 16 Jan 2012 21:50:22 +0400, Dmitry Kurochkin 
 wrote:
> Isn't this function the same as something like "test_expect_equal $x
> t"?

Yes, except that it differs in how it reports differences.

> IMO the function seems too complex for what it does (and basically that
> is "compare $x with t").  Why do we need to implement it in such a way?
> 
> Also, the function has nothing to do with emacs (except for the fact
> that 't' is commonly used in it).
> 
> I think a more useful approach would be to add a function which takes a
> lisp expression, runs test_emacs and compares the result with "t" using
> test_expect_equal or similar.  This way you do not need to make an
> explicit test_emacs call and avoid code duplication when checking the
> result.  test_emacs_expect_t should be a good name for it.  What do you
> think?

Agreed. I'll do it.


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


Re: [PATCH v5 1/5] cli: slightly refactor "notmuch reply" address scanning functions

2012-01-16 Thread David Edmondson
On Mon, 16 Jan 2012 22:06:15 +0400, Dmitry Kurochkin 
 wrote:
> Hello.
> 
> Since this patches got in, I have yet to send a single email to the
> address(es) I intend to :( I am really used to the bindings and this
> change is a pain.  From IRC discussion, it seems like I am not alone
> here.
> 
> There was a proposal to change reply bindings to 'ra' and 'rs'.  When
> 'r' is pressed an appropriate help message can be given in the
> minibuffer.  I like this proposal.  What do others think?
> 
> If others like it, how about reverting to the old bindings until the new
> ones are implemented?

I'm inclined to push on for a while and see if it sticks. Previous
experience with this kind of change suggests that it takes a week or so.


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


Re: [PATCH] emacs: Don't attempt to colour tags in `notmuch-show-mode'.

2012-01-16 Thread David Edmondson
On Mon, 16 Jan 2012 18:21:24 -0400, David Bremner  wrote:
> I'm leaning to revert this patch. Any opposition?

Please revert it and I'll investigate further.


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


Re: [PATCH v2 4/4] emacs: Use the new JSON reply format.

2012-01-17 Thread David Edmondson
Much nicer now that it uses the mm stuff.

On Mon, 16 Jan 2012 11:13:23 -0700, Adam Wolfe Gordon  
wrote:
> +(defun find-parts (parts type)

Sorry for being a nuisance - this needs a name that indicates that it
relates to notmuch. How about `notmuch-parts-filter-by-type'?

> +  "Return a list of message parts with the given type"
> +  (delq nil (mapcar (lambda (part)
> +   (if (string= (cdr (assq 'content-type part)) type)
> +   (cdr (assq 'content part
> + parts)))

'(delq nil ...)' can more readably be implemented using something like:

   (loop for part in parts
 if (string= (cdr (assq 'content-type part)) type)
 collect (cdr (assq 'content part)))

(untested).

> +(defun notmuch-mua-insert-part-quoted (part)
> +  (save-restriction
> +(narrow-to-region (point) (point))
> +(insert part)
> +(goto-char (point-min))
> +(perform-replace "^" "> " nil t nil)

Narrowing to '(point) (point)' seems a bit weird and using
`perform-replace' is discouraged in programs. It would be more normal to
use a loop of `re-search-forward' and `replace-match' with a limit after
the insertion. Something like:

  (let ((start (point))
limit)
(insert part)
(setq limit (point))
(goto-char start)
(while (re-search-forward "^" limit t)
  (replace-match "> "))

...

(untested).

> +(insert "\n")
> +(set-buffer-modified-p nil)))
  
Is this newline always required? Is it the cause of the spurious blank
line down below?

> +(defun notmuch-mua-parse-html-part (part)
> +  (with-temp-buffer
> +(insert part)
> +(let ((handle (mm-make-handle (current-buffer) (list "text/html")))
> +   (end-of-orig (point-max)))
> +  (mm-display-part handle)
> +  (kill-region (point-min) end-of-orig)
> +  (fill-region (point-min) (point-max))
> +  (buffer-substring (point-min) (point-max)

`kill-region' will save content in the kill ring. Was that intended?
(Maybe `delete-region' instead?)

>  (defun notmuch-mua-reply (query-string &optional sender reply-all)
> ...
> +  (insert (format "On %s, %s wrote:\n"
> +   (cdr (assq 'date original-headers))
> +   (cdr (assq 'from original-headers

I wonder whether emacs should be regenerating this or not. I'm okay with
it, but previous discussion was that it should remain the responsibility
of the CLI.

> +  (if (null plain-parts)
> +   (mapc (lambda (part) (notmuch-mua-insert-part-quoted 
> (notmuch-mua-parse-html-part part))) html-parts)
> + (mapc (lambda (part) (notmuch-mua-insert-part-quoted part)) 
> plain-parts))

Flip the 'then' and 'else' clauses to get rid of the `null'?

> --- a/test/emacs
> +++ b/test/emacs
> @@ -270,6 +270,7 @@ Fcc: $(pwd)/mail/sent
>  --text follows this line--
>  On 01 Jan 2000 12:00:00 -, Notmuch Test Suite 
>  wrote:
>  > This is a test that messages are sent via SMTP
> +> 

It would be good if you could get rid of this trailing blank line.


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


Re: how about message-citation-line-format (was: Re: [PATCH v2 5/4] emacs: Add customization for the first line of quotes.)

2012-01-17 Thread David Edmondson
On Tue, 17 Jan 2012 08:17:49 +0100, Gregor Zattler  wrote:
> Hi Adam, notmuch developers,
> * Adam Wolfe Gordon  [16. Jan. 2012]:
> > Add a customization option, notmuch-mua-reply-quoth, which controls
> > the first line of the reply body (typically, "On %date%, %from% wrote:").
> > This allows users who like other styles or correspond in other languages
> > to set an appropriate line using any of the quoted message's headers.
> 
> I really missed this feature in notmuch.  There is already
> message-citation-line-format which is part of message mode or
> gnus and is not used in notmuch.  Wouldn't it be more consistent
> to reuse this?

If we're going to do it, this would be the right approach.


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


Re: [PATCH v2 3/3] search: Support automatic tag exclusions

2012-01-17 Thread David Edmondson
On Mon, 16 Jan 2012 15:16:24 -0700, Jeremy Nickurak  wrote:
> On Mon, Jan 16, 2012 at 12:28, Austin Clements  wrote:
> >> Having "deleted" and "spam" as default settings in the configuration
> >> file might be more reasonable.
> 
> If I read correctly:
> 
> 1) If no exclude options are in the config file, none should be used.

Yes.

> 2) On notmuch setup, "deleted" and "spam" should be added to .notmuch-config

I might argue between 'should' and 'could', but the sense is correct.


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


Re: [PATCH] emacs: Improved printing support.

2012-01-17 Thread David Edmondson
On Mon, 16 Jan 2012 16:27:06 -0500, Aaron Ecay  wrote:
> > +;;
> 
> The above is just a stray comment line, right?

I tend to use them as spacers, but, sure.

> > +(defun notmuch-show-with-message-as-text (fn)
> > +  "Apply function `fn' to a text representation of the current
> > +message."
> 
> I think the docstring should say what agrs get passed to ‘fn’.  Also,
> function arguments should be referred to with capital letters, and the
> first line should be a complete sentence.  I’d recommend “Apply FN to
> (...the rest unchanged)” for brevity in the first line.
> 
> (For anyone who is curious, these and other conventions are documented
> in section D.6 of the Elisp manual.)

Will fix.
> > + (concat "Tags: "
> > + (mapconcat '(lambda (tag) tag) tags ", ") "\n")
> 
> #'identity instead of the lambda

/me slaps head. What was I thinking?

> > +(all (buffer-substring (notmuch-show-message-top)
> > +   (notmuch-show-message-bottom)))
> > +
> > +(file (make-temp-file "notmuch")))
> > +(with-temp-file file
> > +  (insert all)
> > +  (indent-rigidly (point-min) (point-max) (- depth))
> > +  ;; Remove the original header.
> > +  (goto-char (point-min))
> > +  (re-search-forward "^$" (point-max) nil)
> > +  (delete-region (point-min) (point))
> > +  (insert header))
> > +(funcall fn file (notmuch-show-get-message-properties))
> > +(delete-file file)))
> 
> Why does this function write to a file?  It seems that, of the print
> methods, two (ps-print and lpr) don’t use the file at all.  One
> (ps-print/evince) creates yet another file, without depending on the
> first.  The other muttprint functions do use the file.  So:
> - This function would be more general if it didn’t handle file-writing
>   itself, but rather let each consumer of text-ified messages handle
>   that if needed.
> - It would be cleaner if print backends that don’t crucially depend on
>   the existence of a file didn’t create one at all.  If muttprint can
>   accept a message on stdin (it looks from the source like it can; it
>   gives me some error message about Iconv Perl modules when I try to run
>   it, so I can’t be sure), maybe writing to a file isn’t necessary at
>   all.

I'll rework it, thanks for the review!


pgpt4nqi8rZ5I.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-17 Thread David Edmondson
On Mon, 16 Jan 2012 23:48:30 -0500, Antoine Beaupré  
wrote:
> Jumping in here, I have modified the previously posted code here to
> provide me with a more complete solution.

This looks good. I'll switch over to using it.

> Code is attached. Obviously, those function names would change if they
> would be to integrate into notmuch. ;)

I wondered about pushing to have notmuch do this by default. In general
I like the idea, but it suffers if a recipient occasionally uses a mail
client that does not support decryption (phone, PDA, webmail, ...).


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


[PATCH 1/4] test: Add `test_emacs_expect_t'.

2012-01-17 Thread David Edmondson
Add a new test function to allow simpler testing of emacs
functionality.

`test_emacs_expect_t' takes two arguments:
  - the name of the test,
  - some lisp to evaluate.

The test passes if the lisp returns `t', otherwise it fails and the
output is reported to the tester.
---
 test/emacs-test-functions.sh |8 
 test/notmuch-test|1 +
 test/test-lib.sh |   24 
 3 files changed, 33 insertions(+), 0 deletions(-)
 create mode 100755 test/emacs-test-functions.sh

diff --git a/test/emacs-test-functions.sh b/test/emacs-test-functions.sh
new file mode 100755
index 000..969cc78
--- /dev/null
+++ b/test/emacs-test-functions.sh
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+
+test_description="emacs test function sanity"
+. test-lib.sh
+
+test_emacs_expect_t "emacs test function sanity" 't'
+
+test_done
diff --git a/test/notmuch-test b/test/notmuch-test
index 6a99ae3..d034f99 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -52,6 +52,7 @@ TESTS="
   python
   hooks
   argument-parsing
+  emacs-test-functions.sh
 "
 TESTS=${NOTMUCH_TESTS:=$TESTS}
 
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 7c9ce24..15da973 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -503,6 +503,30 @@ test_expect_equal_file ()
 fi
 }
 
+test_emacs_expect_t () {
+   test "$#" = 2 || error "bug in the test script: not 2 parameters to 
test_emacs_expect_t"
+   test_reset_state_
+   if ! test_skip "$1"
+   then
+   # We cannot call 'test_emacs' in a subshell, because
+   # the setting of EMACS_SERVER would not persist
+   # throughout a sequence of tests, so we use a
+   # temporary file.
+   tmp="$TMPDIR"; if [ -z "$tmp" ]; then tmp=/tmp; fi
+   output="$tmp/test_emacs_output.$$"
+   test_emacs "$2" >"${output}"
+   result=$(cat "${output}")
+   rm -f "${output}"
+
+   if [ "$result" == t ]
+   then
+   test_ok_ "$1"
+   else
+   test_failure_ "$1" "$(eval printf ${result})"
+   fi
+   fi
+}
+
 NOTMUCH_NEW ()
 {
 notmuch new | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* 
total file'
-- 
1.7.7.3

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


[PATCH 3/4] emacs: Avoid `mail-header-parse-address' in `notmuch-show-clean-address'.

2012-01-17 Thread David Edmondson
`mail-header-parse-address' expects un-decoded mailbox parts, which is
not what we have at this point. Replace it with simple string
deconstruction.
---
 emacs/notmuch-show.el |   48 +++-
 1 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 797f94b..8b2fbb3 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -227,21 +227,43 @@ indentation."
   "Try to clean a single email ADDRESS for display.  Return
 unchanged ADDRESS if parsing fails."
   (condition-case nil
-(let* ((parsed (mail-header-parse-address address))
-  (address (car parsed))
-  (name (cdr parsed)))
-  ;; Remove double quotes. They might be required during transport,
-  ;; but we don't need to see them.
-  (when name
-(setq name (replace-regexp-in-string "\"" "" name)))
+(let (p-name p-address)
+  ;; It would be convenient to use `mail-header-parse-address',
+  ;; but that expects un-decoded mailbox parts, whereas our
+  ;; mailbox parts are already decoded (and hence may contain
+  ;; UTF-8). Given that notmuch should handle most of the awkward
+  ;; cases, some simple string deconstruction should be sufficient
+  ;; here.
+  (cond
+   ;; "User " style.
+   ((string-match "\\(.*\\) <\\(.*\\)>" address)
+   (setq p-name (match-string 1 address)
+ p-address (match-string 2 address)))
+
+   ;; "" style.
+   ((string-match "<\\(.*\\)>" address)
+   (setq p-address (match-string 1 address)))
+
+   ;; Everything else.
+   (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)))
+
   ;; If the address is 'f...@bar.com ' then show just
   ;; 'f...@bar.com'.
-  (when (string= name address)
-(setq name nil))
-
-  (if (not name)
-address
-(concat name " <" address ">")))
+  (when (string= p-name p-address)
+(setq p-name nil))
+
+  ;; If no name results, return just the address.
+  (if (not p-name)
+ p-address
+   ;; Otherwise format the name and address together.
+   (concat p-name " <" p-address ">")))
 (error address)))
 
 (defun notmuch-show-insert-headerline (headers date tags depth)
-- 
1.7.7.3

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


emacs based tests, version 3

2012-01-17 Thread David Edmondson
Taking Dmitry's suggestions on board. The end result does indeed feel
better, thanks!

[PATCH 1/4] test: Add `test_emacs_expect_t'.
[PATCH 2/4] test: Add address cleaning tests.
[PATCH 3/4] emacs: Avoid `mail-header-parse-address' in
[PATCH 4/4] emacs: Another special case for
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


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

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

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 8b2fbb3..90c9c05 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -248,11 +248,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 ' then show just
   ;; 'f...@bar.com'.
diff --git a/test/address-cleaning.el b/test/address-cleaning.el
index 59e8d92..83d6263 100644
--- a/test/address-cleaning.el
+++ b/test/address-cleaning.el
@@ -20,10 +20,12 @@
   (let* ((input '("ДБ "
  "foo (at home) "
  "foo [at home] "
- "Foo Bar"))
+ "Foo Bar"
+ "Fred Dibna \\[extraordinaire\\] "))
 (expected '("ДБ "
 "foo (at home) "
 "foo [at home] "
-"Foo Bar"))
+"Foo Bar"
+"Fred Dibna [extraordinaire] "))
 (output (mapcar #'notmuch-show-clean-address input)))
 (notmuch-test-compare output expected)))
-- 
1.7.7.3

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


[PATCH 2/4] test: Add address cleaning tests.

2012-01-17 Thread David Edmondson
Including some more test framework in test-lib.el.
---
 test/address-cleaning.el |   29 +
 test/address-cleaning.sh |   11 +++
 test/notmuch-test|1 +
 test/test-lib.el |   29 +
 4 files changed, 70 insertions(+), 0 deletions(-)
 create mode 100644 test/address-cleaning.el
 create mode 100755 test/address-cleaning.sh

diff --git a/test/address-cleaning.el b/test/address-cleaning.el
new file mode 100644
index 000..59e8d92
--- /dev/null
+++ b/test/address-cleaning.el
@@ -0,0 +1,29 @@
+(defun notmuch-test-address-cleaning-1 ()
+  (notmuch-test-compare (notmuch-show-clean-address "d...@dme.org")
+   "d...@dme.org"))
+
+(defun notmuch-test-address-cleaning-2 ()
+  (let* ((input '("f...@bar.com"
+ ""
+ "Foo Bar "
+ "f...@bar.com "
+ "\"Foo Bar\" "))
+(expected '("f...@bar.com"
+"f...@bar.com"
+"Foo Bar "
+"f...@bar.com"
+"Foo Bar "))
+(output (mapcar #'notmuch-show-clean-address input)))
+(notmuch-test-compare output expected)))
+
+(defun notmuch-test-address-cleaning-3 ()
+  (let* ((input '("ДБ "
+ "foo (at home) "
+ "foo [at home] "
+ "Foo Bar"))
+(expected '("ДБ "
+"foo (at home) "
+"foo [at home] "
+"Foo Bar"))
+(output (mapcar #'notmuch-show-clean-address input)))
+(notmuch-test-compare output expected)))
diff --git a/test/address-cleaning.sh b/test/address-cleaning.sh
new file mode 100755
index 000..7ec011a
--- /dev/null
+++ b/test/address-cleaning.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+
+test_description="emacs address cleaning"
+. test-lib.sh
+
+for i in 1 2 3; do
+test_emacs_expect_t "notmuch-test-address-clean-$i" \
+'(load "address-cleaning.el") (notmuch-test-address-cleaning-'$i')'
+done
+
+test_done
diff --git a/test/notmuch-test b/test/notmuch-test
index d034f99..7768c32 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -53,6 +53,7 @@ TESTS="
   hooks
   argument-parsing
   emacs-test-functions.sh
+  address-cleaning.sh
 "
 TESTS=${NOTMUCH_TESTS:=$TESTS}
 
diff --git a/test/test-lib.el b/test/test-lib.el
index 3b817c3..cf8a46d 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -20,6 +20,8 @@
 ;;
 ;; Authors: Dmitry Kurochkin 
 
+(require 'cl)  ;; This code is generally used uncompiled.
+
 ;; `read-file-name' by default uses `completing-read' function to read
 ;; user input.  It does not respect `standard-input' variable which we
 ;; use in tests to provide user input.  So replace it with a plain
@@ -76,3 +78,30 @@ nothing."
 
 (add-hook-counter 'notmuch-hello-mode-hook)
 (add-hook-counter 'notmuch-hello-refresh-hook)
+
+;; Functions to help when writing tests:
+
+(defun notmuch-test-reporter (output expected)
+  "Report that the `output' does not match the `expected' result."
+  (concat "Expect:\t" (prin1-to-string expected) "\n"
+ "Output:\t" (prin1-to-string output) "\n"))
+
+(defun notmuch-test-unsimilar (output expected)
+  "`output' and `expected' are dissimilar. Show a summary of
+the differences, ignoring similarities."
+  (cond ((and (listp output)
+ (listp expected))
+(apply #'concat (loop for o in output
+  for e in expected
+  if (not (equal o e))
+  collect (notmuch-test-reporter o e
+
+   (t
+;; Catch all case.
+(notmuch-test-reporter output expected
+
+(defun notmuch-test-compare (output expected)
+  "Compare `output' with `expected'. Report any discrepencies."
+  (if (equal output expected)
+  t
+(notmuch-test-unsimilar output expected)))
-- 
1.7.7.3

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


Re: [PATCH 2/4] test: Add address cleaning tests.

2012-01-17 Thread David Edmondson
On Tue, 17 Jan 2012 17:11:58 +0400, Dmitry Kurochkin 
 wrote:
> Since test/ directory is used for all kind of tests not just Emacs
> UI-specific, so I think address-cleaning.* files should be
> emacs-address-cleaning.

Okay.


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


Re: [PATCH 1/4] test: Add `test_emacs_expect_t'.

2012-01-17 Thread David Edmondson
(And one for the list...)

On Tue, 17 Jan 2012 17:09:35 +0400, Dmitry Kurochkin 
 wrote:
> -1
> 
> This is not what I suggested.  I do not like the approach when a single
> function is used to both declare a subtest and test for result (as
> opposed to test_begin_subtest).  The fact that it is possible to write
> tests in two different ways makes it hard to maintain and improve the
> test framework (one example would be known broken test support).  I
> consider the proper way to write tests to be using the
> test_begin_subtest function.  Other functions are not currently
> deprecated, but I am against adding new code that make the situation
> worse.

Sigh. Okay.

> Also, please consider documenting new functions in README.

Missed that, sorry.


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


[PATCH 1/3] test: Don't return the result of checking for running emacs to the tester.

2012-01-17 Thread David Edmondson
---
 test/test-lib.sh |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index d1fbc05..7c9ce24 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -926,7 +926,7 @@ test_emacs () {
--eval '(orphan-watchdog $$)'" || return
EMACS_SERVER="$server_name"
# wait until the emacs server is up
-   until test_emacs '()' 2>/dev/null; do
+   until test_emacs '()' >/dev/null 2>/dev/null; do
sleep 1
done
fi
-- 
1.7.7.3

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


[PATCH 3/3] test: Add address cleaning tests.

2012-01-17 Thread David Edmondson
Including some more test framework in test-lib.el.
---

notmuch-test-address-cleaning-3 currently fails, in order that you can
see the output format in that case.

 test/emacs-address-cleaning.el |   29 +
 test/emacs-address-cleaning.sh |   12 
 test/notmuch-test  |1 +
 test/test-lib.el   |   29 +
 4 files changed, 71 insertions(+), 0 deletions(-)
 create mode 100644 test/emacs-address-cleaning.el
 create mode 100755 test/emacs-address-cleaning.sh

diff --git a/test/emacs-address-cleaning.el b/test/emacs-address-cleaning.el
new file mode 100644
index 000..59e8d92
--- /dev/null
+++ b/test/emacs-address-cleaning.el
@@ -0,0 +1,29 @@
+(defun notmuch-test-address-cleaning-1 ()
+  (notmuch-test-compare (notmuch-show-clean-address "d...@dme.org")
+   "d...@dme.org"))
+
+(defun notmuch-test-address-cleaning-2 ()
+  (let* ((input '("f...@bar.com"
+ ""
+ "Foo Bar "
+ "f...@bar.com "
+ "\"Foo Bar\" "))
+(expected '("f...@bar.com"
+"f...@bar.com"
+"Foo Bar "
+"f...@bar.com"
+"Foo Bar "))
+(output (mapcar #'notmuch-show-clean-address input)))
+(notmuch-test-compare output expected)))
+
+(defun notmuch-test-address-cleaning-3 ()
+  (let* ((input '("ДБ "
+ "foo (at home) "
+ "foo [at home] "
+ "Foo Bar"))
+(expected '("ДБ "
+"foo (at home) "
+"foo [at home] "
+"Foo Bar"))
+(output (mapcar #'notmuch-show-clean-address input)))
+(notmuch-test-compare output expected)))
diff --git a/test/emacs-address-cleaning.sh b/test/emacs-address-cleaning.sh
new file mode 100755
index 000..1a6eff5
--- /dev/null
+++ b/test/emacs-address-cleaning.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+
+test_description="emacs address cleaning"
+. test-lib.sh
+
+for i in 1 2 3; do
+test_begin_subtest "notmuch-test-address-clean-$i"
+test_emacs_expect_t \
+   '(load "emacs-address-cleaning.el") 
(notmuch-test-address-cleaning-'$i')'
+done
+
+test_done
diff --git a/test/notmuch-test b/test/notmuch-test
index d034f99..3f1740c 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -53,6 +53,7 @@ TESTS="
   hooks
   argument-parsing
   emacs-test-functions.sh
+  emacs-address-cleaning.sh
 "
 TESTS=${NOTMUCH_TESTS:=$TESTS}
 
diff --git a/test/test-lib.el b/test/test-lib.el
index 3b817c3..cf8a46d 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -20,6 +20,8 @@
 ;;
 ;; Authors: Dmitry Kurochkin 
 
+(require 'cl)  ;; This code is generally used uncompiled.
+
 ;; `read-file-name' by default uses `completing-read' function to read
 ;; user input.  It does not respect `standard-input' variable which we
 ;; use in tests to provide user input.  So replace it with a plain
@@ -76,3 +78,30 @@ nothing."
 
 (add-hook-counter 'notmuch-hello-mode-hook)
 (add-hook-counter 'notmuch-hello-refresh-hook)
+
+;; Functions to help when writing tests:
+
+(defun notmuch-test-reporter (output expected)
+  "Report that the `output' does not match the `expected' result."
+  (concat "Expect:\t" (prin1-to-string expected) "\n"
+ "Output:\t" (prin1-to-string output) "\n"))
+
+(defun notmuch-test-unsimilar (output expected)
+  "`output' and `expected' are dissimilar. Show a summary of
+the differences, ignoring similarities."
+  (cond ((and (listp output)
+ (listp expected))
+(apply #'concat (loop for o in output
+  for e in expected
+  if (not (equal o e))
+  collect (notmuch-test-reporter o e
+
+   (t
+;; Catch all case.
+(notmuch-test-reporter output expected
+
+(defun notmuch-test-compare (output expected)
+  "Compare `output' with `expected'. Report any discrepencies."
+  (if (equal output expected)
+  t
+(notmuch-test-unsimilar output expected)))
-- 
1.7.7.3

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


[PATCH 2/3] test: Add `test_emacs_expect_t'.

2012-01-17 Thread David Edmondson
Add a new test function to allow simpler testing of emacs
functionality.

`test_emacs_expect_t' takes one argument - a list expression to
evaluate. The test passes if the expression returns `t', otherwise it
fails and the output is reported to the tester.
---

Re-worked as Dmitry suggested.

 test/README  |8 
 test/emacs-test-functions.sh |9 +
 test/notmuch-test|1 +
 test/test-lib.sh |   33 +
 4 files changed, 51 insertions(+), 0 deletions(-)
 create mode 100755 test/emacs-test-functions.sh

diff --git a/test/README b/test/README
index bde6db0..9dbe2ee 100644
--- a/test/README
+++ b/test/README
@@ -189,6 +189,14 @@ library for your script to use.
tests that may run in the same Emacs instance.  Use `let' instead
so the scope of the changed variables is limited to a single test.
 
+ test_emacs_expect_t 
+
+  This function executes the provided emacs lisp script within
+  emacs in a manner similar to 'test_emacs'. The expressions should
+  return the value `t' to indicate that the test has passed. If the
+  test does not return `t' then it is considered failed and all data
+  returned by the test is reported to the tester.
+
  test_done
 
Your test script must have test_done at the end.  Its purpose
diff --git a/test/emacs-test-functions.sh b/test/emacs-test-functions.sh
new file mode 100755
index 000..0e1f9fc
--- /dev/null
+++ b/test/emacs-test-functions.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+
+test_description="emacs test function sanity"
+. test-lib.sh
+
+test_begin_subtest "emacs test function sanity"
+test_emacs_expect_t 't'
+
+test_done
diff --git a/test/notmuch-test b/test/notmuch-test
index 6a99ae3..d034f99 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -52,6 +52,7 @@ TESTS="
   python
   hooks
   argument-parsing
+  emacs-test-functions.sh
 "
 TESTS=${NOTMUCH_TESTS:=$TESTS}
 
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 7c9ce24..4b05760 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -503,6 +503,39 @@ test_expect_equal_file ()
 fi
 }
 
+test_emacs_expect_t () {
+   test "$#" = 1 || error "bug in the test script: not 1 parameter to 
test_emacs_expect_t"
+
+   # Run the test.
+   if ! test_skip "$test_subtest_name"
+   then
+   # We cannot call 'test_emacs' in a subshell, because
+   # the setting of EMACS_SERVER would not persist
+   # throughout a sequence of tests, so we use a
+   # temporary file.
+   tmp="$TMPDIR"; if [ -z "$tmp" ]; then tmp=/tmp; fi
+   output="$tmp/test_emacs_output.$$"
+   test_emacs "$1" > "${output}"
+   result=$(cat "${output}")
+   rm -f "${output}"
+   fi
+
+   # Restore state after the test.
+   exec 1>&6 2>&7  # Restore stdout and stderr
+   inside_subtest=
+
+   # Report success/failure.
+   if ! test_skip "$test_subtest_name"
+   then
+   if [ "$result" == t ]
+   then
+   test_ok_ "$test_subtest_name"
+   else
+   test_failure_ "$test_subtest_name" "$(eval printf 
${result})"
+   fi
+   fi
+}
+
 NOTMUCH_NEW ()
 {
 notmuch new | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* 
total file'
-- 
1.7.7.3

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


Re: [PATCH 1/2] emacs: add invisible dot instead of space at the end of notmuch-hello search box

2012-01-17 Thread David Edmondson
On Tue, 17 Jan 2012 17:24:45 +0400, Dmitry Kurochkin 
 wrote:
> This makes `show-trailing-whitespace' happy, i.e. it does not mark the
> whole search box line as trailing spaces.

Why should `whitespace-mode' be active in `notmuch-hello' buffers?


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


Re: [PATCH 1/2] emacs: add invisible dot instead of space at the end of notmuch-hello search box

2012-01-17 Thread David Edmondson
On Tue, 17 Jan 2012 18:13:26 +0400, Dmitry Kurochkin 
 wrote:
> On Tue, 17 Jan 2012 14:08:58 +0000, David Edmondson  wrote:
> > On Tue, 17 Jan 2012 17:24:45 +0400, Dmitry Kurochkin 
> >  wrote:
> > > This makes `show-trailing-whitespace' happy, i.e. it does not mark the
> > > whole search box line as trailing spaces.
> > 
> > Why should `whitespace-mode' be active in `notmuch-hello' buffers?
> 
> I do not say that it should be active in notmuch-hello.
> 
> For me `show-trailing-whitespace' is activated everywhere with some
> exceptions.  Notmuch-hello is one of these exceptions.  This change make
> it one step closer to removing the exception.

Okay. Please add a comment to explain why it is a . rather than a space,
then +1.


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


Re: [PATCH 2/3] test: Add `test_emacs_expect_t'.

2012-01-17 Thread David Edmondson
On Tue, 17 Jan 2012 18:26:41 +0400, Dmitry Kurochkin 
 wrote:
> Sorry, I still do not understand why we can not implement
> test_emacs_expect_t() like:
> 
>   result=${test_emacs $@}
>   test_expect_equal $result t
> 
> Can you please explain?

In the failure case test_expect_equal does:

  test_failure_ "$test_subtest_name" "$(diff -u $testname.expected 
$testname.output)"

that diff output is not useful here, because the test harness doesn't
have any expected output other than `t' with which to diff the actual
output.

The emacs-address-cleaning test shows how we will provide expected
vs. actual output directly from within emacs, making it easier for the
developer to figure out what went wrong.


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


Re: [PATCH 1/3] test: Don't return the result of checking for running emacs to the tester.

2012-01-17 Thread David Edmondson
(And for the list...)

On Tue, 17 Jan 2012 18:20:04 +0400, Dmitry Kurochkin 
 wrote:
> Can you please elaborate why this is needed?

This code:

# wait until the emacs server is up
until test_emacs '()' 2>/dev/null; do
sleep 1
done

outputs 'nil', so the first caller to test_emacs has 'nil\n' prepended
to their expected output.


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


Re: [PATCH 2/3] test: Add `test_emacs_expect_t'.

2012-01-17 Thread David Edmondson
On Tue, 17 Jan 2012 18:49:36 +0400, Dmitry Kurochkin 
 wrote:
> > +   # We cannot call 'test_emacs' in a subshell, because
> > +   # the setting of EMACS_SERVER would not persist
> > +   # throughout a sequence of tests, so we use a
> > +   # temporary file.
> > +   tmp="$TMPDIR"; if [ -z "$tmp" ]; then tmp=/tmp; fi
> > +   output="$tmp/test_emacs_output.$$"
> > +   test_emacs "$1" > "${output}"
> > +   result=$(cat "${output}")
> > +   rm -f "${output}"
> 
> I wonder if there is any bash trick which can help here?

I'm not aware of one, but I'm not a bash expert.

> Another option is to start emacs server before using test_emacs in
> subshell.  See emacs-subject-to-filename for an example.  I think this
> is a better option than using a temporary file.

I think that's a very poor option. Forcing knowledge the breakage into
all of the users may make applying any future fix more difficult.


pgpZsJ84ifN6A.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-17 Thread David Edmondson
>(if (and force (re-search-forward "<#secure [> >]*>\n" nil t))
>  (replace-match "" nil nil))
>;; If we can encrypt, do so, else just sign.
>(if (or force (not (re-search-forward "<#secure [> >]*>\n" nil t)))

Is this second test for `force' necessary? If `force' is set then you'll
remove the <#secure..> just above, so it will not be found here.

>  (if (anarcat/message-guess-encryption)
>  (insert "<#secure method=pgpmime mode=signencrypt>\n")
>(insert "<#secure method=pgpmime mode=sign>\n"))
>)


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


Re: [PATCH v2] emacs: add invisible dot instead of space at the end of notmuch-hello search box

2012-01-17 Thread David Edmondson
+1.


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


Re: [PATCH v2 4/5] emacs: Use the new JSON reply format.

2012-01-17 Thread David Edmondson
On Tue, 17 Jan 2012 15:53:37 -0700, Adam Wolfe Gordon  
wrote:
> +(defun notmuch-parts-filter-by-type (parts type)
> +  "Return a list of message parts with the given type"
> +  (let (result)
> +(dolist (part (append parts nil) result)
> +  (if (string= (cdr (assq 'content-type part)) type)
> +   (setq result (append result (list (cdr (assq 'content part)))
> +result))

I still think that `loop' is easier to read :-) But no objection to this
code.

> +(defun notmuch-mua-insert-part-quoted (part)
> +  (let ((start (point))
> + limit)
> +(insert part)
> +(setq limit (point))
> +(goto-char start)
> +(while (re-search-forward "\\(^\\)[^$]" limit 0)
> +  (replace-match "> " nil nil nil 1)
> +  ;; We have added two characters to the quotable region
> +  (setq limit (+ limit 2)))
> +(set-buffer-modified-p nil)))

You could use a marker for the limit, as it would then move along
automagically (sorry for not noticing this last time).


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


[PATCH] emacs: Improved printing support.

2012-01-18 Thread David Edmondson
Add various functions to print notmuch messages and tie them together
with a simple frontend.

Add a binding ('#') in `notmuch-show-mode' to print the current
message.
---

Updates based on Aaron's review - the comments were very useful in
improving things - thanks!

Add a keybinding to `notmuch-show-mode'.

 emacs/Makefile.local   |3 +-
 emacs/notmuch-print.el |   85 
 emacs/notmuch-show.el  |   53 ++
 3 files changed, 140 insertions(+), 1 deletions(-)
 create mode 100644 emacs/notmuch-print.el

diff --git a/emacs/Makefile.local b/emacs/Makefile.local
index 0c58b82..4fee0e8 100644
--- a/emacs/Makefile.local
+++ b/emacs/Makefile.local
@@ -13,7 +13,8 @@ emacs_sources := \
$(dir)/notmuch-maildir-fcc.el \
$(dir)/notmuch-message.el \
$(dir)/notmuch-crypto.el \
-   $(dir)/coolj.el
+   $(dir)/coolj.el \
+   $(dir)/notmuch-print.el
 
 emacs_images := \
$(srcdir)/$(dir)/notmuch-logo.png
diff --git a/emacs/notmuch-print.el b/emacs/notmuch-print.el
new file mode 100644
index 000..77f10bb
--- /dev/null
+++ b/emacs/notmuch-print.el
@@ -0,0 +1,85 @@
+;; notmuch-print.el --- printing messages from notmuch.
+;;
+;; Copyright © David Edmondson
+;;
+;; This file is part of Notmuch.
+;;
+;; Notmuch is free software: you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; Notmuch is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with Notmuch.  If not, see <http://www.gnu.org/licenses/>.
+;;
+;; Authors: David Edmondson 
+
+(defcustom notmuch-print-mechanism 'notmuch-print-lpr
+  "How should printing be done?"
+  :group 'notmuch
+  :type '(choice
+ (function :tag "Use lpr" notmuch-print-lpr)
+ (function :tag "Use ps-print" notmuch-print-ps-print)
+ (function :tag "Use ps-print then evince" 
notmuch-print-ps-print/evince)
+ (function :tag "Use muttprint" notmuch-print-muttprint)
+ (function :tag "Use muttprint then evince" 
notmuch-print-muttprint/evince)
+ (function :tag "Using a custom function")))
+
+;; Utility functions:
+
+(defun notmuch-print-run-evince (file)
+  "View FILE using 'evince'."
+  (start-process "evince" nil "evince" file))
+
+(defun notmuch-print-run-muttprint (&optional output)
+  "Pass the contents of the current buffer to 'muttprint'.
+
+Optional OUTPUT allows passing a list of flags to muttprint."
+  (apply #'call-process-region (point-min) (point-max)
+;; Reads from stdin.
+"muttprint"
+nil nil nil
+;; Show the tags.
+"--printed-headers" "Date_To_From_CC_Newsgroups_*Subject*_/Tags/"
+output))
+
+;; User-visible functions:
+
+(defun notmuch-print-lpr (msg)
+  "Print a message buffer using lpr."
+  (lpr-buffer))
+
+(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)))
+(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)))
+(rename-buffer subject t)
+(ps-print-buffer ps-file)
+(notmuch-print-run-evince ps-file)))
+
+(defun notmuch-print-muttprint (msg)
+  "Print a message using muttprint."
+  (notmuch-print-run-muttprint))
+ 
+(defun notmuch-print-muttprint/evince (msg)
+  "Preview a message buffer using muttprint and evince."
+  (let ((ps-file (make-temp-file "notmuch")))
+(notmuch-print-run-muttprint (list "--printer" (concat "TO_FILE:" 
ps-file)))
+(notmuch-print-run-evince ps-file)))
+
+(defun notmuch-print-message (msg)
+  "Print a message using the user-selected mechanism."
+  (funcall notmuch-print-mechanism msg))
+
+(provide 'notmuch-print)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 797f94b..db25565 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -34,6 +34,7 @@
 (require 'notmuch-wash)
 (require 'notmuch-mua)
 (require 'notmuch-crypto)
+(require 'notmuch-print)
 
 (declare-function notmuch-call-notmuch-process "

Re: [PATCH 1/6] emacs: break up notmuch-show-archive-thread-internal into two generally useful functions

2012-01-18 Thread David Edmondson
Very happy with the overall ideas.

On Tue, 17 Jan 2012 10:05:26 -0800, Jameson Graef Rollins 
 wrote:
> -(defun notmuch-show-archive-thread-internal (show-next)
> -  ;; Remove the tag from the current set of messages.
> +(defun notmuch-show-tag-thread-internal (tag &optional remove)
> +  ;; Add tag to the current set of messages.  If the remove switch is
> +  ;; given, tags will be removed instead of added.
>(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 'notmuch-show-add-tag))
> +(if remove
> + (setq tag-function 'notmuch-show-remove-tag))

This seems odd. How about:

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

Otherwise good.


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


Re: [PATCH 2/6] emacs: break out thread navigation from notmuch-show-archive-thread

2012-01-18 Thread David Edmondson
+1.


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


Re: [PATCH 3/6] emacs: add message archiving functions

2012-01-18 Thread David Edmondson
+1.


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


Re: [PATCH 4/6] emacs: add option to notmuch-show-next-open-message to pop out to parent buffer if at end

2012-01-18 Thread David Edmondson
On Tue, 17 Jan 2012 10:05:29 -0800, Jameson Graef Rollins 
 wrote:
> -(defun notmuch-show-next-open-message ()
> +(defun notmuch-show-next-open-message (&optional pop-at-end)
>"Show the next message."
>(interactive)
> -  (let (r)
> +  (let ((r)
> + (parent-buffer notmuch-show-parent-buffer))

No need for brackets around `r'. Please put initialised local variables
before uninitialised.

>  (while (and (setq r (notmuch-show-goto-message-next))
>   (not (notmuch-show-message-visible-p
>  (if r
>   (progn
> (notmuch-show-mark-read)
> (notmuch-show-message-adjust))
> -  (goto-char (point-max)
> +  (if (and parent-buffer pop-at-end)
> +   (progn
> + (kill-this-buffer)
> + (switch-to-buffer parent-buffer)
> + (forward-line 1))
> + (goto-char (point-max))

Can you explain in words how this is expected to behave please?


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


Re: [PATCH 6/6] emacs: modify the default show-mode key bindings for archiving

2012-01-18 Thread David Edmondson
+1.


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


Re: [PATCH 1/6] emacs: break up notmuch-show-archive-thread-internal into two generally useful functions

2012-01-18 Thread David Edmondson
On Tue, 17 Jan 2012 12:17:54 -0800, Jameson Graef Rollins 
 wrote:
> On Tue, 17 Jan 2012 15:10:40 -0500, Aaron Ecay  wrote:
> > This should be a docstring instead of a comment.  (This applies equally
> > to the old version)
> 
> We're not currently in the habit of adding doc strings for
> non-interactive programs.  Do we need to go down that route?

They are nice to have, especially if we already have the comment.


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


Re: on deleting messages

2012-01-18 Thread David Edmondson
Add the bindings. Provide documentation that makes it clear that they
just add tags and never delete anything.


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


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

2012-01-18 Thread David Edmondson
Looks fine.


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


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

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

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

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

Should user-typed queries be trimmed?


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


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

2012-01-18 Thread David Edmondson
+1.


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


Re: [PATCH v2 3/3] search: Support automatic tag exclusions

2012-01-18 Thread David Edmondson
On Tue, 17 Jan 2012 15:32:11 -0500, Austin Clements  wrote:
> Quoth David Edmondson on Jan 17 at  9:08 am:
> > On Mon, 16 Jan 2012 15:16:24 -0700, Jeremy Nickurak  
> > wrote:
> > > On Mon, Jan 16, 2012 at 12:28, Austin Clements  wrote:
> > > >> Having "deleted" and "spam" as default settings in the configuration
> > > >> file might be more reasonable.
> > > 
> > > If I read correctly:
> > > 
> > > 1) If no exclude options are in the config file, none should be used.
> > 
> > Yes.
> > 
> > > 2) On notmuch setup, "deleted" and "spam" should be added to 
> > > .notmuch-config
> > 
> > I might argue between 'should' and 'could', but the sense is correct.
> 
> Oh, I think I see.  I don't know if I can do precisely that, since the
> config code doesn't know if it's being called from setup, but is
> something like this essentially what you're suggesting?
> 
> if (notmuch_config_get_auto_exclude_tags (config, &tmp) == NULL) {
> if (is_new) {
> const char *tags[] = { "deleted", "spam" };
> notmuch_config_set_auto_exclude_tags (config, tags, 2);
> } else {
> notmuch_config_set_auto_exclude_tags (config, NULL, 0);
> }
> }
> 
> (where is_new is TRUE if this is a brand-new config file)

I'm not sure, as I haven't looked at the configuration code at
all, sorry.

Something must create the initial configuration file if none exists. I'd
be okay with that code adding 'deleted' and 'spam' to the excluded list.

This would mean that an existing user would see no change without taking
some action (adding the tags to the configuration file) and a new user
would see the new behaviour (automatic exclusion).

I'm not completely sure that automatically adding the exclusion of the
specified tags via the configuration file for new users is a great
idea. It seems as though it will lead to confusion for someone at some
point.


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


Re: [PATCH 4/6] emacs: add option to notmuch-show-next-open-message to pop out to parent buffer if at end

2012-01-18 Thread David Edmondson
On Wed, 18 Jan 2012 00:47:11 -0800, Jameson Graef Rollins 
 wrote:
> > >  (while (and (setq r (notmuch-show-goto-message-next))
> > >   (not (notmuch-show-message-visible-p
> > >  (if r
> > >   (progn
> > > (notmuch-show-mark-read)
> > > (notmuch-show-message-adjust))
> > > -  (goto-char (point-max)
> > > +  (if (and parent-buffer pop-at-end)
> > > +   (progn
> > > + (kill-this-buffer)
> > > + (switch-to-buffer parent-buffer)
> > > + (forward-line 1))
> > > + (goto-char (point-max))
> > 
> > Can you explain in words how this is expected to behave please?
> 
> Do you see a problem?

Not a problem, just trying to understand the behaviour (I have to revive
my advance/rewind patches at some point).

> If there is not another message, but there is a parent buffer and the
> pop-at-end variable is set, kill this buffer, go the parent, and move to
> the next thread.  Otherwise, go to the max point in the buffer.

I'm used to the cursor going to the bottom of the thread to let me know
that I reached the end, then I hit 'space' and move on to the next
thread. Will that behaviour be retained with this patch? (Well,
including your other patch which seemed to set `pop-at-end'.)

It's one of those things that I have to try out to understand properly I
expect.


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


Re: [PATCH v2 3/3] search: Support automatic tag exclusions

2012-01-18 Thread David Edmondson
On Wed, 18 Jan 2012 00:52:09 -0800, Jameson Graef Rollins 
 wrote:
> On Wed, 18 Jan 2012 08:38:23 +0000, David Edmondson  wrote:
> > Something must create the initial configuration file if none exists. I'd
> > be okay with that code adding 'deleted' and 'spam' to the excluded list.
> >
> > This would mean that an existing user would see no change without taking
> > some action (adding the tags to the configuration file) and a new user
> > would see the new behaviour (automatic exclusion).
> 
> What you describe is indeed how it currently works.  For new users or
> old users who rerun setup, the config file will automatically include
> the exclusions.  Otherwise, users will see no change.

Good, thanks.

> > I'm not completely sure that automatically adding the exclusion of the
> > specified tags via the configuration file for new users is a great
> > idea. It seems as though it will lead to confusion for someone at some
> > point.
> 
> Without any keys pre-bound to add "deleted" or "spam" tags, it probably
> won't make much difference for new users.  And as long as it's
> documented, users will be warned of the behavior.  Reading the config
> file would also make it clear how the variable changes behavior.

I agree that as long as no keys are pre-bound it will make little
difference. That just transfers the discussion to the thread about
adding the bindings, which seems silly.

Anyway, I'm not too worried - I just won't answer any of the questions
about it on the list :-)


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


Re: [PATCH] v2 [RFC] emacs: merge overhauled `notmuch-cycle-notmuch-buffers' into `notmuch'

2012-01-18 Thread David Edmondson
On Wed, 18 Jan 2012 11:03:09 +0100, Pieter Praet  wrote:
> > [...] What's wrong with '(loop ... collect ...)'?
> 
> Nothing at all.  I was fixing my own patch [1] without resorting to
> requiring the `cl' package at runtime :)  Would be nice if we could
> get rid of the compile-time dependency as well, though.

Can you explain why it's necessary at runtime?


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


Re: [PATCH] v2 [RFC] emacs: merge overhauled `notmuch-cycle-notmuch-buffers' into `notmuch'

2012-01-18 Thread David Edmondson
On Wed, 18 Jan 2012 13:15:55 +0100, Pieter Praet  wrote:
> On Wed, 18 Jan 2012 10:13:35 +0000, David Edmondson  wrote:
> > On Wed, 18 Jan 2012 11:03:09 +0100, Pieter Praet  wrote:
> > > > [...] What's wrong with '(loop ... collect ...)'?
> > > 
> > > Nothing at all.  I was fixing my own patch [1] without resorting to
> > > requiring the `cl' package at runtime :)  Would be nice if we could
> > > get rid of the compile-time dependency as well, though.
> > 
> > Can you explain why it's necessary at runtime?
> 
> Because otherwise `remove-if-not' and `member-if-not' would
> be void, as you alluded to previously [1,2].

Ah, not macros. Sorry for being slow.


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


compressing header lines - quick prototype

2012-01-18 Thread David Edmondson
Here's something that I was playing with this morning. It's not
finished, but has some nasty corners, so I'd like to solicit opinion on
whether it's worth finishing.

When faced with a long thread where most of the messages are closed, it
might be convenient to hide large stretches of closed headers. This code
attempts to do that.

You can run `dme/notmuch-show-compress-headers' manually in a
`notmuch-show-mode' buffer or (for the terminally brave) attach the same
function to `notmuch-show-hook'.

There are still problems with the nested invisibility specs and the
current `notmuch-show-advance-and-archive' and friends get confused, but
it should be enough for you to get the idea.

After using it for a bit I came to the conclusion that it's not worth
pursuing, but figured that I'd post it to get feedback from others.



bins6DRyb7D5f.bin
Description: application/emacs-lisp


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


Re: RFC: tag macros

2012-01-18 Thread David Edmondson
On Wed, 18 Jan 2012 10:45:06 -0400, David Bremner  wrote:
> Here is a very early stage proposal to provide tagging macros for
> notmuch show mode. 

Nice idea. Please make it work on regions as well.


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


Re: [PATCH v2 4/5] emacs: Use the new JSON reply format.

2012-01-18 Thread David Edmondson
On Wed, 18 Jan 2012 09:32:34 -0700, Adam Wolfe Gordon  
wrote:
> Using the new JSON reply format allows emacs to quote HTML
> parts nicely by using mm-display-part to turn them into displayable
> text, then quoting them. This is very useful for users who
> regularly receive HTML-only email.
> 
> The behavior for messages that contain plain text parts should be
> unchanged.

I think that this looks pretty good now. We should get some experience
of using it.


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


[PATCH] emacs: Make the part content available to the mm-inline* checks.

2012-01-18 Thread David Edmondson
The `mm-inlinable-p' and `mm-inlined-p' functions work better if they
have access to the data of the relevant part, so load that content
before calling either function.

This fixes the display of attached image/jpeg parts, for example.
---

I dropped this on the floor after discussing it in #notmuch, sorry!

 emacs/notmuch-show.el |   19 +++
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 2df8d3b..71309c3 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -330,14 +330,17 @@ current buffer, if possible."
 (with-temp-buffer
   (let* ((charset (plist-get part :content-charset))
 (handle (mm-make-handle (current-buffer) `(,content-type (charset 
. ,charset)
-   (if (and (mm-inlinable-p handle)
-(mm-inlined-p handle))
-   (let ((content (notmuch-show-get-bodypart-content msg part nth)))
- (insert content)
- (set-buffer display-buffer)
- (mm-display-part handle)
- t)
- nil)
+   (insert (notmuch-show-get-bodypart-content msg part nth))
+   (when (and (mm-inlinable-p handle)
+  (mm-inlined-p handle))
+ (set-buffer display-buffer)
+
+ ;; Nonsense required to have the new gnus `shr' HTML
+ ;; display code work.
+ (let ((gnus-inhibit-images nil))
+   (makunbound 'gnus-summary-buffer) ; Blech.
+   (mm-display-part handle))
+ t)
 
 (defvar notmuch-show-multipart/alternative-discouraged
   '(
-- 
1.7.8.3

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


Re: [PATCH] emacs: Make the part content available to the mm-inline* checks.

2012-01-18 Thread David Edmondson
On Wed, 18 Jan 2012 17:33:13 +, David Edmondson  wrote:
> +   ;; Nonsense required to have the new gnus `shr' HTML
> +   ;; display code work.
> +   (let ((gnus-inhibit-images nil))
> + (makunbound 'gnus-summary-buffer) ; Blech.
> + (mm-display-part handle))
> +   t)

Bleugh. Sorry, don't apply this patch. I'll produce a clean one.


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


[PATCH v2] emacs: Make the part content available to the mm-inline* checks.

2012-01-18 Thread David Edmondson
The `mm-inlinable-p' and `mm-inlined-p' functions work better if they
have access to the data of the relevant part, so load that content
before calling either function.

This fixes the display of attached image/jpeg parts, for example.
---

Removed the cruft that crept into the previous patch.

 emacs/notmuch-show.el |   14 ++
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 2df8d3b..f280df2 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -330,14 +330,12 @@ current buffer, if possible."
 (with-temp-buffer
   (let* ((charset (plist-get part :content-charset))
 (handle (mm-make-handle (current-buffer) `(,content-type (charset 
. ,charset)
-   (if (and (mm-inlinable-p handle)
-(mm-inlined-p handle))
-   (let ((content (notmuch-show-get-bodypart-content msg part nth)))
- (insert content)
- (set-buffer display-buffer)
- (mm-display-part handle)
- t)
- nil)
+   (insert (notmuch-show-get-bodypart-content msg part nth))
+   (when (and (mm-inlinable-p handle)
+  (mm-inlined-p handle))
+ (set-buffer display-buffer)
+ (mm-display-part handle)
+ t)
 
 (defvar notmuch-show-multipart/alternative-discouraged
   '(
-- 
1.7.8.3

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


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

2012-01-18 Thread David Edmondson
On Wed, 18 Jan 2012 21:57:27 +0400, Dmitry Kurochkin 
 wrote:
> > The test output updates included here should be with the previous patch,
> > shouldn't they?
> 
> Indeed.  Would send v2.

That's not necessary for me.

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

Okay.


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


Re: [PATCH v2] emacs: Make the part content available to the mm-inline* checks.

2012-01-18 Thread David Edmondson
On Wed, 18 Jan 2012 22:04:36 +0400, Dmitry Kurochkin 
 wrote:
> On Wed, 18 Jan 2012 17:39:31 +0000, David Edmondson  wrote:
> > The `mm-inlinable-p' and `mm-inlined-p' functions work better if they
> > have access to the data of the relevant part, so load that content
> > before calling either function.
> > 
> > This fixes the display of attached image/jpeg parts, for example.
> 
> Not so long ago I made an opposite change to avoid fetching useless
> parts (e.g. audio files).  Looks like we need a better check here.  Can
> we know from Content-Type if fetching a part body would be useful?

What if `notmuch-show-insert-part-*/*' consulted a list of content-type
regexps to attempt to inline?

That would allow a sane default (("image/*" "text/*") perhaps), but also
allow more to be added to that list (or some to be removed), either by
code that detected the (in)ability to render it or the user.


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


Re: [PATCH 2/2] Silence buildbot warnings about unused results

2012-01-18 Thread David Edmondson
On Wed, 18 Jan 2012 19:40:11 -0500, Austin Clements  wrote:
> +/* See handle_sigint in notmuch-new.c for the justification for
> + * ignoring write's result. */
> +IGNORE_RESULT (write (2, msg, sizeof(msg)-1));

Just include the comment in both places. Someone will work over the code
in notmuch-new.c and we'll lose it.

Then, +1.


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


  1   2   3   4   5   6   7   8   9   10   >