[PATCH] Add pseudo-compatibility with gmime 2.6
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. This is mostly based on id:"8762i8hrb9@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). --- 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 (); + node->decrypted_child = g_mime_multipart_encrypted_decrypt + (encrypteddata, node->ctx->cryptoctx, &decrypt_result, &err); + 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")); +#else node->decrypted_child = g_mime_multipart_encrypted_decrypt (encrypteddata, node->ctx->cryptoctx, &err); if (node->decrypted_child) { node->decrypt_success = node->verify_attempted = TRUE; node->sig_validity = g_mime_multipart_encrypted_get_signature_validity (encrypteddata); +#endif } else { fprintf (stderr, "Failed to decrypt part: %s\n", (err ? err->message : "no error explanation given")); @@ -182,6 +211,18 @@ _mime_node_create (const mime_node_t *parent, GMimeObject *part) "(must be exactly 2)\n", node->nchildren); } else { +#ifdef GMIME_26 + GMimeSignatureList *sig_list = g_mime_multipart_signed_verify + (GMIME_MULTIPART_SIGNED (part), node->ctx->cryptoctx, &err); + node->verify_attempted = TRUE; + node->sig_list = sig_list; + if (sig_list) { + GMimeSignatureList **proxy = + talloc (node, GMimeSignatureList *); + *proxy = sig_list; + talloc_set_destructor (proxy, _signature_list_free); + } +#else /* For some reason the GMimeSignatureValidity returned * here is not a const (inconsistent with that * returned by @@ -200,10 +241,15 @@ _mime_node_create (const mime_node_t *parent, GMimeObject *part) *proxy = sig_validity; talloc_set_destructor (proxy, _signature_validity_free); } +#endif } } +#ifdef GMIME_26 +if (node->verify_attempted && !node->sig_list) +#else if (node->verify_attempted && !node->sig_validity) +#endif fprintf (stderr, "Failed to verify signed part: %s\n",
Re: [PATCH] Add pseudo-compatibility with gmime 2.6
On Mon, 16 Jan 2012 22:47:14 -0500, Austin Clements wrote: > 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. Thanks for reviewing this so quickly. Replies inline, and new patches incoming soon. > > This is mostly based on id:"8762i8hrb9@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? The test looks like that: FAIL signature verification with signer key unavailable --- crypto.4.expected 2012-01-16 23:05:06.765651183 + +++ crypto.4.output 2012-01-16 23:05:06.765651183 + @@ -12,9 +12,7 @@ "Bcc": "", "Date": "01 Jan 2000 12:00:00 -"}, "body": [{"id": 1, - "sigstatus": [{"status": "error", - "keyid": "6D92612D94E46381", - "errors": 2}], + "sigstatus": [], "content-type": "multipart/signed", "content": [{"id": 2, "content-type": "text/plain", Failed to verify signed part: gpg: keyblock resource `/home/schnouki/dev/notmuch/test/tmp.crypto/gnupg/pubring.gpg': file open error gpg: armor header: Version: GnuPG v1.4.11 (GNU/Linux) gpg: Signature made Mon Jan 16 23:05:06 2012 UTC using RSA key ID 94E46381 gpg: Can't check signature: public key not found So basically if a signer public key is missing, we can't get the status signature: empty "sigstatus" field in the JSON output, "Unknown signature status" in Emacs. IMHO this is a bug in gmime 2.6, and I think I know what causes it. I'll file a bug in gmime and hopefully they'll find a cleaner way to fix it than the one I came up with :) > > > --- > > 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,
[PATCH v2 2/2] Add pseudo-compatibility with gmime 2.6
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. This is mostly based on id:"8762i8hrb9@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). --- mime-node.c | 56 ++-- notmuch-client.h | 28 +++- notmuch-reply.c |7 notmuch-show.c | 95 ++ show-message.c |4 ++ 5 files changed, 185 insertions(+), 5 deletions(-) diff --git a/mime-node.c b/mime-node.c index d26bb44..e575e1c 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,22 @@ _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 = NULL; + node->decrypted_child = g_mime_multipart_encrypted_decrypt + (encrypteddata, node->ctx->cryptoctx, &decrypt_result, &err); +#else node->decrypted_child = g_mime_multipart_encrypted_decrypt (encrypteddata, node->ctx->cryptoctx, &err); +#endif if (node->decrypted_child) { - node->decrypt_success = node->verify_attempted = TRUE; + node->decrypt_success = node->verify_attempted =TRUE; +#ifdef GMIME_26 + /* This may be NULL if the part is not signed. */ + node->sig_list = g_mime_decrypt_result_get_signatures (decrypt_result); +#else node->sig_validity = g_mime_multipart_encrypted_get_signature_validity (encrypteddata); +#endif } else { fprintf (stderr, "Failed to decrypt part: %s\n", (err ? err->message : "no error explanation given")); @@ -182,6 +210,16 @@ _mime_node_create (const mime_node_t *parent, GMimeObject *part) "(must be exactly 2)\n", node->nchildren); } else { +#ifdef GMIME_26 + GMimeSignatureList *sig_list = g_mime_multipart_signed_verify + (GMIME_MULTIPART_SIGNED (part), node->ctx->cryptoctx, &err); + node->verify_attempted = TRUE; + node->sig_list = sig_list; + + if (!sig_list) + fprintf (stderr, "Failed to verify signed part: %s\n", +(err ? err->message : "no error explanation given")); +#else /* For some reason the GMimeSignatureValidity returned * here is not a const (inconsistent with that * returned by @@ -200,12 +238,24 @@ _mime_node_create (const mime_node_t *parent, GMimeObject *part) *proxy = sig_validity; talloc_set_destructor (proxy, _signature_validity_free); } +#endif } } +#ifdef GMIME_26 +/* sig_list may be created in both above cases, so we need to + * cleanly handle it here. */ +if (node->sig_list) { + GMimeSignatureList **proxy = + talloc (node, GMimeSignatureList *); + *proxy = node->sig_list; + talloc_set_destructor (proxy, _signature_list_free); +} +#else if (node->verify_attempted && !node->sig_validity) fprintf (stderr, "Fai
[PATCH v2 1/2] show: don't use hex literals in JSON output
JSON does not support hex literals (0x..) so numbers must be formatted as %d instead of %x. --- notmuch-show.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index d14dac9..91f566c 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -641,7 +641,7 @@ format_part_sigstatus_json (const GMimeSignatureValidity* validity) printf (", \"keyid\": %s", json_quote_str (ctx_quote, signer->keyid)); } if (signer->errors != GMIME_SIGNER_ERROR_NONE) { - printf (", \"errors\": %x", signer->errors); + printf (", \"errors\": %d", signer->errors); } printf ("}"); -- 1.7.8.3 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH v2 2/2] Add pseudo-compatibility with gmime 2.6
On Tue, 17 Jan 2012 14:48:34 +0200, Tomi Ollila wrote: > On Tue, 17 Jan 2012 11:50:53 +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. > > > > This is mostly based on id:"8762i8hrb9@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). > > --- > > LGTM. Some whitespace things but most of those were there already; > I'd have one uncrustify round to be applied to the source and after > that be more strict about those... Thanks! I'll fix the whitespace issues in these patches when the source in Git is uncrustified then. > actually gmime 2.4 has GMIME_CHECK_VERSION defined as > g_mime_check_version (major, minor, micro) so the comment about it > is not entirely accurate (it is unusable in our context, though) Oops, yes. What I really meant is that GMIME_MAJOR_VERSION is not available as a preprocessor constant in 2.4, and GMIME_CHECK_VERSION is unusable in our context since it just calls a runtime function. By the way, how do you guys feel about setting GMIME_26 in notmuch-client.h? Is that good enough, or should it be done in configure so that gcc is called with "-DGMIME_26"? I filed a bug about gmime 2.6 incorrect handling of signatures with missing public keys: https://bugzilla.gnome.org/show_bug.cgi?id=668085. A patch is attached there, feel free to test and comment. (Arch Linux users: I made a little PKGBUILD that includes this patch if you want to build your own gmime 2.6.4: http://fichiers.schnouki.net/tmp/gmime-2.6.4-1.src.tar.gz) Best regards, -- Thomas/Schnouki pgp3y7I0N927m.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH v2 2/2] Add pseudo-compatibility with gmime 2.6
Thanks for this review Austin. New version coming soon. On Tue, 17 Jan 2012 17:25:46 -0500, Austin Clements wrote: > Quoth Thomas Jost on Jan 17 at 11:50 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. > > > > This is mostly based on id:"8762i8hrb9@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). > > --- > > mime-node.c | 56 ++-- > > notmuch-client.h | 28 +++- > > notmuch-reply.c |7 > > notmuch-show.c | 95 > > ++ > > show-message.c |4 ++ > > 5 files changed, 185 insertions(+), 5 deletions(-) > > > > diff --git a/mime-node.c b/mime-node.c > > index d26bb44..e575e1c 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,22 @@ _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 = NULL; > > Reading through the GMime code, it looks like we do have to unref > decrypt_result. I think this is easy, though. Right after you call > g_mime_decrypt_result_get_signatures below, do: > > g_object_ref (node->sig_list); > g_object_unref (decrypt_result); Added, thanks! > > > + node->decrypted_child = g_mime_multipart_encrypted_decrypt > > + (encrypteddata, node->ctx->cryptoctx, &decrypt_result, &err); > > +#else > > node->decrypted_child = g_mime_multipart_encrypted_decrypt > > (encrypteddata, node->ctx->cryptoctx, &err); > > +#endif > > if (node->decrypted_child) { > > - node->decrypt_success = node->verify_attempted = TRUE; > > + node->decrypt_success = node->verify_attempted =TRUE; > > Whitespace. (There should be no diff on the above line) Oops, my bad. > > > +#ifdef GMIME_26 > > + /* This may be NULL if the part is not signed. */ > > + node->sig_list = g_mime_decrypt_result_get_signatures > > (decrypt_result); > > +#else > > node->sig_validity = > > g_mime_multipart_encrypted_get_signature_validity (encrypteddata); > > +#endif > > } else { > >
Re: [PATCH v2 2/2] Add pseudo-compatibility with gmime 2.6
On Wed, 18 Jan 2012 12:35:34 -0500, Austin Clements wrote: > Quoth Tomi Ollila on Jan 18 at 10:15 am: > > On Tue, 17 Jan 2012 17:25:46 -0500, Austin Clements > > wrote: > > > Quoth Thomas Jost on Jan 17 at 11:50 am: > > > > > > > > +#ifdef GMIME_26 > > > > +/* sig_list may be created in both above cases, so we need to > > > > + * cleanly handle it here. */ > > > > +if (node->sig_list) { > > > > + GMimeSignatureList **proxy = > > > > + talloc (node, GMimeSignatureList *); > > > > > > This doesn't need to be split into two lines. > > > > > > > + *proxy = node->sig_list; > > > > + talloc_set_destructor (proxy, _signature_list_free); > > > > +} > > > > +#else > > > > if (node->verify_attempted && !node->sig_validity) > > > > fprintf (stderr, "Failed to verify signed part: %s\n", > > > > (err ? err->message : "no error explanation given")); > > > > +#endif > > > > > > I'd rather see the above as a separate #ifdef GMIME_26 and #ifndef > > > GMIME_26, since they aren't logical alternates of each other. > > > > That reminds me that it should then be like GMIME_ATLEAST_26, so > > that this might be useful when GMIME > 2.6 is available... > > Hopefully before GMIME 2.8 comes out, we'll be able to remove all of > the GMIME 2.4 compatibility. But GMIME_ATLEAST_26 would be fine, too. Heh, maybe things will change again in 2.8 and "ATLEAST_26" will become "ONLY_26"... But changed to GMIME_ATLEAST_26 anyway, thanks for the suggestion :) -- Thomas/Schnouki pgpsFpyXbJlyG.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH v2 2/2] Add pseudo-compatibility with gmime 2.6
On Wed, 18 Jan 2012 20:00:12 +0200, Tomi Ollila wrote: > On Wed, 18 Jan 2012 12:19:45 -0500, Tom Prince > wrote: > > > > How did you test against multiple versions? Using different machines? If > > there was a way for configure (or something to pick the version, I would > > setup the buildbot to test against both, so we don't regress either. > > I currently compile notmuch on Fedora 15 so that I have > > LIBRARY_PATH=/my/own/path/to/x86_64-linux/lib > and > CPATH=/my/own/path/to/x86_64-linux/include > > and gmime 2.4 development files are located in these > directories. I'll be hiding gmime 2.4 stuff from these > soon in order to build against 2.6 stuff. > > Tomi For testing gmime 2.4 and 2.6, I just uninstalled 2.6 and reinstalled 2.4 (kept the binary package on purpose -- not a problem since notmuch is the only package using gmime on my system). When hacking the gmime git in order to fix https://bugzilla.gnome.org/show_bug.cgi?id=668085, I set some environment variables before calling "./configure" and building notmuch: LDFLAGS="-Wl,-rpath,/home/schnouki/dev/gmime/gmime/.libs" ./configure --prefix=/usr --sysconfdir=/etc make ldd ./notmuch Regards, -- Thomas/Schnouki pgpybiDupPPyc.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] Add pseudo-compatibility with gmime 2.6
On Tue, 17 Jan 2012 15:38:36 -0500, Austin Clements wrote: > Quoth Thomas Jost on Jan 17 at 11:48 am: > > On Mon, 16 Jan 2012 22:47:14 -0500, Austin Clements > > wrote: > > > Quoth Thomas Jost on Jan 17 at 12:56 am: > > > > This is mostly based on id:"8762i8hrb9@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? > > > > The test looks like that: > > > > FAIL signature verification with signer key unavailable > >--- crypto.4.expected 2012-01-16 23:05:06.765651183 + > >+++ crypto.4.output 2012-01-16 23:05:06.765651183 + > >@@ -12,9 +12,7 @@ > > "Bcc": "", > > "Date": "01 Jan 2000 12:00:00 -"}, > > "body": [{"id": 1, > >- "sigstatus": [{"status": "error", > >- "keyid": "6D92612D94E46381", > >- "errors": 2}], > >+ "sigstatus": [], > > "content-type": "multipart/signed", > > "content": [{"id": 2, > > "content-type": "text/plain", > >Failed to verify signed part: gpg: keyblock resource > > `/home/schnouki/dev/notmuch/test/tmp.crypto/gnupg/pubring.gpg': file open > > error > >gpg: armor header: Version: GnuPG v1.4.11 (GNU/Linux) > >gpg: Signature made Mon Jan 16 23:05:06 2012 UTC using RSA key ID > > 94E46381 > >gpg: Can't check signature: public key not found > > > > So basically if a signer public key is missing, we can't get the status > > signature: empty "sigstatus" field in the JSON output, "Unknown > > signature status" in Emacs. > > > > IMHO this is a bug in gmime 2.6, and I think I know what causes it. I'll > > file a bug in gmime and hopefully they'll find a cleaner way to fix it > > than the one I came up with :) > > Oh, okay. That does seem like a bug in GMime. Do you think it would > be possible to mark this test as "broken" if notmuch is using GMime > 2.6? Off the top of my head, I can't think of an easy way to plumb > that information through to the test suite. I don't think we should > push any patches that knowingly break a test, even if it's in just one > configuration. Here is how I did: (ldd notmuch | grep -q gmime-2.6) && test_subtest_known_broken ldd notmuch will show "/path/to/libgmime-2.4.so.*" or "libgmime-2.6.so.*" so we can easily check this in the test suite. It's a little hacky but it seems to work. AFAIK ldd is a pretty standard tool so it should be available (almost) everywhere. However if you have a better idea I'll be glad to hear it. > > > > +#ifdef GMIME_26 > > > > +if (node->verify_attempted && !node->sig_list) > > > > > > Hmm. This is correct for signed parts, but will incorrectly trigger > > > for an encrypted part with no signatures. For 2.6, I think this error > > > checking may have to move into the branches of the if encrypted/signed > > > since for encrypted parts you have to check if > > > g_mime_multipart_encrypted_decrypt returned NULL. > > > > That sound right. The weird part is that it did not cause anything to > > fail in the test suite... > > It would be worth adding a test with an encrypted but unsigned part. > I don't know enough GPG myself to do that. It looks like there's already one: "emacs delivery of encrypted message with attachment" + following decryptions. Regards, -- Thomas/Schnouki pgpSQQuGYQQ6s.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v3 0/2] gmime 2.6 compatibilty, 3rd iteration
Hi list, Here's another update of the patches to add gmime 2.6 compatibilty while still preserving compatibility with gmime 2.4. Any comments or review will be much appreciated. The changes compared to the previous version ([1] and [2]) are pretty minor: - space and indentation fixes - correctly dereference the instance of GMimeDecryptResult allocated by g_mime_decrypt_result_get_signatures() - remove a useless local variable - rename the preprocessor constant GMIME_26 to GMIME_ATLEAST_26 - mark one crypto test as broken when using gmime 2.6 (because of a bug in gmime [3]) The first patch is really not specific to gmime so it could probably be pushed right away. Thanks to Austin Clements, Tomi Ollila and Adrian Perez for their reviews of the previous patches! Best regards, Thomas [1] id:"1326797453-9405-1-git-send-email-schno...@schnouki.net" [2] id:"1326797453-9405-2-git-send-email-schno...@schnouki.net" [3] https://bugzilla.gnome.org/show_bug.cgi?id=668085 Thomas Jost (2): show: don't use hex literals in JSON output Add compatibility with gmime 2.6 mime-node.c | 60 +++-- notmuch-client.h | 30 +++- notmuch-reply.c |7 notmuch-show.c | 97 +- show-message.c |4 ++ test/crypto |2 + 6 files changed, 193 insertions(+), 7 deletions(-) -- 1.7.8.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v3 1/2] show: don't use hex literals in JSON output
JSON does not support hex literals (0x..) so numbers must be formatted as %d instead of %x. --- notmuch-show.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index d14dac9..91f566c 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -641,7 +641,7 @@ format_part_sigstatus_json (const GMimeSignatureValidity* validity) printf (", \"keyid\": %s", json_quote_str (ctx_quote, signer->keyid)); } if (signer->errors != GMIME_SIGNER_ERROR_NONE) { - printf (", \"errors\": %x", signer->errors); + printf (", \"errors\": %d", signer->errors); } printf ("}"); -- 1.7.8.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v3 2/2] Add compatibility with gmime 2.6
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. This is mostly based on id:"8762i8hrb9@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 is currently broken (signature verification with signer key unavailable), most likely because of a bug in gmime which will hopefully be fixed in a future version. --- mime-node.c | 60 -- notmuch-client.h | 30 - notmuch-reply.c |7 notmuch-show.c | 95 ++ show-message.c |4 ++ test/crypto |2 + 6 files changed, 192 insertions(+), 6 deletions(-) diff --git a/mime-node.c b/mime-node.c index d26bb44..ad19f5e 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_ATLEAST_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_ATLEAST_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_ATLEAST_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,24 @@ _mime_node_create (const mime_node_t *parent, GMimeObject *part) GMimeMultipartEncrypted *encrypteddata = GMIME_MULTIPART_ENCRYPTED (part); node->decrypt_attempted = TRUE; +#ifdef GMIME_ATLEAST_26 + GMimeDecryptResult *decrypt_result = NULL; + node->decrypted_child = g_mime_multipart_encrypted_decrypt + (encrypteddata, node->ctx->cryptoctx, &decrypt_result, &err); +#else node->decrypted_child = g_mime_multipart_encrypted_decrypt (encrypteddata, node->ctx->cryptoctx, &err); +#endif if (node->decrypted_child) { node->decrypt_success = node->verify_attempted = TRUE; +#ifdef GMIME_ATLEAST_26 + /* This may be NULL if the part is not signed. */ + node->sig_list = g_mime_decrypt_result_get_signatures (decrypt_result); + g_object_ref (node->sig_list); + g_object_unref (decrypt_result); +#else node->sig_validity = g_mime_multipart_encrypted_get_signature_validity (encrypteddata); +#endif } else { fprintf (stderr, "Failed to decrypt part: %s\n", (err ? err->message : "no error explanation given")); @@ -182,6 +212,15 @@ _mime_node_create (const mime_node_t *parent, GMimeObject *part) "(must be exactly 2)\n", node->nchildren); } else { +#ifdef GMIME_ATLEAST_26 + node->sig_list = g_mime_multipart_signed_verify + (GMIME_MULTIPART_SIGNED (part), node->ctx->cryptoctx, &err); + node->verify_attempted = TRUE; + + if (!node->sig_list) + fprintf (stderr, "Failed to verify signed part: %s\n", +(err ? err->message : "no error explanation given")); +#else /* For some reason the GMimeSignatureValidity returned * here is not a const (inconsistent with that * returned by @@ -195,17 +234,30 @@ _mime_node_create (const mime_node_t *parent, GMimeObject *part) node->verify_attempted = TRUE; node->sig_validity = sig_validity; if (sig_validity) { - GMimeSignatureValidity **proxy = - talloc (node, GMimeSignatureValidity *); + GMimeSignatureValidity **proxy = talloc (node, GMimeSignatureValidity *); *proxy = sig_validity; talloc_set_destructor (proxy, _signature_validity_free); } +#endif } } +#ifdef GMIME_ATLEAST_26 +/* sig_list may be created in both above cases, so we need to +
Re: [PATCH v3 2/2] Add compatibility with gmime 2.6
On Thu, 19 Jan 2012 23:10:44 -0500, Austin Clements wrote: > Nearly there. A few more small comments. Thanks again :) Will post new version soon, including a new patch to update NEWS and INSTALL. > Quoth Thomas Jost on Jan 20 at 1:06 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. > > > > This is mostly based on id:"8762i8hrb9@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 > > is > > currently broken (signature verification with signer key unavailable), most > > likely because of a bug in gmime which will hopefully be fixed in a future > > version. > > --- > > mime-node.c | 60 -- > > notmuch-client.h | 30 - > > notmuch-reply.c |7 > > notmuch-show.c | 95 > > ++ > > show-message.c |4 ++ > > test/crypto |2 + > > 6 files changed, 192 insertions(+), 6 deletions(-) > > > > diff --git a/mime-node.c b/mime-node.c > > index d26bb44..ad19f5e 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_ATLEAST_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_ATLEAST_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_ATLEAST_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,24 @@ _mime_node_create (const mime_node_t *parent, > > GMimeObject *part) > > GMimeMultipartEncrypted *encrypteddata = > > GMIME_MULTIPART_ENCRYPTED (part); > > node->decrypt_attempted = TRUE; > > +#ifdef GMIME_ATLEAST_26 > > + GMimeDecryptResult *decrypt_result = NULL; > > + node->decrypted_child = g_mime_multipart_encrypted_decrypt > > + (encrypteddata, node->ctx->cryptoctx, &decrypt_result, &err); > > +#else > > node->decrypted_child = g_mime_multipart_encrypted_decrypt > > (encrypteddata, node->ctx->cryptoctx, &err); > > +#endif > > if (node->decrypted_child) { > > node->decrypt_success = node->verify_attempted = TRUE; > > +#ifdef GMIME_ATLEAST_26 > > + /* This may be NULL if the part is not signed. */ > > + node->sig_list = g_mime_decrypt_result_get_signatures > > (decrypt_result); > > + g_object_ref (node->sig_list); > > Apparently you can't g_object_ref NULL, so there should be a > conditional around this. Right, added. Thanks. > (Does g_mime_decrypt_result_get_signatures *really* return NULL for an > empty list? I feel like various tests should have failed in various > versions of this patch if it did.) Yes it does. I added some fprintf() in gmime (in gpg_decrypt() and g_mime_decrypt_result_get_signatures()). Decryption tests (after "emacs delivery of encrypted message with attachment") clearly sho
[PATCH v4 1/3] show: don't use hex literals in JSON output
JSON does not support hex literals (0x..) so numbers must be formatted as %d instead of %x. --- notmuch-show.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index d14dac9..91f566c 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -641,7 +641,7 @@ format_part_sigstatus_json (const GMimeSignatureValidity* validity) printf (", \"keyid\": %s", json_quote_str (ctx_quote, signer->keyid)); } if (signer->errors != GMIME_SIGNER_ERROR_NONE) { - printf (", \"errors\": %x", signer->errors); + printf (", \"errors\": %d", signer->errors); } printf ("}"); -- 1.7.8.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v4 2/3] Add compatibility with gmime 2.6
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. This is mostly based on id:"8762i8hrb9@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 is currently broken (signature verification with signer key unavailable), most likely because of a bug in gmime which will hopefully be fixed in a future version. --- mime-node.c | 57 +++- notmuch-client.h | 30 - notmuch-reply.c |7 notmuch-show.c | 95 ++ show-message.c |4 ++ test/crypto |2 + 6 files changed, 191 insertions(+), 4 deletions(-) diff --git a/mime-node.c b/mime-node.c index d26bb44..27077f7 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_ATLEAST_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_ATLEAST_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_ATLEAST_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,25 @@ _mime_node_create (const mime_node_t *parent, GMimeObject *part) GMimeMultipartEncrypted *encrypteddata = GMIME_MULTIPART_ENCRYPTED (part); node->decrypt_attempted = TRUE; +#ifdef GMIME_ATLEAST_26 + GMimeDecryptResult *decrypt_result = NULL; + node->decrypted_child = g_mime_multipart_encrypted_decrypt + (encrypteddata, node->ctx->cryptoctx, &decrypt_result, &err); +#else node->decrypted_child = g_mime_multipart_encrypted_decrypt (encrypteddata, node->ctx->cryptoctx, &err); +#endif if (node->decrypted_child) { node->decrypt_success = node->verify_attempted = TRUE; +#ifdef GMIME_ATLEAST_26 + /* This may be NULL if the part is not signed. */ + node->sig_list = g_mime_decrypt_result_get_signatures (decrypt_result); + if (node->sig_list) + g_object_ref (node->sig_list); + g_object_unref (decrypt_result); +#else node->sig_validity = g_mime_multipart_encrypted_get_signature_validity (encrypteddata); +#endif } else { fprintf (stderr, "Failed to decrypt part: %s\n", (err ? err->message : "no error explanation given")); @@ -182,6 +213,15 @@ _mime_node_create (const mime_node_t *parent, GMimeObject *part) "(must be exactly 2)\n", node->nchildren); } else { +#ifdef GMIME_ATLEAST_26 + node->sig_list = g_mime_multipart_signed_verify + (GMIME_MULTIPART_SIGNED (part), node->ctx->cryptoctx, &err); + node->verify_attempted = TRUE; + + if (!node->sig_list) + fprintf (stderr, "Failed to verify signed part: %s\n", +(err ? err->message : "no error explanation given")); +#else /* For some reason the GMimeSignatureValidity returned * here is not a const (inconsistent with that * returned by @@ -200,12 +240,25 @@ _mime_node_create (const mime_node_t *parent, GMimeObject *part) *proxy = sig_validity; talloc_set_destructor (proxy, _signature_validity_free); } +#endif } } +#ifdef GMIME_ATLEAST_26 +/* sig_list may be created in both above cases, so we need to + * cleanly handle it here. */ +if (node->sig_list) { + GMimeSignatureList **proxy = talloc (node, GMimeSignatureList *); + *proxy = node->sig_list; + talloc_set_destructor (proxy, _signature_list_free); +} +#endif + +#ifndef GMIME_ATLEAST_26 if (node->ve
[PATCH v4 3/3] Update NEWS and INSTALL about gmime 2.6
--- INSTALL | 12 ++-- NEWS|9 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/INSTALL b/INSTALL index e51b397..bc98f1d 100644 --- a/INSTALL +++ b/INSTALL @@ -20,8 +20,8 @@ configure stage. Dependencies -Notmuch depends on three libraries: Xapian, GMime 2.4, and Talloc -which are each described below: +Notmuch depends on three libraries: Xapian, GMime 2.4 or 2.6, and +Talloc which are each described below: Xapian -- @@ -39,14 +39,14 @@ which are each described below: reading mail while notmuch would wait for Xapian when removing the "inbox" and "unread" tags from messages in a thread. - GMime 2.4 - - - GMime 2.4 provides decoding of MIME email messages for Notmuch. + GMime 2.4 or 2.6 + + GMime provides decoding of MIME email messages for Notmuch. Without GMime, Notmuch would not be able to extract and index the actual text from email message encoded as BASE64, etc. - GMime 2.4 is available from http://spruce.sourceforge.net/gmime/ + GMime is available from http://spruce.sourceforge.net/gmime/ Talloc -- diff --git a/NEWS b/NEWS index 6afa912..e78472c 100644 --- a/NEWS +++ b/NEWS @@ -36,6 +36,15 @@ New functions notmuch_query_add_tag_exclude supports the new tag exclusion feature. +Build fixes +--- + +Compatibility with GMime 2.6 + + It is now possible to build notmuch against both GMime 2.4 and 2.6. + However they may be some issues in PGP signature verification + because of a bug in current versions of GMime 2.6. + Notmuch 0.11 (2012-01-13) = -- 1.7.8.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH v4 1/3] show: don't use hex literals in JSON output
On Fri, 20 Jan 2012 07:55:03 -0400, David Bremner wrote: > On Fri, 20 Jan 2012 10:39:23 +0100, Thomas Jost wrote: > > JSON does not support hex literals (0x..) so numbers must be formatted as %d > > instead of %x. > > --- > > notmuch-show.c |2 +- > > 1 files changed, 1 insertions(+), 1 deletions(-) > > Probably I'm just being lazy here, but can you explain why this change > does not require a corresponding change on the emacs side? Because Emacs already does the right thing. JSON numbers are supposed to be decimal only (see http://json.org/: digits are 0-9 only), but the current code could result in displaying a hexadecimal number instead ("c" instead of "12"). This would then trigger an error in Emacs, or in any other correct JSON parser. However we are quite lucky: because of the possible values of the gmime error codes, such an error cannot happen. The most common gmime error codes are 1 (expired signature), 2 (no public key), 4 (expired key) and 8 (revoked key). The other possible value is 16 (unsupported algorithm) but obviously it is much more rare. If this happens, the current code will add '"errors": 10' (hex for 16...). This is valid JSON (it looks like a decimal number) but it is incorrect (should be 16, not 10). With this patch, notmuch will correctly display '"errors": 16' if such a case happens. (By the way, this issue was spotted by Austin Clements in id:"20120117034714.gg16...@mit.edu", so he deserves the credits :)) Regards, -- Thomas/Schnouki pgpaN5CBNzUcv.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] show: don't use hex literals in JSON output
JSON does not support hex literals (0x..) so numbers must be formatted as %d instead of %x. Currently, the possible values for the gmime error code are 1 (expired signature), 2 (no public key), 4 (expired key) and 8 (revoked key). The other possible value is 16 (unsupported algorithm) but obviously it is much more rare. If this happens, the current code will add '"errors": 10'. This is valid JSON (it looks like a decimal number) but it is incorrect (should be 16, not 10). Since this is just an issue in the JSON encoder, no changes are needed on the Emacs side (or in other UIs using the JSON output). --- notmuch-show.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index 43ee211..7b40568 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -728,7 +728,7 @@ format_part_sigstatus_json (const GMimeSignatureValidity* validity) printf (", \"keyid\": %s", json_quote_str (ctx_quote, signer->keyid)); } if (signer->errors != GMIME_SIGNER_ERROR_NONE) { - printf (", \"errors\": %x", signer->errors); + printf (", \"errors\": %d", signer->errors); } printf ("}"); -- 1.7.8.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] Fix NEWS about gmime 2.6
Previous version had a typo ("they may be" instead of "there may be") and was lacking a proper description of the gmime bug. --- Argh. Did not know how to tell it in proper English, ended with a huge typo. Sorry about that, and thanks for noticing and fixing it :) NEWS |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index e78472c..2c2d9e9 100644 --- a/NEWS +++ b/NEWS @@ -42,8 +42,8 @@ Build fixes Compatibility with GMime 2.6 It is now possible to build notmuch against both GMime 2.4 and 2.6. - However they may be some issues in PGP signature verification - because of a bug in current versions of GMime 2.6. + However, a bug in current GMime 2.6 causes notmuch not to report + signatures where the signer key is unavailable (GNOME bug 668085). Notmuch 0.11 (2012-01-13) = -- 1.7.8.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 1/2] emacs: Avoid `mail-header-parse-address' in `notmuch-show-clean-address'.
On Wed, 25 Jan 2012 11:45:03 +, David Edmondson wrote: > `mail-header-parse-address' expects un-decoded mailbox parts, which is > not what we have at this point. Replace it with simple string > deconstruction. > > Mark the corresponding test as no longer broken. > > Minor whitespace cleanup. > --- > emacs/notmuch-show.el | 50 --- > test/emacs-address-cleaning.sh |1 - > 2 files changed, 36 insertions(+), 15 deletions(-) > > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el > index e6a5b31..1fd2524 100644 > --- a/emacs/notmuch-show.el > +++ b/emacs/notmuch-show.el > @@ -289,21 +289,43 @@ operation on the contents of the current buffer." >"Try to clean a single email ADDRESS for display. Return > unchanged ADDRESS if parsing fails." >(condition-case nil > -(let* ((parsed (mail-header-parse-address address)) > -(address (car parsed)) > -(name (cdr parsed))) > - ;; Remove double quotes. They might be required during transport, > - ;; but we don't need to see them. > - (when name > -(setq name (replace-regexp-in-string "\"" "" name))) > +(let (p-name p-address) > + ;; It would be convenient to use `mail-header-parse-address', > + ;; but that expects un-decoded mailbox parts, whereas our > + ;; mailbox parts are already decoded (and hence may contain > + ;; UTF-8). Given that notmuch should handle most of the awkward > + ;; cases, some simple string deconstruction should be sufficient > + ;; here. > + (cond > + ;; "User " style. > + ((string-match "\\(.*\\) <\\(.*\\)>" address) > + (setq p-name (match-string 1 address) > + p-address (match-string 2 address))) > + > + ;; "" style. > + ((string-match "<\\(.*\\)>" address) > + (setq p-address (match-string 1 address))) > + > + ;; Everything else. > + (t > + (setq p-address address))) > + > + ;; Remove outer double quotes. They might be required during > + ;; transport, but we don't need to see them. > + (when (and p-name > + (string-match "^\"\\(.*\\)\"$" p-name)) > + (setq p-name (match-string 1 p-name))) > + >;; If the address is 'f...@bar.com ' then show just >;; 'f...@bar.com'. > - (when (string= name address) > -(setq name nil)) > - > - (if (not name) > -address > -(concat name " <" address ">"))) > + (when (string= p-name p-address) > + (setq p-name nil)) > + > + ;; If no name results, return just the address. > + (if (not p-name) > + p-address > + ;; Otherwise format the name and address together. > + (concat p-name " <" p-address ">"))) > (error address))) > > (defun notmuch-show-insert-headerline (headers date tags depth) > @@ -1417,7 +1439,7 @@ than only the current message." >(interactive "P\nsPipe message to command: ") >(let (shell-command) > (if entire-thread > - (setq shell-command > + (setq shell-command > (concat notmuch-command " show --format=mbox " > (shell-quote-argument > (mapconcat 'identity > (notmuch-show-get-message-ids-for-open-messages) " OR ")) > diff --git a/test/emacs-address-cleaning.sh b/test/emacs-address-cleaning.sh > index 0d85bdc..51018fe 100755 > --- a/test/emacs-address-cleaning.sh > +++ b/test/emacs-address-cleaning.sh > @@ -12,7 +12,6 @@ test_emacs_expect_t \ > '(load "emacs-address-cleaning.el") (notmuch-test-address-cleaning-2)' > > test_begin_subtest "notmuch-test-address-clean part 3" > -test_subtest_known_broken > test_emacs_expect_t \ > '(load "emacs-address-cleaning.el") (notmuch-test-address-cleaning-3)' > > -- > 1.7.8.3 Hello David, Works fine for me, but this also breaks en Emacs test: FAIL notmuch-show for message with invalid From --- emacs.10.expected 2012-01-25 12:50:00.310786410 + +++ emacs.10.output 2012-01-25 12:50:00.310786410 + @@ -1,4 +1,4 @@ -"Invalid " From" (2001-01-05) (inbox) +Invalid " From (2001-01-05) (inbox) Subject: message-with-invalid-from To: Notmuch Test Suite Date: Fri, 05 Jan 2001 15:43:57 + nil Thanks for this patch anyway :) Regards, -- Thomas/Schnouki pgp6DpEIypKye.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: Spellcheck second language
On Thu, 16 Feb 2012 11:45:10 -0500, Philippe LeCavalier wrote: > Hi. > > I get this[1] when envoking keybindings to a second language > flyspell. Any ideas? I've already tried alternate titles to reference > the dictionary in question ie french, francais and français to no avail. > > Also, how would I apply a variation to the dictionary ie. fr_ca? > > ref. > [1] ispell-change-dictionary: Undefined dictionary: français > > rel sys details: > emacs 23.3-9.fc16 > hunspell 1.3.2-1.fc16 > hunspell-en 0.20110318-1.fc16 > hunspell-fr 4.1-1.fc16 > > Please ask if you need more info. Hi Philippe, Do you have aspell? If you do, do you also have aspell-fr? I don't know ispell.el very well, but apparently it will try to use aspell, then ispell, then hunspell in that order. So if you have /usr/bin/aspell but not the French aspell dictionary, that may explain your problem. Now for fr_CA... I don't use it myself (only fr_FR) and apparently there's no specific file for fr_CA (nor fr_BE btw) in aspell-fr. So I guess you should try to stick with "francais". If you *really* want to use fr_CA, you may have to switch to hunspell, since hunspell-fr *has* a dictionary for fr_CA. The problem is then to tell emacs about this dictionary. Here's something that almost works: (setq ispell-program-name "/usr/bin/hunspell" ispell-extra-args '("-i" "latin1")) (add-to-list 'ispell-local-dictionary-alist (cons "fr_CA" (cdr (assoc "francais" ispell-dictionary-base-alist (it copies settings from the fr_FR dictionary but names it fr_CA). Problems: - you need to enter the encoding manually to avoid getting such errors: UTF-8 encoding error. Missing continuation byte in 0. [...] but of course this means that this won't work in UTF-8 buffers... - using these settings, I get another error when changing the dictionary to american and running flyspell-buffer ("Can't check region"). I have to revert to aspell for it to work again. So even if it's not a perfect solution, you should probably keep on using "francais" with aspell. Hope this helps. Best regards -- Thomas/Schnouki pgpgYW2wQvhpF.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] Update crypto test for gmime 2.6.5
gmime 2.6 had a bug [1] which made it impossible to tell why a signature verification failed when the signer key was unavailable (empty "sigstatus" field in the JSON output). Since 00b5623d the corresponding test is marked as broken when using gmime 2.6 (2.4 is fine). The bug has been fixed in gmime 2.6.5. Consequently, the crypto test needs to be adjusted so that it is only marked broken for gmime 2.6.4 and below. [1] https://bugzilla.gnome.org/show_bug.cgi?id=668085 --- Hello world, Here's a little update about gmime 2.6. The latest version (2.6.5) fixes the little regression introduced in 2.6. In all honesty, I'm not sure adding such a workaround in the test suite is worth the effort. If gmime 2.6.5 is quickly packaged by major distros (it's already in Arch), we could as well make notmuch depend on gmime >= 2.6.5. (One line to change in configure). Or we could just stop trying to mark the test as broken and let it fail for buggy versions of gmime. What do you think? Best regards, Thomas test/crypto |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/crypto b/test/crypto index 1dbb60a..cbab216 100755 --- a/test/crypto +++ b/test/crypto @@ -104,8 +104,8 @@ test_expect_equal \ "$expected" test_begin_subtest "signature verification with signer key unavailable" -# this is broken with current versions of gmime-2.6 -(ldd $(which notmuch) | grep -Fq gmime-2.6) && test_subtest_known_broken +# this is broken with gmime-2.6.x for x <= 4 +ldd $(which notmuch) | grep -Fq gmime-2.6 && pkg-config --max-version=2.6.4 gmime-2.6 && test_subtest_known_broken # move the gnupghome temporarily out of the way mv "${GNUPGHOME}"{,.bak} output=$(notmuch show --format=json --verify subject:"test signed message 001" \ -- 1.7.9.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] build: Require gmime 2.6.5
gmime-2.6 had a bug [1] which made it impossible to tell why a signature verification failed when the signer key was unavailable (empty "sigstatus" field in the JSON output). Since 00b5623d the corresponding test is marked as broken when using gmime-2.6 (2.4 is fine). This bug has been fixed in gmime 2.6.5, which is now the minimal gmime-2.6 version required for building notmuch (gmime-2.4 is still available). As a consequence the version check in test/crypto can be removed. [1] https://bugzilla.gnome.org/show_bug.cgi?id=668085 --- Hi Tomi, hi again list, I agree it's a better solution. Here is another patch that makes gmime >= 2.6.5 a requirement. Building against gmime-2.4 is of course still possible. Apparently gmime 2.6.5 is not available yet in Debian, nor in Fedora, so I think we should wait a little bit before pushing this. Best regards, Thomas configure |4 +++- test/crypto |2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 8b85b9d..279e650 100755 --- a/configure +++ b/configure @@ -273,9 +273,11 @@ if [ ${have_xapian} = "0" ]; then errors=$((errors + 1)) fi +# If using GMime 2.6, we need to have a version >= 2.6.5 to avoid a +# crypto bug. printf "Checking for GMime development files... " have_gmime=0 -for gmimepc in gmime-2.6 gmime-2.4; do +for gmimepc in 'gmime-2.6 >= 2.6.5' gmime-2.4; do if pkg-config --exists $gmimepc; then printf "Yes ($gmimepc).\n" have_gmime=1 diff --git a/test/crypto b/test/crypto index 1dbb60a..6723ef8 100755 --- a/test/crypto +++ b/test/crypto @@ -104,8 +104,6 @@ test_expect_equal \ "$expected" test_begin_subtest "signature verification with signer key unavailable" -# this is broken with current versions of gmime-2.6 -(ldd $(which notmuch) | grep -Fq gmime-2.6) && test_subtest_known_broken # move the gnupghome temporarily out of the way mv "${GNUPGHOME}"{,.bak} output=$(notmuch show --format=json --verify subject:"test signed message 001" \ -- 1.7.9.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH v3 1/4] emacs: Let the user choose where to compose new mails
Le 15 avril 2012 à 16:52 CEST, David Bremner a écrit : > Jameson Graef Rollins writes: > >> I think the issues that David was experiencing have to do with flakiness >> in emacs's dedicated windows, not in this patch itself. > > Thomas, > > Did you have a change to investigate this as proposed in > id:"87zke0aifa@thor.loria.fr"? David, Sorry for the delay. I did investigate a little bit, but I did not try to write a patch to fix the wrong behaviour in Emacs 23. AFAICT, Emacs 23 is just buggy in this case. By reading the code of message-send-and-exit and message-bury [1], here is what happens when you call message-send-buffer-and-exit with message-kill-buffer-on-exit set to nil: - message is sent - buffer is buried with burry-buffer - message-bury: if the window is dedicated and its frame not the only visible frame, then this frame is deleted which explains what happens in Emacs 23 both in daemon and non-daemon mode. In Emacs 24 [2], here is what happens: - message is sent - message-bury: buffer is buried with bury-buffer which is (obviously?) correct. Really, this looks like a bug in Emacs 23 to me. Emacs 24 has been fixed by Gnus commits [3] and [4] (maybe [3] is enough, I didn't try). Users of Emacs 23 can probably just use an up-to-date version of Gnus to have this issue fixed. So I'm not sure it would make sense to try to come up with a workaround in my patch, nor if it would be worth it. Maybe just adding a message suggesting Emacs 23 users to enable message-kill-buffer-on-exit if they use the Gnus version shipped with Emacs? Other than that, Jameson's commit [5] is exactly the same as the one in my tree with a better commit message, so I'm in favor of pulling it. [1] http://bzr.savannah.gnu.org/lh/emacs/emacs-23/annotate/head:/lisp/gnus/message.el [2] http://bzr.savannah.gnu.org/lh/emacs/emacs-24/annotate/head:/lisp/gnus/message.el [3] http://git.gnus.org/cgit/gnus.git/commit/?id=30eb6d24d30bc028fce91a0c62044c5dc1fdd90e [4] http://git.gnus.org/cgit/gnus.git/commit/?id=e3fc7cb33eb07dd3b48cfc72f0cada1f1edbcb85 [5] id:"1334436137-6099-1-git-send-email-jroll...@finestructure.net" Regards, -- Thomas/Schnouki pgpU4xJp7PmDM.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v6] emacs: Let the user choose where to compose new mails
Introduce a new defcustom notmuch-mua-compose-in that allows users to specify where new mails are composed, either in the current window or in a new window or frame. Signed-off-by: Jameson Rollins --- Hi David et al., Here it is again, with a warning in the customize message that only appears in Emacs 23. The indentation is a little bit of a mess but that's needed for the docstring to look good :) (If you want I can remove the test and also display the Emacs 23 warning in Emacs 24.) Does it look good to you? I'm not comfortable with writing docs in English, so feel free to rephrase it if needed. I also moved notmuch-mua-compose-in to the 'notmuch-send group, just as other notmuch-mua-* variables. Regards, Thomas emacs/notmuch-mua.el | 45 +++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 87bd88d..641dae7 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -36,6 +36,26 @@ :group 'notmuch-send :group 'notmuch-hooks) +(defcustom notmuch-mua-compose-in 'current-window + (concat + "Where to create the mail buffer used to compose a new message. +Possible values are `current-window' (default), `new-window' and +`new-frame'. If set to `current-window', the mail buffer will be +displayed in the current window, so the old buffer will be +restored when the mail buffer is killed. If set to `new-window' +or `new-frame', the mail buffer will be displayed in a new +window/frame that will be destroyed when the buffer is killed. +You may want to customize `message-kill-buffer-on-exit' +accordingly." + (when (< emacs-major-version 24) + " Due to a known bug in Emacs 23, you should not set +this to `new-window' if `message-kill-buffer-on-exit' is +disabled: this would result in an incorrect behavior.")) + :group 'notmuch-send + :type '(choice (const :tag "Compose in the current window" current-window) +(const :tag "Compose mail in a new window" new-window) +(const :tag "Compose mail in a new frame" new-frame))) + (defcustom notmuch-mua-user-agent-function 'notmuch-mua-user-agent-full "Function used to generate a `User-Agent:' string. If this is `nil' then no `User-Agent:' will be generated." @@ -55,6 +75,23 @@ list." ;; +(defun notmuch-mua-get-switch-function () + "Get a switch function according to `notmuch-mua-compose-in'." + (cond ((eq notmuch-mua-compose-in 'current-window) +'switch-to-buffer) + ((eq notmuch-mua-compose-in 'new-window) +'switch-to-buffer-other-window) + ((eq notmuch-mua-compose-in 'new-frame) +'switch-to-buffer-other-frame) + (t (error "Invalid value for `notmuch-mua-compose-in'" + +(defun notmuch-mua-maybe-set-window-dedicated () + "Set the selected window as dedicated according to +`notmuch-mua-compose-in'." + (when (or (eq notmuch-mua-compose-in 'new-frame) + (eq notmuch-mua-compose-in 'new-window)) +(set-window-dedicated-p (selected-window) t))) + (defun notmuch-mua-user-agent-full () "Generate a `User-Agent:' string suitable for notmuch." (concat (notmuch-mua-user-agent-notmuch) @@ -148,7 +185,8 @@ list." collect pair))) (notmuch-mua-mail (plist-get reply-headers :To) (plist-get reply-headers :Subject) - (notmuch-headers-plist-to-alist reply-headers + (notmuch-headers-plist-to-alist reply-headers) + nil (notmuch-mua-get-switch-function ;; Insert the message body - but put it in front of the signature ;; if one is present @@ -186,6 +224,7 @@ list." (set-buffer-modified-p nil)) (defun notmuch-mua-forward-message () + (funcall (notmuch-mua-get-switch-function) (current-buffer)) (message-forward) (when notmuch-mua-user-agent-function @@ -195,6 +234,7 @@ list." (message-sort-headers) (message-hide-headers) (set-buffer-modified-p nil) + (notmuch-mua-maybe-set-window-dedicated) (message-goto-to)) @@ -217,6 +257,7 @@ OTHER-ARGS are passed through to `message-mail'." (message-sort-headers) (message-hide-headers) (set-buffer-modified-p nil) + (notmuch-mua-maybe-set-window-dedicated) (message-goto-to)) @@ -273,7 +314,7 @@ the From: address first." (let ((other-headers (when (or prompt-for-sender notmuch-always-prompt-for-sender) (list (cons 'From (notmuch-mua-prompt-for-sender)) -(notmuch-mua-mail nil nil other-headers))) +(notmuch-mua-mail nil nil other-headers nil (notmuch-mua-get-switch-function (defun notmuch-mua-new-forward-message (&optional prompt-for-sender) "Invoke the notmuch message forwarding window. -- 1.7.10.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] Restore original keybinding ('r' = reply-to-all)
Le 28 juin 2012 à 18:21 CEST, Jameson Graef Rollins a écrit : > On Thu, Jun 28 2012, Philip Hands wrote: >> Actually, instead of either of these options, how about some way of >> letting r do the single reply, and then once inside the reply, having >> some key binding to add the rest of the recipients in the group, or flip >> between the two options so one can change one's mind after typing up the >> reply? > > This is a good idea. The other idea I had was to have 'r' query the > user directly about whether or not they want to reply all before > constructing the reply template. Or right before you're about to send. In my config, I use "r a" for "reply to all" and "r s" for "reply to sender". Never got it wrong since I added this to my .emacs. https://github.com/Schnouki/dotfiles/blob/master/emacs/init-50-mail.el#L111-114 Regards, -- Thomas/Schnouki pgpo8HynnX3s2.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: notmuch-haskell
Le 23/09/2010 18:17, Daniel Goldin a écrit : > When I commented out (notmuch-fcc-dirs t), smtpmail started working > again. Any thoughts? notmuch-fcc-dirs should be a string or a list, not just "t". If it's a string, it indicates in which maildir your sent messages will be saved. If it's a list, you can have different outboxes according to the From header of your messages. You should read the documentation for this variable: C-h v notmuch-fcc-dirs RET (or just look for it in notmuch-maildir-fcc.el). Regards, -- Thomas/Schnouki signature.asc Description: OpenPGP digital signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: Multiple sender identities (composing)
On Mon, 16 May 2011 19:29:07 +1000, Stewart Smith wrote: > Thought I'd share this bit of my .emacs snippet that may be useful to go > on the emacs tips page. > > This does the following: > - sets up a list of possible identities to have mail From > - on composing mail, it prompts you for who you want to send mail from > - pressing enter will give you the default (first in the list) > - otherwise you have tab completion And here's the same for choosing the identity when forwarding a mail: ;; Choose the identity used to forward a mail (defun schnouki/notmuch-mua-forward-message () (interactive) (let* ((from (ido-completing-read "Sender identity: " schnouki/mua-identities nil nil nil nil (car schnouki/mua-identities))) (address-components (mail-extract-address-components from)) (user-full-name (car address-components)) (user-mail-address (cadr address-components))) (notmuch-mua-forward-message))) (people who don't use or like ido may want to replace ido-completing-read with completing-read) If anyone is interested, I have some more useful snippets available on https://github.com/Schnouki/dotfiles/blob/master/emacs/init-50-mail.el#L232: - function to choose a signature according to the From header - function to choose the sender identity according to the To header (useful for replying to work e-mails using your work address, or for replying to a ML with a subscribed address that won't be rejected) - function to change the SMTP server that will be used for sending the mail according to the From header It seriously lacks documentation so don't hesitate to ask if you have any problem with it :) Regards, -- Thomas/Schnouki pgpzZnFZb3DRW.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: Multiple sender identities (composing)
On Mon, 16 May 2011 09:52:32 -0700, Jameson Graef Rollins wrote: > On Mon, 16 May 2011 11:52:43 +0200, Thomas Jost wrote: > > On Mon, 16 May 2011 19:29:07 +1000, Stewart Smith > > wrote: > > > Thought I'd share this bit of my .emacs snippet that may be useful to go > > > on the emacs tips page. > > > > > > This does the following: > > > - sets up a list of possible identities to have mail From > > > - on composing mail, it prompts you for who you want to send mail from > > > - pressing enter will give you the default (first in the list) > > > - otherwise you have tab completion > > This is great, guys. I've been wanting to get something like this > working for a while now. > > Have you guys looked at home message-mode does bbdb address completion > in the To: and From: headers? It has the nice benefit of being able to > tab through all full addresses for a bbdb entry. It would be nice to > have this function fill in a default address, with the cursor at the end > of the address, and then just tab through all the options without having > to type in anything. ido is pretty cool, though, and accomplishes a > similar effect. I don't know much about bbdb; right now I'm completing addresses with notmuch-address.el and a little Python script that I wrote [1]. It can complete the From header too, although I had never tried that before writing this mail :) > It would be nice to pull the addresses from the notmuch config, eg: > > notmuch config get user.primary_email > notmuch config get user.other_email Nice idea, I like that. However this way you can only get the address part, not the username part. And when using some addresses I want to put a nickname instead of my full name, so just using a default user name is not very convenient. Or is it possible to put things like "User Name " in the notmuch config? > I would ideally like to be able to choose the From: address right before > sending, as opposed to right before composing. Has anyone tried to get > that working? I was not having much luck with send-hooks, since it > looks like it expects the message to be complete at that point. I haven't tried that, but it would indeed be nice to be able to do that at send time. The message-seend-hook doc states that "this hook is run quite early when sending", so I would expect that to be the best solution. However, if for some reason it doesn't work, it's probably possible to write a little function around message-send (...or even to advise it) to do whatever you want before it is actually executed. I'll try to have a look at this tomorrow. Regards, Thomas [1] https://github.com/Schnouki/dotfiles/blob/master/notmuch/addrbook.py -- Thomas/Schnouki pgpo7HMjRGfGm.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] emacs: Allow user to choose "From" address when composing a new message.
On Tue, 24 May 2011 15:02:01 -0700, Carl Worth wrote: > In order to select a From address, the user simply presses M instead of > m to begin composing a message. By default the list of names/addresses > to be used during completion will be automatically generated by the > settings in the notmuch configuration file. The user can customize > the notmuch-identities variable to provide an alternate list. Thanks, IMHO that's better than my previous solution. And it makes my .emacs smaller, woohoo! :) One little issue though: you did not update notmuch-show-mode-map in notmuch-show.el. I'll reply with a patch that fixes that (or you can just integrate it in your commit when pushing it). I'll also send a few additional patches that make it possible to choose the "From" address when forwarding a message and when replying to a message. Regards, -- Thomas/Schnouki pgpdFuT0kSDRr.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 1/4] emacs: Allow the user choose the "From" address when composing a new message from notmuch-show-mode too.
--- emacs/notmuch-show.el |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 825988c..93f46ac 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -847,7 +847,8 @@ function is used. " (define-key map (kbd "") 'notmuch-show-previous-button) (define-key map (kbd "TAB") 'notmuch-show-next-button) (define-key map "s" 'notmuch-search) - (define-key map "m" 'notmuch-mua-mail) + (define-key map "m" 'notmuch-mua-new-mail) + (define-key map "M" 'notmuch-mua-new-mail-prompt-for-sender) (define-key map "f" 'notmuch-show-forward-message) (define-key map "r" 'notmuch-show-reply) (define-key map "|" 'notmuch-show-pipe-message) -- 1.7.5.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 2/4] emacs: Move the "prompt for sender" code to a new function.
This allows the code to be reused in different functions without duplicating it. --- emacs/notmuch-mua.el | 15 +-- 1 files changed, 9 insertions(+), 6 deletions(-) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index cd4d75d..0bde02c 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -157,21 +157,24 @@ name and addresses configured in the notmuch configuration file." (concat (notmuch-user-name) " <" address ">")) (cons (notmuch-user-primary-email) (notmuch-user-other-email) +(defvar notmuch-mua-sender-history nil) + +(defun notmuch-mua-prompt-for-sender () + (interactive) + (let ((collection (notmuch-mua-sender-collection))) +(ido-completing-read "Send mail From: " collection +nil 'confirm nil 'notmuch-mua-sender-history (car collection + (defun notmuch-mua-new-mail-from (&optional sender) (if sender (notmuch-mua-mail nil nil (list (cons 'from sender))) (notmuch-mua-mail))) -(defvar notmuch-mua-sender-history nil) - (defun notmuch-mua-new-mail (&optional prompt-for-sender) "Begin composing a new email with notmuch." (interactive "P") (if prompt-for-sender - (let* ((collection (notmuch-mua-sender-collection)) -(sender (ido-completing-read "Send mail From: " collection - nil 'confirm nil 'notmuch-mua-sender-history (car collection - (notmuch-mua-new-mail-from sender)) + (notmuch-mua-new-mail-from (notmuch-mua-prompt-for-sender)) (notmuch-mua-mail))) (defun notmuch-mua-new-mail-prompt-for-sender () -- 1.7.5.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 3/4] emacs: Allow the user to choose the "From" address when forwarding a message.
--- emacs/notmuch-mua.el |8 emacs/notmuch-show.el |7 +++ 2 files changed, 15 insertions(+), 0 deletions(-) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 0bde02c..7c08a6e 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -182,6 +182,14 @@ name and addresses configured in the notmuch configuration file." (interactive) (notmuch-mua-new-mail t)) +(defun notmuch-mua-forward-message-prompt-for-sender () + (interactive) + (let* ((sender (notmuch-mua-prompt-for-sender)) +(address-components (mail-extract-address-components sender)) +(user-full-name (car address-components)) +(user-mail-address (cadr address-components))) +(notmuch-mua-forward-message))) + (defun notmuch-mua-send-and-exit (&optional arg) (interactive "P") (message-send-and-exit arg)) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 93f46ac..50b20b2 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -850,6 +850,7 @@ function is used. " (define-key map "m" 'notmuch-mua-new-mail) (define-key map "M" 'notmuch-mua-new-mail-prompt-for-sender) (define-key map "f" 'notmuch-show-forward-message) + (define-key map "F" 'notmuch-show-forward-message-prompt-for-sender) (define-key map "r" 'notmuch-show-reply) (define-key map "|" 'notmuch-show-pipe-message) (define-key map "w" 'notmuch-show-save-attachments) @@ -1165,6 +1166,12 @@ any effects from previous calls to (with-current-notmuch-show-message (notmuch-mua-forward-message))) +(defun notmuch-show-forward-message-prompt-for-sender () + "Forward the current message, prompting for the From: address first." + (interactive) + (with-current-notmuch-show-message + (notmuch-mua-forward-message-prompt-for-sender))) + (defun notmuch-show-next-message () "Show the next message." (interactive) -- 1.7.5.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 4/4] emacs: Allow the user to choose the "From" address when replying to a message.
--- emacs/notmuch-mua.el |9 - emacs/notmuch-show.el |6 ++ emacs/notmuch.el |7 +++ 3 files changed, 21 insertions(+), 1 deletions(-) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 7c08a6e..d04e69c 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -69,7 +69,7 @@ list." (push header message-hidden-headers))) notmuch-mua-hidden-headers)) -(defun notmuch-mua-reply (query-string) +(defun notmuch-mua-reply (query-string &optional sender) (let (headers body (args '("reply"))) @@ -90,6 +90,9 @@ list." (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. @@ -190,6 +193,10 @@ name and addresses configured in the notmuch configuration file." (user-mail-address (cadr address-components))) (notmuch-mua-forward-message))) +(defun notmuch-mua-reply-prompt-for-sender (query-string) + (interactive) + (notmuch-mua-reply query-string (notmuch-mua-prompt-for-sender))) + (defun notmuch-mua-send-and-exit (&optional arg) (interactive "P") (message-send-and-exit arg)) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 50b20b2..2c69e96 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -852,6 +852,7 @@ function is used. " (define-key map "f" 'notmuch-show-forward-message) (define-key map "F" 'notmuch-show-forward-message-prompt-for-sender) (define-key map "r" 'notmuch-show-reply) + (define-key map "R" 'notmuch-show-reply-prompt-for-sender) (define-key map "|" 'notmuch-show-pipe-message) (define-key map "w" 'notmuch-show-save-attachments) (define-key map "V" 'notmuch-show-view-raw-message) @@ -1160,6 +1161,11 @@ any effects from previous calls to (interactive) (notmuch-mua-reply (notmuch-show-get-message-id))) +(defun notmuch-show-reply-prompt-for-sender () + "Reply to the current message, prompting for the From: address first." + (interactive) + (notmuch-mua-reply-prompt-for-sender (notmuch-show-get-message-id))) + (defun notmuch-show-forward-message () "Forward the current message." (interactive) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 1791d84..153dc74 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -204,6 +204,7 @@ For a mouse binding, return nil." (define-key map "p" 'notmuch-search-previous-thread) (define-key map "n" 'notmuch-search-next-thread) (define-key map "r" 'notmuch-search-reply-to-thread) +(define-key map "R" 'notmuch-search-reply-to-thread-prompt-for-sender) (define-key map "m" 'notmuch-mua-new-mail) (define-key map "M" 'notmuch-mua-new-mail-prompt-for-sender) (define-key map "s" 'notmuch-search) @@ -449,6 +450,12 @@ Complete list of currently available key bindings: (let ((message-id (notmuch-search-find-thread-id))) (notmuch-mua-reply message-id))) +(defun notmuch-search-reply-to-thread-prompt-for-sender () + "Begin composing a reply to the entire current thread in a new buffer, prompting for the From: address first." + (interactive) + (let ((message-id (notmuch-search-find-thread-id))) +(notmuch-mua-reply-prompt-for-sender message-id))) + (defun notmuch-call-notmuch-process (&rest args) "Synchronously invoke \"notmuch\" with the given list of arguments. -- 1.7.5.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] emacs: Allow user to choose "From" address when composing a new message.
On Wed, 25 May 2011 15:17:05 -0700, Carl Worth wrote: > > I'll also send a few additional patches that make it possible to choose > > the "From" address when forwarding a message and when replying to a > > message. > > The only real concern I have with the series is that it grabs 'R' for > reply-with-custom-from where I've been planning to implement 'R' as > reply-to-sender-only, (a long-missing and often-requested feature). That would be nice indeed :) > When I first started implementing the custom-from feature I planned to > use a prefix argument to get the behavior (such as "C-u m" rather than > "M" for compose-new-mail-with-custom-from). You might even see I've got > some code written along those lines. Good idea, this will probably seem more natural for Emacs users. > When I went to test it though, it didn't work. That was probably some > silly mistake on my part, (we do already have working code that changes > behavior with a prefix argument in the case of "M-RET" for example). > > If you want to update the series to move away from capital-letter > keybindings in favor of a prefix argument, I'll be glad to accept it. Done and tested locally, seems OK so far. This makes the code smaller and IMHO nicer because it eliminates all the -prompt-for-sender variants. I'll send the updated patch series very soon. Thanks, -- Thomas/Schnouki pgpkt88BUhmiW.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2 1/4] emacs: Helpers needed for the user to be able to choose the "From" address when composing a new message
This adds functions and variables needed for this feature to be implemented. Once it's done, the user will be able to use a prefix argument (e.g. pressing C-u m instead of m) and be able to select a From address. By default the list of names/addresses to be used during completion will be automatically generated by the settings in the notmuch configuration file. The user can customize the notmuch-identities variable to provide an alternate list. This is based on a previous patch by Carl Worth (id:"87wrhfvk6a@yoom.home.cworth.org" and follow-ups). --- emacs/notmuch-mua.el | 23 +++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 003b313..2baf6bd 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -143,6 +143,29 @@ list." (message-goto-to)) +(defcustom notmuch-identities nil + "Identities that can be used as the From: address when composing a new message. + +If this variable is left unset, then a list will be constructed from the +name and addresses configured in the notmuch configuration file." + :group 'notmuch + :type '(repeat string)) + +(defun notmuch-mua-sender-collection () + (if notmuch-identities + notmuch-identities +(mapcar (lambda (address) + (concat (notmuch-user-name) " <" address ">")) + (cons (notmuch-user-primary-email) (notmuch-user-other-email) + +(defvar notmuch-mua-sender-history nil) + +(defun notmuch-mua-prompt-for-sender () + (interactive) + (let ((collection (notmuch-mua-sender-collection))) +(ido-completing-read "Send mail From: " collection +nil 'confirm nil 'notmuch-mua-sender-history (car collection + (defun notmuch-mua-send-and-exit (&optional arg) (interactive "P") (message-send-and-exit arg)) -- 1.7.5.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2 2/4] emacs: Allow the user to choose the "From" address when composing a new message
When pressing C-u m, the user will be prompted for the identity to use. --- emacs/notmuch-hello.el |2 +- emacs/notmuch-mua.el | 11 +++ emacs/notmuch-show.el |2 +- emacs/notmuch.el |2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index e58dd24..ab06d3a 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -298,7 +298,7 @@ should be. Returns a cons cell `(tags-per-line width)'." (define-key map "=" 'notmuch-hello-update) (define-key map "G" 'notmuch-hello-poll-and-update) (define-key map (kbd "") 'widget-backward) -(define-key map "m" 'notmuch-mua-mail) +(define-key map "m" 'notmuch-mua-new-mail) (define-key map "s" 'notmuch-hello-goto-search) map) "Keymap for \"notmuch hello\" buffers.") diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 2baf6bd..74c9fc1 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -166,6 +166,17 @@ name and addresses configured in the notmuch configuration file." (ido-completing-read "Send mail From: " collection nil 'confirm nil 'notmuch-mua-sender-history (car collection +(defun notmuch-mua-new-mail (&optional prompt-for-sender) + "Invoke the notmuch mail composition window. + +If PROMPT-FOR-SENDER is non-nil, the user will be prompted for +the From: address first." + (interactive "P") + (let ((other-headers +(when prompt-for-sender + (list (cons 'from (notmuch-mua-prompt-for-sender)) +(notmuch-mua-mail nil nil other-headers))) + (defun notmuch-mua-send-and-exit (&optional arg) (interactive "P") (message-send-and-exit arg)) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 825988c..48d2926 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -847,7 +847,7 @@ function is used. " (define-key map (kbd "") 'notmuch-show-previous-button) (define-key map (kbd "TAB") 'notmuch-show-next-button) (define-key map "s" 'notmuch-search) - (define-key map "m" 'notmuch-mua-mail) + (define-key map "m" 'notmuch-mua-new-mail) (define-key map "f" 'notmuch-show-forward-message) (define-key map "r" 'notmuch-show-reply) (define-key map "|" 'notmuch-show-pipe-message) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 1d683f8..21e0314 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -204,7 +204,7 @@ For a mouse binding, return nil." (define-key map "p" 'notmuch-search-previous-thread) (define-key map "n" 'notmuch-search-next-thread) (define-key map "r" 'notmuch-search-reply-to-thread) -(define-key map "m" 'notmuch-mua-mail) +(define-key map "m" 'notmuch-mua-new-mail) (define-key map "s" 'notmuch-search) (define-key map "o" 'notmuch-search-toggle-order) (define-key map "c" 'notmuch-search-stash-map) -- 1.7.5.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2 3/4] emacs: Allow the user to choose the "From" address when forwarding a message
When pressing C-u f, the user will be prompted for the identity to use. --- emacs/notmuch-mua.el | 14 ++ emacs/notmuch-show.el |6 +++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 74c9fc1..1b777d9 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -177,6 +177,20 @@ the From: address first." (list (cons 'from (notmuch-mua-prompt-for-sender)) (notmuch-mua-mail nil nil other-headers))) +(defun notmuch-mua-new-forward-message (&optional prompt-for-sender) + "Invoke the notmuch message forwarding window. + +If PROMPT-FOR-SENDER is non-nil, the user will be prompted for +the From: address first." + (interactive "P") + (if prompt-for-sender + (let* ((sender (notmuch-mua-prompt-for-sender)) +(address-components (mail-extract-address-components sender)) +(user-full-name (car address-components)) +(user-mail-address (cadr address-components))) + (notmuch-mua-forward-message)) +(notmuch-mua-forward-message))) + (defun notmuch-mua-send-and-exit (&optional arg) (interactive "P") (message-send-and-exit arg)) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 48d2926..7e493e9 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1158,11 +1158,11 @@ any effects from previous calls to (interactive) (notmuch-mua-reply (notmuch-show-get-message-id))) -(defun notmuch-show-forward-message () +(defun notmuch-show-forward-message (&optional prompt-for-sender) "Forward the current message." - (interactive) + (interactive "P") (with-current-notmuch-show-message - (notmuch-mua-forward-message))) + (notmuch-mua-new-forward-message prompt-for-sender))) (defun notmuch-show-next-message () "Show the next message." -- 1.7.5.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2 4/4] emacs: Allow the user to choose the "From" address when replying to a message
When pressing C-u r, the user will be prompted for the identity to use. --- emacs/notmuch-mua.el | 13 - emacs/notmuch-show.el |6 +++--- emacs/notmuch.el |6 +++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 1b777d9..f2d86bb 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -69,7 +69,7 @@ list." (push header message-hidden-headers))) notmuch-mua-hidden-headers)) -(defun notmuch-mua-reply (query-string) +(defun notmuch-mua-reply (query-string &optional sender) (let (headers body (args '("reply"))) @@ -90,6 +90,9 @@ list." (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. @@ -191,6 +194,14 @@ the From: address first." (notmuch-mua-forward-message)) (notmuch-mua-forward-message))) +(defun notmuch-mua-new-reply (query-string &optional prompt-for-sender) + "Invoke the notmuch reply window." + (interactive "P") + (let ((sender +(when prompt-for-sender + (notmuch-mua-prompt-for-sender +(notmuch-mua-reply query-string sender))) + (defun notmuch-mua-send-and-exit (&optional arg) (interactive "P") (message-send-and-exit arg)) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 7e493e9..1c5dfd7 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1153,10 +1153,10 @@ any effects from previous calls to ;; Move to the previous message. (notmuch-show-previous-message) -(defun notmuch-show-reply () +(defun notmuch-show-reply (&optional prompt-for-sender) "Reply to the current message." - (interactive) - (notmuch-mua-reply (notmuch-show-get-message-id))) + (interactive "P") + (notmuch-mua-new-reply (notmuch-show-get-message-id) prompt-for-sender)) (defun notmuch-show-forward-message (&optional prompt-for-sender) "Forward the current message." diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 21e0314..3d984bc 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -442,11 +442,11 @@ Complete list of currently available key bindings: crypto-switch) (error "End of search results" -(defun notmuch-search-reply-to-thread () +(defun notmuch-search-reply-to-thread (&optional prompt-for-sender) "Begin composing a reply to the entire current thread in a new buffer." - (interactive) + (interactive "P") (let ((message-id (notmuch-search-find-thread-id))) -(notmuch-mua-reply message-id))) +(notmuch-mua-new-reply message-id prompt-for-sender))) (defun notmuch-call-notmuch-process (&rest args) "Synchronously invoke \"notmuch\" with the given list of arguments. -- 1.7.5.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] emacs: Add a customization allowing to always prompt for the "From" address when composing a new message
--- Hi Jameson, Here it is :) I'm sure it will be useful for many other people too, including myself. To be applied on top of my other patches, then you can set notmuch-always-prompt-for-sender to t. Regards, Thomas emacs/notmuch-mua.el | 11 --- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index f2d86bb..7c05a81 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -154,6 +154,11 @@ name and addresses configured in the notmuch configuration file." :group 'notmuch :type '(repeat string)) +(defcustom notmuch-always-prompt-for-sender nil + "Always prompt for the From: address when composing a new message." + :group 'notmuch + :type 'boolean) + (defun notmuch-mua-sender-collection () (if notmuch-identities notmuch-identities @@ -176,7 +181,7 @@ If PROMPT-FOR-SENDER is non-nil, the user will be prompted for the From: address first." (interactive "P") (let ((other-headers -(when prompt-for-sender +(when (or prompt-for-sender notmuch-always-prompt-for-sender) (list (cons 'from (notmuch-mua-prompt-for-sender)) (notmuch-mua-mail nil nil other-headers))) @@ -186,7 +191,7 @@ the From: address first." If PROMPT-FOR-SENDER is non-nil, the user will be prompted for the From: address first." (interactive "P") - (if prompt-for-sender + (if (or prompt-for-sender notmuch-always-prompt-for-sender) (let* ((sender (notmuch-mua-prompt-for-sender)) (address-components (mail-extract-address-components sender)) (user-full-name (car address-components)) @@ -198,7 +203,7 @@ the From: address first." "Invoke the notmuch reply window." (interactive "P") (let ((sender -(when prompt-for-sender +(when (or prompt-for-sender notmuch-always-prompt-for-sender) (notmuch-mua-prompt-for-sender (notmuch-mua-reply query-string sender))) -- 1.7.5.2 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 1/2] emacs: Don't always prompt for the "From" address when replying
When replying, the From: address is already filled in by notmuch reply, so most of the time there is no need to prompt the user for it. --- Hi Jameson, You're right, this is mostly annoying when replying to messages. Here's a fix. Regards, Thomas emacs/notmuch-mua.el |7 +-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 7c05a81..556d2bf 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -155,7 +155,10 @@ name and addresses configured in the notmuch configuration file." :type '(repeat string)) (defcustom notmuch-always-prompt-for-sender nil - "Always prompt for the From: address when composing a new message." + "Always prompt for the From: address when composing or forwarding a message. + +This is not taken into account when replying to a message, because in that case +the From: header is already filled in by notmuch." :group 'notmuch :type 'boolean) @@ -203,7 +206,7 @@ the From: address first." "Invoke the notmuch reply window." (interactive "P") (let ((sender -(when (or prompt-for-sender notmuch-always-prompt-for-sender) +(when prompt-for-sender (notmuch-mua-prompt-for-sender (notmuch-mua-reply query-string sender))) -- 1.7.5.2 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 2/2] emacs: Cleaner interface when prompting for sender address
Most of the time, every entry in the list of identities has the same user name part. It can then be filled in automatically, and the user can only be prompted for the email address, which makes the interface much cleaner. --- Hi Jameson, Once again, a very good suggestion. I had doubts at first (because I sometimes send mails using a nickname or on behalf of a group using that group's name), but then I noticed I already had only one name in notmuch-identities :) So here's a patch. It handle 3 different cases: - notmuch-identities is not set --> only one name - notmuch-identities set with only one name - notmuch-identities set with several different names I tried to make it as compact and readable as possible, so the first two cases are handled by a single call to ido-completing-read. But there is probably still room for improvements: reviews, comments and suggestions are welcome. Regards, Thomas emacs/notmuch-mua.el | 33 +++-- 1 files changed, 23 insertions(+), 10 deletions(-) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 556d2bf..274c5da 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -162,20 +162,33 @@ the From: header is already filled in by notmuch." :group 'notmuch :type 'boolean) -(defun notmuch-mua-sender-collection () - (if notmuch-identities - notmuch-identities -(mapcar (lambda (address) - (concat (notmuch-user-name) " <" address ">")) - (cons (notmuch-user-primary-email) (notmuch-user-other-email) - (defvar notmuch-mua-sender-history nil) (defun notmuch-mua-prompt-for-sender () (interactive) - (let ((collection (notmuch-mua-sender-collection))) -(ido-completing-read "Send mail From: " collection -nil 'confirm nil 'notmuch-mua-sender-history (car collection + (let (name addresses one-name-only) +;; If notmuch-identities is non-nil, check if there is a fixed user name. +(if notmuch-identities + (let ((components (mapcar 'mail-extract-address-components notmuch-identities))) + (setq name (caar components) + addresses (mapcar 'cadr components) + one-name-only (eval + (cons 'and +(mapcar (lambda (identity) + (string-equal name (car identity))) +components) + ;; If notmuch-identities is nil, use values from the notmuch configuration file. + (setq name (notmuch-user-name) + addresses (cons (notmuch-user-primary-email) (notmuch-user-other-email)) + one-name-only t)) +;; Now prompt the user, either for an email address only or for a full identity. +(if one-name-only + (let ((address + (ido-completing-read (concat "Sender address for " name ": ") addresses + nil nil nil 'notmuch-mua-sender-history (car addresses + (concat name " <" address ">")) + (ido-completing-read "Send mail From: " notmuch-identities + nil nil nil 'notmuch-mua-sender-history (car notmuch-identities) (defun notmuch-mua-new-mail (&optional prompt-for-sender) "Invoke the notmuch mail composition window. -- 1.7.5.2 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[RFC] Several minor enhancements to the Emacs interface
Hi list, The thread regarding multiple sender identities seems to have been of interest for several people, so I'd like to share a few other snippets From my Emacs configuration file. Please tell me what you think of them. If you like them, I'd be glad to write some patches so they can be merged in notmuch. *** HTML support *** The current solution for opening HTML parts in a browser seems to be an external script relying on the "munpack" executable: http://notmuchmail.org/emacstips/#index8h2 However Emacs has everything that is needed. Here's a function that will open text/html parts in a browser using nothing but pure elisp: (defun schnouki/notmuch-view-html () "Open the HTML parts of a mail in a web browser." (interactive) (with-current-notmuch-show-message (let ((mm-handle (mm-dissect-buffer))) (notmuch-foreach-mime-part (lambda (p) (if (string-equal (mm-handle-media-type p) "text/html") (mm-display-external p (lambda () (message "Opening web browser...") (browse-url-of-buffer) (bury-buffer) mm-handle (Bound to "H" in notmuch-show-mode in my .emacs) *** Filter by date *** When displaying a search with lots of results (like tag:notmuch...), I'm often only interested in what happened during the last few days. Here's a little function, bound to "d" in notmuch-search-mode in my .emacs, that asks for the number of days to display on restricts the search accordingly: (defun schnouki/notmuch-search-filter-by-date (days) (interactive "NNumber of days to display: ") (let* ((now (current-time)) (beg (time-subtract now (days-to-time days))) (filter (concat (format-time-string "%s.." beg) (format-time-string "%s" now (notmuch-search-filter filter))) The funny thing is that it also works with decimal inputs: d 1.5 RET, and here is the list of messages received during the last 36 hours :) This is really basic and could be improved by using something like calendar-read-date (or better: org-read-date) to select the bounds of the search. Please tell me if you're interested. *** Autorefresh notmuch-hello via D-Bus *** I process my incoming mails with a massive shell scripts that does many things: the obvious and essential ones (offlineimap, notmuch new, call autotag script), and the optional and fancy ones (update desktop widget with a unread messages counter, display a desktop notification with the last unread messages, make a daily backup of the notmuch DB, etc.). A recent addition was to tell Emacs to update the *notmuch-hello* buffer by calling a D-Bus method. This requires Emacs 23 compiled with D-Bus support. Here's the corresponding code: (require 'dbus) (defun schnouki/notmuch-dbus-notify () (when (get-buffer "*notmuch-hello*") (message "Notmuch notify") (notmuch-hello-update t))) (dbus-register-method :session dbus-service-emacs dbus-path-emacs dbus-service-emacs "NotmuchNotify" 'schnouki/notmuch-dbus-notify) The shell script then runs the following command: dbus-send --session --dest="org.gnu.Emacs" \ "/org/gnu/Emacs" "org.gnu.Emacs.NotmuchNotify" Et voilà ! *notmuch-hello* is updated. (This probably shouldn't be integrated in notmuch because it has almost nothing to do with notmuch itself, but it's still a cool hack and I'm quite proud of it, so I just wanted to share it here :)) *** Automagical message signature selection *** This function selects the signature to insert at the end of a message according to the From header. It's based on a set of rules: when the From header matches a rule, the content of the corresponding file is inserted at the end of the message. (setq schnouki/message-signatures '(("m...@work.tld" . "~/.signature/work") ("m...@fsfe.org" . "~/.signature/fsfe") (".*" . "~/.signature/normal")) (defun schnouki/choose-signature () (let* ((from (message-fetch-field "From")) (sigfile (catch 'first-match (dolist (re-file schnouki/message-signatures) (when (string-match-p (car re-file) from) (throw 'first-match (cdr re-file))) (if sigfile (with-temp-buffer (insert-file-contents sigfile) (buffer-string) (setq message-signature 'schnouki/choose-signature) *** Not done yet :) *** notmuch-search-archive-thread and notmuch-show-archive-thread are nice, but they only remove the "inbox" tag. When quickly browsing through messages I don't wan't to read, I'd also want it to remove the "unread" tag. Right now I copy-pasted them in my .emacs
Re: Multiple sender identities (composing)
On Wed, 1 Jun 2011 15:53:18 +1000, Brian May wrote: > On 16 May 2011 19:29, Stewart Smith wrote: > > > Thought I'd share this bit of my .emacs snippet that may be useful to go > > on the emacs tips page. > > > > This does the following: > > - sets up a list of possible identities to have mail From > > - on composing mail, it prompts you for who you want to send mail from > > - pressing enter will give you the default (first in the list) > > - otherwise you have tab completion > > > > Is it possible to have it change the signature per identity also? There's a function that changes the signature according to the From header in the message I sent on this list yesterday (id:"87pqmznczk@thor.loria.fr", near the end of the message). Regards, -- Thomas/Schnouki pgpkXiMXyteq3.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] test: run emacs inside tmux if screen is not available
Before this change, the test suite reported many failed tests on machines where screen is not installed (which is the case of many *BSD systems). This patch makes the test suite try to use tmux, another terminal multiplexer, if screen is not available. --- test/test-lib.sh | 13 +++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/test/test-lib.sh b/test/test-lib.sh index 0608e42..5851b3d 100755 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -860,12 +860,21 @@ EOF test_emacs () { if [ -z "$EMACS_SERVER" ]; then EMACS_SERVER="notmuch-test-suite-$$" - # start a detached screen session with an emacs server + # start a detached screen or tmux session with an emacs server screen -S "$EMACS_SERVER" -d -m "$TMP_DIRECTORY/run_emacs" \ --no-window-system \ --eval "(setq server-name \"$EMACS_SERVER\")" \ --eval '(server-start)' \ - --eval "(orphan-watchdog $$)" || return + --eval "(orphan-watchdog $$)" + if [ "$?" != 0 ] + then + tmux -f /dev/null -L "$EMACS_SERVER" new-session -d "$TMP_DIRECTORY/run_emacs \ + --no-window-system \ + --eval \"(setq server-name \\\"$EMACS_SERVER\\\")\" \ + --eval '(server-start)' \ + --eval \"(orphan-watchdog $$)\"" || return + fi + # wait until the emacs server is up until test_emacs '()' 2>/dev/null; do sleep 1 -- 1.7.6 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] libnotmuch: only build symbols list after the modules are built
If the notmuch.sym target does not explicitly depend on $(libnotmuch_modules), gen-version-script.sh may be run before all the .o files are created. This can be observed when doing a parallel build on a machine with many cores: $ make -j ... sh lib/gen-version-script.sh lib/notmuch.h lib/filenames.o lib/string-list.o lib/libsha1.o lib/message-file.o lib/messages.o lib/sha1.o lib/tags.o lib/xutil.o lib/database.o lib/directory.o lib/index.o lib/message.o lib/query.o lib/thread.o > notmuch.sym nm: 'lib/libsha1.o': No such file nm: 'lib/message-file.o': No such file nm: 'lib/database.o': No such file nm: 'lib/directory.o': No such file nm: 'lib/index.o': No such file nm: 'lib/message.o': No such file nm: 'lib/query.o': No such file nm: 'lib/thread.o': No such file ... --- lib/Makefile.local |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/lib/Makefile.local b/lib/Makefile.local index 9210f0e..fbc2f6a 100644 --- a/lib/Makefile.local +++ b/lib/Makefile.local @@ -74,7 +74,7 @@ $(dir)/libnotmuch.a: $(libnotmuch_modules) $(dir)/$(LIBNAME): $(libnotmuch_modules) notmuch.sym $(call quiet,CXX $(CXXFLAGS)) $(libnotmuch_modules) $(FINAL_LIBNOTMUCH_LDFLAGS) $(LIBRARY_LINK_FLAG) -o $@ -notmuch.sym: lib/notmuch.h +notmuch.sym: lib/notmuch.h $(libnotmuch_modules) sh lib/gen-version-script.sh $< $(libnotmuch_modules) > $@ $(dir)/$(SONAME): $(dir)/$(LIBNAME) -- 1.7.6 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] test: run emacs inside tmux if screen is not available
On Wed, 20 Jul 2011 10:28:38 -0700, Jameson Graef Rollins wrote: Non-text part: multipart/signed > On Wed, 20 Jul 2011 17:37:35 +0400, Dmitry Kurochkin > wrote: > > On Wed, 20 Jul 2011 14:36:36 +0200, Thomas Jost > > wrote: > > > Before this change, the test suite reported many failed tests on machines > > > where > > > screen is not installed (which is the case of many *BSD systems). This > > > patch > > > makes the test suite try to use tmux, another terminal multiplexer, if > > > screen is > > > not available. > > > > This is a nice improvement. But I think we should make it even better :) > > There are more terminal emulators besides screen and tmux (dtach comes > > to mind). We need a more general mechanism for trying them. There > > should be a list of commands for running terminal emulators in the order > > of preference (I think that is dtach, tmux, screen), and we should try > > each one in a loop (this would also avoid repeating the long emacs > > command). > > Hi, guys. I suppose you can go down this route if you want, but I worry > that it just adds a lot of extra code to the test suite that will > ultimately make it less robust. What's wrong with just depending on > screen for the tests? I'm sure screen is available on every operating > system that we currently support. > > It makes me wary that we would be starting a precedent for making a > bunch of conditionals for all of the possible alternative tools we use > in the test suite. Maybe that's an overblown concern, though. > > jamie. You're right, just depending on screen would be enough (the package is just 864 kB on Arch Linux...), and supporting alternative tools would make the test suite more complicated and less robust. But the dependency on screen should be more *explicit*: if it's not available, the test suite should skip all the emacs tests and display a message about screen. Apparently test-lib.sh includes some things about prerequisites. I'll try to use these to implement the explicit dependency on screen. Regards, -- Thomas/Schnouki pgpVj7WlrZLJN.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] libnotmuch: only build symbols list after the modules are built
If the notmuch.sym target does not explicitly depend on $(libnotmuch_modules), gen-version-script.sh may be run before all the .o files are created, for example when doing a parallel build on a machine with many cores. --- Hi David, Here's an updated version of the patch with a shorter commit message. For the record, the build log I sent earlier was obtained on my work PC, which has two 8-core CPUs. No problem on my laptop with its dual-core CPU though :) Regards, Thomas lib/Makefile.local |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/lib/Makefile.local b/lib/Makefile.local index 9210f0e..fbc2f6a 100644 --- a/lib/Makefile.local +++ b/lib/Makefile.local @@ -74,7 +74,7 @@ $(dir)/libnotmuch.a: $(libnotmuch_modules) $(dir)/$(LIBNAME): $(libnotmuch_modules) notmuch.sym $(call quiet,CXX $(CXXFLAGS)) $(libnotmuch_modules) $(FINAL_LIBNOTMUCH_LDFLAGS) $(LIBRARY_LINK_FLAG) -o $@ -notmuch.sym: lib/notmuch.h +notmuch.sym: lib/notmuch.h $(libnotmuch_modules) sh lib/gen-version-script.sh $< $(libnotmuch_modules) > $@ $(dir)/$(SONAME): $(dir)/$(LIBNAME) -- 1.7.6 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] python: fix Message.get_filenames()
Previously, the Filenames generator only yielded *one* filename before returning, making Message.get_filenames() behave as Message.get_filename(). This commit fixes this incorrect behavior: now the generator yields all the filenames, as expected. --- bindings/python/notmuch/filename.py | 10 -- 1 files changed, 4 insertions(+), 6 deletions(-) diff --git a/bindings/python/notmuch/filename.py b/bindings/python/notmuch/filename.py index 630886d..b44d4c5 100644 --- a/bindings/python/notmuch/filename.py +++ b/bindings/python/notmuch/filename.py @@ -82,13 +82,11 @@ class Filenames(object): if self._files is None: raise NotmuchError(STATUS.NOT_INITIALIZED) -if not nmlib.notmuch_filenames_valid(self._files): -self._files = None -return +while nmlib.notmuch_filenames_valid(self._files): +yield Filenames._get(self._files) +nmlib.notmuch_filenames_move_to_next(self._files) -file = Filenames._get(self._files) -nmlib.notmuch_filenames_move_to_next(self._files) -yield file +self._files = None def __str__(self): """Represent Filenames() as newline-separated list of full paths -- 1.7.6.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 4/4] emacs: add notmuch-hello-hook
--- emacs/notmuch-hello.el |9 - 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 1cf95d7..00bb5ce 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -111,6 +111,11 @@ So: (integer :tag "Number of characters") (float :tag "Fraction of window"))) +(defcustom notmuch-hello-hook nil + "Functions called after populating a `notmuch-hello' buffer." + :type 'hook + :group 'notmuch) + (defcustom notmuch-thousands-separator "," "The string used as a thousands separator. @@ -551,7 +556,9 @@ Complete list of currently available key bindings: (widget-forward 1))) (unless (widget-at) - (notmuch-hello-goto-search) + (notmuch-hello-goto-search)) + + (run-hooks 'notmuch-hello-hook (defun notmuch-folder () "Deprecated function for invoking notmuch---calling `notmuch' is preferred now." -- 1.7.6.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 1/4] emacs: Add a face for crypto parts headers
--- emacs/notmuch-crypto.el |5 + emacs/notmuch-show.el |4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el index f03266f..673ebb8 100644 --- a/emacs/notmuch-crypto.el +++ b/emacs/notmuch-crypto.el @@ -36,6 +36,11 @@ search." :group 'notmuch :type 'boolean) +(defface notmuch-crypto-part-header + '((t (:foreground "blue"))) + "Face used for crypto parts headers." + :group 'notmuch) + (defface notmuch-crypto-signature-good '((t (:background "green" :foreground "black"))) "Face used for good signatures." diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 90f9af7..6b3b042 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -446,7 +446,7 @@ current buffer, if possible." (defun notmuch-show-insert-part-multipart/signed (msg part content-type nth depth declared-type) (let ((button (notmuch-show-insert-part-header nth declared-type content-type nil))) -(button-put button 'face '(:foreground "blue")) +(button-put button 'face 'notmuch-crypto-part-header) ;; add signature status button if sigstatus provided (if (plist-member part :sigstatus) (let* ((headers (plist-get msg :headers)) @@ -469,7 +469,7 @@ current buffer, if possible." (defun notmuch-show-insert-part-multipart/encrypted (msg part content-type nth depth declared-type) (let ((button (notmuch-show-insert-part-header nth declared-type content-type nil))) -(button-put button 'face '(:foreground "blue")) +(button-put button 'face 'notmuch-crypto-part-header) ;; add encryption status button if encstatus specified (if (plist-member part :encstatus) (let ((encstatus (car (plist-get part :encstatus -- 1.7.6.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 3/4] emacs: rename notmuch-decimal-separator to notmuch-thousands-separator
In 123,456.78, "." is the decimal separator, but "," is the thousands separator. This commit also mentions the space being used as thousands separator in several European countries. --- emacs/notmuch-hello.el |8 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 65fde75..1cf95d7 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -111,10 +111,10 @@ So: (integer :tag "Number of characters") (float :tag "Fraction of window"))) -(defcustom notmuch-decimal-separator "," - "The string used as a decimal separator. +(defcustom notmuch-thousands-separator "," + "The string used as a thousands separator. -Typically \",\" in the US and UK and \".\" in Europe." +Typically \",\" in the US and UK and \".\" or \" \" in Europe." :group 'notmuch :type 'string) @@ -139,7 +139,7 @@ Typically \",\" in the US and UK and \".\" in Europe." (apply #'concat (number-to-string (car result)) (mapcar (lambda (elem) - (format "%s%03d" notmuch-decimal-separator elem)) + (format "%s%03d" notmuch-thousands-separator elem)) (cdr result) (defun notmuch-hello-trim (search) -- 1.7.6.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 0/4] Several minor Emacs enhancements
Hello, This is a little series of 4 patches to the Emacs interfaces. They are quite small, independent from each other, and should be harmless. - The first one adds a face for crypto parts headers, because a hardcoded blue foreground looks quite ugly with my color theme. - The second one creates a customizable notmuch-mua-switch-function, which is then passed to message-mail as switch-function. Using this, you can choose to always compose new mails in new frames or new windows. - The third one renames notmuch-decimal-separator to notmuch-thousands-separator, because that's what it really is. - The last one creates a hook run after notmuch-hello, just like there are hooks run after notmuch-search and notmuch-show. Regards, Thomas Thomas Jost (4): emacs: Add a face for crypto parts headers emacs: Support a message-mode switch function in notmuch-mua emacs: rename notmuch-decimal-separator to notmuch-thousands-separator emacs: add notmuch-hello-hook emacs/notmuch-crypto.el |5 + emacs/notmuch-hello.el | 17 - emacs/notmuch-mua.el| 15 +-- emacs/notmuch-show.el |4 ++-- 4 files changed, 32 insertions(+), 9 deletions(-) -- 1.7.6.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 2/4] emacs: Support a message-mode switch function in notmuch-mua
--- emacs/notmuch-mua.el | 15 +-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 8824b08..68c344e 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -31,6 +31,14 @@ :group 'notmuch :type 'hook) +(defcustom notmuch-mua-switch-function nil + "Function used to switch to and display a new mail buffer." + :group 'notmuch + :type 'function + :options '(nil +switch-to-buffer-other-frame +switch-to-buffer-other-window)) + (defcustom notmuch-mua-user-agent-function 'notmuch-mua-user-agent-full "Function used to generate a `User-Agent:' string. If this is `nil' then no `User-Agent:' will be generated." @@ -99,7 +107,8 @@ list." ((same-window-regexps '("\\*mail .*"))) (notmuch-mua-mail (mail-header 'to headers) (mail-header 'subject headers) - (message-headers-to-generate headers t '(to subject + (message-headers-to-generate headers t '(to subject)) + nil notmuch-mua-switch-function)) ;; insert the message body - but put it in front of the signature ;; if one is present (goto-char (point-max)) @@ -112,6 +121,8 @@ list." (message-goto-body)) (defun notmuch-mua-forward-message () + (when notmuch-mua-switch-function +(funcall notmuch-mua-switch-function (current-buffer))) (message-forward) (when notmuch-mua-user-agent-function @@ -199,7 +210,7 @@ the From: address first." (let ((other-headers (when (or prompt-for-sender notmuch-always-prompt-for-sender) (list (cons 'from (notmuch-mua-prompt-for-sender)) -(notmuch-mua-mail nil nil other-headers))) +(notmuch-mua-mail nil nil other-headers nil notmuch-mua-switch-function))) (defun notmuch-mua-new-forward-message (&optional prompt-for-sender) "Invoke the notmuch message forwarding window. -- 1.7.6.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 3/3] test: add emacs test for hiding a message following an HTML part
On Sun, 02 Oct 2011 05:45:53 +0400, Dmitry Kurochkin wrote: > BTW there were patches to support tmux (or maybe it was dtach). IIRC > the consensus was that supporting it does not worth complicating test > lib. I think this can be reconsidered if it turns out that many users > do not have screen, but do have tmux. But you never know if the > patches are not applied. They have been around for several months, I > doubt you would suddenly get feedback now. I'm the one that wrote the tmux patch (and suggested dtach), and yes in the end the consensus was that it wasn't worth it. About adding prereqs to the test suite -- in my private branch I have a rebased and fixed version of the patch series sent by Pieter Praet [1]. It worked fine last time I tested it on a system without screen and in a chroot without emacs/gpg/screen, so if anyone is interested I can post it here. (Cc'ing Pieter) [1] id:"1307016220-17509-1-git-send-email-pie...@praet.org" -- Thomas/Schnouki pgpkCwVQbAc44.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 01/13] test: define a helper function for defining prereqs on executables
While test_expect_success could be used to define these prereqs, this is probably not a good idea: if a prereq is not available, using test_expect_success would result in a test being reported as FAILED at the end of the test suite (and its dependencies as skipped). On the contrary, when using test_set_bin_prereq, no test will be reported as FAILED. --- test/test-lib.sh | 13 + 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/test/test-lib.sh b/test/test-lib.sh index f8df6a5..8e16a7e 100755 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -542,6 +542,19 @@ test_have_prereq () { esac } +test_set_bin_prereq () { + bin=$1 + name=$2 + prereq=$3 + if which $bin &>/dev/null + then + test_set_prereq $prereq + else + say_color info "%-6s" "INFO" + echo " Missing test prerequisite: $name" + fi +} + # You are not expected to call test_ok_ and test_failure_ directly, use # the text_expect_* functions instead. -- 1.7.6.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 00/13] Test prereqs and screen-based Emacs tests
Here it is: a rebased version of Pieter's patch series adding prereqs for the emacs and crypto tests [1], and Dmitry's patches for running emacs inside screen in the test suite [2]. (Please note that this one also includes fixes to improve hidden signatures handling in notmuch-show-advance-and-archive.) I had to do several changes to the original patches: - prereqs are not tested using test_expect_success as they were in Pieter's original patches, but using a new function called test_set_bin_prereq. I wrote this before the gdb prereq was added, hence the different way to set it. - some fixes in Pieter's patches so that it actually works when gpg is not installed. Can't exactly remember what (...but you can just check his original patches), but in the end it was working fine in a chroot without gpg. - I added a little patch to smtp-dummy that makes the test suite work again in Emacs 24 (tested with emacs-pretest 24.0.90). Here are the results when running the test suite on my computer: - without GNU Screen: All 247 tests behaved as expected (1 expected failure). 46 tests skipped. - with GNU Screen: 242/247 tests passed. 2 broken tests failed as expected. 3 tests failed. (The 3 failed tests come from some trouble with Emacs 24, I'll try to fix this later.) *Many* thanks to Dmitry Kurochkin and Pieter Praet for their work! Regards, Thomas [1] id:"1307016220-17509-1-git-send-email-pie...@praet.org" [2] id:"1309496122-4965-1-git-send-email-dmitry.kuroch...@gmail.com" Dmitry Kurochkin (7): test: run emacs inside screen test: avoid using screen(1) configuration files test: do not set frame width in emacs test: `notmuch-show-advance-and-archive' with invisible signature emacs: improve hidden signatures handling in notmuch-show-advance-and-archive emacs: remove no longer used functions from notmuch-show.el emacs: remove unused `point-invisible-p' function Pieter Praet (4): test: add 'GnuPG' prereq to dependent 'crypto' tests test: add 'Emacs' prereq to dependent 'crypto' tests test: add 'Emacs' prereq to dependent 'emacs' tests test: add 'Emacs' prereq to dependent 'emacs-large-search-buffer' tests Thomas Jost (2): test: define a helper function for defining prereqs on executables test: make smtp-dummy work with Emacs 24 emacs/notmuch-lib.el | 15 --- emacs/notmuch-show.el | 25 --- test/crypto| 46 ++--- test/emacs | 85 --- test/emacs-large-search-buffer |9 +++- test/smtp-dummy.c |2 +- test/test-lib.el |3 - test/test-lib.sh | 31 +-- 8 files changed, 127 insertions(+), 89 deletions(-) -- 1.7.6.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 02/13] test: add 'GnuPG' prereq to dependent 'crypto' tests
From: Pieter Praet Adds a new test that checks for the presence of 'gpg', and adds that test as a prereq to all subsequent tests that rely on GnuPG. This causes tests with unmet dependencies to be skipped. Signed-off-by: Pieter Praet --- test/crypto | 35 --- 1 files changed, 20 insertions(+), 15 deletions(-) diff --git a/test/crypto b/test/crypto index b49a4e0..4ee318f 100755 --- a/test/crypto +++ b/test/crypto @@ -7,11 +7,16 @@ test_description='PGP/MIME signature verification and decryption' . ./test-lib.sh +# GnuPG is a prereq. +test_set_bin_prereq gpg "GnuPG" GPG + + add_gnupg_home () { local output [ -d ${GNUPGHOME} ] && return mkdir -m 0700 "$GNUPGHOME" +test_have_prereq GPG || return gpg --no-tty --import <$TEST_DIRECTORY/gnupg-secret-key.asc >"$GNUPGHOME"/import.log 2>&1 test_debug "cat $GNUPGHOME/import.log" if (gpg --quick-random --version >/dev/null 2>&1) ; then @@ -25,13 +30,13 @@ add_gnupg_home () add_gnupg_home # get key fingerprint -FINGERPRINT=$(gpg --no-tty --list-secret-keys --with-colons --fingerprint | grep '^fpr:' | cut -d: -f10) +test_have_prereq GPG && FINGERPRINT=$(gpg --no-tty --list-secret-keys --with-colons --fingerprint | grep '^fpr:' | cut -d: -f10) # for some reason this is needed for emacs_deliver_message to work, # although I can't figure out why add_email_corpus -test_expect_success 'emacs delivery of signed message' \ +test_expect_success GPG 'emacs delivery of signed message' \ 'emacs_deliver_message \ "test signed message 001" \ "This is a test signed message." \ @@ -64,7 +69,7 @@ expected='[[[{"id": "X", {"id": 3, "content-type": "application/pgp-signature"}]}]}, [' -test_expect_equal \ +test_expect_equal GPG \ "$output" \ "$expected" @@ -99,7 +104,7 @@ expected='[[[{"id": "X", {"id": 3, "content-type": "application/pgp-signature"}]}]}, [' -test_expect_equal \ +test_expect_equal GPG \ "$output" \ "$expected" @@ -132,7 +137,7 @@ expected='[[[{"id": "X", {"id": 3, "content-type": "application/pgp-signature"}]}]}, [' -test_expect_equal \ +test_expect_equal GPG \ "$output" \ "$expected" mv "${GNUPGHOME}"{.bak,} @@ -141,7 +146,7 @@ mv "${GNUPGHOME}"{.bak,} catOUTPUT -test_expect_equal_file OUTPUT TESTATTACHMENT +test_expect_equal_file GPG OUTPUT TESTATTACHMENT test_begin_subtest "decryption failure with missing key" mv "${GNUPGHOME}"{,.bak} @@ -258,12 +263,12 @@ expected='[[[{"id": "X", {"id": 3, "content-type": "application/octet-stream"}]}]}, [' -test_expect_equal \ +test_expect_equal GPG \ "$output" \ "$expected" mv "${GNUPGHOME}"{.bak,} -test_expect_success 'emacs delivery of encrypted + signed message' \ +test_expect_success GPG 'emacs delivery of encrypted + signed message' \ 'emacs_deliver_message \ "test encrypted message 002" \ "This is another test encrypted message.\n" \ @@ -298,7 +303,7 @@ expected='[[[{"id": "X", "content-type": "text/plain", "content": "This is another test encrypted message.\n"}]}]}, [' -test_expect_equal \ +test_expect_equal GPG \ "$output" \ "$expected" @@ -312,7 +317,7 @@ On 01 Jan 2000 12:00:00 -, Notmuch Test Suite w Non-text part: multipart/encrypted Non-text part: application/pgp-encrypted > This is another test encrypted message.' -test_expect_equal \ +test_expect_equal GPG \ "$output" \ "$expected" @@ -353,7 +358,7 @@ expected='[[[{"id": "X", {"id": 3, "content-type": "application/pgp-signature"}]}]}, [' -test_expect_equal \ +test_expect_equal GPG \ "$output" \ "$expected" -- 1.7.6.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 04/13] test: add 'Emacs' prereq to dependent 'emacs' tests
From: Pieter Praet Adds a new test that checks for the presence of 'emacs', and adds that test as a prereq to all subsequent tests that rely on Emacs. This causes tests with unmet dependencies to be skipped. Signed-off-by: Pieter Praet --- test/emacs | 71 --- 1 files changed, 38 insertions(+), 33 deletions(-) diff --git a/test/emacs b/test/emacs index 8b627c7..50958ec 100755 --- a/test/emacs +++ b/test/emacs @@ -3,6 +3,11 @@ test_description="emacs interface" . test-lib.sh +# Emacs is a prereq. +test_set_bin_prereq screen "GNU Screen" SCREEN +test_have_prereq SCREEN && test_set_bin_prereq emacs "Emacs" EMACS + + EXPECTED=$TEST_DIRECTORY/emacs.expected-output add_email_corpus @@ -10,7 +15,7 @@ add_email_corpus test_begin_subtest "Basic notmuch-hello view in emacs" test_emacs '(notmuch-hello) (test-output)' -test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello +test_expect_equal_file EMACS OUTPUT $EXPECTED/notmuch-hello test_begin_subtest "Saved search with 0 results" test_emacs '(let ((notmuch-show-empty-saved-searches t) @@ -20,20 +25,20 @@ test_emacs '(let ((notmuch-show-empty-saved-searches t) ("empty" . "tag:doesnotexist" (notmuch-hello) (test-output))' -test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-with-empty +test_expect_equal_file EMACS OUTPUT $EXPECTED/notmuch-hello-with-empty test_begin_subtest "No saved searches displayed (all with 0 results)" test_emacs '(let ((notmuch-saved-searches '\''(("empty" . "tag:doesnotexist" (notmuch-hello) (test-output))' -test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-no-saved-searches +test_expect_equal_file EMACS OUTPUT $EXPECTED/notmuch-hello-no-saved-searches test_begin_subtest "Basic notmuch-search view in emacs" test_emacs '(notmuch-search "tag:inbox") (notmuch-test-wait) (test-output)' -test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox +test_expect_equal_file EMACS OUTPUT $EXPECTED/notmuch-search-tag-inbox test_begin_subtest "Navigation of notmuch-hello to search results" test_emacs '(notmuch-hello) @@ -42,13 +47,13 @@ test_emacs '(notmuch-hello) (widget-button-press (point)) (notmuch-test-wait) (test-output)' -test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-view-inbox +test_expect_equal_file EMACS OUTPUT $EXPECTED/notmuch-hello-view-inbox test_begin_subtest "Basic notmuch-show view in emacs" maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.gu3...@dottiness.seas.harvard.edu) test_emacs "(notmuch-show \"$maildir_storage_thread\") (test-output)" -test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage +test_expect_equal_file EMACS OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage test_begin_subtest "notmuch-show for message with invalid From" add_message "[subject]=\"message-with-invalid-from\"" \ @@ -64,7 +69,7 @@ Date: Tue, 05 Jan 2001 15:43:57 - This is just a test message (#1) EOF -test_expect_equal_file OUTPUT EXPECTED +test_expect_equal_file EMACS OUTPUT EXPECTED test_begin_subtest "Navigation of notmuch-search to thread view" test_emacs '(notmuch-search "tag:inbox") @@ -74,7 +79,7 @@ test_emacs '(notmuch-search "tag:inbox") (notmuch-search-show-thread) (notmuch-test-wait) (test-output)' -test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage +test_expect_equal_file EMACS OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage test_begin_subtest "Add tag from search view" os_x_darwin_thread=$(notmuch search --output=threads id:ddd65cda0911171950o4eea4389v86de9525e4605...@mail.gmail.com) @@ -82,26 +87,26 @@ test_emacs "(notmuch-search \"$os_x_darwin_thread\") (notmuch-test-wait) (notmuch-search-add-tag \"tag-from-search-view\")" output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize) -test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-search-view unread)" +test_expect_equal EMACS "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-search-view unread)" test_begin_subtest "Remove tag from search view" test_emacs "(notmuch-search \"$os_x_darwin_thread\") (notmuch-test-wait) (notmuch-search-remove-tag \"tag-from-search-view\")" output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize) -test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)" +test_expect_equal EMACS "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lo
[PATCH 03/13] test: add 'Emacs' prereq to dependent 'crypto' tests
From: Pieter Praet Adds a new test that checks for the presence of 'emacs', and adds that test as a prereq to all subsequent tests that rely on Emacs. This causes tests with unmet dependencies to be skipped. Right now, all crypto tests do depend on Emacs, because it is used to generate the signed/encrypted messages that are needed by the tests. Signed-off-by: Pieter Praet --- test/crypto | 39 +-- 1 files changed, 25 insertions(+), 14 deletions(-) diff --git a/test/crypto b/test/crypto index 4ee318f..cd64275 100755 --- a/test/crypto +++ b/test/crypto @@ -7,9 +7,20 @@ test_description='PGP/MIME signature verification and decryption' . ./test-lib.sh +# Emacs is a prereq. +test_set_bin_prereq screen "GNU Screen" SCREEN +test_have_prereq SCREEN && test_set_bin_prereq emacs "Emacs" EMACS + # GnuPG is a prereq. test_set_bin_prereq gpg "GnuPG" GPG +# Some tests have multiple prereqs, but the test_expect_* functions +# accept only a single argument as prereq tag, and using test_have_prereq +# in and around tests causes various errors for me, so a dirty workaround +# will have to do for the time being. +test_have_prereq EMACS && test_have_prereq GPG \ +&& test_set_prereq EMACS+GPG + add_gnupg_home () { @@ -36,7 +47,7 @@ test_have_prereq GPG && FINGERPRINT=$(gpg --no-tty --list-secret-keys --with-col # although I can't figure out why add_email_corpus -test_expect_success GPG 'emacs delivery of signed message' \ +test_expect_success EMACS+GPG 'emacs delivery of signed message' \ 'emacs_deliver_message \ "test signed message 001" \ "This is a test signed message." \ @@ -69,7 +80,7 @@ expected='[[[{"id": "X", {"id": 3, "content-type": "application/pgp-signature"}]}]}, [' -test_expect_equal GPG \ +test_expect_equal EMACS+GPG \ "$output" \ "$expected" @@ -104,7 +115,7 @@ expected='[[[{"id": "X", {"id": 3, "content-type": "application/pgp-signature"}]}]}, [' -test_expect_equal GPG \ +test_expect_equal EMACS+GPG \ "$output" \ "$expected" @@ -137,7 +148,7 @@ expected='[[[{"id": "X", {"id": 3, "content-type": "application/pgp-signature"}]}]}, [' -test_expect_equal GPG \ +test_expect_equal EMACS+GPG \ "$output" \ "$expected" mv "${GNUPGHOME}"{.bak,} @@ -146,7 +157,7 @@ mv "${GNUPGHOME}"{.bak,} catOUTPUT -test_expect_equal_file GPG OUTPUT TESTATTACHMENT +test_expect_equal_file EMACS+GPG OUTPUT TESTATTACHMENT test_begin_subtest "decryption failure with missing key" mv "${GNUPGHOME}"{,.bak} @@ -263,12 +274,12 @@ expected='[[[{"id": "X", {"id": 3, "content-type": "application/octet-stream"}]}]}, [' -test_expect_equal GPG \ +test_expect_equal EMACS+GPG \ "$output" \ "$expected" mv "${GNUPGHOME}"{.bak,} -test_expect_success GPG 'emacs delivery of encrypted + signed message' \ +test_expect_success EMACS+GPG 'emacs delivery of encrypted + signed message' \ 'emacs_deliver_message \ "test encrypted message 002" \ "This is another test encrypted message.\n" \ @@ -303,7 +314,7 @@ expected='[[[{"id": "X", "content-type": "text/plain", "content": "This is another test encrypted message.\n"}]}]}, [' -test_expect_equal GPG \ +test_expect_equal EMACS+GPG \ "$output" \ "$expected" @@ -317,7 +328,7 @@ On 01 Jan 2000 12:00:00 -, Notmuch Test Suite w Non-text part: multipart/encrypted Non-text part: application/pgp-encrypted > This is another test encrypted message.' -test_expect_equal GPG \ +test_expect_equal EMACS+GPG \ "$output" \ "$expected" @@ -358,7 +369,7 @@ expected='[[[{"id": "X", {"id": 3, "content-type": "application/pgp-signature"}]}]}, [' -test_expect_equal GPG \ +test_expect_equal EMACS+GPG \ "$output" \ "$expected" -- 1.7.6.4 __
[PATCH 05/13] test: add 'Emacs' prereq to dependent 'emacs-large-search-buffer' tests
From: Pieter Praet Adds a new test that checks for the presence of 'emacs', and adds that test as a prereq to all subsequent tests that rely on Emacs. This causes tests with unmet dependencies to be skipped. Signed-off-by: Pieter Praet --- test/emacs-large-search-buffer |9 +++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/test/emacs-large-search-buffer b/test/emacs-large-search-buffer index 6095e9d..018333a 100755 --- a/test/emacs-large-search-buffer +++ b/test/emacs-large-search-buffer @@ -2,6 +2,11 @@ test_description="Emacs with large search results buffer" . test-lib.sh +# Emacs is a prereq. +test_set_bin_prereq screen "GNU Screen" SCREEN +test_have_prereq SCREEN && test_set_bin_prereq emacs "Emacs" EMACS + + x=xx # 10 x=$x$x$x$x$x$x$x$x$x$x # 100 x=$x$x$x$x$x$x$x$x$x # 900 @@ -27,7 +32,7 @@ test_emacs '(notmuch-search "*") (notmuch-test-wait) (test-output)' sed -i -e s', *, ,g' -e 's/xxx*/[BLOB]/g' OUTPUT -test_expect_equal_file OUTPUT EXPEXTED +test_expect_equal_file EMACS OUTPUT EXPEXTED test_begin_subtest "Ensure that emacs doesn't drop error messages" test_emacs '(notmuch-search "--this-option-does-not-exist") @@ -38,6 +43,6 @@ Error: Unexpected output from notmuch search: Unrecognized option: --this-option-does-not-exist End of search results. (process returned 1) EOF -test_expect_equal_file OUTPUT EXPEXTED +test_expect_equal_file EMACS OUTPUT EXPEXTED test_done -- 1.7.6.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 06/13] test: run emacs inside screen
From: Dmitry Kurochkin Before the change, emacs run in daemon mode without any visible buffers. Turns out that this affects emacs behavior in some cases. In particular, `window-end' function returns `point-max' instead of the last visible position. That makes it hard or impossible to implement some tests. The patch runs emacs in a detached screen(1) session. So that it works exactly as if it has a visible window. Note: screen terminates when emacs exits. So the patch does not introduce new "running processes left behind" issues. --- test/test-lib.sh | 16 1 files changed, 12 insertions(+), 4 deletions(-) diff --git a/test/test-lib.sh b/test/test-lib.sh index 8e16a7e..f9fd73e 100755 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -852,14 +852,22 @@ EOF test_emacs () { if [ -z "$EMACS_SERVER" ]; then + # start a detached screen session with an emacs server + which screen &>/dev/null || return EMACS_SERVER="notmuch-test-suite-$$" - "$TMP_DIRECTORY/run_emacs" \ - --daemon \ + screen -S "$EMACS_SERVER" -d -m "$TMP_DIRECTORY/run_emacs" \ + --no-window-system \ --eval "(setq server-name \"$EMACS_SERVER\")" \ + --eval '(server-start)' \ --eval "(orphan-watchdog $$)" || return + # wait until the emacs server is up + until test_emacs '()' 2>/dev/null; do + sleep 1 + done + fi + if [ "$EMACS_SERVER" ]; then + emacsclient --socket-name="$EMACS_SERVER" --eval "(progn $@)" fi - - emacsclient --socket-name="$EMACS_SERVER" --eval "(progn $@)" } -- 1.7.6.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 07/13] test: avoid using screen(1) configuration files
From: Dmitry Kurochkin Set SCREENRC and SYSSCREENRC environment variables to "/dev/null" as suggested by Jim Paris to avoid potential problems with screen(1) configuration files. --- test/test-lib.sh |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/test/test-lib.sh b/test/test-lib.sh index f9fd73e..b22a25c 100755 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -50,6 +50,8 @@ TZ=UTC TERM=dumb export LANG LC_ALL PAGER TERM TZ GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u} +export SCREENRC=/dev/null +export SYSSCREENRC=/dev/null # Protect ourselves from common misconfiguration to export # CDPATH into the environment -- 1.7.6.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 08/13] test: do not set frame width in emacs
From: Dmitry Kurochkin No need for `set-frame-width' in emacs tests since it runs in screen now. --- test/test-lib.el |3 --- 1 files changed, 0 insertions(+), 3 deletions(-) diff --git a/test/test-lib.el b/test/test-lib.el index a783936..97ae593 100644 --- a/test/test-lib.el +++ b/test/test-lib.el @@ -20,9 +20,6 @@ ;; ;; Authors: Dmitry Kurochkin -;; avoid crazy 10-column default of --batch -(set-frame-width (window-frame (get-buffer-window)) 80) - ;; `read-file-name' by default uses `completing-read' function to read ;; user input. It does not respect `standard-input' variable which we ;; use in tests to provide user input. So replace it with a plain -- 1.7.6.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 09/13] test: `notmuch-show-advance-and-archive' with invisible signature
From: Dmitry Kurochkin Add Emacs test to check that `notmuch-show-advance-and-archive' works for the last message in thread with invisible signature. --- test/emacs | 14 ++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/test/emacs b/test/emacs index 50958ec..fddb5cf 100755 --- a/test/emacs +++ b/test/emacs @@ -373,4 +373,18 @@ test_emacs "(notmuch-show \"id:$id\") \ (test-visible-output \"EXPECTED\")" test_expect_equal_file EMACS OUTPUT EXPECTED +test_begin_subtest 'notmuch-show-advance-and-archive with invisible signature' +message1='id:20091118010116.gc25...@dottiness.seas.harvard.edu' +message2='id:1258491078-29658-1-git-send-email-dotted...@dottedmag.net' +test_emacs "(notmuch-search \"$message1 or $message2\") + (notmuch-test-wait) + (notmuch-search-show-thread) + (goto-char (point-max)) + (redisplay) + (notmuch-show-advance-and-archive) + (test-output)" +test_emacs "(notmuch-show \"$message2\") + (test-output \"EXPECTED\")" +test_expect_equal_file EMACS OUTPUT EXPECTED + test_done -- 1.7.6.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 10/13] emacs: improve hidden signatures handling in notmuch-show-advance-and-archive
From: Dmitry Kurochkin Use `previous-single-char-property-change' instead of going through each character by hand and testing it's visibility. This fixes `notmuch-show-advance-and-archive' to work for the last message in thread with hidden signature. --- emacs/notmuch-show.el | 17 + 1 files changed, 9 insertions(+), 8 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 90f9af7..bf267e8 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1106,17 +1106,18 @@ 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." (interactive) - (let ((end-of-this-message (notmuch-show-message-bottom))) + (let* ((end-of-this-message (notmuch-show-message-bottom)) +(visible-end-of-this-message (1- end-of-this-message))) +(while (invisible-p visible-end-of-this-message) + (setq visible-end-of-this-message + (previous-single-char-property-change visible-end-of-this-message + 'invisible))) (cond ;; Ideally we would test `end-of-this-message' against the result ;; of `window-end', but that doesn't account for the fact that - ;; the end of the message might be hidden, so we have to actually - ;; go to the end, walk back over invisible text and then see if - ;; point is visible. - ((save-excursion - (goto-char (- end-of-this-message 1)) - (notmuch-show-move-past-invisible-backward) - (> (point) (window-end))) + ;; the end of the message might be hidden. + ((and visible-end-of-this-message + (> visible-end-of-this-message (window-end))) ;; The bottom of this message is not visible - scroll. (scroll-up nil)) -- 1.7.6.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 11/13] emacs: remove no longer used functions from notmuch-show.el
From: Dmitry Kurochkin Remove `notmuch-show-move-past-invisible-backward' and `notmuch-show-move-past-invisible-forward' functions which are unused. --- emacs/notmuch-show.el |8 1 files changed, 0 insertions(+), 8 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index bf267e8..e6265e8 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -970,14 +970,6 @@ All currently available key bindings: (notmuch-show-move-to-message-top) t)) -(defun notmuch-show-move-past-invisible-forward () - (while (point-invisible-p) -(forward-char))) - -(defun notmuch-show-move-past-invisible-backward () - (while (point-invisible-p) -(backward-char))) - ;; Functions relating to the visibility of messages and their ;; components. -- 1.7.6.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 12/13] emacs: remove unused `point-invisible-p' function
From: Dmitry Kurochkin `point-invisible-p' does not work correctly when `invisible' property is a list. There are standard `invisible-p' and related functions that should be used instead. --- emacs/notmuch-lib.el | 15 --- 1 files changed, 0 insertions(+), 15 deletions(-) diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index f93c957..0f856bf 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -105,21 +105,6 @@ the user hasn't set this variable with the old or new value." ;; -;; XXX: This should be a generic function in emacs somewhere, not -;; here. -(defun point-invisible-p () - "Return whether the character at point is invisible. - -Here visibility is determined by `buffer-invisibility-spec' and -the invisible property of any overlays for point. It doesn't have -anything to do with whether point is currently being displayed -within the current window." - (let ((prop (get-char-property (point) 'invisible))) -(if (eq buffer-invisibility-spec t) - prop - (or (memq prop buffer-invisibility-spec) - (assq prop buffer-invisibility-spec) - (defun notmuch-remove-if-not (predicate list) "Return a copy of LIST with all items not satisfying PREDICATE removed." (let (out) -- 1.7.6.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 13/13] test: make smtp-dummy work with Emacs 24
In Emacs 24, a space is expected after a SMTP response code. If we don't respect that, smtpmail-send-it will wait forever. --- test/smtp-dummy.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/test/smtp-dummy.c b/test/smtp-dummy.c index 9da8202..021af11 100644 --- a/test/smtp-dummy.c +++ b/test/smtp-dummy.c @@ -71,7 +71,7 @@ static int process_command (FILE *peer, FILE *output, const char *command) { if (STRNCMP_LITERAL (command, "EHLO ") == 0) { - fprintf (peer, "502\r\n"); + fprintf (peer, "502 not implemented\r\n"); fflush (peer); } else if (STRNCMP_LITERAL (command, "HELO ") == 0) { fprintf (peer, "250 localhost\r\n"); -- 1.7.6.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 2/4] emacs: Support a message-mode switch function in notmuch-mua
On Mon, 10 Oct 2011 08:50:52 -0700, Jameson Graef Rollins wrote: > However, I find the customization variable a bit clunky. Since I wasn't > presented with any options in the customization, I didn't know what to > put in. I copy and pasted "switch-to-buffer-other-frame" into the > customization field but that didn't work since I didn't protect the > function name. Finally I got it to work by putting in > "'switch-to-buffer-other-frame" (with the initial "'"). > > So I definitely love this feature, but can we make the customization > work better so that it's easier for the user to figure out how to set > it? Heh, I had just tested it using "(setq ...)", not using M-x customize. And yes, when using the customization interface it's not clear at all. The problem is that the ":options" property of customizable variables is only useful for hooks or alists, not for functions (but that isn't documented anywhere, I had to dig in custom.el to find this). So I think the best way to make that clearer and easier to figure out is just to add more details in the docstring. I'll send a patch as a reply to this message. > Another question about this feature: how do you make the window > (frame) go away after the email is sent? I do this: (add-hook 'message-sent-hook 'delete-frame) (added to the doc too). Thanks for your review :) -- Thomas/Schnouki pgp2hbX4jbJk1.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2] emacs: Support a message-mode switch function in notmuch-mua
--- emacs/notmuch-mua.el | 21 +++-- 1 files changed, 19 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 8824b08..639407f 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -31,6 +31,20 @@ :group 'notmuch :type 'hook) +(defcustom notmuch-mua-switch-function nil + "Function used to switch to and display a new mail buffer. If +this is `nil' then the buffer will be displayed in the current +window. Other common values are `switch-to-buffer-other-frame' +and `switch-to-buffer-other-window'. If you change this, you may +also want to change `message-sent-hook' accordingly: +(setq notmuch-muas-witch-function 'switch-to-buffer-other-frame) +(add-hook 'message-sent-hook '(delete-frame))" + :group 'notmuch + :type 'function + :options '(nil +switch-to-buffer-other-frame +switch-to-buffer-other-window)) + (defcustom notmuch-mua-user-agent-function 'notmuch-mua-user-agent-full "Function used to generate a `User-Agent:' string. If this is `nil' then no `User-Agent:' will be generated." @@ -99,7 +113,8 @@ list." ((same-window-regexps '("\\*mail .*"))) (notmuch-mua-mail (mail-header 'to headers) (mail-header 'subject headers) - (message-headers-to-generate headers t '(to subject + (message-headers-to-generate headers t '(to subject)) + nil notmuch-mua-switch-function)) ;; insert the message body - but put it in front of the signature ;; if one is present (goto-char (point-max)) @@ -112,6 +127,8 @@ list." (message-goto-body)) (defun notmuch-mua-forward-message () + (when notmuch-mua-switch-function +(funcall notmuch-mua-switch-function (current-buffer))) (message-forward) (when notmuch-mua-user-agent-function @@ -199,7 +216,7 @@ the From: address first." (let ((other-headers (when (or prompt-for-sender notmuch-always-prompt-for-sender) (list (cons 'from (notmuch-mua-prompt-for-sender)) -(notmuch-mua-mail nil nil other-headers))) +(notmuch-mua-mail nil nil other-headers nil notmuch-mua-switch-function))) (defun notmuch-mua-new-forward-message (&optional prompt-for-sender) "Invoke the notmuch message forwarding window. -- 1.7.7 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] Separate Emacs miscellaneous files directory from Emacs code directory.
On Mon, 24 Oct 2011 22:13:11 -0300, David Bremner wrote: > On Mon, 24 Oct 2011 20:34:58 +0200, Amadeusz Żołnowski > wrote: > > --emacsetcdir was added, but it's set default to the same value as > > --emacslispdir for backward compatibility. > > --- > > At a quick search, I couldn't find any reference to --emacsetcdir > outside Gentoo. I'd like to hear what other people think about this one. I had never heard of that, but apparently there's a /usr/share/emacs/24.0.90/etc on my system which contains images, READMEs and other misc files. It's also described in the "data-directory" variable in Emacs: data-directory is a variable defined in `C source code'. Its value is "/usr/share/emacs/24.0.90/etc/" Documentation: Directory of machine-independent files that come with GNU Emacs. These are files intended for Emacs to use while it runs. So I guess it can't hurt to add this. However there is something annoying in the commit: +# The directory to which emacs lisp files should be installed +emacsetcdir=${EMACSETCDIR} $EMACSETCDIR is not for emacs lisp files (that's what $EMACSLISPDIR is for), so this line needs be fixed. Regards -- Thomas/Schnouki pgpLPSrxZpqhF.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 2/4] emacs: Support a message-mode switch function in notmuch-mua
On Tue, 18 Oct 2011 07:46:48 -0700, Jameson Graef Rollins wrote: > On Tue, 11 Oct 2011 21:49:48 +0200, Thomas Jost wrote: > > > Another question about this feature: how do you make the window > > > (frame) go away after the email is sent? > > > > I do this: > > (add-hook 'message-sent-hook 'delete-frame) > > Hey, Thomas. Would it be possible to add this frame/window close > functionality directly into this new configuration? It would be really > nice if we could work it out such that if you have new mail buffers open > in a new window/frame that the window/frame is automatically closed once > the message is sent. Yes, it's possible using dedicated windows (for details: C-h f set-window-dedicated-p). But it's a little trickier to use: if you call it from a switch-function, it doesn't work when forwarding a message. There's probably something in message-forward that causes the dedicated flag to be reset to nil, but I could not find what. So instead I wrote a little workaround that may be easier to use. I'll send the commit as a reply. Regards, -- Thomas/Schnouki pgpkhibPbAbYg.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] emacs: Let the user choose where to compose new mails
--- emacs/notmuch-mua.el | 37 +++-- 1 files changed, 35 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 8824b08..ebc922f 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -31,6 +31,34 @@ :group 'notmuch :type 'hook) +(defvar notmuch-mua-switch-function nil + "Function used to switch and display the mail buffer. This is + normally set by `notmuch-mua-compose-in'.") +(defvar notmuch-mua-dedicated-flag nil + "Flag to pass to `set-window-dedicated-p' in the mail buffer. + This is normally set by `notmuch-mua-compose-in'.") +(defcustom notmuch-mua-compose-in 'current-window + "Where to create the mail buffer used to compose a new message. + Possible values are `current-window' (default), `new-window' + and `new-frame'. If set to `new-window' or `new-frame', the + mail buffer will be displayer in a new window/frame that will + be destroyed when the buffer is killed. You may want to + customize `message-kill-buffer-on-exit' accordingly." + :group 'notmuch + :type 'symbol + :set (lambda (sym val) +(cond ((eq val 'current-window) + (setq notmuch-mua-switch-function nil + notmuch-mua-dedicated-flag nil)) + ((eq val 'new-window) + (setq notmuch-mua-switch-function 'switch-to-buffer-other-window + notmuch-mua-dedicated-flag 1)) + ((eq val 'new-frame) + (setq notmuch-mua-switch-function 'switch-to-buffer-other-frame + notmuch-mua-dedicated-flag 1)) + (t (error (concat "Bad value for notmuch-mua-compose-in: " +(symbol-value val))) + (defcustom notmuch-mua-user-agent-function 'notmuch-mua-user-agent-full "Function used to generate a `User-Agent:' string. If this is `nil' then no `User-Agent:' will be generated." @@ -99,7 +127,8 @@ list." ((same-window-regexps '("\\*mail .*"))) (notmuch-mua-mail (mail-header 'to headers) (mail-header 'subject headers) - (message-headers-to-generate headers t '(to subject + (message-headers-to-generate headers t '(to subject)) + nil notmuch-mua-switch-function)) ;; insert the message body - but put it in front of the signature ;; if one is present (goto-char (point-max)) @@ -112,6 +141,8 @@ list." (message-goto-body)) (defun notmuch-mua-forward-message () + (when notmuch-mua-switch-function +(funcall notmuch-mua-switch-function (current-buffer))) (message-forward) (when notmuch-mua-user-agent-function @@ -121,6 +152,7 @@ list." (message-sort-headers) (message-hide-headers) (set-buffer-modified-p nil) + (set-window-dedicated-p (selected-window) notmuch-mua-dedicated-flag) (message-goto-to)) @@ -143,6 +175,7 @@ list." (message-sort-headers) (message-hide-headers) (set-buffer-modified-p nil) + (set-window-dedicated-p (selected-window) notmuch-mua-dedicated-flag) (message-goto-to)) @@ -199,7 +232,7 @@ the From: address first." (let ((other-headers (when (or prompt-for-sender notmuch-always-prompt-for-sender) (list (cons 'from (notmuch-mua-prompt-for-sender)) -(notmuch-mua-mail nil nil other-headers))) +(notmuch-mua-mail nil nil other-headers nil notmuch-mua-switch-function))) (defun notmuch-mua-new-forward-message (&optional prompt-for-sender) "Invoke the notmuch message forwarding window. -- 1.7.7 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: how do you do everyday mail catchup with notmuch? (was: Re: search for date received possible?)
On Tue, 25 Oct 2011 19:31:01 +0200, Gregor Zattler wrote: > With a convectional email setup, emails are filtered in > one/several folders and one looks in these folders for new emails > which weren't there last time. (Especially outlook) users get > fooled if important emails have for one reason or another a wrong > date and are therefore not sorted at the end/beginning of their > emails so they are missed. Best way to not miss newly arrived > email for me is to sort them chronologically according to time of > arrival. > > Is there another solution to this email handling problem which > works with notmuch (and of which I'm not aware ATM)? > > How do you make sure you don't miss emails while using notmuch? Here's my setup: - on my server, mails are sorted with Dovecot sieve module. They are put in several folders so that I have something usable when I use my webmail (RoundCube) or my phone (with IMAP access). - on my PC, I run a script every few minutes which does the following: - run offlineimap to sync mails between the remote IMAP server and my local Maildir - run "notmuch new", configured to add the tags "inbox" and "new" to the new messages - run an autotag script inspired by [1] but *much* more complex and longer... I wrote it in Python, which is faster than running notmuch several dozens of times. It only filters mails with the "new" tag, and removes this tag after that, so that they are only sorted once. - after new mails are tagged, run a "notify" script that displays a notification with a list of unread messages (using libnotify, so nicely integrated to the desktop). - once per day, run "notmuch dump" to a backup dir. - I then read mails in Emacs, with several saved searches: "tag:unread", "tag:inbox", "tag:flagged", "tag:todo", etc. Mails are sorted chronologically (oldest first). Using notmuch-search-line-faces, they are also displayed in several colors: unread with a specific background, "flagged" with another, "tag:todo" with yet another, etc., so that you can spot important messages instantly. - When I have read a message, I archive it by removing both the "unread" and "inbox" tags (I bound that to a single key in notmuch-search and notmuch-show). And of course I try to keep the numbers of mails in my "inbox" as low as possible :) The combination of the "inbox", "unread", "flagged" and "todo" tags and faces works quite well for me. I've been using this setup for several months without any problem. You can find my whole mailsync and notify scripts on Github [2], as well as my Emacs config [3]. However I keep my autotag script private because there are many email addresses in plaintext there, but if you want I can send you a copy off-list (or a stripped-down version on the list). Regards, [1]: http://notmuchmail.org/initial_tagging/ [2]: https://github.com/Schnouki/dotfiles/tree/master/notmuch [3]: https://github.com/Schnouki/dotfiles/blob/master/emacs/init-50-mail.el -- Thomas/Schnouki pgp9gjgv2nBNb.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: Emacs: notmuch-show-mode failing to actually update tags
On Thu, 27 Oct 2011 10:23:48 +0200, Erlend Simonsen wrote: > These seemed to fail: > > > FAIL Add tag from notmuch-show view > --- emacs.11.expected 2011-10-27 08:04:40.542525380 + > +++ emacs.11.output 2011-10-27 08:04:40.544525353 + > @@ -1 +1 @@ > -thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; > [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-show-view > unread) > +thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; > [notmuch] Mac OS X/Darwin compatibility issues (inbox unread) > nil > > FAIL Message with .. in Message-Id: > --- emacs.13.expected 2011-10-27 08:04:40.712523199 + > +++ emacs.13.output 2011-10-27 08:04:40.712523199 + > @@ -1 +1 @@ > -thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Message with .. in > Message-Id (inbox search-add show-add) > + > *ERROR*: Error: notmuch tag requires at least one search term. Both of these work for me, both with latest master and 0.9-6-g8bb5b62, using Emacs-pretest 24.0.90 (compiled it myself) on Arch Linux... Weird. > Yep, issue already reported, it's a problem with smtp-dummy. You can fix it by applying the patch from this message: id:"1317660447-27520-14-git-send-email-schno...@schnouki.net" (or just killall smtp-dummy several times while running the test suite :)) -- Thomas/Schnouki pgp87jI8OXFPf.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: Emacs: notmuch-show-mode failing to actually update tags
On Thu, 27 Oct 2011 08:01:08 -0700, Jameson Graef Rollins wrote: > On Thu, 27 Oct 2011 15:57:00 +0200, Thomas Jost wrote: > > Both of these work for me, both with latest master and 0.9-6-g8bb5b62, > > using Emacs-pretest 24.0.90 (compiled it myself) on Arch Linux... Weird. > > Erlend, are you sure you don't have anything else in your emacs > environment that may be affecting this? What system do you use? How > was your version of emacs obtained? Additionnal questions: which version of bash are you using, is it bash or dash? > > > > > > > Yep, issue already reported, it's a problem with smtp-dummy. You can fix > > it by applying the patch from this message: > > id:"1317660447-27520-14-git-send-email-schno...@schnouki.net" (or just > > killall smtp-dummy several times while running the test suite :)) > > Was this patch not applied? It's part of a series of other patches that > I think *were* applied. I would be curious to know why this one wasn't. No. It was part of the series with patches that add emacs+gpg prereqs and "run emacs in screen" to the test suite, but just after I sent the series the ML stalled for almost a day... and apparently everyone forgot about them :) Regards, -- Thomas/Schnouki pgpFaKp8FS8Zs.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [Patch] Fix Emacs interface bug dealing with invisible text
On Fri, 28 Oct 2011 20:29:49 -0400, Ivy Foster wrote: > Hey, folks, > > I'm new to notmuch, but like much of what I've tried so far. > Thanks to all the contributors! > > The following patch fixes a bug I've noticed in Emacs's > notmuch-show mode. Specifically, if you: > > - have certain kinds of washing turned on (I've noticed > it with signature hiding), and > > - are looking at the last or only message in a thread > > If you then hit Space (`notmuch-show-advance-or-archive') to > move on, Emacs will fail to advance and/or archive the > message, due to being kicked out of area of the invisible > text before it can do what it's gotta do. > > The patch should fix the problem at the root, which seems to > be with notmuch-show-move-past-invisible-[forward|backward]. Hi Ivy, Thanks for this patch. I haven't tested it, but I will! However, I'm wondering something: wasn't this issue already addressed in Dmitry's patch series that I rebased and reposted almost a month ago, specifically patches 9/13 to 12/13? Patch 9/13 of the rebased series is id:"1317660447-27520-10-git-send-email-schno...@schnouki.net". Regards, -- Thomas/Schnouki pgp0E2Tq1xvxn.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 3/3] Add notmuch-hello-mode-hook
On Sat, 29 Oct 2011 12:35:04 -0400, Ivy Foster wrote: > The following patch adds a mode-hook to notmuch-hello-mode. > Not much else to say, really. I agree it's useful, but id:"1317643438-31272-5-git-send-email-schno...@schnouki.net" ;) (the hooks are not run from the same place though) > Would people find hooks for before and/or after adding the > tags useful? There are such hooks already: notmuch-{after,before}-tag-hook. Or do you mean something different? Regards, -- Thomas/Schnouki pgpGyosljBsKi.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] emacs: Let the user choose where to compose new mails
On Fri, 4 Nov 2011 23:51:55 -0400, Austin Clements wrote: > This seems like a good option to have, but your approach seems > unnecessarily complicated. I'm always wary of defcustom's :set because > it means you can't just setq the variable, which defeats the > underlying beauty of the customize system. Actually I use it with setq without any problem. But yes, it's too complicated... > You could eliminate the other two variables and compute them on the > fly, or, if you really feel they may need to be controlled > independently, make the custom variable a pair or alist (which you can > hide behind a few const choices). Computing them on the fly is probably cleaner. But I'm not sure if the switch-function and dedicated flag must be independent or not. From what I've tested it's *much* more pleasant to use with the dedicated flag, but I don't know how other people feel about this... > Alternatively, it seems like the variable could instead > take a single function (basically what notmuch-mua-switch-function is > now) and you could provide two new functions that simply combine > switch-to-buffer-other-x and set-window-dedicated-p. I've tried that, but for some reason it doesn't work when forwarding a message: the dedicated flag is reset somewhere inside message-forward, but I don't know where nor why. (I haven't investigated much though.) > The defcustom would be more user-friendly if it gave a choice between > const values, rather than requiring the user to enter a symbol value > (and then possibly rejecting it on validation). Something like > :type '(choice (const :tag "Compose in the current window" current-window) > (const :tag "Compose mail in a new window" new-window) > (const :tag "Compose mail in a new frame" new-frame)) Yep, that's much better. I'll try to rewrite this patch using this and on-the-fly computations of the switch-function and dedicated flag. Thank you for the review! Regards, -- Thomas/Schnouki pgpMnKvcJHEBa.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2] emacs: Let the user choose where to compose new mails
--- emacs/notmuch-mua.el | 40 ++-- 1 files changed, 38 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 8824b08..90834d6 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -31,6 +31,21 @@ :group 'notmuch :type 'hook) +(defcustom notmuch-mua-compose-in 'current-window + "Where to create the mail buffer used to compose a new message. + Possible values are `current-window' (default), `new-window' + and `new-frame'. If set to `current-window', the mail buffer + will be displayed in the current window, so the old buffer will + be restored when the mail buffer is killed. If set to + `new-window' or `new-frame', the mail buffer will be displayed + in a new window/frame that will be destroyed when the buffer is + killed. You may want to customize `message-kill-buffer-on-exit' + accordingly." + :group 'notmuch + :type '(choice (const :tag "Compose in the current window" current-window) +(const :tag "Compose mail in a new window" new-window) +(const :tag "Compose mail in a new frame" new-frame))) + (defcustom notmuch-mua-user-agent-function 'notmuch-mua-user-agent-full "Function used to generate a `User-Agent:' string. If this is `nil' then no `User-Agent:' will be generated." @@ -48,6 +63,23 @@ list." ;; +(defun notmuch-mua-get-switch-function () + "Get a switch function according to `notmuch-mua-compose-in'." + (cond ((eq notmuch-mua-compose-in 'current-window) +'switch-to-buffer) + ((eq notmuch-mua-compose-in 'new-window) +'switch-to-buffer-other-window) + ((eq notmuch-mua-compose-in 'new-frame) +'switch-to-buffer-other-frame) + (t (error "Invalid value for `notmuch-mua-compose-in'" + +(defun notmuch-mua-maybe-set-window-dedicated () + "Set the selected window as dedicated according to +`notmuch-mua-compose-in'." + (when (or (eq notmuch-mua-compose-in 'new-frame) + (eq notmuch-mua-compose-in 'new-window)) +(set-window-dedicated-p (selected-window) t))) + (defun notmuch-mua-user-agent-full () "Generate a `User-Agent:' string suitable for notmuch." (concat (notmuch-mua-user-agent-notmuch) @@ -99,7 +131,8 @@ list." ((same-window-regexps '("\\*mail .*"))) (notmuch-mua-mail (mail-header 'to headers) (mail-header 'subject headers) - (message-headers-to-generate headers t '(to subject + (message-headers-to-generate headers t '(to subject)) + nil (notmuch-mua-get-switch-function))) ;; insert the message body - but put it in front of the signature ;; if one is present (goto-char (point-max)) @@ -112,6 +145,7 @@ list." (message-goto-body)) (defun notmuch-mua-forward-message () + (funcall (notmuch-mua-get-switch-function) (current-buffer)) (message-forward) (when notmuch-mua-user-agent-function @@ -121,6 +155,7 @@ list." (message-sort-headers) (message-hide-headers) (set-buffer-modified-p nil) + (notmuch-mua-maybe-set-window-dedicated) (message-goto-to)) @@ -143,6 +178,7 @@ list." (message-sort-headers) (message-hide-headers) (set-buffer-modified-p nil) + (notmuch-mua-maybe-set-window-dedicated) (message-goto-to)) @@ -199,7 +235,7 @@ the From: address first." (let ((other-headers (when (or prompt-for-sender notmuch-always-prompt-for-sender) (list (cons 'from (notmuch-mua-prompt-for-sender)) -(notmuch-mua-mail nil nil other-headers))) +(notmuch-mua-mail nil nil other-headers nil (notmuch-mua-get-switch-function (defun notmuch-mua-new-forward-message (&optional prompt-for-sender) "Invoke the notmuch message forwarding window. -- 1.7.7.3 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 06/13] test: run emacs inside screen
On Wed, 09 Nov 2011 23:36:12 -0800, Jameson Graef Rollins wrote: > So I just found out (via git bisect) that this patch is causing tests > that use smtp-dummy to hang for me. Has no one else seen the same > problem? Any suggestions about what the issue could be? > > jamie. The only time I've seen such an issue, it was with Emacs 24 (pretest), and I posted a fix here: id:"1317660447-27520-14-git-send-email-schno...@schnouki.net" If it's a problem with smtp-dummy, I suggest you add printf() statements in smtp-dummy.c and run it in another term, *then* run the test suite, so that you can see *where* it hangs exactly. That's what I did for the Emacs 24 issue :) Regards, -- Thomas/Schnouki pgpO8sJyluJBa.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 1/6] test: define a helper function for defining prereqs on executables
While test_expect_success could be used to define these prereqs, this is probably not a good idea: if a prereq is not available, using test_expect_success would result in a test being reported as FAILED at the end of the test suite (and its dependencies as skipped). (Thanks to Pieter Praet for suggesting the use of "hash" instead of "which".) --- test/test-lib.sh | 13 + 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/test/test-lib.sh b/test/test-lib.sh index 1ea7fa9..382934f 100755 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -543,6 +543,19 @@ test_have_prereq () { esac } +test_set_bin_prereq () { + bin=$1 + name=$2 + prereq=$3 + if hash $bin &>/dev/null + then + test_set_prereq $prereq + else + say_color info "%-6s" "INFO" + echo " Missing test prerequisite: $name" + fi +} + # You are not expected to call test_ok_ and test_failure_ directly, use # the text_expect_* functions instead. -- 1.7.7.3 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 0/6] Rebase of Pieter's "set test prereqs"
Hello list, This is another rebased version of Pieter's series to add GPG and Emacs as test prereqs, plus some additions on my own. (Rebased and posted as requested by Pieter [1].) Changes as compared to Pieter's patches (including parts from [2]): - prereqs are not tested using test_expect_success as they were in Pieter's original patches, but using a new function called test_set_bin_prereq. I wrote this before the gdb prereq was added, hence the different way to set it. - some fixes in Pieter's patches so that it actually works when gpg is not installed. Can't exactly remember what (...but you can just check his original patches), but in the end it was working fine in a chroot without gpg. - since Emacs is now run using dtach, the emacs prereq also depends on dtach. The presence of emacs and dtach is also checked in the test_emacs() function of the test suite. - testing for prereqs is now done using the "hash" built-in instead of "which", as suggested in [3]. Tested with and without dtach. A previous version of this series was also without emacs/gpg in a chroot, but not this one :) [1] id:"874ny4fcdz@praet.org" [2] id:"1317660447-27520-1-git-send-email-schno...@schnouki.net" [3] id:"87zkgemodd@praet.org" Pieter Praet (4): test: add 'GnuPG' prereq to dependent 'crypto' tests test: add 'Emacs' prereq to dependent 'crypto' tests test: add 'Emacs' prereq to dependent 'emacs' tests test: add 'Emacs' prereq to dependent 'emacs-large-search-buffer' tests Thomas Jost (2): test: define a helper function for defining prereqs on executables test: check if emacs and dtach are available in test_emacs() test/crypto| 46 +++--- test/emacs | 82 +-- test/emacs-large-search-buffer |9 +++- test/test-lib.sh | 17 4 files changed, 99 insertions(+), 55 deletions(-) -- 1.7.7.3 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 2/6] test: check if emacs and dtach are available in test_emacs()
The test_emacs() function is run by the emacs tests even if the EMACS prereq is not available. This causes an issue when running the test suite on a system where dtach is not installed: the emacs server will not start, but since the $EMACS_SERVER variable is set on the first call to test_emacs, subsequent calls may result in attempts to run emacsclient, which will then report "can't find socket". This patch fixes this issue by making sure that dtach and emacs are available before doing anything else in test_emacs(). --- test/test-lib.sh |4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/test/test-lib.sh b/test/test-lib.sh index 382934f..ca1f412 100755 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -852,6 +852,10 @@ EOF } test_emacs () { + # First check that emacs and dtach are available + hash emacs &>/dev/null || return + hash dtach &>/dev/null || return + if [ -z "$EMACS_SERVER" ]; then EMACS_SERVER="notmuch-test-suite-$$" # start a detached session with an emacs server -- 1.7.7.3 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 3/6] test: add 'GnuPG' prereq to dependent 'crypto' tests
From: Pieter Praet Adds a new test that checks for the presence of 'gpg', and adds that test as a prereq to all subsequent tests that rely on GnuPG. This causes tests with unmet dependencies to be skipped. Signed-off-by: Pieter Praet --- test/crypto | 35 --- 1 files changed, 20 insertions(+), 15 deletions(-) diff --git a/test/crypto b/test/crypto index 0af4aa8..eca59b6 100755 --- a/test/crypto +++ b/test/crypto @@ -7,11 +7,16 @@ test_description='PGP/MIME signature verification and decryption' . ./test-lib.sh +# GnuPG is a prereq. +test_set_bin_prereq gpg "GnuPG" GPG + + add_gnupg_home () { local output [ -d ${GNUPGHOME} ] && return mkdir -m 0700 "$GNUPGHOME" +test_have_prereq GPG || return gpg --no-tty --import <$TEST_DIRECTORY/gnupg-secret-key.asc >"$GNUPGHOME"/import.log 2>&1 test_debug "cat $GNUPGHOME/import.log" if (gpg --quick-random --version >/dev/null 2>&1) ; then @@ -25,13 +30,13 @@ add_gnupg_home () add_gnupg_home # get key fingerprint -FINGERPRINT=$(gpg --no-tty --list-secret-keys --with-colons --fingerprint | grep '^fpr:' | cut -d: -f10) +test_have_prereq GPG && FINGERPRINT=$(gpg --no-tty --list-secret-keys --with-colons --fingerprint | grep '^fpr:' | cut -d: -f10) # for some reason this is needed for emacs_deliver_message to work, # although I can't figure out why add_email_corpus -test_expect_success 'emacs delivery of signed message' \ +test_expect_success GPG 'emacs delivery of signed message' \ 'emacs_deliver_message \ "test signed message 001" \ "This is a test signed message." \ @@ -64,7 +69,7 @@ expected='[[[{"id": "X", {"id": 3, "content-type": "application/pgp-signature"}]}]}, [' -test_expect_equal \ +test_expect_equal GPG \ "$output" \ "$expected" @@ -99,7 +104,7 @@ expected='[[[{"id": "X", {"id": 3, "content-type": "application/pgp-signature"}]}]}, [' -test_expect_equal \ +test_expect_equal GPG \ "$output" \ "$expected" @@ -132,7 +137,7 @@ expected='[[[{"id": "X", {"id": 3, "content-type": "application/pgp-signature"}]}]}, [' -test_expect_equal \ +test_expect_equal GPG \ "$output" \ "$expected" mv "${GNUPGHOME}"{.bak,} @@ -141,7 +146,7 @@ mv "${GNUPGHOME}"{.bak,} catOUTPUT -test_expect_equal_file OUTPUT TESTATTACHMENT +test_expect_equal_file GPG OUTPUT TESTATTACHMENT test_begin_subtest "decryption failure with missing key" mv "${GNUPGHOME}"{,.bak} @@ -258,12 +263,12 @@ expected='[[[{"id": "X", {"id": 3, "content-type": "application/octet-stream"}]}]}, [' -test_expect_equal \ +test_expect_equal GPG \ "$output" \ "$expected" mv "${GNUPGHOME}"{.bak,} -test_expect_success 'emacs delivery of encrypted + signed message' \ +test_expect_success GPG 'emacs delivery of encrypted + signed message' \ 'emacs_deliver_message \ "test encrypted message 002" \ "This is another test encrypted message.\n" \ @@ -298,7 +303,7 @@ expected='[[[{"id": "X", "content-type": "text/plain", "content": "This is another test encrypted message.\n"}]}]}, [' -test_expect_equal \ +test_expect_equal GPG \ "$output" \ "$expected" @@ -310,7 +315,7 @@ Subject: Re: test encrypted message 002 On 01 Jan 2000 12:00:00 -, Notmuch Test Suite wrote: > This is another test encrypted message.' -test_expect_equal \ +test_expect_equal GPG \ "$output" \ "$expected" @@ -351,7 +356,7 @@ expected='[[[{"id": "X", {"id": 3, "content-type": "application/pgp-signature"}]}]}, [' -test_expect_equal \ +test_expect_equal GPG \ "$output" \ "$expected" -- 1.7.7.3 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 6/6] test: add 'Emacs' prereq to dependent 'emacs-large-search-buffer' tests
From: Pieter Praet Adds a new test that checks for the presence of 'emacs', and adds that test as a prereq to all subsequent tests that rely on Emacs. This causes tests with unmet dependencies to be skipped. Signed-off-by: Pieter Praet --- test/emacs-large-search-buffer |9 +++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/test/emacs-large-search-buffer b/test/emacs-large-search-buffer index 6095e9d..63eb87c 100755 --- a/test/emacs-large-search-buffer +++ b/test/emacs-large-search-buffer @@ -2,6 +2,11 @@ test_description="Emacs with large search results buffer" . test-lib.sh +# Emacs is a prereq. +test_set_bin_prereq dtach "dtach" DTACH +test_have_prereq DTACH && test_set_bin_prereq emacs "Emacs" EMACS + + x=xx # 10 x=$x$x$x$x$x$x$x$x$x$x # 100 x=$x$x$x$x$x$x$x$x$x # 900 @@ -27,7 +32,7 @@ test_emacs '(notmuch-search "*") (notmuch-test-wait) (test-output)' sed -i -e s', *, ,g' -e 's/xxx*/[BLOB]/g' OUTPUT -test_expect_equal_file OUTPUT EXPEXTED +test_expect_equal_file EMACS OUTPUT EXPEXTED test_begin_subtest "Ensure that emacs doesn't drop error messages" test_emacs '(notmuch-search "--this-option-does-not-exist") @@ -38,6 +43,6 @@ Error: Unexpected output from notmuch search: Unrecognized option: --this-option-does-not-exist End of search results. (process returned 1) EOF -test_expect_equal_file OUTPUT EXPEXTED +test_expect_equal_file EMACS OUTPUT EXPEXTED test_done -- 1.7.7.3 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 4/6] test: add 'Emacs' prereq to dependent 'crypto' tests
From: Pieter Praet Adds a new test that checks for the presence of 'emacs', and adds that test as a prereq to all subsequent tests that rely on Emacs. This causes tests with unmet dependencies to be skipped. Right now, all crypto tests do depend on Emacs, because it is used to generate the signed/encrypted messages that are needed by the tests. Signed-off-by: Pieter Praet --- test/crypto | 39 +-- 1 files changed, 25 insertions(+), 14 deletions(-) diff --git a/test/crypto b/test/crypto index eca59b6..085070b 100755 --- a/test/crypto +++ b/test/crypto @@ -7,9 +7,20 @@ test_description='PGP/MIME signature verification and decryption' . ./test-lib.sh +# Emacs is a prereq. +test_set_bin_prereq dtach "dtach" DTACH +test_have_prereq DTACH && test_set_bin_prereq emacs "Emacs" EMACS + # GnuPG is a prereq. test_set_bin_prereq gpg "GnuPG" GPG +# Some tests have multiple prereqs, but the test_expect_* functions +# accept only a single argument as prereq tag, and using test_have_prereq +# in and around tests causes various errors for me, so a dirty workaround +# will have to do for the time being. +test_have_prereq EMACS && test_have_prereq GPG \ +&& test_set_prereq EMACS+GPG + add_gnupg_home () { @@ -36,7 +47,7 @@ test_have_prereq GPG && FINGERPRINT=$(gpg --no-tty --list-secret-keys --with-col # although I can't figure out why add_email_corpus -test_expect_success GPG 'emacs delivery of signed message' \ +test_expect_success EMACS+GPG 'emacs delivery of signed message' \ 'emacs_deliver_message \ "test signed message 001" \ "This is a test signed message." \ @@ -69,7 +80,7 @@ expected='[[[{"id": "X", {"id": 3, "content-type": "application/pgp-signature"}]}]}, [' -test_expect_equal GPG \ +test_expect_equal EMACS+GPG \ "$output" \ "$expected" @@ -104,7 +115,7 @@ expected='[[[{"id": "X", {"id": 3, "content-type": "application/pgp-signature"}]}]}, [' -test_expect_equal GPG \ +test_expect_equal EMACS+GPG \ "$output" \ "$expected" @@ -137,7 +148,7 @@ expected='[[[{"id": "X", {"id": 3, "content-type": "application/pgp-signature"}]}]}, [' -test_expect_equal GPG \ +test_expect_equal EMACS+GPG \ "$output" \ "$expected" mv "${GNUPGHOME}"{.bak,} @@ -146,7 +157,7 @@ mv "${GNUPGHOME}"{.bak,} catOUTPUT -test_expect_equal_file GPG OUTPUT TESTATTACHMENT +test_expect_equal_file EMACS+GPG OUTPUT TESTATTACHMENT test_begin_subtest "decryption failure with missing key" mv "${GNUPGHOME}"{,.bak} @@ -263,12 +274,12 @@ expected='[[[{"id": "X", {"id": 3, "content-type": "application/octet-stream"}]}]}, [' -test_expect_equal GPG \ +test_expect_equal EMACS+GPG \ "$output" \ "$expected" mv "${GNUPGHOME}"{.bak,} -test_expect_success GPG 'emacs delivery of encrypted + signed message' \ +test_expect_success EMACS+GPG 'emacs delivery of encrypted + signed message' \ 'emacs_deliver_message \ "test encrypted message 002" \ "This is another test encrypted message.\n" \ @@ -303,7 +314,7 @@ expected='[[[{"id": "X", "content-type": "text/plain", "content": "This is another test encrypted message.\n"}]}]}, [' -test_expect_equal GPG \ +test_expect_equal EMACS+GPG \ "$output" \ "$expected" @@ -315,7 +326,7 @@ Subject: Re: test encrypted message 002 On 01 Jan 2000 12:00:00 -, Notmuch Test Suite wrote: > This is another test encrypted message.' -test_expect_equal GPG \ +test_expect_equal EMACS+GPG \ "$output" \ "$expected" @@ -356,7 +367,7 @@ expected='[[[{"id": "X", {"id": 3, "content-type": "application/pgp-signature"}]}]}, [' -test_expect_equal GPG \ +test_expect_equal EMACS+GPG \ "$output" \ "$expected" -- 1.7.7.3 ___ notm
[PATCH 5/6] test: add 'Emacs' prereq to dependent 'emacs' tests
From: Pieter Praet Adds a new test that checks for the presence of 'emacs', and adds that test as a prereq to all subsequent tests that rely on Emacs. This causes tests with unmet dependencies to be skipped. Signed-off-by: Pieter Praet Conflicts: test/emacs --- test/emacs | 82 --- 1 files changed, 44 insertions(+), 38 deletions(-) diff --git a/test/emacs b/test/emacs index 75a0a74..ea641af 100755 --- a/test/emacs +++ b/test/emacs @@ -3,6 +3,11 @@ test_description="emacs interface" . test-lib.sh +# Emacs is a prereq. +test_set_bin_prereq dtach "dtach" DTACH +test_have_prereq DTACH && test_set_bin_prereq emacs "Emacs" EMACS + + EXPECTED=$TEST_DIRECTORY/emacs.expected-output add_email_corpus @@ -10,7 +15,7 @@ add_email_corpus test_begin_subtest "Basic notmuch-hello view in emacs" test_emacs '(notmuch-hello) (test-output)' -test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello +test_expect_equal_file EMACS OUTPUT $EXPECTED/notmuch-hello test_begin_subtest "Saved search with 0 results" test_emacs '(let ((notmuch-show-empty-saved-searches t) @@ -20,20 +25,20 @@ test_emacs '(let ((notmuch-show-empty-saved-searches t) ("empty" . "tag:doesnotexist" (notmuch-hello) (test-output))' -test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-with-empty +test_expect_equal_file EMACS OUTPUT $EXPECTED/notmuch-hello-with-empty test_begin_subtest "No saved searches displayed (all with 0 results)" test_emacs '(let ((notmuch-saved-searches '\''(("empty" . "tag:doesnotexist" (notmuch-hello) (test-output))' -test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-no-saved-searches +test_expect_equal_file EMACS OUTPUT $EXPECTED/notmuch-hello-no-saved-searches test_begin_subtest "Basic notmuch-search view in emacs" test_emacs '(notmuch-search "tag:inbox") (notmuch-test-wait) (test-output)' -test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox +test_expect_equal_file EMACS OUTPUT $EXPECTED/notmuch-search-tag-inbox test_begin_subtest "Navigation of notmuch-hello to search results" test_emacs '(notmuch-hello) @@ -42,13 +47,13 @@ test_emacs '(notmuch-hello) (widget-button-press (point)) (notmuch-test-wait) (test-output)' -test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-view-inbox +test_expect_equal_file EMACS OUTPUT $EXPECTED/notmuch-hello-view-inbox test_begin_subtest "Basic notmuch-show view in emacs" maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.gu3...@dottiness.seas.harvard.edu) test_emacs "(notmuch-show \"$maildir_storage_thread\") (test-output)" -test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage +test_expect_equal_file EMACS OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage test_begin_subtest "notmuch-show for message with invalid From" add_message "[subject]=\"message-with-invalid-from\"" \ @@ -64,7 +69,7 @@ Date: Tue, 05 Jan 2001 15:43:57 - This is just a test message (#1) EOF -test_expect_equal_file OUTPUT EXPECTED +test_expect_equal_file EMACS OUTPUT EXPECTED test_begin_subtest "Navigation of notmuch-search to thread view" test_emacs '(notmuch-search "tag:inbox") @@ -74,7 +79,7 @@ test_emacs '(notmuch-search "tag:inbox") (notmuch-search-show-thread) (notmuch-test-wait) (test-output)' -test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage +test_expect_equal_file EMACS OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage test_begin_subtest "Add tag from search view" os_x_darwin_thread=$(notmuch search --output=threads id:ddd65cda0911171950o4eea4389v86de9525e4605...@mail.gmail.com) @@ -82,26 +87,26 @@ test_emacs "(notmuch-search \"$os_x_darwin_thread\") (notmuch-test-wait) (notmuch-search-add-tag \"tag-from-search-view\")" output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize) -test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-search-view unread)" +test_expect_equal EMACS "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-search-view unread)" test_begin_subtest "Remove tag from search view" test_emacs "(notmuch-search \"$os_x_darwin_thread\") (notmuch-test-wait) (notmuch-search-remove-tag \"tag-from-search-view\")" output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize) -test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)" +test_expect_equal EMACS "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jia
Re: [PATCH 0/6] Rebase of Pieter's "set test prereqs"
On Wed, 16 Nov 2011 10:53:42 -0800, Jameson Graef Rollins wrote: > On Wed, 16 Nov 2011 15:33:49 +0100, Thomas Jost wrote: > > Hello list, > > > > This is another rebased version of Pieter's series to add GPG and Emacs as > > test > > prereqs, plus some additions on my own. (Rebased and posted as requested by > > Pieter [1].) > > > > Changes as compared to Pieter's patches (including parts from [2]): > > - prereqs are not tested using test_expect_success as they were in Pieter's > > original patches, but using a new function called test_set_bin_prereq. I > > wrote > > this before the gdb prereq was added, hence the different way to set it. > > Hey, Thomas. Thanks so much for this work. This sounds like a better > solution. > > However, in the patches you send I see a lot of changes of the form > > -test_expect_success 'emacs delivery of encrypted message with attachment' \ > +test_expect_success GPG 'emacs delivery of encrypted message with > attachment' \ > > and > > -test_expect_equal \ > +test_expect_equal GPG \ > > which seems to contradict what you've said above. Not to mention that I > don't see anything that modifies calls to the test_expect_ functions. > Basically I see a lot more in the diffs than I would have expected in a > cursory look. Is this just a rebase flub, or is there something I'm > missing? > > jamie. Hi Jamie, I guess I wasn't clear in my explanations :) Pieter's patches use this to detect the presence of GPG/Emacs and set the prereq: +# GnuPG is a prereq. +test_expect_success "prereq: GnuPG is present" "which gpg" \ +&& test_set_prereq GPG There are 2 problems with this approach: - test_expect_success returns 0 regardless of the actual result of the command it runs. So even if gpg is not installed, text_expect_success "..." "which gpg" will succeed, and "test_set_prereq GPG" will be run. This, however, has been fixed in commit 003e7180 -- which had not been pushed when I wrote this in the first place :) - using test_expect_* to set a prereq does not make sense. If emacs is absent, the test suite would report a failed test. But a missing prereq is *not* a notmuch issue, so this should *not* be reported as a failed test. Hence my first patch, which defines test_set_bin_prereq, a new helper function to set a prereq without using any test_expect_*. After that we can use the normal prereq syntax from the test suite: - test_expect_success COMMAND --> run COMMAND, expecting it to succeed - test_expect_success PREREQ COMMAND --> skip if PREREQ is not set, else run the test as before (and same thing with the other test_expect_* functions) Does it make more sense now? Regards, -- Thomas/Schnouki pgpkXPnYrMIC2.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 0/9] test: (hopefully) better test prerequisites
On Thu, 17 Nov 2011 05:56:17 +0400, Dmitry Kurochkin wrote: > Hi all. > > The following patch series is an attempt to introduce proper > dependencies for external binaries in a less intrusive way than > [1]. The primary aim was to avoid changing every subtest that > uses external binaries. > > There are still failing tests if a dependency is > missing (e.g. "Verify that sent messages are > saved/searchable (via FCC)" fails if there is no emacs). It > happens because such tests depend on others which are skipped. > This issues are not addressed by this patch series. > > If others do like the approach and it is pushed, I will work on > updating tests that use the old style prerequisites (atomicity). > > A careful review is needed! > > Regards, > Dmitry > > [1] id:"1321454035-22023-1-git-send-email-schno...@schnouki.net" Hi Dmitry, This series looks quite good to me. It's a good approach, cleaner than explicitely adding the prereqs to each test as in my previous patches (and Pieter's). Now, a few questions: - same as Jamie: emacs_deliver_message hangs if dtach is not installed. In my patches I had to do this: "test_have_prereq EMACS && emacs_deliver_message ...". Any idea how to handle this? - what about indirect, "hidden" dependencies? The crypto test need to have a signed message delivered by emacs, so actually *all* the crypto tests depend on emacs. Right now, when dtach is not installed, the first test ("emacs delivery of signed message") is skipped and all the others fail. Would it be possible to handle this case without having to add explicit prereqs? - right now functions like test_expect_success can be used as "test_expect_success COMMAND" or "test_expect_success PREREQ COMMAND". If we use your approach (and I hope we will!), do we need to keep that second syntax available in test-lib.sh too, or should we do some cleanup to get rid of it? Thanks, -- Thomas/Schnouki pgpl9dNrBMHU1.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 0/6] Rebase of Pieter's "set test prereqs"
On Wed, 16 Nov 2011 21:50:17 +0100, Pieter Praet wrote: > On Wed, 16 Nov 2011 15:33:49 +0100, Thomas Jost wrote: > > Hello list, > > > > This is another rebased version of Pieter's series to add GPG and Emacs as > > test > > prereqs, plus some additions on my own. (Rebased and posted as requested by > > Pieter [1].) > > > > Thanks Thomas! > > Although... you may have misread (or maybe I mistyped :), but what I > actually intended [1] was for you to rebase *only* your fixes on top of > my rebased series (e.g. see "tjost-fixes.patch" in att), so you could > receive proper credit for cleaning up my mess. Oh, ok, I must have misread that :) Right now your patches don't apply cleanly on master (conflict in patch 3 due to commit 5964a7), and I think that Dmitry's patches [1] may be a better way to handle prereqs. So I probably won't send those patches until we decide which approach is the way to go. [1] id:"1321494986-18998-1-git-send-email-dmitry.kuroch...@gmail.com" > Also, while my apprehension [2,3] re the inclusion of the SCREEN/DTACH > prereq in patches #4,5,6 didn't have much merit (it's an all-or-nothing > affair anyways), the issue [3] in patch #5 @ "Reply within emacs" still > stands: `sed' will run unconditionally, and treat "EMACS" as an input > file. (see "sed-prereq-fix.patch" in att). Nice catch with this sed issue. Looks like I need to be more careful when replacing "OUTPUT" with "EMACS OUTPUT"... Thanks, -- Thomas/Schnouki pgpsE3YkxBLkn.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] python: use wrapped notmuch_*_t types instead of raw pointers
Now that types are checked correctly, we also need to make sure that all the arguments actually are instances of these types. Otherwise the function calls will fail and raise an exception similar to this one: ctypes.ArgumentError: argument 3: : expected LP_LP_NotmuchMessageS instance instead of pointer to c_void_p --- bindings/python/notmuch/database.py |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py index 25b4b1b..c24555e 100644 --- a/bindings/python/notmuch/database.py +++ b/bindings/python/notmuch/database.py @@ -378,7 +378,7 @@ class Database(object): be added. """ self._assert_db_is_initialized() -msg_p = c_void_p() +msg_p = NotmuchMessageP() status = self._add_message(self._db, _str(filename), byref(msg_p)) if not status in [STATUS.SUCCESS, STATUS.DUPLICATE_MESSAGE_ID]: @@ -446,7 +446,7 @@ class Database(object): the database was not intitialized. """ self._assert_db_is_initialized() -msg_p = c_void_p() +msg_p = NotmuchMessageP() status = Database._find_message(self._db, _str(msgid), byref(msg_p)) if status != STATUS.SUCCESS: raise NotmuchError(status) @@ -479,7 +479,7 @@ class Database(object): *Added in notmuch 0.9*""" self._assert_db_is_initialized() -msg_p = c_void_p() +msg_p = NotmuchMessageP() status = Database._find_message_by_filename(self._db, _str(filename), byref(msg_p)) if status != STATUS.SUCCESS: -- 1.7.7.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 2/2] test: use python2 instead of python if available
Some distros (Arch Linux) ship Python as python2 and Python 3 as python. Checking for python2 is necessary for the Python tests to work on these platforms. --- test/test-lib.sh |9 - 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/test/test-lib.sh b/test/test-lib.sh index 519bd84..155ad3c 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -923,8 +923,14 @@ test_python() { export LD_LIBRARY_PATH=$TEST_DIRECTORY/../lib export PYTHONPATH=$TEST_DIRECTORY/../bindings/python + # Some distros (e.g. Arch Linux) ship Python 2.* as /usr/bin/python2, + # most others as /usr/bin/python. So first try python2, and fallback to + # python if python2 doesn't exist. + cmd=python2 + [[ "$test_missing_external_prereq_python2_" = t ]] && cmd=python + (echo "import sys; _orig_stdout=sys.stdout; sys.stdout=open('OUTPUT', 'w')"; cat) \ - | python - + | $cmd - } test_reset_state_ () { @@ -1157,3 +1163,4 @@ test_declare_external_prereq emacsclient test_declare_external_prereq gdb test_declare_external_prereq gpg test_declare_external_prereq python +test_declare_external_prereq python2 -- 1.7.8 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 1/2] test: add a function to run Python tests
The new test_python() function makes writing Python tests a little easier: - it sets the environment variables as needed - it redirects stdout to the OUTPUT file (like test_emacs()). This commit also declares python as an external prereq. The stdout redirection is required to avoid trouble when running commands like "python 'script' | sort > OUTPUT": in such a case, any error due to a missing external prereq would be "swallowed" by sort, resulting to a failed test instead of a skipped one. --- test/python |6 ++ test/test-lib.sh |9 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/test/python b/test/python index f737749..c3aa726 100755 --- a/test/python +++ b/test/python @@ -5,9 +5,7 @@ test_description="python bindings" add_email_corpus test_begin_subtest "compare thread ids" -LD_LIBRARY_PATH=$TEST_DIRECTORY/../lib \ -PYTHONPATH=$TEST_DIRECTORY/../bindings/python \ -python < OUTPUT +test_python < EXPECTED -test_expect_equal_file OUTPUT EXPECTED +test_expect_equal_file <(sort OUTPUT) EXPECTED test_done diff --git a/test/test-lib.sh b/test/test-lib.sh index a975957..519bd84 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -919,6 +919,14 @@ test_emacs () { emacsclient --socket-name="$EMACS_SERVER" --eval "(progn $@)" } +test_python() { + export LD_LIBRARY_PATH=$TEST_DIRECTORY/../lib + export PYTHONPATH=$TEST_DIRECTORY/../bindings/python + + (echo "import sys; _orig_stdout=sys.stdout; sys.stdout=open('OUTPUT', 'w')"; cat) \ + | python - +} + test_reset_state_ () { test -z "$test_init_done_" && test_init_ @@ -1148,3 +1156,4 @@ test_declare_external_prereq emacs test_declare_external_prereq emacsclient test_declare_external_prereq gdb test_declare_external_prereq gpg +test_declare_external_prereq python -- 1.7.8 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 1/5] Fix comments about what is stored in the database
Commit 567bcbc2 introduced two new values for each message (content of the "From" and "Subject" headers), but the comments about the database schema had not been updated accordingly. --- lib/database.cc |6 +- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/lib/database.cc b/lib/database.cc index 98f101e..2025189 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -81,13 +81,17 @@ typedef struct { * STRING is the name of a file within that * directory for this mail message. * - *A mail document also has two values: + *A mail document also has four values: * * TIMESTAMP: The time_t value corresponding to the message's * Date header. * * MESSAGE_ID: The unique ID of the mail mess (see "id" above) * + * FROM: The value of the "From" header + * + * SUBJECT:The value of the "Subject" header + * * In addition, terms from the content of the message are added with * "from", "to", "attachment", and "subject" prefixes for use by the * user in searching. Similarly, terms from the path of the mail -- 1.7.8 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 0/5] Store message modification times in the DB
Hello world, This is a patch series I've been working on for some time in order to be able to sync my tags on several computers. I'm posting it now, but please consider it as a RFC rather than something that is ready to be pushed. The basic idea is to the last time each message was modified, i.e. "the message was added to the DB", "a tag was added" or "a tag was removed". This mtime is accessible through a library function and in the JSON output of "notmuch show". It is also searchable with the "mtime:" prefix and with timestamp ranges, like for searching messages by date: notmuch search mtime:$(date +%s 2011-12-01)..$(date +%s) This can then be used in scripts or helper programs to do incremental dumps or tags synchronization. (I already have a script to do incremental backups, but it needs some cleaning, and I'm still working on something for sync'ing tags, but it's starting to work really well; I'll post them later). This can be seen as an alternative to David Bremner's jlog branch, but with several differences: + no external dependency + everything is stored in the notmuch DB: atomicity for free! - when a message is removed we lose everything about it, which makes the sync process more complicated - for a human, it's harder to manipulate timestamps than log messages - this can store much less data than a proper log system On IRC amdragon suggested using a simple sequence number instead of a timestamp. This would indeed eliminate the need for proper time synchronization between computers one would want to keep in sync, and it would reduce the risk of time-going-backward problems, but IMHO it would cause more problems: no global clock --> no simple way to tell if DB #A is more recent than DB #B. So, here are the patches: - first a little fix to the comments describing the DB schema (not specific to this patch series at all, I just noticed it when rebasing this series) - the second commit adds the MTIME value to the database schema, and creates the functions used to update and access this value. - the third commit makes the MTIME value searchable with a range syntax. - the fourth commit adds the MTIME to the JSON output of "notmuch show". - the fifth and last commit adds Message.get_mtime() to the Python bindings. Please tell me what you think of this. Best regards, Thomas Thomas Jost (5): Fix comments about what is stored in the database lib: Add a MTIME value to every mail document lib: Make MTIME values searchable show: include mtime in JSON output python: add get_mtime() to the Message class bindings/python/notmuch/message.py | 20 lib/database-private.h |1 + lib/database.cc| 14 +- lib/message.cc | 32 lib/notmuch-private.h |6 +- lib/notmuch.h |4 notmuch-show.c |7 --- notmuch.1 | 14 -- notmuch.c | 13 ++--- 9 files changed, 101 insertions(+), 10 deletions(-) -- 1.7.8 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 2/5] lib: Add a MTIME value to every mail document
This is a time_t value, similar to the message date (TIMESTAMP). It is first set when the message is added to the database, and is then updated every time a tag is added or removed. It can thus be used for doing incremental dumps of the database or for synchronizing it between several computers. This value can be read freely (with notmuch_message_get_mtime()) but for now it can't be set to an arbitrary value: it can only be set to "now" when updated. There's no specific reason for this except that I don't really see a real use case for setting it to an arbitrary value. --- lib/database.cc |7 ++- lib/message.cc| 32 lib/notmuch-private.h |6 +- lib/notmuch.h |4 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/lib/database.cc b/lib/database.cc index 2025189..6dc6f73 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -81,7 +81,7 @@ typedef struct { * STRING is the name of a file within that * directory for this mail message. * - *A mail document also has four values: + *A mail document also has five values: * * TIMESTAMP: The time_t value corresponding to the message's * Date header. @@ -92,6 +92,9 @@ typedef struct { * * SUBJECT:The value of the "Subject" header * + * MTIME: The time_t value corresponding to the last time + * a tag was added or removed on the message. + * * In addition, terms from the content of the message are added with * "from", "to", "attachment", and "subject" prefixes for use by the * user in searching. Similarly, terms from the path of the mail @@ -1735,6 +1738,8 @@ notmuch_database_add_message (notmuch_database_t *notmuch, date = notmuch_message_file_get_header (message_file, "date"); _notmuch_message_set_header_values (message, date, from, subject); +_notmuch_message_update_mtime (message); + _notmuch_message_index_file (message, filename); } else { ret = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID; diff --git a/lib/message.cc b/lib/message.cc index 0075425..0c98589 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -830,6 +830,34 @@ _notmuch_message_set_header_values (notmuch_message_t *message, message->doc.add_value (NOTMUCH_VALUE_SUBJECT, subject); } +/* Get the message mtime, i.e. when it was added or the last time a tag was + * added/removed. */ +time_t +notmuch_message_get_mtime (notmuch_message_t *message) +{ +std::string value; + +try { + value = message->doc.get_value (NOTMUCH_VALUE_MTIME); +} catch (Xapian::Error &error) { + INTERNAL_ERROR ("Failed to read mtime value from document."); + return 0; +} + +return Xapian::sortable_unserialise (value); +} + +/* Set the message mtime to "now". */ +void +_notmuch_message_update_mtime (notmuch_message_t *message) +{ +time_t time_value; + +time_value = time (NULL); +message->doc.add_value (NOTMUCH_VALUE_MTIME, +Xapian::sortable_serialise (time_value)); +} + /* Synchronize changes made to message->doc out into the database. */ void _notmuch_message_sync (notmuch_message_t *message) @@ -994,6 +1022,8 @@ notmuch_message_add_tag (notmuch_message_t *message, const char *tag) private_status); } +_notmuch_message_update_mtime (message); + if (! message->frozen) _notmuch_message_sync (message); @@ -1022,6 +1052,8 @@ notmuch_message_remove_tag (notmuch_message_t *message, const char *tag) private_status); } +_notmuch_message_update_mtime (message); + if (! message->frozen) _notmuch_message_sync (message); diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index 60a932f..9859872 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -95,7 +95,8 @@ typedef enum { NOTMUCH_VALUE_TIMESTAMP = 0, NOTMUCH_VALUE_MESSAGE_ID, NOTMUCH_VALUE_FROM, -NOTMUCH_VALUE_SUBJECT +NOTMUCH_VALUE_SUBJECT, +NOTMUCH_VALUE_MTIME } notmuch_value_t; /* Xapian (with flint backend) complains if we provide a term longer @@ -276,6 +277,9 @@ _notmuch_message_set_header_values (notmuch_message_t *message, const char *from, const char *subject); void +_notmuch_message_update_mtime (notmuch_message_t *message); + +void _notmuch_message_sync (notmuch_message_t *message); notmuch_status_t diff --git a/lib/notmuch.h b/lib/notmuch.h index 9f23a10..643ebce 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -910,6 +910,10 @@ notmuch_message_set_flag (notmuch_message_t *message, time_t notmuch_message_get_date (notmuch_message_t *message); +/* Get the mtime of 'message' as a time_t value. */ +time_t +notmuch_message_get_mtime (notmuch_message_t *message); +
[PATCH 3/5] lib: Make MTIME values searchable
Tag modification times are now searchable as ranges (just like regular message dates) with the "mtime:" prefix. --- lib/database-private.h |1 + lib/database.cc|3 +++ notmuch.1 | 14 -- notmuch.c | 13 ++--- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/lib/database-private.h b/lib/database-private.h index 88532d5..e71c8e4 100644 --- a/lib/database-private.h +++ b/lib/database-private.h @@ -52,6 +52,7 @@ struct _notmuch_database { Xapian::QueryParser *query_parser; Xapian::TermGenerator *term_gen; Xapian::ValueRangeProcessor *value_range_processor; +Xapian::ValueRangeProcessor *mtime_value_range_processor; }; /* Return the list of terms from the given iterator matching a prefix. diff --git a/lib/database.cc b/lib/database.cc index 6dc6f73..cc970c1 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -677,12 +677,14 @@ notmuch_database_open (const char *path, notmuch->term_gen = new Xapian::TermGenerator; notmuch->term_gen->set_stemmer (Xapian::Stem ("english")); notmuch->value_range_processor = new Xapian::NumberValueRangeProcessor (NOTMUCH_VALUE_TIMESTAMP); + notmuch->mtime_value_range_processor = new Xapian::NumberValueRangeProcessor (NOTMUCH_VALUE_MTIME, "mtime:"); notmuch->query_parser->set_default_op (Xapian::Query::OP_AND); notmuch->query_parser->set_database (*notmuch->xapian_db); notmuch->query_parser->set_stemmer (Xapian::Stem ("english")); notmuch->query_parser->set_stemming_strategy (Xapian::QueryParser::STEM_SOME); notmuch->query_parser->add_valuerangeprocessor (notmuch->value_range_processor); + notmuch->query_parser->add_valuerangeprocessor (notmuch->mtime_value_range_processor); for (i = 0; i < ARRAY_SIZE (BOOLEAN_PREFIX_EXTERNAL); i++) { prefix_t *prefix = &BOOLEAN_PREFIX_EXTERNAL[i]; @@ -726,6 +728,7 @@ notmuch_database_close (notmuch_database_t *notmuch) delete notmuch->query_parser; delete notmuch->xapian_db; delete notmuch->value_range_processor; +delete notmuch->mtime_value_range_processor; talloc_free (notmuch); } diff --git a/notmuch.1 b/notmuch.1 index 3dbd67e..2235096 100644 --- a/notmuch.1 +++ b/notmuch.1 @@ -644,6 +644,8 @@ terms to match against specific portions of an email, (where folder: + mtime: + The .B from: prefix is used to match the name or address of the sender of an email @@ -707,8 +709,8 @@ operators, but will have to be protected from interpretation by the shell, (such as by putting quotation marks around any parenthesized expression). -Finally, results can be restricted to only messages within a -particular time range, (based on the Date: header) with a syntax of: +Results can be restricted to only messages within a particular time range, +(based on the Date: header) with a syntax of: .. @@ -721,6 +723,14 @@ specify a date range to return messages from 2009\-10\-01 until the current time: $(date +%s \-d 2009\-10\-01)..$(date +%s) + +Finally, the +.B mtime: +prefix can be used to search for messages which were modified (e.g. tags were +added or removed) within a particular time range, with the same syntax as +before: + + mtime:.. .SH HOOKS Hooks are scripts (or arbitrary executables or symlinks to such) that notmuch invokes before and after certain actions. These scripts reside in diff --git a/notmuch.c b/notmuch.c index c0ce026..443cf59 100644 --- a/notmuch.c +++ b/notmuch.c @@ -71,6 +71,7 @@ static const char search_terms_help[] = "\t\tid:\n" "\t\tthread:\n" "\t\tfolder:\n" +"\t\tmtime:\n" "\n" "\tThe from: prefix is used to match the name or address of\n" "\tthe sender of an email message.\n" @@ -112,8 +113,8 @@ static const char search_terms_help[] = "\tinterpretation by the shell, (such as by putting quotation\n" "\tmarks around any parenthesized expression).\n" "\n" -"\tFinally, results can be restricted to only messages within a\n" -"\tparticular time range, (based on the Date: header) with:\n" +"\tResults can be restricted to only messages within a particular\n" +"\ttime range, (based on the Date: header) with:\n" "\n" "\t\t..\n" "\n" @@ -125,7 +126,13 @@ static const char search_terms_help[] = "\tfollowing syntax would specify a date range to return messages\n" "\tfrom 2009-10-01 until the current time:\n" "\n" -"\t\t$(date +%%s -d 2009-10-01)..$(date +%%s)\n\n"; +"\t\t$(date +%%s -d 2009-10-01)..$(date +%%s)\n\n" +"\n" +"\tFinally, the mtime: prefix can be used to search for messages\n" +"\twhich were modified (e.g. tags were added or removed) within a\n" +"\tparticular time range, with the same syntax as before:\n" +"\n" +"\t\tmtime:..\n"; static const char hooks_help[] = "\tHooks are scripts (or arbitrary executables or symlin
[PATCH 4/5] show: include mtime in JSON output
This could be used by a UI implementation somehow. --- notmuch-show.c |7 --- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index 873a7c4..7279601 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -202,17 +202,18 @@ format_message_json (const void *ctx, notmuch_message_t *message, unused (int in notmuch_tags_t *tags; int first = 1; void *ctx_quote = talloc_new (ctx); -time_t date; +time_t date, mtime; const char *relative_date; date = notmuch_message_get_date (message); relative_date = notmuch_time_relative_date (ctx, date); +mtime = notmuch_message_get_mtime (message); -printf ("\"id\": %s, \"match\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [", +printf ("\"id\": %s, \"match\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"mtime\": %ld, \"tags\": [", json_quote_str (ctx_quote, notmuch_message_get_message_id (message)), notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? "true" : "false", json_quote_str (ctx_quote, notmuch_message_get_filename (message)), - date, relative_date); + date, relative_date, mtime); for (tags = notmuch_message_get_tags (message); notmuch_tags_valid (tags); -- 1.7.8 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch