make fails with gmime-2.6.4

2012-01-16 Thread Jameson Graef Rollins
On Tue, 17 Jan 2012 07:48:27 -, Mark Foxwell  wrote:
> Not sure if you're aware of this? 

Yes, we are aware.  There are actually two fresh patches to the list to
address this, though:

id:"1326758199-18058-1-git-send-email-schnouki at schnouki.net"
id:"1326767208-25174-1-git-send-email-aperez at igalia.com"

The former will likely get (and in fact already has received) more
attention, since it attempts to provide compatibility for both 2.4 and
2.6, which we will likely need to support for a while.

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


[PATCH 2/3] emacs: whitespace-cleanup and indent-region for emacs/*.el files

2012-01-16 Thread Austin Clements
Cleanup is the type of pain that should only be suffered once, so I'd
be much happier with this if there was an accompanying git hook that
prevented more mis-formatted code from slipping in.

Quoth Tomi Ollila on Jan 16 at 11:04 am:
> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> index 00ed589..7b63348 100644
> --- a/emacs/notmuch-lib.el
> +++ b/emacs/notmuch-lib.el
> @@ -143,7 +143,7 @@ The result is a new function which does the same as FUN, 
> except that
>  the first N arguments are fixed at the values with which this function
>  was called."
> (lexical-let ((fun fun) (args1 args))
> - (lambda ( args2) (apply fun (append args1 args2))
> + (lambda ( args2) (apply fun (append args1 args2))

Ack.  What happened here?  This shows up in at least one other place,
too.  I'm betting you need to load cl in some form to get the
indentation rule for lexical-let.


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

2012-01-16 Thread Jani Nikula
On Mon, 16 Jan 2012 15:51:30 -0500, Aaron Ecay  wrote:
> On Mon, 16 Jan 2012 11:22:27 +, David Edmondson  wrote:
> > 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?
> 
> The tags look nice and yellow-green for me too on a trunk build of emacs
> (which is one flavor of emacs 24).  Adding and removing tags works as
> expected ? the tags dis/appear and are the right color.
> 
> I haven?t reloaded the notmuch *.el files since this change landed, but
> I agree with Pieter that the overlays were nice.

Missing them too. Emacs 23.3.1.

BR,
Jani.


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

2012-01-16 Thread Austin Clements
Quoth Tomi Ollila on Jan 16 at 11:04 am:
> In order for emacs (indent-region) to (re)indent emacs lisp
> properly there needs to be at least 2 comment characters (;;).
> ---
> 
> $ perl -ne 's/;;.*//; print $_ if /(^|[^;]);([^;]|$)/' *.el | less
> 
> shows that there is (only) need to change comments in the beginning
> of line...
> 
> $ perl -pi -e 's/^(\s*);([^;]|$)/$1;;$2/' *.el
> 
> did that change.

1/3 definitely LGTM.


[PATCH v2] Document external dependencies in the test suite

2012-01-16 Thread Jani Nikula
On Mon, 16 Jan 2012 22:09:55 +0100, Xavier Maillard  
wrote:
> Hi,
> 
> On Mon, 16 Jan 2012 13:52:47 -0500, Ethan Glasser-Camp  
> wrote:
> 
> [...]
> 
> > +Prerequisites
> > +-
> > +Some tests require external dependencies to run. Without them, they
> > +will be skipped, or (rarely) marked failed. Please install these, so
> > +that you know if you break anything.
> > +
> > +  - dtach(1)
> > +  - emacs(1)
> > +  - emacsclient(1)
> > +  - gdb(1)
> > +  - gpg(1)
> > +  - python(1)
> 
> Looks good but just a nit: what is the meaning of the '1' ?

It's the man page section. See 'man man'.

HTH,
Jani.


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

2012-01-16 Thread Jani Nikula
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.

What does "merge" mean here? Will it still be possible for me to hit one
key to unconditionally get to notmuch-hello, and another to cycle
through the buffers? I wouldn't want to lose that ability.

> ---
>  emacs/notmuch.el |   40 ++--
>  1 files changed, 14 insertions(+), 26 deletions(-)
> 
> 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)
> +(if next-buffer
> + (progn
> +   (switch-to-buffer next-buffer)
> +   (bury-buffer old-buffer))
> +  (notmuch-hello

notmuch-cycle-notmuch-buffers pretty much explains in the name what it
does, but additionally it has documentation, and explanatory
comments. Please don't drop those.

BR,
Jani



>  
>  (defun notmuch-interesting-buffer (b)
>"Is the current buffer of interest to a notmuch user?"
> @@ -1078,31 +1091,6 @@ current search results AND that are tagged with the 
> given tag."
>  message-mode
>  
>  ;;;###autoload
> -(defun notmuch-cycle-notmuch-buffers ()
> -  "Cycle through any existing notmuch buffers (search, show or hello).
> -
> -If the current buffer is the only notmuch buffer, bury it. If no
> -notmuch buffers exist, run `notmuch'."
> -  (interactive)
> -
> -  (let (start first)
> -;; If the current buffer is a notmuch buffer, remember it and then
> -;; bury it.
> -(when (notmuch-interesting-buffer (current-buffer))
> -  (setq start (current-buffer))
> -  (bury-buffer))
> -
> -;; Find the first notmuch buffer.
> -(setq first (loop for buffer in (buffer-list)
> -  if (notmuch-interesting-buffer buffer)
> -  return buffer))
> -
> -(if first
> - ;; If the first one we found is any other than the starting
> - ;; buffer, switch to it.
> - (unless (eq first start)
> -   (switch-to-buffer first))
> -  (notmuch
>  
>  (setq mail-user-agent 'notmuch-user-agent)
>  
> -- 
> 1.7.8.1
> 
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] Add pseudo-compatibility with gmime 2.6

2012-01-16 Thread Kazuo Teramoto
On Tue, Jan 17, 2012 at 12:56:39AM +0100, Thomas Jost wrote:
> There are lots of API changes in gmime 2.6 crypto handling. By adding
> preprocessor directives, it is however possible to add gmime 2.6 compatibility
> while preserving compatibility with gmime 2.4 too.

I tested this with gmime 2.4.31 and 2.6.4. Works for me.

In a related note: Arch Linux started to ship gmime 2.6.4.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120116/45eec978/attachment-0001.pgp>


[PATCH] Add pseudo-compatibility with gmime 2.6

2012-01-16 Thread Austin Clements
Quoth Thomas Jost on Jan 17 at 12:56 am:
> There are lots of API changes in gmime 2.6 crypto handling. By adding
> preprocessor directives, it is however possible to add gmime 2.6 compatibility
> while preserving compatibility with gmime 2.4 too.

Awesome.  Comments inline below.

> This is mostly based on id:"8762i8hrb9.fsf at bookbinder.fernseed.info".
> 
> This was tested against both gmime 2.6.4 and 2.4.31. With gmime 2.4.31, the
> crypto tests all work fine (as expected). With gmime 2.6.4, one crypto test
> fails (signature verification with signer key unavailable) but this will be 
> hard
> to fix since the new API does not report the reason why a signature 
> verification
> fails (other than the human-readable error message).

What is the result of this failing test?

> ---
>  mime-node.c  |   50 ++-
>  notmuch-client.h |   27 ++-
>  notmuch-reply.c  |7 
>  notmuch-show.c   |   97 
> ++
>  show-message.c   |4 ++
>  5 files changed, 181 insertions(+), 4 deletions(-)
> 
> diff --git a/mime-node.c b/mime-node.c
> index d26bb44..ae2473d 100644
> --- a/mime-node.c
> +++ b/mime-node.c
> @@ -33,7 +33,11 @@ typedef struct mime_node_context {
>  GMimeMessage *mime_message;
>  
>  /* Context provided by the caller. */
> +#ifdef GMIME_26
> +GMimeCryptoContext *cryptoctx;
> +#else
>  GMimeCipherContext *cryptoctx;
> +#endif
>  notmuch_bool_t decrypt;
>  } mime_node_context_t;
>  
> @@ -57,8 +61,12 @@ _mime_node_context_free (mime_node_context_t *res)
>  
>  notmuch_status_t
>  mime_node_open (const void *ctx, notmuch_message_t *message,
> - GMimeCipherContext *cryptoctx, notmuch_bool_t decrypt,
> - mime_node_t **root_out)
> +#ifdef GMIME_26
> + GMimeCryptoContext *cryptoctx,
> +#else
> + GMimeCipherContext *cryptoctx,
> +#endif
> + notmuch_bool_t decrypt, mime_node_t **root_out)
>  {
>  const char *filename = notmuch_message_get_filename (message);
>  mime_node_context_t *mctx;
> @@ -112,12 +120,21 @@ DONE:
>  return status;
>  }
>  
> +#ifdef GMIME_26
> +static int
> +_signature_list_free (GMimeSignatureList **proxy)
> +{
> +g_object_unref (*proxy);
> +return 0;
> +}
> +#else
>  static int
>  _signature_validity_free (GMimeSignatureValidity **proxy)
>  {
>  g_mime_signature_validity_free (*proxy);
>  return 0;
>  }
> +#endif
>  
>  static mime_node_t *
>  _mime_node_create (const mime_node_t *parent, GMimeObject *part)
> @@ -165,11 +182,23 @@ _mime_node_create (const mime_node_t *parent, 
> GMimeObject *part)
>   GMimeMultipartEncrypted *encrypteddata =
>   GMIME_MULTIPART_ENCRYPTED (part);
>   node->decrypt_attempted = TRUE;
> +#ifdef GMIME_26
> + GMimeDecryptResult *decrypt_result = g_mime_decrypt_result_new ();

I think g_mime_multipart_encrypted_decrypt allocates the
GMimeDecryptResult for you, so this will just leak memory.

> + node->decrypted_child = g_mime_multipart_encrypted_decrypt
> + (encrypteddata, node->ctx->cryptoctx, _result, );
> + if (node->decrypted_child) {
> + node->decrypt_success = node->verify_attempted = TRUE;
> + node->sig_list = g_mime_decrypt_result_get_signatures 
> (decrypt_result);
> + if (!node->sig_list)
> + fprintf (stderr, "Failed to get signatures: %s\n",
> +  (err ? err->message : "no error explanation 
> given"));

My understanding is that g_mime_decrypt_result_get_signatures returns
NULL if there are no signatures and that this isn't an error.  This
differs from 2.4, which would return an empty but non-NULL list.

Also, I believe you have to free the sig_list in both branches now,
which means the talloc_set_destructor can be moved to common logic
outside of the if decrypted/signed.

> +#else
>   node->decrypted_child = g_mime_multipart_encrypted_decrypt
>   (encrypteddata, node->ctx->cryptoctx, );
>   if (node->decrypted_child) {
>   node->decrypt_success = node->verify_attempted = TRUE;
>   node->sig_validity = 
> g_mime_multipart_encrypted_get_signature_validity (encrypteddata);
> +#endif

It's confusing to have the open braces in the #ifdef'd region with a
matching close brace outside of it (and I imagine this confuses
editors and uncrustify, too).  You could either copy the else part in
both branches of the #ifdef or avoid duplicated code with something
like

#ifdef GMIME_26
  .. node->decrypted_child = ..
#else
  .. node->decrypted_child = ..
#endif
  if (node->decrypted_child) {
node->decrypt_success = node->verify_attempted = TRUE;
#ifdef GMIME_26
node->sig_list = ..
#else
node->sig_validity = ..
#endif
  } else {
fprintf (stderr, ..);
  }

>   } else {
>   fprintf (stderr, "Failed to decrypt part: %s\n",
>

Partial words on notmuch search?

2012-01-16 Thread Andrei Popescu
On Du, 15 ian 12, 17:07:36, mailinglists at nawaz.org wrote:
> 
> Use '*'.
> 
> For example, Obam* should match "Obama".

Hmm...

$ notmuch count 'Debian'
65888
$ notmuch count '*ebian'
3
$ notmuch count '?ebian'
3
$ notmuch count 'ebian'
3
$ notmuch count '0ebian'
0

As far as I can tell, anything that is not a number or a letter is just 
stripped.

This is also interesting:
$ notmuch count 'debian'
65888
$ notmuch count 'dEbian'
65888
$ notmuch count 'Debian'
65887

Where can I read more about this? (except the source :)

Thanks,
Andrei
-- 
If you can't explain it simply, you don't understand it well enough.
(Albert Einstein)
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120116/e56d0b28/attachment.pgp>


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

2012-01-16 Thread Xavier Maillard
On Mon, 16 Jan 2012 09:07:52 +, David Edmondson  wrote:
> 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.

If I can help, just tell :D

/Xavier


[PATCH 2/3] emacs: whitespace-cleanup and indent-region for emacs/*.el files

2012-01-16 Thread Jameson Graef Rollins
On Mon, 16 Jan 2012 23:32:00 -0500, Austin Clements  wrote:
> Cleanup is the type of pain that should only be suffered once, so I'd
> be much happier with this if there was an accompanying git hook that
> prevented more mis-formatted code from slipping in.

Agreed.  However, if we're really going to go down this pedantic route,
we need to make sure it is very easy for new contributors to know,
apply, and develop with these new rules.  Otherwise we're asking for a
lot more review churn on the list, and more frustration on the part of
potential contributors.

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


[PATCH v2] Document external dependencies in the test suite

2012-01-16 Thread Xavier Maillard
Hi,

On Mon, 16 Jan 2012 13:52:47 -0500, Ethan Glasser-Camp  
wrote:

[...]

> +Prerequisites
> +-
> +Some tests require external dependencies to run. Without them, they
> +will be skipped, or (rarely) marked failed. Please install these, so
> +that you know if you break anything.
> +
> +  - dtach(1)
> +  - emacs(1)
> +  - emacsclient(1)
> +  - gdb(1)
> +  - gpg(1)
> +  - python(1)

Looks good but just a nit: what is the meaning of the '1' ?

/Xavier


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

2012-01-16 Thread Dmitry Kurochkin
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?

Regards,
  Dmitry


[PATCH] Document the dependency on dtach in the test suite

2012-01-16 Thread Dmitry Kurochkin
On Mon, 16 Jan 2012 12:16:08 -0500, Ethan Glasser-Camp  
wrote:
> From: Ethan Glasser-Camp 
> 
> dtach (and before that, screen) are used to run emacs with more
> verisimilitude, but this is only mentioned in the NEWS. Mention this
> in the test/README file, to make it easier to find out why a bunch of
> tests are failing/skipped.
> 

Can you please add other prerequisites as well?  There is gpg and
probably more.

Can we just make it an alphabetically-sorted list?  That would make it
easier to read and add more dependencies in the future.  I.e.:

  Some tests require the following external dependencies to run:

* emacs(1)
* emacsclient(1)
...

Regards,
  Dmitry

> Signed-off-by: Ethan Glasser-Camp 
> ---
> 
> Just cutting my teeth on the codebase, and it took me a little while
> to figure this out, so I thought I'd document it.
> 
>  test/README |5 +
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/test/README b/test/README
> index bde6db0..29afb3b 100644
> --- a/test/README
> +++ b/test/README
> @@ -6,6 +6,11 @@ When fixing bugs or enhancing notmuch, you are strongly 
> encouraged to
>  add tests in this directory to cover what you are trying to fix or
>  enhance.
>  
> +Prerequisites
> +-
> +emacs is run within dtach, so you need to have that installed to run
> +emacs tests (or crypto tests, which rely on emacs to run).
> +
>  Running Tests
>  -
>  The easiest way to run tests is to say "make test", (or simply run the
> -- 
> 1.7.5.4
> 
> ___
> notmuch mailing list
> notmuch at 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 Dmitry Kurochkin
Hi David.

On Mon, 16 Jan 2012 16:47:32 +, David Edmondson  wrote:
> "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.

Isn't this function the same as something like "test_expect_equal $x t"?

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?

Regards,
  Dmitry

> ---
> 
> 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 at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 1/1] Make buttons for attachments allow viewing as well as saving

2012-01-16 Thread Mark Walters

(My apologies, owing to various errors on my part the patch has ended up
in a separate thread:
id:"1326749910-30437-1-git-send-email-markwalters1009 at gmail.com")

On Mon, 16 Jan 2012 11:31:16 -0800, Jameson Graef Rollins  wrote:
> > Keymap on a button is: s for save, v for view and o for view with
> > other program. Default (i.e. enter or mouse button) is save but is
> > easily configurable e.g. set to view with
> > (setq notmuch-show-part-button-default-action 
> > 'notmuch-show-part-view-action)
> 
> Actually, this should really be a defcustom.  Maybe something like this:
> 
> (defcustom notmuch-show-part-button-default-action 
> 'notmuch-show-part-button-save
>   "Default part header button action (on ENTER or mouse click)."
>   :group 'notmuch
>   :type '(choice (function :tag "Save part"
>   :value notmuch-show-part-button-save)
> (function :tag "View part"
>   :value notmuch-show-part-button-view)
> (function :tag "View interactively"
>   :value notmuch-show-part-button-interactively-view))
> 
> Unfortunately this isn't quite working right, since it's not setting the
> default properly, but if someone can help me figure out what I'm doing
> wrong, I think this is at least the right idea.

This did not work for me, nor did Austin's suggestion but the following
does
+(defcustom notmuch-show-part-button-default-action 
'notmuch-show-part-save-action
+  "Default part header button action (on ENTER or mouse click)."
+  :group 'notmuch
+  :type '(choice (const :tag "Save part"
+   notmuch-show-part-save-action)
+(const :tag "View part"
+   notmuch-show-part-view-action)
+(const :tag "View interactively"
+   notmuch-show-part-interactively-view-action)))

I wonder if the "problem" comes from me doing things in a non-lispy
fashion (I am completely new to lisp). Thus
notmuch-show-part-button-default-action is a variable that gets passed
around rather than a function.

> There's a white space at the end of this line, which produces the
> following git warning:
> 
>   Applying: Make buttons for attachments allow viewing as well as saving
>   /home/jrollins/src/notmuch/git/.git/rebase-apply/patch:96: trailing 
> whitespace.
>   (defvar notmuch-show-part-button-default-action 
> 'notmuch-show-part-save-action)
>   warning: 1 line adds whitespace errors.
> 
> So if you go with (an improved version of) my defcustom suggestion above
> you can kill two birds with one stone:

Right I have fixed this as above and think the whitespace is ok now (it
passes git diff --check). I intended to send the patch as a reply to
this email but it has ended up here:
id:"1326749910-30437-1-git-send-email-markwalters1009 at gmail.com"

Best wishes

Mark



[PATCH v2] Make buttons for attachments allow viewing as well as saving

2012-01-16 Thread Mark Walters
Define a keymap for attachment buttons to allow multiple actions.
Define 3 possible actions:
save attachment: exactly as currently,
view attachment: uses mailcap entry,
view attachment with user chosen program

Keymap on a button is: s for save, v for view and o for view with
other program. Default (i.e. enter or mouse button) is save but this
is configurable in notmuch customize.

One implementation detail: the view attachment function forces all
attachments to be "displayed" using mailcap even if emacs could
display them itself. Thus, for example, text/html appears in a browser
and text/plain asks whether to save (on a standard debian setup)
---
 emacs/notmuch-show.el |   89 +++-
 1 files changed, 72 insertions(+), 17 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 03c1f6b..6935525 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -281,10 +281,21 @@ message at DEPTH in the current thread."
(run-hooks 'notmuch-show-markup-headers-hook)

 (define-button-type 'notmuch-show-part-button-type
-  'action 'notmuch-show-part-button-action
+  'action 'notmuch-show-part-button-default
+  'keymap 'notmuch-show-part-button-map
   'follow-link t
   'face 'message-mml)

+(defvar notmuch-show-part-button-map
+  (let ((map (make-sparse-keymap)))
+   (set-keymap-parent map button-map)
+   (define-key map "s" 'notmuch-show-part-button-save)
+   (define-key map "v" 'notmuch-show-part-button-view)
+   (define-key map "o" 'notmuch-show-part-button-interactively-view)
+map)
+  "Submap for button commands")
+(fset 'notmuch-show-part-button-map notmuch-show-part-button-map)
+
 (defun notmuch-show-insert-part-header (nth content-type declared-type 
 name comment)
   (let ((button))
 (setq button
@@ -299,29 +310,43 @@ message at DEPTH in the current thread."
   " ]")
   :type 'notmuch-show-part-button-type
   :notmuch-part nth
-  :notmuch-filename name))
+  :notmuch-filename name
+  :notmuch-content-type content-type))
 (insert "\n")
 ;; return button
 button))

 ;; Functions handling particular MIME parts.

+;; this function is kept for the tests and any external users
 (defun notmuch-show-save-part (message-id nth  filename)
+  (notmuch-show-part-action 'notmuch-show-part-save-action message-id nth nil 
filename))
+
+(defun notmuch-show-part-action (action message-id nth content-type  
filename)
   (let ((process-crypto notmuch-show-process-crypto))
 (with-temp-buffer
   (setq notmuch-show-process-crypto process-crypto)
   ;; Always acquires the part via `notmuch part', even if it is
   ;; available in the JSON output.
   (insert (notmuch-show-get-bodypart-internal message-id nth))
-  (let ((file (read-file-name
-  "Filename to save as: "
-  (or mailcap-download-directory "~/")
-  nil nil
-  filename)))
-   ;; Don't re-compress .gz & al.  Arguably we should make
-   ;; `file-name-handler-alist' nil, but that would chop
-   ;; ange-ftp, which is reasonable to use here.
-   (mm-write-region (point-min) (point-max) file nil nil nil 
'no-conversion t)
+  (cond ((eq action 'notmuch-show-part-save-action)
+(let ((file (read-file-name
+ "Filename to save as: "
+ (or mailcap-download-directory "~/")
+ nil nil
+ filename)))
+  ;; Don't re-compress .gz & al.  Arguably we should make
+  ;; `file-name-handler-alist' nil, but that would chop
+  ;; ange-ftp, which is reasonable to use here.
+  (mm-write-region (point-min) (point-max) file nil nil nil 
'no-conversion t)))
+   ((eq action 'notmuch-show-part-view-action)
+;; set mm-inlined-types to nil to force an external viewer
+(let ((handle (mm-make-handle (current-buffer) (list 
content-type)))
+  (mm-inlined-types nil))
+  (mm-display-part handle)))
+   ((eq action 'notmuch-show-part-interactively-view-action)
+(let ((handle (mm-make-handle (current-buffer) (list 
content-type
+  (mm-interactively-view-part handle)))

 (defun notmuch-show-mm-display-part-inline (msg part nth content-type)
   "Use the mm-decode/mm-view functions to display a part in the
@@ -1502,12 +1527,42 @@ buffer."

 ;; Commands typically bound to buttons.

-(defun notmuch-show-part-button-action (button)
-  (let ((nth (button-get button :notmuch-part)))
-(if nth
-   (notmuch-show-save-part (notmuch-show-get-message-id) nth
-   (button-get button :notmuch-filename))
-  (message "Not a valid part (is it a fake part?)."
+(defcustom notmuch-show-part-button-default-action 
'notmuch-show-part-save-action
+  "Default 

Partial words on notmuch search?

2012-01-16 Thread Austin Clements
Quoth Andrei Popescu on Jan 16 at 10:21 pm:
> This is also interesting:
> $ notmuch count 'debian'
> 65888
> $ notmuch count 'dEbian'
> 65888
> $ notmuch count 'Debian'
> 65887

The first two will match stemmed versions of "debian" such as
"debian's" and "debianed".  However, starting a term with a capital
letter suppresses stemming (because it suggests that it's a name,
which you wouldn't want to modify), so your last query matches only
the term "debian".  This is probably documented somewhere, though I
don't know where.

> Where can I read more about this? (except the source :)

Most of this is in the Xapian query syntax document you found.  Really
we ought to beef-up Notmuch's query syntax documentation.


[PATCH 1/1] Make buttons for attachments allow viewing as well as saving

2012-01-16 Thread Austin Clements
Quoth Mark Walters on Jan 16 at  9:44 pm:
> On Mon, 16 Jan 2012 11:31:16 -0800, Jameson Graef Rollins  finestructure.net> wrote:
> > > Keymap on a button is: s for save, v for view and o for view with
> > > other program. Default (i.e. enter or mouse button) is save but is
> > > easily configurable e.g. set to view with
> > > (setq notmuch-show-part-button-default-action 
> > > 'notmuch-show-part-view-action)
> > 
> > Actually, this should really be a defcustom.  Maybe something like this:
> > 
> > (defcustom notmuch-show-part-button-default-action 
> > 'notmuch-show-part-button-save
> >   "Default part header button action (on ENTER or mouse click)."
> >   :group 'notmuch
> >   :type '(choice (function :tag "Save part"
> >   :value notmuch-show-part-button-save)
> > (function :tag "View part"
> >   :value notmuch-show-part-button-view)
> > (function :tag "View interactively"
> >   :value 
> > notmuch-show-part-button-interactively-view))
> > 
> > Unfortunately this isn't quite working right, since it's not setting the
> > default properly, but if someone can help me figure out what I'm doing
> > wrong, I think this is at least the right idea.
> 
> This did not work for me, nor did Austin's suggestion but the following
> does
> +(defcustom notmuch-show-part-button-default-action 
> 'notmuch-show-part-save-action
> +  "Default part header button action (on ENTER or mouse click)."
> +  :group 'notmuch
> +  :type '(choice (const :tag "Save part"
> +   notmuch-show-part-save-action)
> +(const :tag "View part"
> +   notmuch-show-part-view-action)
> +(const :tag "View interactively"
> +   notmuch-show-part-interactively-view-action)))
> 
> I wonder if the "problem" comes from me doing things in a non-lispy
> fashion (I am completely new to lisp). Thus
> notmuch-show-part-button-default-action is a variable that gets passed
> around rather than a function.

Sorry, I should have looked at the bigger context in this patch.  I
think Jameson was implying that notmuch-show-part-button-default
should change to

(defun notmuch-show-part-button-default ( button)
  (interactive)
  (funcall notmuch-show-part-button-default-action button))

I would go one step further and say that each action should probably
be a separate function.  That is, break notmuch-show-part-action into
separate functions and simply invoke the appropriate function, rather
than performing a fixed data dispatch.  This would be more flexible
and Lispy.  It may be that your approach works out better, but I'd at
least give this a shot.


[PATCH 1/2] test: add known broken test for reply from address in named group list

2012-01-16 Thread David Bremner
On Sat, 14 Jan 2012 23:49:49 +0200, Jani Nikula  wrote:
> If a message was received to the user's address that was in a named
> group list, notmuch reply does not use that address for picking the
> from address.

Pushed.

d


[PATCH v3 0/2] Automatic tag-based exclusion

2012-01-16 Thread David Bremner
On Sat, 14 Jan 2012 19:17:32 -0500, Austin Clements  wrote:
> This fixes the symbol visibility warning Jamie pointed out.

Third time the charm.

pushed. 

Please (somebody) consider writing NEWS and man page updates.

d


[RFC] vim plugin rewrite II

2012-01-16 Thread Anton Khirnov

On Mon, 16 Jan 2012 09:34:59 -0800, Jameson Graef Rollins  wrote:
> On Sun, 15 Jan 2012 16:34:08 +0100, Anton Khirnov  
> wrote:
> > Yes, it's still synchronous. I suppose making it asynchronous shouldn't
> > be all that hard, i just never found enough time and motivation for that
> > (it was never a huge problem here).
> 
> My understanding was that vim was not actually capable of loading files
> asynchronously.  That would be very interesting if it was.
> 

It should be possible to run the query in a separate python thread which
would write the results into the vim buffer.

-- 
Anton Khirnov


[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.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120116/06824ed7/attachment.pgp>


[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.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120116/c118d6ea/attachment.pgp>


[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 +, 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.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120116/1f30ad7d/attachment.pgp>


Partial words on notmuch search?

2012-01-16 Thread David Bremner
On Mon, 16 Jan 2012 22:21:03 +0200, Andrei Popescu  wrot> 
> $ notmuch count 'Debian'
> 65888
> $ notmuch count '*ebian'
> 3
> $ notmuch count '?ebian'
> 3
> $ notmuch count 'ebian'
> 3
> $ notmuch count '0ebian'

You have to delve into the mysteries of xapian query parsing
unfortunately.

The short answer is that "*" only works at the end of a word.


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

2012-01-16 Thread David Bremner
On Mon, 16 Jan 2012 15:51:30 -0500, Aaron Ecay  wrote:
> On Mon, 16 Jan 2012 11:22:27 +, David Edmondson  wrote:
> > 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?
> 
> The tags look nice and yellow-green for me too on a trunk build of emacs
> (which is one flavor of emacs 24).  Adding and removing tags works as
> expected ? the tags dis/appear and are the right color.
> 
> I haven?t reloaded the notmuch *.el files since this change landed, but
> I agree with Pieter that the overlays were nice.

I'm leaning to revert this patch. Any opposition?

d


[PATCH v2 5/4] emacs: Add customization for the first line of quotes.

2012-01-16 Thread Adam Wolfe Gordon
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.
---

Due to some subsequent discussions in the thread about my original patch series,
I decided I may as well implement this sooner rather than later.

 emacs/notmuch-mua.el |   16 
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index b03c62c..c7fd9f8 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -91,6 +91,14 @@ list."
   (fill-region (point-min) (point-max))
   (buffer-substring (point-min) (point-max)

+(defcustom notmuch-mua-reply-quoth "On %date%, %from% wrote:"
+  "The first line of a reply body, typically 'On %date%, %from% wrote:'.
+
+Any header fields from the message being replied to can be inserted by
+enclosing them in percents."
+  :group 'notmuch
+  :type 'string)
+
 (defun notmuch-mua-reply (query-string  sender reply-all)
   (let ((args '("reply" "--format=json"))
reply
@@ -132,10 +140,10 @@ list."
  (forward-line -1)
(goto-char (point-max)))

-  (insert (format "On %s, %s wrote:\n"
- (cdr (assq 'date original-headers))
- (cdr (assq 'from original-headers
-  
+  (let ((quoth (replace-regexp-in-string "%.+?%" 
+(lambda (hdr) (cdr (assq (intern 
(substring hdr 1 (- (length hdr) 1))) original-headers)))
+notmuch-mua-reply-quoth)))
+   (insert quoth "\n"))

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



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

2012-01-16 Thread Pieter Praet
* emacs/notmuch-show.el (notmuch-show-buttonized-link-colors):
  new defcustom, allows toggling colorization of buttonized links.

* emacs/notmuch-show.el (notmuch-show-buttonized-link-present),
* emacs/notmuch-show.el (notmuch-show-buttonized-link-present-and-unread),
* emacs/notmuch-show.el (notmuch-show-buttonized-link-missing):
  new faces for buttonized id: links.

* emacs/notmuch-show.el (notmuch-show-found-target-p): add optional arg
  VERIFY-UNREAD which causes results to be filtered by "tag:unread".

* emacs/notmuch-show.el (notmuch-show-buttonize-links): use different
  face property depending on the result of `notmuch-show-found-target-p',
  causing buttons to available, available-and-unread and missing messages
  to be displayed in a different color.

---

v2:

- add `notmuch-show-buttonized-link-colors': new defcustom, allows
  toggling colorization of buttonized links, to address concerns re
  performance.
- ... and some minor refactoring


 emacs/notmuch-show.el |   45 ++---
 1 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 7a79d06..c6d7e29 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -794,6 +794,38 @@ current buffer, if possible."
 (defvar notmuch-show-buffer-name nil)
 (make-variable-buffer-local 'notmuch-show-buffer-name)

+(defcustom notmuch-show-buttonized-link-colors t
+  "Colorize buttonized links depending on their target's state.
+
+Also see `notmuch-show-buttonized-link-available',
+ `notmuch-show-buttonized-link-available-and-unread',
+ `notmuch-show-buttonized-link-missing'.
+
+Might impact performance."
+  :type 'boolean
+  :group 'notmuch-show)
+
+(defface notmuch-show-buttonized-link-available
+  '((t (:inherit goto-address-mail-face :foreground "blue")))
+  "Face used for buttonized links to messages which are present
+in the mail store."
+  :group 'notmuch-show
+  :group 'notmuch-faces)
+
+(defface notmuch-show-buttonized-link-available-and-unread
+  '((t (:inherit goto-address-mail-face :foreground "green")))
+  "Face used for buttonized links to messages which are present
+in the mail store, and are tagged `unread'."
+  :group 'notmuch-show
+  :group 'notmuch-faces)
+
+(defface notmuch-show-buttonized-link-missing
+  '((t (:inherit goto-address-mail-face :foreground "red")))
+  "Face used for buttonized links to messages which are NOT
+present in in the mail store."
+  :group 'notmuch-show
+  :group 'notmuch-faces)
+
 (defun notmuch-show-buttonize-links (start end)
   "Buttonize URLs and mail addresses between START and END.

@@ -813,7 +845,14 @@ a corresponding notmuch search."
 (notmuch-show-if-found ,message-id))
  'follow-link t
  'help-echo "Mouse-1, RET: search for this message"
- 'face goto-address-mail-face)
+ 'face (if notmuch-show-buttonized-link-colors
+   (cond
+((notmuch-show-found-target-p message-id 
"and tag:unread")
+ 
'notmuch-show-buttonized-link-available-and-unread)
+((notmuch-show-found-target-p message-id 
nil)
+ 'notmuch-show-buttonized-link-available)
+(t 'notmuch-show-buttonized-link-missing))
+ 'goto-address-mail-face))

 ;;;###autoload
 (defun notmuch-show (thread-id  parent-buffer query-context 
buffer-name crypto-switch)
@@ -906,8 +945,8 @@ thread id.  If a prefix is given, crypto processing is 
toggled."
 (notmuch-kill-this-buffer)
 (notmuch-show-worker thread-id parent-buffer query-context buffer-name 
process-crypto)))

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


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

2012-01-16 Thread Pieter Praet
On Mon, 16 Jan 2012 11:45:13 +, David Edmondson  wrote:
> 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 [...]

Rightly so :)

> [...] (we're up to two
> 'notmuch' invocations for a missing or read message).

I'll at least add an option to toggle it.

Patch follows.


Peace

-- 
Pieter


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

2012-01-16 Thread Pieter Praet
On Mon, 16 Jan 2012 11:45:13 +, David Edmondson  wrote:
> 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 [...]

Rightly so :)

> [...] (we're up to two
> 'notmuch' invocations for a missing or read message).

I'll at least add an option to toggle it.

Patch follows.


Peace

-- 
Pieter


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

2012-01-16 Thread Pieter Praet
* emacs/notmuch-show.el (notmuch-show-found-target-p): new predicate function
  that uses notmuch(1) 'count' to see if a query turns up any results.

* emacs/notmuch-show.el (notmuch-show-if-found): new function that only shows
  a message/thread if present in the database and otherwise returns an error.

* emacs/notmuch-show.el (notmuch-show-buttonize-links): some deduplication,
  and use new function `notmuch-show-if-found' instead of `notmuch-show'
  to prevent showing a blank screen for Message-Id's which aren't present
  in the database.

---

v2:  (corrections by David Edmondson [1])

 - `notmuch-show-found-target-p' : removed useless `substring'.
 - `notmuch-show-if-found' : remove redundant `format'.

... and added a missing closing paren due to badly splitting up the
original commit.

[1] id:"cun7h0r50v6.fsf at hotblack-desiato.hh.sledj.net"


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

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index f101d76..7a79d06 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -803,14 +803,17 @@ a corresponding notmuch search."
   (save-excursion
 (goto-char start)
 (while (re-search-forward "id:\\(\"?\\)[^[:space:]\"]+\\1" end t)
-  ;; remove the overlay created by goto-address-mode
-  (remove-overlays (match-beginning 0) (match-end 0) 'goto-address t)
-  (make-text-button (match-beginning 0) (match-end 0)
-   'action `(lambda (arg)
-  (notmuch-show ,(match-string-no-properties 
0)))
-   'follow-link t
-   'help-echo "Mouse-1, RET: search for this message"
-   'face goto-address-mail-face
+  (let ((message-id (match-string-no-properties 0))
+   (string-start (match-beginning 0))
+   (string-end (match-end 0)))
+   ;; remove the overlay created by goto-address-mode
+   (remove-overlays string-start string-end 'goto-address t)
+   (make-text-button string-start string-end
+ 'action `(lambda (arg)
+(notmuch-show-if-found ,message-id))
+ 'follow-link t
+ 'help-echo "Mouse-1, RET: search for this message"
+ 'face goto-address-mail-face)

 ;;;###autoload
 (defun notmuch-show (thread-id  parent-buffer query-context 
buffer-name crypto-switch)
@@ -903,6 +906,18 @@ thread id.  If a prefix is given, crypto processing is 
toggled."
 (notmuch-kill-this-buffer)
 (notmuch-show-worker thread-id parent-buffer query-context buffer-name 
process-crypto)))

+(defun notmuch-show-found-target-p (target)
+  (let ((args `("count" ,target)))
+(> (string-to-number
+   (with-output-to-string
+ (apply 'call-process notmuch-command nil standard-output nil args)))
+   0)))
+
+(defun notmuch-show-if-found (target  args)
+  (if (notmuch-show-found-target-p target)
+  (notmuch-show target args)
+(error "Can't find target: %s" target)))
+
 (defvar notmuch-show-stash-map
   (let ((map (make-sparse-keymap)))
 (define-key map "c" 'notmuch-show-stash-cc)
-- 
1.7.8.1



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

2012-01-16 Thread Pieter Praet
On Mon, 16 Jan 2012 11:43:25 +, David Edmondson  wrote:
> 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).
> 

Hardly noticable (if at all) AFAICT, but yeah, it *does* cost one
extra notmuch(1) invocation at every `push-button' event...

Still, rather that than potentially dumping users in a blank screen IMO.

Can't think of a better solution ATM.

> > +(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.
> 

Correct.  Mindless proactiveness, I guess :)  Removed.

> > +(defun notmuch-show-if-found (target  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.

Idem.

Patch follows.


Peace

-- 
Pieter


[PATCH] test: cli: getting/setting/removing config values

2012-01-16 Thread Pieter Praet
On Mon, 16 Jan 2012 07:37:13 -0400, David Bremner  wrote:
> On Mon, 16 Jan 2012 11:31:11 +0100, Pieter Praet  wrote:
> > 
> > Hmmm, `dnsdomainname' returns "(none)" here;  Does it work for you?
> > 
> > Running `domainname' instead seems to do the right thing though...
> > 
> 
> I make no claims to have "correctly" configured this machine on my home
> network, [...]

Same here :)

> [...] but here it is the opposite.  The docs refer to NIS for
> domainname, which I guess is not _that_ common for home networks (or at
> all anymore?).
> 

$ grep hosts /etc/nsswitch.conf
hosts: files dns

I guess that's a no.

> d


Perhaps others could chime in?


Peace

-- 
Pieter


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

2012-01-16 Thread Pieter Praet
Make `notmuch-cycle-notmuch-buffers' more Lispy and merge into `notmuch',
eliminating the need to hog yet another keybind.

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

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)
+(if next-buffer
+   (progn
+ (switch-to-buffer next-buffer)
+ (bury-buffer old-buffer))
+  (notmuch-hello

 (defun notmuch-interesting-buffer (b)
   "Is the current buffer of interest to a notmuch user?"
@@ -1078,31 +1091,6 @@ current search results AND that are tagged with the 
given tag."
   message-mode

 ;;;###autoload
-(defun notmuch-cycle-notmuch-buffers ()
-  "Cycle through any existing notmuch buffers (search, show or hello).
-
-If the current buffer is the only notmuch buffer, bury it. If no
-notmuch buffers exist, run `notmuch'."
-  (interactive)
-
-  (let (start first)
-;; If the current buffer is a notmuch buffer, remember it and then
-;; bury it.
-(when (notmuch-interesting-buffer (current-buffer))
-  (setq start (current-buffer))
-  (bury-buffer))
-
-;; Find the first notmuch buffer.
-(setq first (loop for buffer in (buffer-list)
-if (notmuch-interesting-buffer buffer)
-return buffer))
-
-(if first
-   ;; If the first one we found is any other than the starting
-   ;; buffer, switch to it.
-   (unless (eq first start)
- (switch-to-buffer first))
-  (notmuch

 (setq mail-user-agent 'notmuch-user-agent)

-- 
1.7.8.1



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

2012-01-16 Thread Pieter Praet
On Mon, 16 Jan 2012 11:47:03 +, David Edmondson  wrote:
> 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.)

Good call !  No joy:
  Debugger entered--Lisp error: (void-function remove-if-not)

Should've known.

So let's just get rid of that cl requirement, shall we :)

Patch follows.


Peace

-- 
Pieter


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

2012-01-16 Thread Aaron Ecay
On Mon, 16 Jan 2012 08:39:30 +, David Edmondson  wrote:
> On Mon, 16 Jan 2012 02:38:38 -0500, Aaron Ecay  wrote:
> > - 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.

I think it requires some amount of configuration, but it can be done
sensibly.  I am much more proficient with Elisp than with C, and
Emacs has prejudiced me towards solutions that allow me to have a
Turing-complete configuration language.  :)

I think a good starting point for thinking about mailing lists is what
Mutt does:
http://www.mutt.org/doc/manual/manual-4.html#using_lists

Notmuch at the CLI/C code level could aim for a comparable level of
expressiveness, and I think it would suffice for most people (including
me).

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

I avoided that, as it seemed to me that just before the message is sent
is too late to be doing these things (I?d like to see confirmation when
writing the message that the address/signature changes were applied
correctly).  But ?M-x apropos RET message hook RET? shows that there are
some earlier points to hook into as well.  Thanks.

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

One advantage of supercite is that it allows non-English speakers to set
up the ?On X, X wrote? line as they prefer.  Notmuch?s current approach
(a hard-coded C string) is the opposite of internationalized.  So it
would be nice to support some customization of that as well, even if we
don?t go the supercite route.

-- 
Aaron Ecay


[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-uknot at 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.fsf at hotblack-desiato.hh.sledj.net"

-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120116/4041a02b/attachment.pgp>


[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 'foo at bar.com ' then show just
   ;; 'foo at 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



[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 'foo at bar.com ' then show just
   ;; 'foo at 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



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

2012-01-16 Thread David Edmondson
Nice. +1.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120116/d6e88e8a/attachment-0001.pgp>


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

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


[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.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120116/5d30ecee/attachment.pgp>


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

2012-01-16 Thread Aaron Ecay
On Mon, 16 Jan 2012 14:13:22 +, David Edmondson  wrote:
> 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.

+1

-- 
Aaron Ecay


[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 .
+;;
+;; 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 "dme at dme.org")
+   "dme at dme.org"))
+
+(defun notmuch-test-clean-address-2 ()
+  (let* ((input '("foo at bar.com"
+ ""
+ "Foo Bar "
+ "foo at bar.com "
+ "\"Foo Bar\" "))
+(expected '("foo at bar.com"
+"foo at bar.com"
+"Foo Bar "
+"foo at 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



[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



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

2012-01-16 Thread Aaron Ecay
On Mon, 16 Jan 2012 17:57:33 +0100, Pieter Praet  wrote:
> * emacs/notmuch-show.el (notmuch-show-buttonized-link-colors):
>   new defcustom, allows toggling colorization of buttonized links.
> 
> * emacs/notmuch-show.el (notmuch-show-buttonized-link-present),
> * emacs/notmuch-show.el (notmuch-show-buttonized-link-present-and-unread),
> * emacs/notmuch-show.el (notmuch-show-buttonized-link-missing):
>   new faces for buttonized id: links.
> 
> * emacs/notmuch-show.el (notmuch-show-found-target-p): add optional arg
>   VERIFY-UNREAD which causes results to be filtered by "tag:unread".
> 
> * emacs/notmuch-show.el (notmuch-show-buttonize-links): use different
>   face property depending on the result of `notmuch-show-found-target-p',
>   causing buttons to available, available-and-unread and missing messages
>   to be displayed in a different color.

I really like the idea behind this patch, but it has the very small
problem that it colorizes too much.  So in reading this thread, there
are things like ?id:?s? and ?id:?? that get colored the missing-message
color (a very angry red, by default).  Though this isn?t likely to be a
very frequent problem with email messages that are not on this listserv
:), it would be nice to fix it.  Maybe you could change the regex that
matches id:?s to require a little more structure ? an at-sign, perhaps.
Or even requiring more than (say) 5 non-space characters after the
message id would cut down sharply on the false positive rate.

-- 
Aaron Ecay


[PATCH] emacs: Improved printing support.

2012-01-16 Thread Aaron Ecay
I don?t have (easy access to) a printer, so I haven?t actually exercised
the printing functionality of this patch.

In general, the patch LGTM.  Specific comments below.

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.
> ---
> 
> Fix the lack of shell quoting for muttprint. Rename the ps-print
> buffers to have a relevant name.
> 
>  emacs/Makefile.local   |3 +-
>  emacs/notmuch-print.el |   79 
> 
>  emacs/notmuch-show.el  |   51 +++
>  3 files changed, 132 insertions(+), 1 deletions(-)
>  create mode 100644 emacs/notmuch-print.el
> 
> diff --git a/emacs/Makefile.local b/emacs/Makefile.local

[...]

> --- /dev/null
> +++ b/emacs/notmuch-print.el
> @@ -0,0 +1,79 @@
> +;; 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 .
> +;;
> +;; 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")))
> +
> +(defmacro notmuch-print-with-file (filename  body)
> +  `(with-temp-buffer
> + (insert-file-contents ,filename)
> + (set-buffer-modified-p nil)
> + , at body))
> +
> +(defun notmuch-print-lpr (filename msg)
> +  (notmuch-print-with-file filename
> +(lpr-buffer)))
> +
> +(defun notmuch-print-ps-print (filename msg)
> +  (let ((subject (plist-get (notmuch-show-get-prop :headers msg) :Subject)))
> +(notmuch-print-with-file filename
> +  (rename-buffer subject t)
> +  (ps-print-buffer
> +
> +(defun notmuch-print-ps-print/evince (filename msg)
> +  (let ((ps-file (make-temp-file "notmuch"))
> + (subject (plist-get (notmuch-show-get-prop :headers msg) :Subject)))
> +(notmuch-print-with-file filename
> +  (rename-buffer subject t)
> +  (ps-print-buffer ps-file)
> +  (async-shell-command (concat "evince " ps-file)
> +
> +(defun notmuch-print-muttprint (filename msg)
> +  (shell-command
> +   (concat "muttprint "
> +"--file " (shell-quote-argument filename) " "
> +;; Show the tags.
> +"--printed-headers 'Date_To_From_CC_Newsgroups_*Subject*_/Tags/'")))
> +
> +(defun notmuch-print-muttprint/evince (filename msg)
> +  (let ((ps-file (make-temp-file "notmuch")))
> +(call-process-shell-command
> + (concat "muttprint "
> +  "--file " (shell-quote-argument filename) " "
> +  ;; Show the tags.
> +  "--printed-headers 'Date_To_From_CC_Newsgroups_*Subject*_/Tags/' "
> +  "--printer 'TO_FILE:" (shell-quote-argument ps-file) "'"))
> +(async-shell-command (concat "evince " ps-file
> +
> +(defun notmuch-print-message (filename msg)
> +  (funcall notmuch-print-mechanism filename msg))
> +
> +;;

The above is just a stray comment line, right?

> +
> +(provide 'notmuch-print)
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 5502efd..55ccfc5 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 "notmuch" ( args))
>  (declare-function notmuch-fontify-headers "notmuch" nil)
> @@ -186,6 +187,51 @@ indentation."
>mm-handle (> (notmuch-count-attachments mm-handle) 1
>(message "Done"))
>  
> +(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 

[PATCH v2] Document external dependencies in the test suite

2012-01-16 Thread Ethan Glasser-Camp
On 01/16/2012 04:09 PM, Xavier Maillard wrote:
> Looks good but just a nit: what is the meaning of the '1' ? 

It's a manpage-like indication that these are standalone programs and 
not, say, libraries or system calls :) Not that I expect there to be 
library dependencies for just the test suite, I just followed Dmitry's 
suggestion.

Ethan



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

2012-01-16 Thread Aaron Ecay
On Mon, 16 Jan 2012 11:22:27 +, David Edmondson  wrote:
> 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?

The tags look nice and yellow-green for me too on a trunk build of emacs
(which is one flavor of emacs 24).  Adding and removing tags works as
expected ? the tags dis/appear and are the right color.

I haven?t reloaded the notmuch *.el files since this change landed, but
I agree with Pieter that the overlays were nice.

-- 
Aaron Ecay


[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'?
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120116/de0bd52a/attachment.pgp>


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

2012-01-16 Thread Adam Wolfe Gordon
On Mon, Jan 16, 2012 at 15:31, Aaron Ecay  wrote:
> One advantage of supercite is that it allows non-English speakers to set
> up the ?On X, X wrote? line as they prefer. ?Notmuch?s current approach
> (a hard-coded C string) is the opposite of internationalized. ?So it
> would be nice to support some customization of that as well, even if we
> don?t go the supercite route.

Note that with my patch, the "On X, X wrote" string is no longer
hardcoded in the CLI (at least when using the JSON reply format).  I
intend to make it configurable in emacs, though right now it is
hardcoded in notmuch-mua.el.

-- 
Adam Wolfe Gordon


[PATCH 1/4] emacs: unify search mechanisms

2012-01-16 Thread Dmitry Kurochkin
On Mon, 16 Jan 2012 11:35:37 +, David Edmondson  wrote:
> On Sun, 25 Dec 2011 08:14:52 +0400, Dmitry Kurochkin  gmail.com> 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?

Right.  We will just need to fix the 's' key binding.  Looking forward
for that.

Regards,
  Dmitry


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

2012-01-16 Thread David Bremner
On Mon, 16 Jan 2012 22:06:15 +0400, Dmitry Kurochkin  wrote:
> 
> If others like it, how about reverting to the old bindings until the new
> ones are implemented?
> 

Flip-flopping the bindings will just cause more confusion, in my opinion.

It is easy (and documented in the wiki) to customize the bindings
in your .emacs. 

So as a temporary measure, the latter seems simplest.

d


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

2012-01-16 Thread Tomi Ollila
On Mon, 16 Jan 2012 08:49:03 +, David Edmondson  wrote:
> On Sun, 15 Jan 2012 12:58:40 -0500, Austin Clements  
> wrote:
> 
> 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?

Either from a header or from the body of the *HTTP*. Html meta tag is part
of the header of the HTML document, body of the HTTP message.

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

In case of w3m interface if charset is not told it defaults
to iso-8859-1 as both input and output encoding.

That is no problem in w3m -- it just doesn't do any conversion.

But emacs thinks that it gets input in iso-8859-1 format and will
attempt to convert that to whatever charset the window user has
is using. 

If input was utf8 but emacs thinks input was latin1 then we get
this infamous 'double-utf8'ied output (a subset of wtf-8 charset ;)
(in case window charset is utf8)

In case of w3m the content feed to w3m could be pre-encoded to utf-8
and w3m interface is told that charset is utf-8 -- w3m will now
called using utf-8 as input and output encoding -- and at the end
emacs does conversion from utf-8 to the window encoding (if needed).

As mentioned in IRC: 2012-01-10 11:46 (UTC)  xxxXX  indeed, the headers
should take precedence to meta tag, as defined in HTML4

So, complying clients takes the precedence from command line options
(which, in case of command line clients makes perfect sense).

Tomi


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

2012-01-16 Thread Jeremy Nickurak
On Mon, Jan 16, 2012 at 12:28, Austin Clements  wrote:
> Quoth David Edmondson on Jan 16 at ?9:12 am:
>> Having "deleted" and "spam" as default settings in the configuration
>> file might be more reasonable.
>
> Sorry, I'm confused. ?Are you saying deleted;spam should or should not
> be the default?

If I read correctly:

1) If no exclude options are in the config file, none should be used.
2) On notmuch setup, "deleted" and "spam" should be added to .notmuch-config


[PATCH 1/1] Make buttons for attachments allow viewing as well as saving

2012-01-16 Thread Austin Clements
Quoth Jameson Graef Rollins on Jan 16 at 11:31 am:
> On Sun, 15 Jan 2012 12:16:36 +, Mark Walters  gmail.com> wrote:
> > Define a keymap for attachment buttons to allow multiple actions.
> > Define 3 possible actions:
> > save attachment: exactly as currently,
> > view attachment: uses mailcap entry,
> > view attachment with user chosen program
> 
> Great improvement, Mark!  Thanks for this.  I've been wanting this kind
> of functionality for a while, actually, and this is a really great
> implementation.  It works like a charm, and the code looks good to me,
> modulo a couple small comments below.
> 
> > Keymap on a button is: s for save, v for view and o for view with
> > other program. Default (i.e. enter or mouse button) is save but is
> > easily configurable e.g. set to view with
> > (setq notmuch-show-part-button-default-action 
> > 'notmuch-show-part-view-action)
> 
> Actually, this should really be a defcustom.  Maybe something like this:
> 
> (defcustom notmuch-show-part-button-default-action 
> 'notmuch-show-part-button-save
>   "Default part header button action (on ENTER or mouse click)."
>   :group 'notmuch
>   :type '(choice (function :tag "Save part"
>   :value notmuch-show-part-button-save)
> (function :tag "View part"
>   :value notmuch-show-part-button-view)
> (function :tag "View interactively"
>   :value notmuch-show-part-button-interactively-view))
> 
> Unfortunately this isn't quite working right, since it's not setting the
> default properly, but if someone can help me figure out what I'm doing
> wrong, I think this is at least the right idea.

Jamie's defcustom doesn't work for me either (apparently it works even
less for me than it does for Jamie), but the following works for me

(defcustom notmuch-show-part-button-default-action 
'notmuch-show-part-button-save
  "Default part header button action (on ENTER or mouse click)."
  :group 'notmuch
  :type '(choice (const :tag "Save part"
notmuch-show-part-button-save)
 (const :tag "View part"
notmuch-show-part-button-view)
 (const :tag "View interactively"
notmuch-show-part-button-interactively-view)))


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

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

+1

Tomi


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

2012-01-16 Thread Austin Clements
Quoth David Edmondson on Jan 16 at  9:12 am:
> On Sat, 14 Jan 2012 15:40:26 -0800, Jameson Graef Rollins  finestructure.net> 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, ) == 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.

Sorry, I'm confused.  Are you saying deleted;spam should or should not
be the default?


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

2012-01-16 Thread Jameson Graef Rollins
On Mon, 16 Jan 2012 15:18:18 -0700, Jeremy Nickurak  wrote:
> 1) If no exclude options are in the config file, none should be used.
> 2) On notmuch setup, "deleted" and "spam" should be added to .notmuch-config

That's correct.

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


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

2012-01-16 Thread Austin Clements
LGTM.

Quoth Pieter Praet on Jan 16 at 11:38 am:
> - Add `notmuch-send' to the `message' group, as per Austin's
>   recommendation [1].

This is actually the reverse of what I was suggesting (though is also
reasonable).  Since notmuch uses message-mode, I was saying that the
notmuch group (or the notmuch-send group) should link to the message
group.  That way, if you customize-group notmuch, you get all of the
options that affect notmuch, even those that aren't strictly notmuch
variables.


[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



[PATCH v2] Make buttons for attachments allow viewing as well as saving

2012-01-16 Thread Jameson Graef Rollins
On Mon, 16 Jan 2012 21:38:30 +, Mark Walters  
wrote:
> Define a keymap for attachment buttons to allow multiple actions.

Thanks, Mark.  This new patch works great.  I'm still not quite sure why
it wasn't working for me before, but this patch works great.

+1

We'll need to add a ":group notmuch-show" if Pieter's defcustom
groupings patch does in first, but that's minor.

Thanks for the nice functionality!

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


[PATCH v2] Document external dependencies in the test suite

2012-01-16 Thread Ethan Glasser-Camp
From: Ethan Glasser-Camp 

Add an explicit note to the README explaining what programs are
necessary and the perhaps-surprising behavior of skipping tests if
they aren't present.

Signed-off-by: Ethan Glasser-Camp 
---

v2 suggested by Dmitry Kurochkin: document all the dependencies.

 test/README |   13 +
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/test/README b/test/README
index bde6db0..44ff653 100644
--- a/test/README
+++ b/test/README
@@ -6,6 +6,19 @@ When fixing bugs or enhancing notmuch, you are strongly 
encouraged to
 add tests in this directory to cover what you are trying to fix or
 enhance.

+Prerequisites
+-
+Some tests require external dependencies to run. Without them, they
+will be skipped, or (rarely) marked failed. Please install these, so
+that you know if you break anything.
+
+  - dtach(1)
+  - emacs(1)
+  - emacsclient(1)
+  - gdb(1)
+  - gpg(1)
+  - python(1)
+
 Running Tests
 -
 The easiest way to run tests is to say "make test", (or simply run the
-- 
1.7.5.4



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

-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120116/029db09b/attachment-0001.pgp>


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

2012-01-16 Thread Daniel Schoepe
On Mon, 16 Jan 2012 11:33:59 +, David Edmondson  wrote:
> Daniel, will you include this in your next version? (I'd like to mark it
> 'obsolete'.)

Yes, it sounds like a great improvement.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120116/f3717455/attachment.pgp>


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

2012-01-16 Thread Pieter Praet
On Mon, 16 Jan 2012 11:22:27 +, David Edmondson  wrote:
> 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?

Yup, they do;  But I'm still chillin' with v23.3.1.

No problem.  For the time being, I'll just make do with
reverting 4b256ff5 on my local branch.


Peace

-- 
Pieter


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

2012-01-16 Thread Pieter Praet
On Mon, 16 Jan 2012 12:28:06 +0100, Pieter Praet  wrote:
> On Mon, 16 Jan 2012 11:06:25 +, David Edmondson  wrote:
> > 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'. [...]
> 
> Hmmm, true.  The path of least resistance is elusive.
> 
> > [...] I suppose
> > that I can replace my binding for `notmuch' with one for
> > `notmuch-hello'.
> > 
> 
> Perhaps we could use `ido-completion-help', like Org-mode does with
> `org-iswitchb' ?  OTOH, that would require an extra [RET].  Bah...
> 

s/ido-completion-help/ido-completing-read

> > 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.
> 
> 
> Peace
> 
> -- 
> Pieter


Peace

-- 
Pieter


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

2012-01-16 Thread Pieter Praet
On Mon, 16 Jan 2012 11:06:25 +, David Edmondson  wrote:
> 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'. [...]

Hmmm, true.  The path of least resistance is elusive.

> [...] I suppose
> that I can replace my binding for `notmuch' with one for
> `notmuch-hello'.
> 

Perhaps we could use `ido-completion-help', like Org-mode does with
`org-iswitchb' ?  OTOH, that would require an extra [RET].  Bah...

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


Peace

-- 
Pieter


[PATCH 1/4] emacs: unify search mechanisms

2012-01-16 Thread Jani Nikula
On Mon, 16 Jan 2012 15:39:14 +0400, Dmitry Kurochkin  wrote:
> On Mon, 16 Jan 2012 11:35:37 +, David Edmondson  wrote:
> > On Sun, 25 Dec 2011 08:14:52 +0400, Dmitry Kurochkin  > gmail.com> 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?
> 
> Right.  We will just need to fix the 's' key binding.  Looking forward
> for that.

Isn't (something like) this still needed to merge the search histories:

id:"1324698436-8532-1-git-send-email-dmitry.kurochkin at gmail.com"


Jani.


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

2012-01-16 Thread Pieter Praet
On Tue, 27 Dec 2011 16:47:14 +, David Edmondson  wrote:
> The tags were coloured using text properties. Unfortunately that text
> (the header line) also has an overlay, which overrides the text
> properties. There's not point in applying text properties that will
> never be seen.
> ---
>  emacs/notmuch-show.el |8 ++--
>  1 files changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 8c9d846..24f0b40 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -221,10 +221,7 @@ indentation."
>  (goto-char (notmuch-show-message-top))
>  (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
>   (let ((inhibit-read-only t))
> -   (replace-match (concat "("
> -  (propertize (mapconcat 'identity tags " ")
> -  'face 'notmuch-tag-face)
> -  ")"))
> +   (replace-match (concat "(" (mapconcat 'identity tags " ") ")"))
>  
>  (defun notmuch-show-clean-address (address)
>"Try to clean a single email ADDRESS for display.  Return
> @@ -278,8 +275,7 @@ message at DEPTH in the current thread."
>   " ("
>   date
>   ") ("
> - (propertize (mapconcat 'identity tags " ")
> - 'face 'notmuch-tag-face)
> + (mapconcat 'identity tags " ")
>   ")\n")
>  (overlay-put (make-overlay start (point)) 'face 
> 'notmuch-message-summary-face)))
>  
> -- 
> 1.7.7.3

Alas, those text properties actually *were* effective (and I liked them :)

- Before: http://i.imgur.com/Ipxnm.png
- After:  http://i.imgur.com/XcaaF.png


Peace

-- 
Pieter


[PATCH] Document the dependency on dtach in the test suite

2012-01-16 Thread Ethan Glasser-Camp
From: Ethan Glasser-Camp 

dtach (and before that, screen) are used to run emacs with more
verisimilitude, but this is only mentioned in the NEWS. Mention this
in the test/README file, to make it easier to find out why a bunch of
tests are failing/skipped.

Signed-off-by: Ethan Glasser-Camp 
---

Just cutting my teeth on the codebase, and it took me a little while
to figure this out, so I thought I'd document it.

 test/README |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/test/README b/test/README
index bde6db0..29afb3b 100644
--- a/test/README
+++ b/test/README
@@ -6,6 +6,11 @@ When fixing bugs or enhancing notmuch, you are strongly 
encouraged to
 add tests in this directory to cover what you are trying to fix or
 enhance.

+Prerequisites
+-
+emacs is run within dtach, so you need to have that installed to run
+emacs tests (or crypto tests, which rely on emacs to run).
+
 Running Tests
 -
 The easiest way to run tests is to say "make test", (or simply run the
-- 
1.7.5.4



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

2012-01-16 Thread Daniel Schoepe
On Mon, 16 Jan 2012 10:59:39 +, David Edmondson  wrote:
> 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?

Yes, I plan to do that (I know I already said that in December) and
already have a partially rebased version. I hope I will get to finish it
up and incorporate the suggestions from this thread soon.

Cheers,
Daniel

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


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

2012-01-16 Thread Pieter Praet
On Mon, 16 Jan 2012 10:56:03 +, David Edmondson  wrote:
> Given the discussion that followed this patch I'd like to mark it as
> 'obsolete'.
> 
> Any objections?

None whatsoever :)


Peace

-- 
Pieter


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

2012-01-16 Thread Pieter Praet
Less code, same results, without sacrificing readability.

---

v2: Fixed indentation oversight @ `notmuch-hello-insert-tags'.

 emacs/notmuch-address.el |6 +++---
 emacs/notmuch-hello.el   |   22 +++---
 emacs/notmuch-show.el|   12 ++--
 emacs/notmuch.el |8 
 4 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 8eba7a0..d72b169 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -37,9 +37,9 @@ line."
 (defvar notmuch-address-history nil)

 (defun notmuch-address-message-insinuate ()
-  (if (not (memq notmuch-address-message-alist-member 
message-completion-alist))
-  (setq message-completion-alist
-   (push notmuch-address-message-alist-member 
message-completion-alist
+  (unless (memq notmuch-address-message-alist-member message-completion-alist)
+(setq message-completion-alist
+ (push notmuch-address-message-alist-member 
message-completion-alist

 (defun notmuch-address-options (original)
   (process-lines notmuch-address-command original))
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 02017ce..8aa2ad5 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -317,8 +317,8 @@ should be. Returns a cons cell `(tags-per-line width)'."

 ;; If the last line was not full (and hence did not include a
 ;; carriage return), insert one now.
-(if (not (eq (% count tags-per-line) 0))
-   (widget-insert "\n"))
+(unless (eq (% count tags-per-line) 0)
+  (widget-insert "\n"))
 found-target-pos))

 (defun notmuch-hello-goto-search ()
@@ -401,7 +401,7 @@ Complete list of currently available key bindings:

   ; Jump through a hoop to get this value from the deprecated variable
   ; name (`notmuch-folders') or from the default value.
-  (if (not notmuch-saved-searches)
+  (unless notmuch-saved-searches
 (setq notmuch-saved-searches (notmuch-saved-searches)))

   (if no-display
@@ -567,18 +567,18 @@ Complete list of currently available key bindings:
  (widget-insert "\n\n")
  (let ((start (point)))
(setq found-target-pos (notmuch-hello-insert-tags alltags-alist 
widest target))
-   (if (not final-target-pos)
-   (setq final-target-pos found-target-pos))
+   (unless final-target-pos
+ (setq final-target-pos found-target-pos))
(indent-rigidly start (point) notmuch-hello-indent)))

(widget-insert "\n")

-   (if (not notmuch-show-all-tags-list)
-   (widget-create 'push-button
-  :notify (lambda (widget  ignore)
-(setq notmuch-show-all-tags-list t)
-(notmuch-hello-update))
-  "Show all tags")))
+   (unless notmuch-show-all-tags-list
+ (widget-create 'push-button
+:notify (lambda (widget  ignore)
+  (setq notmuch-show-all-tags-list t)
+  (notmuch-hello-update))
+"Show all tags")))

   (let ((start (point)))
(widget-insert "\n\n")
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 1a250a3..72bf888 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -656,8 +656,8 @@ current buffer, if possible."
   ;; part, so we make sure that we're down at the end.
   (goto-char (point-max))
   ;; Ensure that the part ends with a carriage return.
-  (if (not (bolp))
-  (insert "\n")))
+  (unless (bolp)
+(insert "\n")))

 (defun notmuch-show-insert-body (msg body depth)
   "Insert the body BODY at depth DEPTH in the current thread."
@@ -737,8 +737,8 @@ current buffer, if possible."
 (setq body-start (point-marker))
 (notmuch-show-insert-body msg (plist-get msg :body) depth)
 ;; Ensure that the body ends with a newline.
-(if (not (bolp))
-   (insert "\n"))
+(unless (bolp)
+  (insert "\n"))
 (setq body-end (point-marker))
 (setq content-end (point-marker))

@@ -879,8 +879,8 @@ buffer."
   (run-hooks 'notmuch-show-hook))

 ;; Move straight to the first open message
-(if (not (notmuch-show-message-visible-p))
-   (notmuch-show-next-open-message))
+(unless (notmuch-show-message-visible-p)
+  (notmuch-show-next-open-message))

 ;; Set the header line to the subject of the first open message.
 (setq header-line-format (notmuch-show-strip-re 
(notmuch-show-get-subject)))
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index ef4dcc7..c5fcc80 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -643,8 +643,8 @@ This function advances the next thread when finished."
(if notmuch-search-process-filter-data
(insert (concat "Error: Unexpected output from 
notmuch search:\n" notmuch-search-process-filter-data)))
 

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

2012-01-16 Thread David Bremner
On Mon, 16 Jan 2012 15:50:45 +, David Edmondson  wrote:
> 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'?

Yeah, I was thinking the same. Go for it.

d


[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.)
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120116/72e6a33d/attachment.pgp>


[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.)
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120116/23d8da12/attachment.pgp>


[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).
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120116/b16fd3ac/attachment.pgp>


[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  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.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120116/874115a1/attachment.pgp>


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

2012-01-16 Thread Pieter Praet
CLisp'ier version of `notmuch-cycle-notmuch-buffers', merged into `notmuch',
eliminating the need to hog yet another keybind.

FYI: causes 2 compile warnings due to requiring the cl package at runtime.
---
 emacs/notmuch.el |   34 --
 1 files changed, 8 insertions(+), 26 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index ef4dcc7..60ab0b2 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -1067,7 +1067,14 @@ 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 (remove-if-not #'notmuch-interesting-buffer 
(buffer-list)))
+(next-buffer (first (member-if-not #'(lambda (b) (eq old-buffer b)) 
interesting-buffers
+(if next-buffer
+   (progn
+ (switch-to-buffer next-buffer)
+ (bury-buffer old-buffer))
+  (notmuch-hello

 (defun notmuch-interesting-buffer (b)
   "Is the current buffer of interest to a notmuch user?"
@@ -1078,31 +1085,6 @@ current search results AND that are tagged with the 
given tag."
   message-mode

 ;;;###autoload
-(defun notmuch-cycle-notmuch-buffers ()
-  "Cycle through any existing notmuch buffers (search, show or hello).
-
-If the current buffer is the only notmuch buffer, bury it. If no
-notmuch buffers exist, run `notmuch'."
-  (interactive)
-
-  (let (start first)
-;; If the current buffer is a notmuch buffer, remember it and then
-;; bury it.
-(when (notmuch-interesting-buffer (current-buffer))
-  (setq start (current-buffer))
-  (bury-buffer))
-
-;; Find the first notmuch buffer.
-(setq first (loop for buffer in (buffer-list)
-if (notmuch-interesting-buffer buffer)
-return buffer))
-
-(if first
-   ;; If the first one we found is any other than the starting
-   ;; buffer, switch to it.
-   (unless (eq first start)
- (switch-to-buffer first))
-  (notmuch

 (setq mail-user-agent 'notmuch-user-agent)

-- 
1.7.8.1



[PATCH] test: don't bail out of `run_emacs' too early when missing prereqs

2012-01-16 Thread Pieter Praet
On Sun, 15 Jan 2012 17:56:37 +0400, Dmitry Kurochkin  wrote:
> On Sat, 14 Jan 2012 10:07:41 +0100, Pieter Praet  wrote:
> > On Thu, 12 Jan 2012 21:34:29 +0400, Dmitry Kurochkin  > gmail.com> wrote:
> > > On Thu, 12 Jan 2012 18:16:59 +0100, Pieter Praet  
> > > wrote:
> > > > When running the Emacs tests in verbose mode, only the first missing
> > > > prereq is reported because the `run_emacs' function is short-circuited
> > > > early:
> > > > 
> > > >   #+begin_example
> > > > emacs: Testing emacs interface
> > > >  missing prerequisites: [0]  emacs(1)
> > > >  skipping test: [0]  Basic notmuch-hello view in emacs
> > > >  SKIP   [0]  Basic notmuch-hello view in emacs
> > > >   #+end_example
> > > > 
> > > > This can lead to situations reminiscent of "dependency hell", so instead
> > > > of returning based on each individual `test_require_external_prereq's 
> > > > exit
> > > > status, we now do so by checking 
> > > > $test_subtest_missing_external_prereqs_:
> > > > 
> > > >   #+begin_example
> > > > emacs: Testing emacs interface
> > > >  missing prerequisites: [0]  dtach(1) emacs(1) emacsclient(1)
> > > >  skipping test: [0]  Basic notmuch-hello view in emacs
> > > >  SKIP   [0]  Basic notmuch-hello view in emacs
> > > >   #+end_example
> > > > 
> > > > Also add missing prereq for dtach(1).
> > > > 
> > > > ---
> > > >  test/test-lib.sh |6 --
> > > >  1 files changed, 4 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/test/test-lib.sh b/test/test-lib.sh
> > > > index 82767c0..6ec3882 100644
> > > > --- a/test/test-lib.sh
> > > > +++ b/test/test-lib.sh
> > > > @@ -907,8 +907,10 @@ EOF
> > > >  
> > > >  test_emacs () {
> > > > # test dependencies beforehand to avoid the waiting loop below
> > > > -   test_require_external_prereq emacs || return
> > > > -   test_require_external_prereq emacsclient || return
> > > > +   test_require_external_prereq dtach
> > > > +   test_require_external_prereq emacs
> > > > +   test_require_external_prereq emacsclient
> > > > +   test -z "$test_subtest_missing_external_prereqs_" || return
> > > 
> > > There may be other missing dependencies before test_emacs() is called
> > > and $test_subtest_missing_external_prereqs_ would not be blank.  [...]
> > 
> > True, hadn't though of that...
> > 
> > > [...] Also, I
> > > would like to keep the number of functions that use
> > > $test_subtest_missing_external_prereqs_ minimal.  [...]
> > 
> > Could you elaborate on that?
> > 
> 
> This variable is supposed to be internal.  I would like to be able to
> change it's meaning or replace it with something better with minimal
> changes in the other code.  So I prefer it to be used only by few
> "low-level" dependency functions.
> 

Ok, thanks!


> This is not some strict rule, in other situation I may agree that using
> $test_subtest_missing_external_prereqs_ directly is the best option.
> But in this case, introducing a local variable with clean and simple
> meaning is better IMO.
> 

Agreed.


> Regards,
>   Dmitry
> 
> > > [...] How about:
> > > 
> > >   missing_dependencies=
> > >   test_require_... dtach || missing_dependencies=1
> > >   test_require_... emacs || missing_dependencies=1
> > >   ...
> > >   test -z "$missing_dependencies" || return
> > > 
> > 
> > Agreed!  Patch follows.
> > 
> > > Regards,
> > >   Dmitry
> > > 
> > > >  
> > > > if [ -z "$EMACS_SERVER" ]; then
> > > > server_name="notmuch-test-suite-$$"
> > > > -- 
> > > > 1.7.8.1
> > > > 
> > 
> > 
> > Peace
> > 
> > -- 
> > Pieter


Peace

-- 
Pieter


[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.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120116/492672ef/attachment.pgp>


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

2012-01-16 Thread Pieter Praet
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
- External Commands
- Appearance

As an added benefit, defcustom keyword args are now consistently
ordered as they appear @ defcustom's docstring (OCD much?).

Proper defgroup docstrings and various other improvements
by courtesy of Austin Clements.

---

ChangeLog:

v2
- `notmuch-crypto-part-header' was added post-v1 (430fb27) : move to
  `notmuch-crypto' and `notmuch-appearance'.
- `notmuch-crypto-process-mime' was erroneously added to `notmuch-hello'
  in v1 : move to `notmuch-crypto'.
- `notmuch-hello-mode-hook' was added post-v1 (db352df) : move to
  `notmuch-hello' and `notmuch-hooks'.
- `notmuch-hello-refresh-hook' was added post-v1 (4e2fe89) : move to
  `notmuch-hello' and `notmuch-hooks'.
- `notmuch-saved-search-sort-function' was added post-v1 (e312705) :
  move to `notmuch-hello'.
- `notmuch-show-indent-messages-width' was added post-v1 (46eb1c1,
  74bced6) : move to `notmuch-show' and `notmuch-appearance'.
- ... and reorder all defcustom keyword args to match their order of
  appearance in `defcustom's docstring.

v3
- Add some really bad docstrings to the subgroup definitions.

v4
- Replace horrible docstrings with Austin's suggestions [1].
- Remove redundant ":tag" attributes from group definitions,
  as per Austin's recommendation [1].
- Add `notmuch-send' to the `message' group, as per Austin's
  recommendation [1].
- `notmuch-show-logo' was added to `notmuch-appearance' in v1, but
  doesn't really belong there : remove from `notmuch-appearance'.
- `notmuch-show-indent-messages-width' was added to `notmuch-appearance'
  in v2, but doesn't really belong there : remove from `notmuch-appearance'.
- `notmuch-appearance' now only contains face definitions, and still
  lacks a proper docstring : rename to `notmuch-faces' and set docstring.
- `notmuch-hooks', `notmuch-external' : set proper docstrings.
- `notmuch-show-hook' was only added to `notmuch-show' in v1 :
  add to `notmuch-hooks' as well.
- `notmuch-show-insert-text/plain-hook' was only added to `notmuch-show'
  in v1 : add to group `notmuch-hooks' as well.

[1] id:"20120114180828.GD1801 at mit.edu"


 emacs/notmuch-address.el |3 ++-
 emacs/notmuch-crypto.el  |   22 ++
 emacs/notmuch-hello.el   |   33 ++---
 emacs/notmuch-lib.el |   37 +++--
 emacs/notmuch-maildir-fcc.el |6 +++---
 emacs/notmuch-message.el |2 +-
 emacs/notmuch-mua.el |   21 +++--
 emacs/notmuch-show.el|   34 ++
 emacs/notmuch.el |   35 ++-
 9 files changed, 124 insertions(+), 69 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 8eba7a0..2e8b840 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -28,7 +28,8 @@
 single argument and output a list of possible matches, one per
 line."
   :type 'string
-  :group 'notmuch)
+  :group 'notmuch-send
+  :group 'notmuch-external)

 (defvar notmuch-address-message-alist-member
   
'("^\\(Resent-\\)?\\(To\\|B?Cc\\|Reply-To\\|From\\|Mail-Followup-To\\|Mail-Copies-To\\):"
diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index ac30098..80ac350 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -34,38 +34,44 @@ The effect of setting this variable can be seen temporarily 
by
 providing a prefix when viewing a signed or encrypted message, or
 by providing a prefix when reloading the message in notmuch-show
 mode."
-  :group 'notmuch
-  :type 'boolean)
+  :type 'boolean
+  :group 'notmuch-crypto)

 (defface notmuch-crypto-part-header
   '((t (:foreground "blue")))
   "Face used for crypto parts headers."
-  :group 'notmuch)
+  :group 'notmuch-crypto
+  :group 'notmuch-faces)

 (defface notmuch-crypto-signature-good
   '((t (:background "green" :foreground "black")))
   "Face used for good signatures."
-  :group 'notmuch)
+  :group 'notmuch-crypto
+  :group 'notmuch-faces)

 (defface notmuch-crypto-signature-good-key
   '((t (:background "orange" :foreground "black")))
   "Face used for good signatures."
-  :group 'notmuch)
+  :group 'notmuch-crypto
+  :group 'notmuch-faces)

 (defface notmuch-crypto-signature-bad
   '((t (:background "red" :foreground "black")))
   "Face used for bad signatures."
-  :group 'notmuch)
+  :group 'notmuch-crypto
+  :group 'notmuch-faces)

 (defface notmuch-crypto-signature-unknown
   '((t (:background "red" :foreground "black")))
   "Face used for signatures of unknown status."
-  :group 'notmuch)
+  :group 'notmuch-crypto
+  :group 'notmuch-faces)

 (defface notmuch-crypto-decryption
   '((t (:background "purple" :foreground "black")))
   "Face used for encryption/decryption status messages."
-  

[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?
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120116/72b34e3c/attachment.pgp>


[PATCH v3 0/2] Automatic tag-based exclusion

2012-01-16 Thread Jameson Graef Rollins
On Sat, 14 Jan 2012 19:17:32 -0500, Austin Clements  wrote:
> This fixes the symbol visibility warning Jamie pointed out.

LGTM.  I'm using this now and it works like a charm.

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


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

2012-01-16 Thread Pieter Praet
On Sat, 14 Jan 2012 13:08:28 -0500, Austin Clements  wrote:
> Quoth Pieter Praet on Jan 14 at 10:04 am:
> > 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
> > - External Commands
> > - Appearance
> > 
> > As an added benefit, defcustom keyword args are now consistently
> > in order of appearance @ defcustom's docstring (OCD much?).
> 
> Thanks for doing this. [...]

You're very welcome!

> [...] I recently went into customize-group notmuch
> and was overwhelmed by the pile of options presented.
> 

Same here :)

> > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> > index 0f856bf..f6f48e9 100644
> > --- a/emacs/notmuch-lib.el
> > +++ b/emacs/notmuch-lib.el
> > @@ -28,17 +28,58 @@
> >"Notmuch mail reader for Emacs."
> >:group 'mail)
> >  
> 
> Group docstrings aren't generally of the form "Options concerning
> ..."; they just jump into what they concern.  E.g.,
> 
> Convenience : Convenience features for faster editing.
> 
> Calendar Hooks : Calendar hooks.
> 

Couldn't agree more!  I must admit, I was rather apathetic at the
time due to a lack of sleep.

> Also, all but one of the tags you give the groups would be
> automatically derived by Emacs, so you can remove those.
> 

How very convenient.  Removed 'em all: the one @ `notmuch-external'
was pretty pointless as well.

> > +(defgroup notmuch-hello nil
> > +  "Options concerning `notmuch-hello-mode'."
> > +  :tag "Notmuch Hello"
> > +  :group 'notmuch)
> 
> Perhaps "Overview of saved searches, tags, etc."
> 
> > +
> > +(defgroup notmuch-search nil
> > +  "Options concerning `notmuch-search-mode'."
> > +  :tag "Notmuch Search"
> > +  :group 'notmuch)
> 
> "Searching and sorting mail"?
> 
> > +
> > +(defgroup notmuch-show nil
> > +  "Options concerning `notmuch-show-mode'."
> > +  :tag "Notmuch Show"
> > +  :group 'notmuch)
> 
> "Showing messages and threads"?
> 
> > +
> > +(defgroup notmuch-send nil
> > +  "Options concerning the sending of messages."
> > +  :tag "Notmuch Send"
> > +  :group 'notmuch)
> 
> "Sending messages from Notmuch"?
> 
> We should probably link to the 'message group, perhaps by adding
>   :link '(custom-group-link message)
> here or maybe to the notmuch group itself.  Unfortunately, I don't
> think you can actually add a group to another group after it's been
> defined (though I could be wrong).
> 

Agreed.  I've added `notmuch-send' to the `message' group.

> > +
> > +(defgroup notmuch-crypto nil
> > +  "Options concerning the processing and fontification of
> > +cryptographic MIME parts in `notmuch-show-mode'."
> > +  :tag "Notmuch Crypto"
> > +  :group 'notmuch)
> 
> "Processing and display of cryptographic MIME parts"?  (You also don't
> want the docstring to be too long, given how it's displayed.)
> 
> > +
> > +(defgroup notmuch-hooks nil
> > +  "Run custom code on well-defined occasions."
> > +  :tag "Notmuch Hooks"
> > +  :group 'notmuch)
> > +
> > +(defgroup notmuch-external nil
> > +  "Run more custom code on different well-defined occasions."
> > +  :tag "Notmuch External Commands"
> > +  :group 'notmuch)
> 
> Oof!  It's okay to be a little redundant in the docstring.  Core Emacs
> options do it.  "External commands"?
> 
> > +
> > +(defgroup notmuch-appearance nil
> > +  "Options concerning how Notmuch looks."
> > +  :tag "Notmuch Appearance"
> > +  :group 'notmuch)
> 
> "How Notmuch looks"?
> 
> I worry that notmuch-appearance is a catch-all that most options
> arguably fit in to.  In particular, some notmuch-show options are also
> in this group and some aren't and it's not clear to me what the rule
> is.
> 
> Perhaps this should be notmuch-faces and limited to just faces (and
> maybe options that aren't technically faces but that affect face
> selection)?  Then the grouping rule would be obvious, like it is for
> all of the other groups.

That was my original intention, but due to `notmuch-hello-logo-background',
I decided to dump `notmuch-show-logo' in there as well, necessitating a
broader designation.  Fixed!

Patch follows.


Peace

-- 
Pieter


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

2012-01-16 Thread Jameson Graef Rollins
On Mon, 16 Jan 2012 09:12:38 +, David Edmondson  wrote:
> 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.

Yes, I agree completely.  The CLI does not, and should not, exclude
anything by default.  I only meant that the patch adds the configuration
variable by default, which seems ok to me.

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


[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'.)
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120116/4b6f40fd/attachment-0001.pgp>


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

2012-01-16 Thread Jameson Graef Rollins
On Mon, 16 Jan 2012 22:06:15 +0400, Dmitry Kurochkin  wrote:
> 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.

Yeah, this has bit me too much recently.

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

My first reaction to this proposal was "yuck".  Then I realized it might
just provide that extra split second to think about where you actually
want the reply to go, which might be a good thing.

Otherwise I could live with any option.  I can get used to the new
bindings.

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


[PATCH 1/1] Make buttons for attachments allow viewing as well as saving

2012-01-16 Thread Jameson Graef Rollins
On Sun, 15 Jan 2012 12:16:36 +, Mark Walters  
wrote:
> Define a keymap for attachment buttons to allow multiple actions.
> Define 3 possible actions:
> save attachment: exactly as currently,
> view attachment: uses mailcap entry,
> view attachment with user chosen program

Great improvement, Mark!  Thanks for this.  I've been wanting this kind
of functionality for a while, actually, and this is a really great
implementation.  It works like a charm, and the code looks good to me,
modulo a couple small comments below.

> Keymap on a button is: s for save, v for view and o for view with
> other program. Default (i.e. enter or mouse button) is save but is
> easily configurable e.g. set to view with
> (setq notmuch-show-part-button-default-action 'notmuch-show-part-view-action)

Actually, this should really be a defcustom.  Maybe something like this:

(defcustom notmuch-show-part-button-default-action 
'notmuch-show-part-button-save
  "Default part header button action (on ENTER or mouse click)."
  :group 'notmuch
  :type '(choice (function :tag "Save part"
  :value notmuch-show-part-button-save)
(function :tag "View part"
  :value notmuch-show-part-button-view)
(function :tag "View interactively"
  :value notmuch-show-part-button-interactively-view))

Unfortunately this isn't quite working right, since it's not setting the
default properly, but if someone can help me figure out what I'm doing
wrong, I think this is at least the right idea.

> One implementation detail: the view attachment function forces all
> attachments to be "displayed" using mailcap even if emacs could
> display them itself. Thus, for example, text/html appears in a browser
> and text/plain asks whether to save (on a standard debian setup)

I think this is good.

> +(defvar notmuch-show-part-button-default-action 
> 'notmuch-show-part-save-action) 

There's a white space at the end of this line, which produces the
following git warning:

  Applying: Make buttons for attachments allow viewing as well as saving
  /home/jrollins/src/notmuch/git/.git/rebase-apply/patch:96: trailing 
whitespace.
  (defvar notmuch-show-part-button-default-action 
'notmuch-show-part-save-action)
  warning: 1 line adds whitespace errors.

So if you go with (an improved version of) my defcustom suggestion above
you can kill two birds with one stone:

-(defvar notmuch-show-part-button-default-action 
'notmuch-show-part-save-action) 
+(defcustom notmuch-show-part-button-default-action '(notmuch-show-part-but=
ton-save)
+  "Default part header button action (on ENTER or mouse click)."
+  :group 'notmuch
+  :type '(choice (function :tag "Save part"
+  :value notmuch-show-part-button-save)
+(function :tag "View part"
+  :value notmuch-show-part-button-view)
+(function :tag "View interactively"
+  :value notmuch-show-part-button-interactively-view))

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


[PATCH] test: cli: getting/setting/removing config values

2012-01-16 Thread Pieter Praet
On Sat, 14 Jan 2012 08:16:30 -0400, David Bremner  wrote:
> On Sat, 14 Jan 2012 09:57:56 +0100, Pieter Praet  wrote:
> > Full test coverage for getting, setting and removing options in
> > notmuch(1)'s config file ($NOTMUCH_CONFIG or $HOME/.notmuch-config).
> > 
> > ---
> > +
> > +# FIXME: Not the most robust nor portable solution here...
> > +# Especially `hostname --domain' may have unwanted effects on
> > +# some platforms, e.g. setting your hostname to "--domain" ;)
> > +fallback_name="$(grep $(id -un) /etc/passwd | cut -d ":" -f 5 | cut -d "," 
> > -f 1)"
> > +fallback_email="$(id -un)@$(hostname).$(hostname --domain)"
> 
> I'm not sure how portable it is, but maybe dnsdomainname would at least
> have better failure modes.
> 

Hmmm, `dnsdomainname' returns "(none)" here;  Does it work for you?

Running `domainname' instead seems to do the right thing though...


It would probably be safest to simply mirror how it's done @
notmuch-config.c:313, but that seems rather excessive.

> I also wondered about using getent instead of grep.
> 

Agreed, much safer;  `grep' might return multiple results.

> d

How about this? :

  #+begin_src sh
fallback_name="$(getent passwd ${USER} | cut -d ":" -f 5 | cut -d "," -f 1)"
test -n "${EMAIL}" \
&& fallback_email="${EMAIL}" \
|| fallback_email="${USER}@$(hostname).$(domainname)"
  #+end_src


Peace

-- 
Pieter


[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).
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120116/2ee82c6f/attachment.pgp>


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

2012-01-16 Thread Jameson Graef Rollins
On Mon, 16 Jan 2012 08:39:30 +, David Edmondson  wrote:
> 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.

Agreed.  I think it's generally better to get the functionality we want
in the CLI if we can, so that all UIs benefit.  Emacs is still certainly
the most actively developed UI, and it's gotten quite complicated with
quite a few special features, but to the extent that we can put
new functionality into the CLI we should.

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


[PATCH] emacs: breakout notmuch-show-advance functionality from notmuch-show-advance-and-archive

2012-01-16 Thread Pieter Praet
On Thu, 12 Jan 2012 18:04:10 +0100, Pieter Praet  wrote:
> On Wed, 16 Nov 2011 23:47:53 +0100, Pieter Praet  wrote:
> > On Sun, 13 Nov 2011 13:16:48 -0800, Jameson Graef Rollins  > finestructure.net> wrote:
> > > This patch breaks out much of the functionality of
> > > notmuch-show-advance-and-archive into a new function:
> > > notmuch-show-advance.  This new function does all the advancing
> > > through a show buffer that notmuch-show-advance-and-archive did,
> > > without all the invasive thread archiving.  The return value of
> > > notmuch-show-advance is nil if the bottom of the thread is not
> > > reached, and t if it is.
> > > 
> > > notmuch-show-advance-and-archive is modified to just call
> > > notmuch-show-advance, and then call notmuch-show-archive-thread if the
> > > return value is true.  In this way the previous functionality of
> > > notmuch-show-advance-and-archive is preserved.
> > > 
> > > This provides a way for people to rebind the space bar to a more sane
> > > function if they don't like the default behavior.
> > > ---
> > >  emacs/notmuch-show.el |   38 +++---
> > >  1 files changed, 23 insertions(+), 15 deletions(-)
> > > 
> > > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> > > index d5c95d8..a7f3263 100644
> > > --- a/emacs/notmuch-show.el
> > > +++ b/emacs/notmuch-show.el
> > > @@ -1135,26 +1135,18 @@ All currently available key bindings:
> > >  
> > >  ;; Commands typically bound to keys.
> > >  
> > > -(defun notmuch-show-advance-and-archive ()
> > > -  "Advance through thread and archive.
> > > -
> > > -This command is intended to be one of the simplest ways to
> > > -process a thread of email. It does the following:
> > > +(defun notmuch-show-advance ()
> > > +  "Advance through thread.
> > >  
> > >  If the current message in the thread is not yet fully visible,
> > >  scroll by a near screenful to read more of the message.
> > >  
> > >  Otherwise, (the end of the current message is already within the
> > > -current window), advance to the next open message.
> > > -
> > > -Finally, if there is no further message to advance to, and this
> > > -last message is already read, then archive the entire current
> > > -thread, (remove the \"inbox\" tag from each message). Also kill
> > > -this buffer, and display the next thread from the search from
> > > -which this thread was originally shown."
> > > +current window), advance to the next open message."
> > >(interactive)
> > >(let* ((end-of-this-message (notmuch-show-message-bottom))
> > > -  (visible-end-of-this-message (1- end-of-this-message)))
> > > +  (visible-end-of-this-message (1- end-of-this-message))
> > > +  (ret nil))
> > >  (while (invisible-p visible-end-of-this-message)
> > >(setq visible-end-of-this-message
> > >   (previous-single-char-property-change visible-end-of-this-message
> > > @@ -1173,8 +1165,24 @@ which this thread was originally shown."
> > >(notmuch-show-next-open-message))
> > >  
> > >   (t
> > > -  ;; This is the last message - archive the thread.
> > > -  (notmuch-show-archive-thread)
> > > +  ;; This is the last message - change the return value
> > > +  (setq ret t)))
> > > +ret))
> > > +
> > > +(defun notmuch-show-advance-and-archive ()
> > > +  "Advance through thread and archive.
> > > +
> > > +This command is intended to be one of the simplest ways to
> > > +process a thread of email. It works exactly like
> > > +notmuch-show-advance, in that it scrolls through messages in a
> > > +show buffer, except that when it gets to the end of the buffer it
> > > +archives the entire current thread, (remove the \"inbox\" tag
> > > +from each message), kills the buffer, and displays the next
> > > +thread from the search from which this thread was originally
> > > +shown."
> > > +  (interactive)
> > > +  (if (notmuch-show-advance)
> > > +  (notmuch-show-archive-thread)))
> > >  
> > >  (defun notmuch-show-rewind ()
> > >"Backup through the thread, (reverse scrolling compared to 
> > > \\[notmuch-show-advance-and-archive]).
> > > -- 
> > > 1.7.7.1
> > > 
> > > ___
> > > notmuch mailing list
> > > notmuch at notmuchmail.org
> > > http://notmuchmail.org/mailman/listinfo/notmuch
> > 
> > 
> > Nice one!
> > 
> > Signed-off-by: Pieter Praet   ;)
> > 
> > 
> > This has also exposed a pre-existing bug: When the last visible message
> > is longer than a screenful and contains a *hidden* signature, you'll
> > never get to see the end of it.
> > 
> > The culprit is presumably seeking shelter from the flyswatter @
> > `notmuch-show-message-extent' or one of its relatives: Cc'ing our
> > resident invisibility guru.
> > 
> > 
> > Peace
> > 
> > -- 
> > Pieter
> 
> 
> FYI, this bug has been fixed by Aaron Ecay [1], commit 8392a7cc, which
> will be included in v0.12.  Not accompanied by a test, though, so keep
> an eye out for regressions.
> 
> Maybe the following 

[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?
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120116/945dde66/attachment.pgp>


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

2012-01-16 Thread Adam Wolfe Gordon
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, except that an additional quoted line is added to the end
of the reply message.  The test has been updated to reflect this.
---
 emacs/notmuch-lib.el |8 
 emacs/notmuch-mua.el |   95 -
 test/emacs   |1 +
 3 files changed, 71 insertions(+), 33 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 0f856bf..d4dd011 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -127,6 +127,14 @@ the user hasn't set this variable with the old or new 
value."
   (list 'when (< emacs-major-version 23)
form))

+(defun find-parts (parts 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)))
+
+
 ;; Compatibility functions for versions of emacs before emacs 23.
 ;;
 ;; Both functions here were copied from emacs 23 with the following copyright:
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index d8ab822..b03c62c 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -19,6 +19,7 @@
 ;;
 ;; Authors: David Edmondson 

+(require 'json)
 (require 'message)

 (require 'notmuch-lib)
@@ -71,50 +72,78 @@ list."
(push header message-hidden-headers)))
notmuch-mua-hidden-headers))

+(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)
+(insert "\n")
+(set-buffer-modified-p nil)))
+
+(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)
+
 (defun notmuch-mua-reply (query-string  sender reply-all)
-  (let (headers
-   body
-   (args '("reply")))
+  (let ((args '("reply" "--format=json"))
+   reply
+   body)
 (if notmuch-show-process-crypto
(setq args (append args '("--decrypt"
 (if reply-all
(setq args (append args '("--reply-to=all")))
   (setq args (append args '("--reply-to=sender"
 (setq args (append args (list query-string)))
-;; This make assumptions about the output of `notmuch reply', but
-;; really only that the headers come first followed by a blank
-;; line and then the body.
+;; Get the reply object as JSON, and parse it into an elisp object.
 (with-temp-buffer
   (apply 'call-process (append (list notmuch-command nil (list t t) nil) 
args))
   (goto-char (point-min))
-  (if (re-search-forward "^$" nil t)
- (save-excursion
-   (save-restriction
- (narrow-to-region (point-min) (point))
- (goto-char (point-min))
- (setq headers (mail-header-extract)
-  (forward-line 1)
-  (setq body (buffer-substring (point) (point-max
-;; If sender is non-nil, set the From: header to its value.
-(when sender
-  (mail-header-set 'from sender headers))
-(let
-   ;; Overlay the composition window on that being used to read
-   ;; the original message.
-   ((same-window-regexps '("\\*mail .*")))
-  (notmuch-mua-mail (mail-header 'to headers)
-   (mail-header 'subject headers)
-   (message-headers-to-generate headers t '(to subject
-;; insert the message body - but put it in front of the signature
-;; if one is present
-(goto-char (point-max))
-(if (re-search-backward message-signature-separator nil t)
+  (setq reply (aref (json-read) 0)))
+
+;; Start with the prelude, based on the headers of the original message.
+(let* ((original (cdr (assq 'original reply)))
+  (headers (cdr (assq 'headers (assq 'reply reply
+  (original-headers (cdr (assq 'headers original)))
+  (body-parts (cdr (assq 'body original)))
+  (plain-parts (find-parts body-parts "text/plain"))
+  (html-parts (find-parts body-parts "text/html")))
+
+  ;; If sender is non-nil, set the From: header to its value.
+  (when sender
+   (mail-header-set 'from sender headers))
+  (let
+ ;; Overlay the composition window on that being used to read
+ ;; the original message.
+ ((same-window-regexps '("\\*mail .*")))
+   (notmuch-mua-mail (mail-header 'to headers)

[PATCH v2 3/4] man: Update notmuch-reply man page for JSON format.

2012-01-16 Thread Adam Wolfe Gordon
---
 man/man1/notmuch-reply.1 |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/man/man1/notmuch-reply.1 b/man/man1/notmuch-reply.1
index 5160ece..ea7f87b 100644
--- a/man/man1/notmuch-reply.1
+++ b/man/man1/notmuch-reply.1
@@ -43,6 +43,11 @@ include
 .BR default
 Includes subject and quoted message body.
 .TP
+.BR json
+Produces JSON output containing headers for a reply message and the
+headers and text parts of the original message. This output can be used
+by a client to create a reply message intelligently.
+.TP
 .BR headers\-only
 Only produces In\-Reply\-To, References, To, Cc, and Bcc headers.
 .RE
-- 
1.7.5.4



[PATCH v2 2/4] reply: Add a JSON reply format.

2012-01-16 Thread Adam Wolfe Gordon
This new JSON format for replies includes headers generated for a reply
message as well as the headers and all text parts of the original message.
Using this data, a client can intelligently create a reply. For example,
the emacs client will be able to create replies with quoted HTML parts by
parsing the HTML parts using w3m.
---
 notmuch-reply.c |  313 ---
 1 files changed, 253 insertions(+), 60 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index da3acce..f5a5dcf 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -30,6 +30,15 @@ reply_headers_message_part (GMimeMessage *message);
 static void
 reply_part_content (GMimeObject *part);

+static void
+reply_part_start_json (GMimeObject *part, int *part_count);
+
+static void
+reply_part_content_json (GMimeObject *part);
+
+static void
+reply_part_end_json (GMimeObject *part);
+
 static const notmuch_show_format_t format_reply = {
 "",
"", NULL,
@@ -46,6 +55,22 @@ static const notmuch_show_format_t format_reply = {
 ""
 };

+static const notmuch_show_format_t format_json = {
+"",
+   "", NULL,
+   "", NULL, NULL, "",
+   "",
+   reply_part_start_json,
+   NULL,
+   NULL,
+   reply_part_content_json,
+   reply_part_end_json,
+   "",
+   "",
+   "", "",
+""
+};
+
 static void
 show_reply_headers (GMimeMessage *message)
 {
@@ -54,14 +79,14 @@ show_reply_headers (GMimeMessage *message)
 stream_stdout = g_mime_stream_file_new (stdout);
 if (stream_stdout) {
g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream_stdout), FALSE);
-   stream_filter = g_mime_stream_filter_new(stream_stdout);
+   stream_filter = g_mime_stream_filter_new (stream_stdout);
if (stream_filter) {
-   g_mime_stream_filter_add(GMIME_STREAM_FILTER(stream_filter),
-g_mime_filter_headers_new());
-   g_mime_object_write_to_stream(GMIME_OBJECT(message), 
stream_filter);
-   g_object_unref(stream_filter);
+   g_mime_stream_filter_add (GMIME_STREAM_FILTER(stream_filter),
+ g_mime_filter_headers_new());
+   g_mime_object_write_to_stream (GMIME_OBJECT(message), 
stream_filter);
+   g_object_unref (stream_filter);
}
-   g_object_unref(stream_stdout);
+   g_object_unref (stream_stdout);
 }
 }

@@ -86,6 +111,17 @@ reply_headers_message_part (GMimeMessage *message)
 printf ("> Date: %s\n", g_mime_message_get_date_as_string (message));
 }

+static notmuch_bool_t
+reply_check_part_type (GMimeObject *part, const char *type, const char 
*subtype,
+  const char *disposition)
+{
+GMimeContentType *content_type = g_mime_object_get_content_type 
(GMIME_OBJECT (part));
+GMimeContentDisposition *part_disposition = 
g_mime_object_get_content_disposition (part);
+
+return (g_mime_content_type_is_type (content_type, type, subtype) &&
+   (!part_disposition ||
+strcmp (part_disposition->disposition, disposition) == 0));
+}

 static void
 reply_part_content (GMimeObject *part)
@@ -108,32 +144,29 @@ reply_part_content (GMimeObject *part)
 {
GMimeStream *stream_stdout = NULL, *stream_filter = NULL;
GMimeDataWrapper *wrapper;
-   const char *charset;
-
-   charset = g_mime_object_get_content_type_parameter (part, "charset");
stream_stdout = g_mime_stream_file_new (stdout);
if (stream_stdout) {
g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream_stdout), 
FALSE);
-   stream_filter = g_mime_stream_filter_new(stream_stdout);
-   if (charset) {
-   g_mime_stream_filter_add(GMIME_STREAM_FILTER(stream_filter),
-g_mime_filter_charset_new(charset, 
"UTF-8"));
-   }
+   stream_filter = g_mime_stream_filter_new (stream_stdout);
+
+   const char *charset = g_mime_object_get_content_type_parameter 
(part, "charset");
+   if (charset)
+   g_mime_stream_filter_add(GMIME_STREAM_FILTER (stream_filter),
+g_mime_filter_charset_new (charset, 
"UTF-8"));
}
-   g_mime_stream_filter_add(GMIME_STREAM_FILTER(stream_filter),
-g_mime_filter_reply_new(TRUE));
+   g_mime_stream_filter_add (GMIME_STREAM_FILTER (stream_filter),
+ g_mime_filter_reply_new (TRUE));
wrapper = g_mime_part_get_content_object (GMIME_PART (part));
if (wrapper && stream_filter)
g_mime_data_wrapper_write_to_stream (wrapper, stream_filter);
if (stream_filter)
-   g_object_unref(stream_filter);
+   g_object_unref (stream_filter);
if (stream_stdout)
-   

[PATCH v2 1/4] test: Add broken test for the new JSON reply format.

2012-01-16 Thread Adam Wolfe Gordon
---
 test/multipart |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/test/multipart b/test/multipart
index f83526b..f5ebf04 100755
--- a/test/multipart
+++ b/test/multipart
@@ -589,6 +589,13 @@ Non-text part: text/html
 EOF
 test_expect_equal_file OUTPUT EXPECTED

+test_begin_subtest "'notmuch reply' to a multipart message with json format"
+notmuch reply --format=json 'id:87liy5ap00.fsf at yoom.home.cworth.org' >OUTPUT
+cat ", "references": " <87liy5ap00.fsf at 
yoom.home.cworth.org>"} }, "original": { "headers": { "from": "Carl Worth 
", "to": "cworth at cworth.org", "cc": "", "subject": 
"Multipart message", "date": "Fri, 05 Jan 2001 15:43:57 +", "in-reply-to": 
"", "references": "" }, "body": [ { "content-type": "text/html", "content": 
"This is an embedded message, with a multipart/alternative part.\n"}, { 
"content-type": "text/plain", "content": "This is an embedded message, with a 
multipart/alternative part.\n"}, { "content-type": "text/plain", "content": 
"And this message is signed.\n\n-Carl\n"}, {} ] } }, {} ]
+EOF
+test_expect_equal_file OUTPUT EXPECTED
+
 test_begin_subtest "'notmuch show --part' does not corrupt a part with CRLF 
pair"
 notmuch show --format=raw --part=3 id:base64-part-with-crlf > crlf.out
 echo -n -e "\xEF\x0D\x0A" > crlf.expected
-- 
1.7.5.4



  1   2   3   >