[PATCH] Handle errors in mime_node_open
On Tue, 6 Mar 2012 18:26:57 +, Austin Clements wrote: > --- > mime-node.c | 15 +++ > 1 files changed, 15 insertions(+), 0 deletions(-) Pushed, d
[PATCH] emacs: fix MML quoting in replies
On Sun, 4 Mar 2012 10:25:38 +0200, Jani Nikula wrote: > The reply MML quoting added in commit ae438cc unintentionally MML > quotes also the signature/encryption MML tags added via > message-setup-hook, causing the reply not to be signed/encrypted. pushed, d
[PATCH 0/5] Move to --with-excluded approach to excludes
On Sat, 3 Mar 2012 13:05:13 +, Mark Walters wrote: > This series implements the proposal in id:"87y5riuz7v.fsf at qmul.ac.uk" > to move to a consistent --with-excluded approach rather than the > previous --no-exclude approach. See the message there and its > descendants for discussion. > > The main user side change is that notmuch-search no longer defaults to > showing all the excluded threads with [0/n] but will do so if the user > says they want all the messages (i.e., by specifying --with-excluded). > > However, it makes everything consistent throughout the commandline and > lib interfaces. In all cases a "message" type search only returns the > non-excluded matches (unless --with-excluded is specified) and a > "thread" type search returns all messages (including excluded ones) in > threads that match in a non-excluded message. Hi, Mark. Thanks so much for working on this. This new solution seems like a good one. It keeps the default as expected (excluded are actually excluded from all output), and the with-excluded option behaves intuitively. Looks good to me. Unfortunately, as I discussed with you on irc today, there seems to be a problem with the patch series that is preventing it from working as expected. The outputs of the following commands should agree, which they do: servo:~/src/notmuch/git [master] 0$ ./notmuch count --with-excluded tag:inbox 51171 servo:~/src/notmuch/git [master] 0$ ./notmuch search --output=messages --with-excluded tag:inbox | wc -l 51171 servo:~/src/notmuch/git [master] 0$ However, they should also agree in this case, which they don't: servo:~/src/notmuch/git [master] 0$ ./notmuch count tag:inbox 115 servo:~/src/notmuch/git [master] 0$ ./notmuch search --output=messages tag:inbox | wc -l 51169 servo:~/src/notmuch/git [master] 0$ In this last case, notmuch search is outputting (some but not all(!)) excluded messages when it shouldn't be. However, if I use a more complicated search term, everything seems to be working fine: servo:~/src/notmuch/git [master] 0$ ./notmuch count tag:inbox and tag:unread 0 servo:~/src/notmuch/git [master] 0$ ./notmuch search --output=messages tag:inbox and tag:unread | wc -l 0 servo:~/src/notmuch/git [master] 0$ ./notmuch count --with-excluded tag:inbox and tag:unread 47245 servo:~/src/notmuch/git [master] 0$ ./notmuch search --output=messages --with-excluded tag:inbox and tag:unread | wc -l 47245 servo:~/src/notmuch/git [master] 0$ It also works if I give a single "from:" search term instead of a single "tag:" search term. So it appears to be something about how the excluded query is constructed. I can't figure out where the problem is, although I'm still looking. If anyone else can figure it out, please let us know. I would really like to get this series applied so that I can get back to following master! Thanks again for all the work. jamie. -- next part -- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 835 bytes Desc: not available URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20120310/1c6a182c/attachment.pgp>
[PATCH] emacs: fix MML quoting in replies
On Sun, 4 Mar 2012 10:25:38 +0200, Jani Nikula wrote: > The reply MML quoting added in commit ae438cc unintentionally MML > quotes also the signature/encryption MML tags added via > message-setup-hook, causing the reply not to be signed/encrypted. > > MML quote just the original message in the temp buffer before > inserting it to the message buffer, to not interfere with message mode > hooks or message construction in general. > > See [1] and [2] for bug reports. > > Thanks to Tim Bielawa for testing. > > [1] id:"87hay78x6l.fsf at wyzanski.jamesvasile.com" > [2] id:"1330812262-28272-1-git-send-email-tbielawa at redhat.com". > > Signed-off-by: Jani Nikula Looks good to me. Tomi
[PATCH] mime_node_open: skip envelope from lines at the start of messages
On Sat, 10 Mar 2012 09:25:31 -0400, David Bremner wrote: > From: David Bremner > > Some MDAs such as procmail (in MH mode), and exim (doing local > delivery in some configurations of the appendfile transport) add a > line to the front of a message with "From " followed by envelope > sender. Since this is not a proper RFC822 header field, gmime (at > least since version 2.6) refuses to parse it, unless in mbox mode. > > This change reads the line of the file, and if they start with > "From ", pass the stream to gmime starting from the second line. > > This makes mime_node_open more consistent with (but still stricter > than) the permissive behaviour of notmuch_file_get_header > (message-file.c), which allows a certain number of "broken_headers". > > We avoid putting gmime into mbox mode in case of side effects; this > leaves the situation of mboxes accidentally indexed by notmuch the > same as before, namely "undefined behaviour". Ideally they should at > least be warned by notmuch-new. Although strict rfc822 adherence > would be one way to detect mboxes, it doesn't seem to fit with the > spirit or code of message-file.c. > --- > This version fixes a few formatting issues, and one bug (the strncmp). +1 Tomi -- next part -- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20120310/92028706/attachment.pgp>
[PATCH] Allow selecting which version of gmime is used to build notmuch.
This allows for testing against both versions of gmime on a single machine, without having to mess with pkg-config paths. --- configure |9 - 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/configure b/configure index 8b85b9d..630d647 100755 --- a/configure +++ b/configure @@ -44,6 +44,7 @@ LIBDIR= WITH_EMACS=1 WITH_BASH=1 WITH_ZSH=1 +WITH_GMIME_VERSIONS='gmime-2.6 gmime-2.4' usage () { @@ -170,6 +171,12 @@ for option; do fi elif [ "${option}" = '--without-zsh-completion' ] ; then WITH_ZSH=0 +elif [ "${option%%=*}" = '--with-gmime-version' ] ; then + if [ "${option#*=}" = '2.4' ]; then + WITH_GMIME_VERSIONS='gmime-2.4' +elif [ "${option#*=}" = '2.6' ]; then + WITH_GMIME_VERSIONS='gmime-2.6' + fi elif [ "${option%%=*}" = '--build' ] ; then build_option="${option#*=}" case ${build_option} in @@ -275,7 +282,7 @@ fi printf "Checking for GMime development files... " have_gmime=0 -for gmimepc in gmime-2.6 gmime-2.4; do +for gmimepc in $WITH_GMIME_VERSIONS; do if pkg-config --exists $gmimepc; then printf "Yes ($gmimepc).\n" have_gmime=1 -- 1.7.8.4
a DoS vulnerability associated with conflated Message-IDs?
On Thu, 8 Mar 2012 10:38:32 -0700, Jeremy Nickurak wrote: > On Thu, Mar 8, 2012 at 10:16, Daniel Kahn Gillmor > wrote: > > Any other suggestions or ideas? > > What about representing the contents from both message in one apparent > message? > - ... > - If the bodies disagree, display both. We'd probably need to do some like doing a diff. I find it annoying enough displaying both text and html copies of a mail. Displaying two copies of a message, just because one of them has a few extra lines as a footer would be equally annoying. Maybe it would be enough to ignore the signature too, when comparing messages?
[PATCH v6 03/10] reply: Require that only one message is returned
On Fri, Mar 9, 2012 at 16:00, Jani Nikula wrote: > On Tue, 21 Feb 2012 23:46:32 -0700, Adam Wolfe Gordon> wrote: >> As the semantics of replying to multiple messages have not yet been >> defined well, make notmuch reply require that the search given returns >> only a single message. > > Is there any real reason, apart from consistency between > --format=default and --format=json, to disable the current multiple > message reply? Also "notmuch show" has format specific features and > limitations. > > I agree the semantics should be clarified, and eventually multiple > message reply should be uniformly supported by all formats, including > --format=json, but IMHO this patch should be dropped (and the TODO patch > amended accordingly). It's just for consistency. I like the idea of dropping support for multi-message replies everywhere now, then re-adding it with new semantics later, but I don't feel very strongly about it. If people who use the CLI would prefer to have the default format left as-is for now that's OK with me.
[PATCH v6 05/10] reply: Add a JSON reply format.
On Fri, Mar 9, 2012 at 16:08, Jani Nikula wrote: >> + ? ?if (!reply) >> + ? ? printf (", %s: %s", >> + ? ? ? ? ? ? json_quote_str (local, "Date"), >> + ? ? ? ? ? ? json_quote_str (local, g_mime_message_get_date_as_string >> (message))); >> + >> + ? ?if (reply) { > > Isn't that an "else"? Indeed. Fixed.
[PATCH v6] emacs: Use the new JSON reply format and message-cite-original
On Fri, Mar 9, 2012 at 16:13, Jani Nikula wrote: >> + ? ? (set-mark (point)) >> + ? ? (goto-char start) >> + ? ? ;; Quote the original message according to the user's configured style. >> + ? ? (message-cite-original) >> + ? ? (goto-char (point-max) >> + >> + ?(push-mark) >> ? ?(message-goto-body) >> - ?;; Original message may contain (malicious) MML tags. ?We must >> - ?;; properly quote them in the reply. ?Note that using `point-max' >> - ?;; instead of `mark' here is wrong. ?The buffer may include user's >> - ?;; signature which should not be MML-quoted. >> - ?(mml-quote-region (point) (mark))) > > Is it okay to drop mml quoting? Why? As Austin pointed out on an earlier version, message-cite-original already does the quoting, so doing it ourselves will result in double-quoting MML tags.
[PATCH 2/2] cli: make --entire-thread=false work for format=json.
The --entire-thread option in notmuch-show.c defaults to true when format=json. Previously there was no way to turn this off. This patch makes it respect --entire-thread=false. The one subtlety is that we initialise a notmuch_bool_t to -1 to indicate that the option parsing has not set it. This allows the code to distinguish between the option being omitted from the command line, and the option being set to false on the command line. --- notmuch-show.c | 15 +-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index 05d51b2..8da1845 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -983,7 +983,12 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) char *query_string; int opt_index, ret; const notmuch_show_format_t *format = _text; -notmuch_show_params_t params = { .part = -1 }; + +/* We abuse the notmuch_bool_t variable params.entire-thread by + * setting it to -1 to denote that the command line parsing has + * not set it. We ensure it is set to TRUE or FALSE before passing + * it to any other function.*/ +notmuch_show_params_t params = { .part = -1, .entire_thread = -1 }; int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED; notmuch_bool_t verify = FALSE; notmuch_bool_t no_exclude = FALSE; @@ -1020,7 +1025,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) switch (format_sel) { case NOTMUCH_FORMAT_JSON: format = _json; - params.entire_thread = TRUE; + /* JSON defaults to entire-thread TRUE */ + if (params.entire_thread == -1) + params.entire_thread = TRUE; break; case NOTMUCH_FORMAT_TEXT: format = _text; @@ -1042,6 +1049,10 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) params.raw = TRUE; break; } +/* Default is entire-thread = FALSE except for format=json which + * is dealt with above. */ +if (params.entire_thread == -1) + params.entire_thread = FALSE; if (params.decrypt || verify) { #ifdef GMIME_ATLEAST_26 -- 1.7.9.1
[PATCH 1/2] cli: Parsing. Allow true/false parameter for boolean options.
Allow NOTMUCH_OPT_BOOLEAN to take a true or false parameter. In particular it allows the user to turn off a boolean option with --option=false. --- command-line-arguments.c | 34 ++ 1 files changed, 26 insertions(+), 8 deletions(-) diff --git a/command-line-arguments.c b/command-line-arguments.c index e711414..76b185f 100644 --- a/command-line-arguments.c +++ b/command-line-arguments.c @@ -28,6 +28,24 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, const char *arg_str) { return FALSE; } +static notmuch_bool_t +_process_boolean_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) { + +if (next == 0) { + *((notmuch_bool_t *)arg_desc->output_var) = TRUE; + return TRUE; +} +if (strcmp (arg_str, "false") == 0) { + *((notmuch_bool_t *)arg_desc->output_var) = FALSE; + return TRUE; +} +if (strcmp (arg_str, "true") == 0) { + *((notmuch_bool_t *)arg_desc->output_var) = TRUE; + return TRUE; +} +return FALSE; +} + /* Search for the {pos_arg_index}th position argument, return FALSE if that does not exist. @@ -76,14 +94,15 @@ parse_option (const char *arg, char *endptr; /* Everything but boolean arguments (switches) needs a -* delimiter, and a non-zero length value +* delimiter, and a non-zero length value. Boolean +* arguments may take an optional =true or =false value. */ - - if (try->opt_type != NOTMUCH_OPT_BOOLEAN) { - if (next != '=' && next != ':') return FALSE; - if (value[0] == 0) return FALSE; + if (next != '=' && next != ':' && next != 0) return FALSE; + if (next == 0) { + if (try->opt_type != NOTMUCH_OPT_BOOLEAN) + return FALSE; } else { - if (next != 0) return FALSE; + if (value[0] == 0) return FALSE; } if (try->output_var == NULL) @@ -94,8 +113,7 @@ parse_option (const char *arg, return _process_keyword_arg (try, value); break; case NOTMUCH_OPT_BOOLEAN: - *((notmuch_bool_t *)try->output_var) = TRUE; - return TRUE; + return _process_boolean_arg (try, next, value); break; case NOTMUCH_OPT_INT: *((int *)try->output_var) = strtol (value, , 10); -- 1.7.9.1
[PATCH v2 0/2] cli: Allow true/false parameter for boolean
Hi Here is a second version of a patch to allow parameters to boolean options on the command line. This version allows parameters (=true|false). My first version is at id:"1331244944-7960-1-git-send-email-markwalters1009 at gmail.com". Jani posted an alternative version there. Jani's version and this one are quite similar: the key difference is that this version abuses a notmuch_bool_t by setting it to -1 (to indicate that the parser has not set this option). This makes the code simpler but is definitely an abuse. I will discuss this further in replies to Jani's series. Best wishes Mark Mark Walters (2): cli: Parsing. Allow true/false parameter for boolean options. cli: make --entire-thread=false work for format=json. command-line-arguments.c | 34 ++ notmuch-show.c | 15 +-- 2 files changed, 39 insertions(+), 10 deletions(-) -- 1.7.9.1
[PATCH] emacs-hello: Do not calculate the count of the messages in hidden sections
On Sat, 18 Feb 2012 23:12:29 +0100, Michal Sojka wrote: > The result is that hello screen shows much faster when some sections are > hidden. pushed. d
Patches for 0.12
As usual, nothing brings out the bug reports like a freeze. There are some patches that should probably go in, but could use one more pair of eyes. id:"1330849538-24558-1-git-send-email-jani at nikula.org" We had a somewhat lively debate about desirablity of the following patch. My decision is that for now, we avoid changing the behaviour of notmuch, and do apply the patch. We can discuss later deprecating or changing this permissive behaviour. id:"1331385931-1610-1-git-send-email-david at tethera.net" This patch from Austin seems innocent enough, and I plan to push it to release. id:"1331058417-13776-1-git-send-email-amdragon at mit.edu" I'm not sure about including id:"1329852935-3019-1-git-send-email-schnouki at schnouki.net" it wouldn't really help debian (as the unstable buildds already have 2.6.6), but I guess it might help others building debian packages. Although id:"1331225101-24385-1-git-send-email-jrollins at finestructure.net" is marked as trivial and is certainly short, I'd like one more pair of eyes before pushing to release. As I mentioned to Pieter in another mail, my current plan is _not_ to push the various testing patches to release, on the grounds that they mainly help developers. d -- next part -- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 315 bytes Desc: not available URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20120310/9d20858a/attachment.pgp>
[PATCH] mime_node_open: skip envelope from lines at the start of messages
From: David BremnerSome MDAs such as procmail (in MH mode), and exim (doing local delivery in some configurations of the appendfile transport) add a line to the front of a message with "From " followed by envelope sender. Since this is not a proper RFC822 header field, gmime (at least since version 2.6) refuses to parse it, unless in mbox mode. This change reads the line of the file, and if they start with "From ", pass the stream to gmime starting from the second line. This makes mime_node_open more consistent with (but still stricter than) the permissive behaviour of notmuch_file_get_header (message-file.c), which allows a certain number of "broken_headers". We avoid putting gmime into mbox mode in case of side effects; this leaves the situation of mboxes accidentally indexed by notmuch the same as before, namely "undefined behaviour". Ideally they should at least be warned by notmuch-new. Although strict rfc822 adherence would be one way to detect mboxes, it doesn't seem to fit with the spirit or code of message-file.c. --- This version fixes a few formatting issues, and one bug (the strncmp). mime-node.c | 24 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/mime-node.c b/mime-node.c index a95bdab..25e9d11 100644 --- a/mime-node.c +++ b/mime-node.c @@ -72,6 +72,8 @@ mime_node_open (const void *ctx, notmuch_message_t *message, mime_node_context_t *mctx; mime_node_t *root; notmuch_status_t status; +char *first_line = NULL; +size_t first_line_size = 0; root = talloc_zero (ctx, mime_node_t); if (root == NULL) { @@ -96,6 +98,23 @@ mime_node_open (const void *ctx, notmuch_message_t *message, goto DONE; } +if (getline (_line, _line_size, mctx->file) < 0) { + fprintf (stderr, "Failed to read first line from %s: %s\n", +filename, strerror (errno)); + status = NOTMUCH_STATUS_FILE_ERROR; + goto DONE; +} + +if (strncmp (first_line, "From ", 5) != 0) { + /* No envelope from line */ + if (fseek (mctx->file, 0L, SEEK_SET)) { + fprintf (stderr, "Failed to rewind %s: %s\n", +filename, strerror (errno)); + status = NOTMUCH_STATUS_FILE_ERROR; + goto DONE; + } +} + mctx->stream = g_mime_stream_file_new (mctx->file); if (!mctx->stream) { fprintf (stderr, "Out of memory.\n"); @@ -111,7 +130,9 @@ mime_node_open (const void *ctx, notmuch_message_t *message, goto DONE; } +g_mime_parser_set_scan_from (mctx->parser, FALSE); mctx->mime_message = g_mime_parser_construct_message (mctx->parser); + if (!mctx->mime_message) { fprintf (stderr, "Failed to parse %s\n", filename); status = NOTMUCH_STATUS_FILE_ERROR; @@ -136,6 +157,9 @@ mime_node_open (const void *ctx, notmuch_message_t *message, return NOTMUCH_STATUS_SUCCESS; DONE: +if (first_line != NULL) + free (first_line); + talloc_free (root); return status; } -- 1.7.9.1
[PATCH] emacs: get rid of trailing spaces in notmuch-hello view
This patch removes trailing spaces in notmuch-hello view. A side effect of this change is that tag/query buttons no longer include a space at the end. This means that pressing RET when the point is at the first character after the tag/query button no longer works (note that this is the standard behavior for buttons). We may change this behavior in the future (without adding trailing spaces back) if people would find this change inconvenient. --- emacs/notmuch-hello.el | 30 test/emacs |2 +- test/emacs.expected-output/notmuch-hello |2 +- .../emacs.expected-output/notmuch-hello-long-names |6 ++-- .../notmuch-hello-new-section |2 +- .../notmuch-hello-section-counts |4 +- .../notmuch-hello-section-hidden-tag |2 +- .../notmuch-hello-section-with-empty |2 +- .../emacs.expected-output/notmuch-hello-with-empty |2 +- 9 files changed, 23 insertions(+), 29 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 28f39f1..17f7edd 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -429,7 +429,8 @@ Such a list can be computed with `notmuch-hello-query-counts'." (let* ((widest (notmuch-hello-longest-label searches)) (tags-and-width (notmuch-hello-tags-per-line widest)) (tags-per-line (car tags-and-width)) -(widest (cdr tags-and-width)) +(column-width (cdr tags-and-width)) +(column-indent 0) (count 0) (reordered-list (notmuch-hello-reflect searches tags-per-line)) ;; Hack the display of the buttons used. @@ -441,32 +442,25 @@ Such a list can be computed with `notmuch-hello-query-counts'." (mapc (lambda (elem) ;; (not elem) indicates an empty slot in the matrix. (when elem + (if (> column-indent 0) + (widget-insert (make-string column-indent ? ))) (let* ((name (first elem)) (query (second elem)) -(msg-count (third elem)) -(formatted-name (format "%s " name))) +(msg-count (third elem))) (widget-insert (format "%8s " (notmuch-hello-nice-number msg-count))) - (if (string= formatted-name notmuch-hello-target) + (if (string= name notmuch-hello-target) (setq found-target-pos (point-marker))) (widget-create 'push-button :notify #'notmuch-hello-widget-search :notmuch-search-terms query - formatted-name) - (unless (eq (% count tags-per-line) (1- tags-per-line)) - ;; If this is not the last tag on the line, insert - ;; enough space to consume the rest of the column. - ;; Because the button for the name is `(1+ (length - ;; name))' long (due to the trailing space) we can - ;; just insert `(- widest (length name))' spaces - the - ;; column separator is included in the button if - ;; `(equal widest (length name)'. - (widget-insert (make-string (max 0 - (- widest (length name))) - ? ) + name) + (setq column-indent + (1+ (max 0 (- column-width (length name))) (setq count (1+ count)) - (if (eq (% count tags-per-line) 0) - (widget-insert "\n"))) + (when (eq (% count tags-per-line) 0) + (setq column-indent 0) + (widget-insert "\n"))) reordered-list) ;; If the last line was not full (and hence did not include a diff --git a/test/emacs b/test/emacs index 29a489c..42780af 100755 --- a/test/emacs +++ b/test/emacs @@ -39,7 +39,7 @@ test_begin_subtest "Navigation of notmuch-hello to search results" test_emacs '(notmuch-hello) (goto-char (point-min)) (re-search-forward "inbox") - (widget-button-press (point)) + (widget-button-press (1- (point))) (notmuch-test-wait) (test-output)' test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-view-inbox diff --git a/test/emacs.expected-output/notmuch-hello b/test/emacs.expected-output/notmuch-hello index 1470790..2d69891 100644 --- a/test/emacs.expected-output/notmuch-hello +++ b/test/emacs.expected-output/notmuch-hello @@ -2,7 +2,7 @@ Saved searches: [edit] - 52 inbox 52 unread + 52 inbox 52 unread Search: . diff --git
[PATCH v2 2/2] test: use subtest name for generated message subject by default
Before the change, messages generated by generate_message() used "Test message #N" for default subject where N is the generated messages counter. Since message subject is commonly present in expected results, there is a chance of breaking other tests when a new generate_message() call is added. The patch changes default subject value for generated messages to subtest name if it is available. If subtest name is not available (i.e. message is generated during test initialization), the old default value is used (in this case it is fine to have the counter in the subject). Another benefit of this change is a sane default value for subject in generated messages, which would allow to simplify code like: test_begin_subtest "test for a cool feature" add_message [subject]="message for test for a cool feature" --- test/encoding|2 +- test/search-folder-coherence |2 +- test/test-lib.sh |6 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/test/encoding b/test/encoding index 98abf77..2e1326e 100755 --- a/test/encoding +++ b/test/encoding @@ -9,7 +9,7 @@ output=$(notmuch show id:${gen_msg_id} 2>&1 | notmuch_show_sanitize) test_expect_equal "$output" "message{ id:msg-001 at notmuch-test-suite depth:0 match:1 excluded:0 filename:/XXX/mail/msg-001 header{ Notmuch Test Suite (2001-01-05) (inbox unread) -Subject: Test message #1 +Subject: Message with text of unknown charset From: Notmuch Test Suite To: Notmuch Test Suite Date: Fri, 05 Jan 2001 15:43:57 + diff --git a/test/search-folder-coherence b/test/search-folder-coherence index f8119cb..3f6ec76 100755 --- a/test/search-folder-coherence +++ b/test/search-folder-coherence @@ -32,7 +32,7 @@ test_expect_equal_file OUTPUT EXPECTED test_begin_subtest "Test matches folder:spam" output=$(notmuch search folder:spam) -test_expect_equal "$output" "thread:0001 2001-01-05 [1/1] Notmuch Test Suite; Test message #1 (inbox unread)" +test_expect_equal "$output" "thread:0001 2001-01-05 [1/1] Notmuch Test Suite; Single new message (inbox unread)" test_begin_subtest "Remove folder:spam copy of email" rm $dir/spam/$(basename $file_x) diff --git a/test/test-lib.sh b/test/test-lib.sh index 2781506..06aaea2 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -318,7 +318,11 @@ generate_message () fi if [ -z "${template[subject]}" ]; then - template[subject]="Test message #${gen_msg_cnt}" + if [ -n "$test_subtest_name" ]; then + template[subject]="$test_subtest_name" + else + template[subject]="Test message #${gen_msg_cnt}" + fi fi if [ -z "${template[date]}" ]; then -- 1.7.9.1
[PATCH v2 1/2] test: remove "Generate some messages" test from raw
Before the change, the first subtest in raw format tests just generated messages and checked that they are added successfully. This is not really a raw format test, it is creating of environment required for other subtests to run. The patch removes the first subtest from raw and replaces it with bare add_message calls, similar to how it is done in other tests. TODO: we should check that test environment was created successfully. Currently, many tests do add_message(), notmuch new and other calls without checking the results. We should come up with a general solution for this, i.e. if any command during test initialization fails, all tests should be skipped with appropriate error message. --- test/raw |7 ++- 1 files changed, 2 insertions(+), 5 deletions(-) diff --git a/test/raw b/test/raw index 0171e64..de0b867 100755 --- a/test/raw +++ b/test/raw @@ -3,11 +3,8 @@ test_description='notmuch show --format=raw' . ./test-lib.sh -test_begin_subtest "Generate some messages" -generate_message -generate_message -output=$(NOTMUCH_NEW) -test_expect_equal "$output" "Added 2 new messages to the database." +add_message +add_message test_begin_subtest "Attempt to show multiple raw messages" output=$(notmuch show --format=raw "*" 2>&1) -- 1.7.9.1
[PATCH v6] emacs: Use the new JSON reply format and message-cite-original
On Tue, 21 Feb 2012 23:46:39 -0700, Adam Wolfe Gordonwrote: > Use the new JSON reply format to create replies in emacs. Quote HTML > parts nicely by using mm-display-part to turn them into displayable > text, then quoting them with message-cite-original. This is very > useful for users who regularly receive HTML-only email. > > Use message-mode's message-cite-original function to create the > quoted body for reply messages. In order to make this act like the > existing notmuch defaults, you will need to set the following in > your emacs configuration: > > message-citation-line-format "On %a, %d %b %Y, %f wrote:" > message-citation-line-function 'message-insert-formatted-citation-line > > The tests have been updated to reflect the (ugly) emacs default. > --- > emacs/notmuch-lib.el | 11 > emacs/notmuch-mua.el | 136 ++--- > test/emacs |8 ++-- > 3 files changed, 109 insertions(+), 46 deletions(-) > > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el > index 7e3f110..8bac596 100644 > --- a/emacs/notmuch-lib.el > +++ b/emacs/notmuch-lib.el > @@ -206,6 +206,17 @@ the user hasn't set this variable with the old or new > value." > (setq seq (nconc (delete elem seq) (list elem)) > seq)) > > +(defun notmuch-parts-filter-by-type (parts type) > + "Given a list of message parts, return a list containing the ones matching > +the given type." > + (remove-if-not > + (lambda (part) (notmuch-match-content-type (plist-get part :content-type) > type)) > + parts)) > + > +(defun notmuch-plist-to-alist (plist) > + (loop for (key value . rest) on plist by #'cddr > + collect (cons (substring (symbol-name key) 1) value))) > + > ;; Compatibility functions for versions of emacs before emacs 23. > ;; > ;; Both functions here were copied from emacs 23 with the following > copyright: > diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el > index 4be7c13..5adf4d8 100644 > --- a/emacs/notmuch-mua.el > +++ b/emacs/notmuch-mua.el > @@ -19,11 +19,15 @@ > ;; > ;; Authors: David Edmondson > > +(require 'json) > (require 'message) > +(require 'format-spec) > > (require 'notmuch-lib) > (require 'notmuch-address) > > +(eval-when-compile (require 'cl)) > + > ;; > > (defcustom notmuch-mua-send-hook '(notmuch-mua-message-send-hook) > @@ -72,56 +76,104 @@ list." > (push header message-hidden-headers))) > notmuch-mua-hidden-headers)) > > +(defun notmuch-mua-get-displayed-part (part query-string) > + (with-temp-buffer > +(if (plist-get part :content) > + (insert (plist-get part :content)) > + (call-process notmuch-command nil t nil "show" "--format=raw" > + (format "--part=%s" (plist-get part :id)) > + query-string)) > + > +(let ((handle (mm-make-handle (current-buffer) (list (plist-get part > :content-type > + (end-of-orig (point-max))) > + (mm-display-part handle) > + (delete-region (point-min) end-of-orig) > + (buffer-substring (point-min) (point-max) > + > +(defun notmuch-mua-get-quotable-parts (parts) > + (loop for part in parts > + if (notmuch-match-content-type (plist-get part :content-type) > "multipart/alternative") > + collect (let* ((subparts (plist-get part :content)) > + (types (mapcar (lambda (part) (plist-get part > :content-type)) subparts)) > + (chosen-type (car (notmuch-multipart/alternative-choose > types > +(loop for part in (reverse subparts) > + if (notmuch-match-content-type (plist-get part > :content-type) chosen-type) > + return part)) > + else if (notmuch-match-content-type (plist-get part :content-type) > "multipart/*") > + append (notmuch-mua-get-quotable-parts (plist-get part :content)) > + else if (notmuch-match-content-type (plist-get part :content-type) > "text/*") > + collect part)) > + > (defun notmuch-mua-reply (query-string sender reply-all) > - (let (headers > - body > - (args '("reply"))) > -(if notmuch-show-process-crypto > - (setq args (append args '("--decrypt" > + (let ((args '("reply" "--format=json")) > + (json-object-type 'plist) > + (json-array-type 'list) > + (json-false 'nil) > + reply > + original) > +(when notmuch-show-process-crypto > + (setq args (append args '("--decrypt" > + > (if reply-all > (setq args (append args '("--reply-to=all"))) >(setq args (append args '("--reply-to=sender" > (setq args (append args (list query-string))) > -;; This make assumptions about the output of `notmuch reply', but > -;; really only that the headers come first followed by a blank > -;; line and then the body. > + > +;; Get the reply object as JSON, and parse it into an elisp object. > (with-temp-buffer >(apply
[PATCH v6 05/10] reply: Add a JSON reply format.
On Tue, 21 Feb 2012 23:46:34 -0700, Adam Wolfe Gordonwrote: > This new JSON format for replies includes headers generated for a > reply message as well as the headers of the original message. Using > this data, a client can intelligently create a reply. For example, the > emacs client will be able to create replies with quoted HTML parts by > parsing the HTML parts. > --- > notmuch-client.h | 10 -- > notmuch-reply.c | 49 + > notmuch-show.c | 30 ++ > test/multipart |1 - > 4 files changed, 79 insertions(+), 11 deletions(-) > > diff --git a/notmuch-client.h b/notmuch-client.h > index f4a62cc..ef4eaba 100644 > --- a/notmuch-client.h > +++ b/notmuch-client.h > @@ -62,13 +62,13 @@ > #define STRINGIFY(s) STRINGIFY_(s) > #define STRINGIFY_(s) #s > > -struct mime_node; > +typedef struct mime_node mime_node_t; > struct notmuch_show_params; > > typedef struct notmuch_show_format { > const char *message_set_start; > void (*part) (const void *ctx, > - struct mime_node *node, int indent, > + mime_node_t *node, int indent, > const struct notmuch_show_params *params); > const char *message_start; > void (*message) (const void *ctx, > @@ -191,6 +191,12 @@ show_message_body (notmuch_message_t *message, > notmuch_status_t > show_one_part (const char *filename, int part); > > +void > +format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first); > + > +void > +format_headers_json (const void *ctx, GMimeMessage *message, notmuch_bool_t > reply); > + > char * > json_quote_chararray (const void *ctx, const char *str, const size_t len); > > diff --git a/notmuch-reply.c b/notmuch-reply.c > index 177e6ca..017c6ae 100644 > --- a/notmuch-reply.c > +++ b/notmuch-reply.c > @@ -601,6 +601,51 @@ notmuch_reply_format_default(void *ctx, > return 0; > } > > +static int > +notmuch_reply_format_json(void *ctx, > + notmuch_config_t *config, > + notmuch_query_t *query, > + notmuch_show_params_t *params, > + notmuch_bool_t reply_all) > +{ > +GMimeMessage *reply; > +notmuch_messages_t *messages; > +notmuch_message_t *message; > +mime_node_t *node; > + > +if (notmuch_query_count_messages (query) != 1) { > + fprintf (stderr, "Error: search term did not match precisely one > message.\n"); > + return 1; > +} > + > +messages = notmuch_query_search_messages (query); > +message = notmuch_messages_get (messages); > +if (mime_node_open (ctx, message, params->cryptoctx, params->decrypt, > + ) != NOTMUCH_STATUS_SUCCESS) > + return 1; > + > +reply = create_reply_message (ctx, config, message, reply_all); > +if (!reply) > + return 1; > + > +/* The headers of the reply message we've created */ > +printf ("{\"reply-headers\": "); > +format_headers_json (ctx, reply, TRUE); > +g_object_unref (G_OBJECT (reply)); > +reply = NULL; > + > +/* Start the original */ > +printf (", \"original\": "); > + > +format_part_json (ctx, node, TRUE); > + > +/* End */ > +printf ("}\n"); > +notmuch_message_destroy (message); > + > +return 0; > +} > + > /* This format is currently tuned for a git send-email --notmuch hook */ > static int > notmuch_reply_format_headers_only(void *ctx, > @@ -663,6 +708,7 @@ notmuch_reply_format_headers_only(void *ctx, > > enum { > FORMAT_DEFAULT, > +FORMAT_JSON, > FORMAT_HEADERS_ONLY, > }; > > @@ -682,6 +728,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[]) > notmuch_opt_desc_t options[] = { > { NOTMUCH_OPT_KEYWORD, , "format", 'f', > (notmuch_keyword_t []){ { "default", FORMAT_DEFAULT }, > + { "json", FORMAT_JSON }, > { "headers-only", FORMAT_HEADERS_ONLY }, > { 0, 0 } } }, > { NOTMUCH_OPT_KEYWORD, _all, "reply-to", 'r', > @@ -700,6 +747,8 @@ notmuch_reply_command (void *ctx, int argc, char *argv[]) > > if (format == FORMAT_HEADERS_ONLY) > reply_format_func = notmuch_reply_format_headers_only; > +else if (format == FORMAT_JSON) > + reply_format_func = notmuch_reply_format_json; > else > reply_format_func = notmuch_reply_format_default; > > diff --git a/notmuch-show.c b/notmuch-show.c > index 6a171a4..2126d78 100644 > --- a/notmuch-show.c > +++ b/notmuch-show.c > @@ -290,8 +290,8 @@ format_headers_message_part_text (GMimeMessage *message) > printf ("Date: %s\n", g_mime_message_get_date_as_string (message)); > } > > -static void > -format_headers_json (const void *ctx, GMimeMessage *message) > +void > +format_headers_json (const void *ctx, GMimeMessage *message, notmuch_bool_t > reply) > { > void *local =
[PATCH v6 03/10] reply: Require that only one message is returned
On Tue, 21 Feb 2012 23:46:32 -0700, Adam Wolfe Gordonwrote: > As the semantics of replying to multiple messages have not yet been > defined well, make notmuch reply require that the search given returns > only a single message. Is there any real reason, apart from consistency between --format=default and --format=json, to disable the current multiple message reply? Also "notmuch show" has format specific features and limitations. I agree the semantics should be clarified, and eventually multiple message reply should be uniformly supported by all formats, including --format=json, but IMHO this patch should be dropped (and the TODO patch amended accordingly). BR, Jani. > --- > notmuch-reply.c | 36 +++- > 1 files changed, 19 insertions(+), 17 deletions(-) > > diff --git a/notmuch-reply.c b/notmuch-reply.c > index 8e56245..177e6ca 100644 > --- a/notmuch-reply.c > +++ b/notmuch-reply.c > @@ -572,30 +572,32 @@ notmuch_reply_format_default(void *ctx, > notmuch_message_t *message; > const notmuch_show_format_t *format = _reply; > > -for (messages = notmuch_query_search_messages (query); > - notmuch_messages_valid (messages); > - notmuch_messages_move_to_next (messages)) > -{ > - message = notmuch_messages_get (messages); > +if (notmuch_query_count_messages (query) != 1) { > + fprintf (stderr, "Error: search term did not match precisely one > message.\n"); > + return 1; > +} > > - reply = create_reply_message (ctx, config, message, reply_all); > +messages = notmuch_query_search_messages (query); > +message = notmuch_messages_get (messages); > > - if (!reply) > - continue; > +reply = create_reply_message (ctx, config, message, reply_all); > > - show_reply_headers (reply); > +if (!reply) > + return 1; > > - g_object_unref (G_OBJECT (reply)); > - reply = NULL; > +show_reply_headers (reply); > > - printf ("On %s, %s wrote:\n", > - notmuch_message_get_header (message, "date"), > - notmuch_message_get_header (message, "from")); > +g_object_unref (G_OBJECT (reply)); > +reply = NULL; > > - show_message_body (message, format, params); > +printf ("On %s, %s wrote:\n", > + notmuch_message_get_header (message, "date"), > + notmuch_message_get_header (message, "from")); > + > +show_message_body (message, format, params); > + > +notmuch_message_destroy (message); > > - notmuch_message_destroy (message); > -} > return 0; > } > > -- > 1.7.5.4 > > ___ > notmuch mailing list > notmuch at notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 3/3] cli: allow switching off entire thread mode in notmuch show json format
Previously --format=json implied --entire-thread with no way to switch it off. Add support for --entire-thread=false usable with json format. Signed-off-by: Jani Nikula --- notmuch-show.c | 12 ++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index 05d51b2..19e0119 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -985,6 +985,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) const notmuch_show_format_t *format = _text; notmuch_show_params_t params = { .part = -1 }; int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED; +int entire_thread = -1; notmuch_bool_t verify = FALSE; notmuch_bool_t no_exclude = FALSE; @@ -996,7 +997,10 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) { "raw", NOTMUCH_FORMAT_RAW }, { 0, 0 } } }, { NOTMUCH_OPT_INT, , "part", 'p', 0 }, - { NOTMUCH_OPT_BOOLEAN, _thread, "entire-thread", 't', 0 }, + { NOTMUCH_OPT_KEYWORD_DEFAULT, _thread, "entire-thread", 't', + (notmuch_keyword_t []){ { "true", TRUE }, + { "false", FALSE }, + { 0, 0 } } }, { NOTMUCH_OPT_BOOLEAN, , "decrypt", 'd', 0 }, { NOTMUCH_OPT_BOOLEAN, , "verify", 'v', 0 }, { NOTMUCH_OPT_BOOLEAN, _exclude, "no-exclude", 'n', 0 }, @@ -1020,7 +1024,8 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) switch (format_sel) { case NOTMUCH_FORMAT_JSON: format = _json; - params.entire_thread = TRUE; + if (entire_thread == -1) + params.entire_thread = TRUE; break; case NOTMUCH_FORMAT_TEXT: format = _text; @@ -1043,6 +1048,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) break; } +if (entire_thread != -1) + params.entire_thread = entire_thread; + if (params.decrypt || verify) { #ifdef GMIME_ATLEAST_26 /* TODO: GMimePasswordRequestFunc */ -- 1.7.5.4
[PATCH 2/3] command-line-arguments: support keyword arguments with default value
Add NOTMUCH_OPT_KEYWORD_DEFAULT to support plain --arg in addition to --arg=value. The value to use is the first in the list of keywords. Signed-off-by: Jani Nikula --- command-line-arguments.c | 11 ++- command-line-arguments.h |1 + 2 files changed, 11 insertions(+), 1 deletions(-) diff --git a/command-line-arguments.c b/command-line-arguments.c index 1bdb881..2a3646f 100644 --- a/command-line-arguments.c +++ b/command-line-arguments.c @@ -15,6 +15,13 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, const char *arg_str) { const notmuch_keyword_t *keywords = arg_desc->keywords; +if (arg_str == NULL) { + /* no keyword specified, use the first keyword as default */ + if (arg_desc->output_var) + *((int *)arg_desc->output_var) = keywords->value; + return TRUE; +} + while (keywords->name) { if (strcmp (arg_str, keywords->name) == 0) { if (arg_desc->output_var) { @@ -105,7 +112,8 @@ parse_option (const char *arg, return FALSE; } else if (next == '\0') { value = NULL; - if (try->opt_type != NOTMUCH_OPT_BOOLEAN) + if (try->opt_type != NOTMUCH_OPT_BOOLEAN && + try->opt_type != NOTMUCH_OPT_KEYWORD_DEFAULT) return FALSE; } else { return FALSE; @@ -116,6 +124,7 @@ parse_option (const char *arg, switch (try->opt_type) { case NOTMUCH_OPT_KEYWORD: + case NOTMUCH_OPT_KEYWORD_DEFAULT: return _process_keyword_arg (try, value); break; case NOTMUCH_OPT_BOOLEAN: diff --git a/command-line-arguments.h b/command-line-arguments.h index de1734a..d70c84c 100644 --- a/command-line-arguments.h +++ b/command-line-arguments.h @@ -8,6 +8,7 @@ enum notmuch_opt_type { NOTMUCH_OPT_BOOLEAN, /* --verbose */ NOTMUCH_OPT_INT, /* --frob=8 */ NOTMUCH_OPT_KEYWORD, /* --format=raw|json|text */ +NOTMUCH_OPT_KEYWORD_DEFAULT,/* --format[=raw|json]*/ NOTMUCH_OPT_STRING,/* --file=/tmp/gnarf.txt */ NOTMUCH_OPT_POSITION /* notmuch dump pos_arg */ }; -- 1.7.5.4
[PATCH 1/3] command-line-arguments: allow true and false keywords for booleans
Add support for --arg=true and --arg=false for NOTMUCH_OPT_BOOLEAN arguments to be able to disable a boolean argument. Plain --arg remains unchanged, meaning true. Signed-off-by: Jani Nikula --- command-line-arguments.c | 36 ++-- 1 files changed, 30 insertions(+), 6 deletions(-) diff --git a/command-line-arguments.c b/command-line-arguments.c index e711414..1bdb881 100644 --- a/command-line-arguments.c +++ b/command-line-arguments.c @@ -28,6 +28,27 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, const char *arg_str) { return FALSE; } +static notmuch_bool_t +_process_boolean_arg (const notmuch_opt_desc_t *arg_desc, const char *arg_str) +{ +notmuch_bool_t value = TRUE; + +if (arg_str) { + if (strcmp (arg_str, "true") == 0) { + value = TRUE; + } else if (strcmp (arg_str, "false") == 0) { + value = FALSE; + } else { + fprintf (stderr, "unknown boolean: %s\n", arg_str); + return FALSE; + } +} + +*((notmuch_bool_t *)arg_desc->output_var) = value; + +return TRUE; +} + /* Search for the {pos_arg_index}th position argument, return FALSE if that does not exist. @@ -79,11 +100,15 @@ parse_option (const char *arg, * delimiter, and a non-zero length value */ - if (try->opt_type != NOTMUCH_OPT_BOOLEAN) { - if (next != '=' && next != ':') return FALSE; - if (value[0] == 0) return FALSE; + if (next == '=' || next == ':') { + if (value[0] == '\0') + return FALSE; + } else if (next == '\0') { + value = NULL; + if (try->opt_type != NOTMUCH_OPT_BOOLEAN) + return FALSE; } else { - if (next != 0) return FALSE; + return FALSE; } if (try->output_var == NULL) @@ -94,8 +119,7 @@ parse_option (const char *arg, return _process_keyword_arg (try, value); break; case NOTMUCH_OPT_BOOLEAN: - *((notmuch_bool_t *)try->output_var) = TRUE; - return TRUE; + return _process_boolean_arg (try, value); break; case NOTMUCH_OPT_INT: *((int *)try->output_var) = strtol (value, , 10); -- 1.7.5.4
[PATCH 0/3] argument parsing additions
Hi Mark - I'm not sure which is worse, criticizing or rewriting other people's patches. I already did the former, and now I'm doing the latter. Apologies for both. I didn't really mean to write these patches, but it turned out to be more fun writing a proper reply in C than in English. Patch 1 adds --arg=true and --arg=false support for booleans. It's not strictly required for the --entire-thread support in patch 3, which uses the extension of keyword arguments from patch 2, but it's for consistency across boolean arguments. Please let me know what you think. BR, Jani. Jani Nikula (3): command-line-arguments: allow true and false keywords for booleans command-line-arguments: support keyword arguments with default value cli: allow switching off entire thread mode in notmuch show json format command-line-arguments.c | 45 +++-- command-line-arguments.h |1 + notmuch-show.c | 12 ++-- 3 files changed, 50 insertions(+), 8 deletions(-) -- 1.7.5.4
[PATCH v2 0/2] cli: Allow true/false parameter for boolean
Hi Here is a second version of a patch to allow parameters to boolean options on the command line. This version allows parameters (=true|false). My first version is at id:1331244944-7960-1-git-send-email-markwalters1...@gmail.com. Jani posted an alternative version there. Jani's version and this one are quite similar: the key difference is that this version abuses a notmuch_bool_t by setting it to -1 (to indicate that the parser has not set this option). This makes the code simpler but is definitely an abuse. I will discuss this further in replies to Jani's series. Best wishes Mark Mark Walters (2): cli: Parsing. Allow true/false parameter for boolean options. cli: make --entire-thread=false work for format=json. command-line-arguments.c | 34 ++ notmuch-show.c | 15 +-- 2 files changed, 39 insertions(+), 10 deletions(-) -- 1.7.9.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 1/2] cli: Parsing. Allow true/false parameter for boolean options.
Allow NOTMUCH_OPT_BOOLEAN to take a true or false parameter. In particular it allows the user to turn off a boolean option with --option=false. --- command-line-arguments.c | 34 ++ 1 files changed, 26 insertions(+), 8 deletions(-) diff --git a/command-line-arguments.c b/command-line-arguments.c index e711414..76b185f 100644 --- a/command-line-arguments.c +++ b/command-line-arguments.c @@ -28,6 +28,24 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, const char *arg_str) { return FALSE; } +static notmuch_bool_t +_process_boolean_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) { + +if (next == 0) { + *((notmuch_bool_t *)arg_desc-output_var) = TRUE; + return TRUE; +} +if (strcmp (arg_str, false) == 0) { + *((notmuch_bool_t *)arg_desc-output_var) = FALSE; + return TRUE; +} +if (strcmp (arg_str, true) == 0) { + *((notmuch_bool_t *)arg_desc-output_var) = TRUE; + return TRUE; +} +return FALSE; +} + /* Search for the {pos_arg_index}th position argument, return FALSE if that does not exist. @@ -76,14 +94,15 @@ parse_option (const char *arg, char *endptr; /* Everything but boolean arguments (switches) needs a -* delimiter, and a non-zero length value +* delimiter, and a non-zero length value. Boolean +* arguments may take an optional =true or =false value. */ - - if (try-opt_type != NOTMUCH_OPT_BOOLEAN) { - if (next != '=' next != ':') return FALSE; - if (value[0] == 0) return FALSE; + if (next != '=' next != ':' next != 0) return FALSE; + if (next == 0) { + if (try-opt_type != NOTMUCH_OPT_BOOLEAN) + return FALSE; } else { - if (next != 0) return FALSE; + if (value[0] == 0) return FALSE; } if (try-output_var == NULL) @@ -94,8 +113,7 @@ parse_option (const char *arg, return _process_keyword_arg (try, value); break; case NOTMUCH_OPT_BOOLEAN: - *((notmuch_bool_t *)try-output_var) = TRUE; - return TRUE; + return _process_boolean_arg (try, next, value); break; case NOTMUCH_OPT_INT: *((int *)try-output_var) = strtol (value, endptr, 10); -- 1.7.9.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 2/2] cli: make --entire-thread=false work for format=json.
The --entire-thread option in notmuch-show.c defaults to true when format=json. Previously there was no way to turn this off. This patch makes it respect --entire-thread=false. The one subtlety is that we initialise a notmuch_bool_t to -1 to indicate that the option parsing has not set it. This allows the code to distinguish between the option being omitted from the command line, and the option being set to false on the command line. --- notmuch-show.c | 15 +-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index 05d51b2..8da1845 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -983,7 +983,12 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) char *query_string; int opt_index, ret; const notmuch_show_format_t *format = format_text; -notmuch_show_params_t params = { .part = -1 }; + +/* We abuse the notmuch_bool_t variable params.entire-thread by + * setting it to -1 to denote that the command line parsing has + * not set it. We ensure it is set to TRUE or FALSE before passing + * it to any other function.*/ +notmuch_show_params_t params = { .part = -1, .entire_thread = -1 }; int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED; notmuch_bool_t verify = FALSE; notmuch_bool_t no_exclude = FALSE; @@ -1020,7 +1025,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) switch (format_sel) { case NOTMUCH_FORMAT_JSON: format = format_json; - params.entire_thread = TRUE; + /* JSON defaults to entire-thread TRUE */ + if (params.entire_thread == -1) + params.entire_thread = TRUE; break; case NOTMUCH_FORMAT_TEXT: format = format_text; @@ -1042,6 +1049,10 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) params.raw = TRUE; break; } +/* Default is entire-thread = FALSE except for format=json which + * is dealt with above. */ +if (params.entire_thread == -1) + params.entire_thread = FALSE; if (params.decrypt || verify) { #ifdef GMIME_ATLEAST_26 -- 1.7.9.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 0/3] argument parsing additions
On Sat, 10 Mar 2012 00:33:27 +0200, Jani Nikula j...@nikula.org wrote: Hi Mark - I'm not sure which is worse, criticizing or rewriting other people's patches. I already did the former, and now I'm doing the latter. Apologies for both. I didn't really mean to write these patches, but it turned out to be more fun writing a proper reply in C than in English. Patch 1 adds --arg=true and --arg=false support for booleans. It's not strictly required for the --entire-thread support in patch 3, which uses the extension of keyword arguments from patch 2, but it's for consistency across boolean arguments. Hi I like patch 1: I have an almost identical to my version (in the series I just sent to the list id:1331377533-30262-1-git-send-email-markwalters1...@gmail.com X-Mailer: git-send-email 1.7.9.1). I am not sure about patch 2 and patch 3. Do you have a use case for --option except when option is a boolean? Otherwise I think I prefer either my approach (abusing a notmuch_bool_t) or just adding an option NOTMUCH_OPT_BOOLEAN_AS_INT which does boolean parsing but returns an int. I guess I am saying that I think allowing boolean options which can sometimes default to true and sometimes to false is more useful than allowing --option for arbitrary keywords (*). What do you think? Best wishes Mark (*) Indeed, I was thinking of the former as a possibility for the exclude code, but I am erring towards just using keywords so I can allow more options as you suggested. Please let me know what you think. BR, Jani. Jani Nikula (3): command-line-arguments: allow true and false keywords for booleans command-line-arguments: support keyword arguments with default value cli: allow switching off entire thread mode in notmuch show json format command-line-arguments.c | 45 +++-- command-line-arguments.h |1 + notmuch-show.c | 12 ++-- 3 files changed, 50 insertions(+), 8 deletions(-) -- 1.7.5.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] emacs-hello: Do not calculate the count of the messages in hidden sections
On Sat, 18 Feb 2012 23:12:29 +0100, Michal Sojka sojk...@fel.cvut.cz wrote: The result is that hello screen shows much faster when some sections are hidden. pushed. d ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] mime_node_open: skip envelope from lines at the start of messages
On Sat, 10 Mar 2012 09:25:31 -0400, David Bremner da...@tethera.net wrote: From: David Bremner brem...@debian.org Some MDAs such as procmail (in MH mode), and exim (doing local delivery in some configurations of the appendfile transport) add a line to the front of a message with From followed by envelope sender. Since this is not a proper RFC822 header field, gmime (at least since version 2.6) refuses to parse it, unless in mbox mode. This change reads the line of the file, and if they start with From , pass the stream to gmime starting from the second line. This makes mime_node_open more consistent with (but still stricter than) the permissive behaviour of notmuch_file_get_header (message-file.c), which allows a certain number of broken_headers. We avoid putting gmime into mbox mode in case of side effects; this leaves the situation of mboxes accidentally indexed by notmuch the same as before, namely undefined behaviour. Ideally they should at least be warned by notmuch-new. Although strict rfc822 adherence would be one way to detect mboxes, it doesn't seem to fit with the spirit or code of message-file.c. --- This version fixes a few formatting issues, and one bug (the strncmp). +1 Tomi pgpEeYZiqiky7.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] emacs: fix MML quoting in replies
On Sun, 4 Mar 2012 10:25:38 +0200, Jani Nikula j...@nikula.org wrote: The reply MML quoting added in commit ae438cc unintentionally MML quotes also the signature/encryption MML tags added via message-setup-hook, causing the reply not to be signed/encrypted. MML quote just the original message in the temp buffer before inserting it to the message buffer, to not interfere with message mode hooks or message construction in general. See [1] and [2] for bug reports. Thanks to Tim Bielawa tbiel...@redhat.com for testing. [1] id:87hay78x6l@wyzanski.jamesvasile.com [2] id:1330812262-28272-1-git-send-email-tbiel...@redhat.com. Signed-off-by: Jani Nikula j...@nikula.org Looks good to me. Tomi ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: a DoS vulnerability associated with conflated Message-IDs?
On Thu, 8 Mar 2012 10:38:32 -0700, Jeremy Nickurak not-m...@trk.nickurak.ca wrote: On Thu, Mar 8, 2012 at 10:16, Daniel Kahn Gillmor d...@fifthhorseman.net wrote: Any other suggestions or ideas? What about representing the contents from both message in one apparent message? - ... - If the bodies disagree, display both. We'd probably need to do some like doing a diff. I find it annoying enough displaying both text and html copies of a mail. Displaying two copies of a message, just because one of them has a few extra lines as a footer would be equally annoying. Maybe it would be enough to ignore the signature too, when comparing messages? ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] Allow selecting which version of gmime is used to build notmuch.
This allows for testing against both versions of gmime on a single machine, without having to mess with pkg-config paths. --- configure |9 - 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/configure b/configure index 8b85b9d..630d647 100755 --- a/configure +++ b/configure @@ -44,6 +44,7 @@ LIBDIR= WITH_EMACS=1 WITH_BASH=1 WITH_ZSH=1 +WITH_GMIME_VERSIONS='gmime-2.6 gmime-2.4' usage () { @@ -170,6 +171,12 @@ for option; do fi elif [ ${option} = '--without-zsh-completion' ] ; then WITH_ZSH=0 +elif [ ${option%%=*} = '--with-gmime-version' ] ; then + if [ ${option#*=} = '2.4' ]; then + WITH_GMIME_VERSIONS='gmime-2.4' +elif [ ${option#*=} = '2.6' ]; then + WITH_GMIME_VERSIONS='gmime-2.6' + fi elif [ ${option%%=*} = '--build' ] ; then build_option=${option#*=} case ${build_option} in @@ -275,7 +282,7 @@ fi printf Checking for GMime development files... have_gmime=0 -for gmimepc in gmime-2.6 gmime-2.4; do +for gmimepc in $WITH_GMIME_VERSIONS; do if pkg-config --exists $gmimepc; then printf Yes ($gmimepc).\n have_gmime=1 -- 1.7.8.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH v6] emacs: Use the new JSON reply format and message-cite-original
On Fri, Mar 9, 2012 at 16:13, Jani Nikula j...@nikula.org wrote: + (set-mark (point)) + (goto-char start) + ;; Quote the original message according to the user's configured style. + (message-cite-original) + (goto-char (point-max) + + (push-mark) (message-goto-body) - ;; Original message may contain (malicious) MML tags. We must - ;; properly quote them in the reply. Note that using `point-max' - ;; instead of `mark' here is wrong. The buffer may include user's - ;; signature which should not be MML-quoted. - (mml-quote-region (point) (mark))) Is it okay to drop mml quoting? Why? As Austin pointed out on an earlier version, message-cite-original already does the quoting, so doing it ourselves will result in double-quoting MML tags. ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH v6 05/10] reply: Add a JSON reply format.
On Fri, Mar 9, 2012 at 16:08, Jani Nikula j...@nikula.org wrote: + if (!reply) + printf (, %s: %s, + json_quote_str (local, Date), + json_quote_str (local, g_mime_message_get_date_as_string (message))); + + if (reply) { Isn't that an else? Indeed. Fixed. ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH v6 03/10] reply: Require that only one message is returned
On Fri, Mar 9, 2012 at 16:00, Jani Nikula j...@nikula.org wrote: On Tue, 21 Feb 2012 23:46:32 -0700, Adam Wolfe Gordon awg+notm...@xvx.ca wrote: As the semantics of replying to multiple messages have not yet been defined well, make notmuch reply require that the search given returns only a single message. Is there any real reason, apart from consistency between --format=default and --format=json, to disable the current multiple message reply? Also notmuch show has format specific features and limitations. I agree the semantics should be clarified, and eventually multiple message reply should be uniformly supported by all formats, including --format=json, but IMHO this patch should be dropped (and the TODO patch amended accordingly). It's just for consistency. I like the idea of dropping support for multi-message replies everywhere now, then re-adding it with new semantics later, but I don't feel very strongly about it. If people who use the CLI would prefer to have the default format left as-is for now that's OK with me. ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
nmfirehose - a crude nmbug companion tool
Hi all - There was some talk on IRC about maintaining a development branch containing the maybe ready patches [1] to better expose them to real-life use before merging to master. I set out to automate this a little, and ended up with nmfirehose. It's a shell script that can be used to grab a bunch of patches from the notmuch mail store based on queries, and apply them to a repository. In particular, it can grab the maybe ready patches and apply them against notmuch master. Inevitable conflicts are handled by applying patches in oldest first order, and dropping any conflicting series. An email thread approximates a patch series; more than one patch series in a thread are folded into one series. Patches are applied incrementally, on top of each other by default, but there's also support for non-incremental per-series apply against master to see if there are conflicts. This is useful for the review query. Conflicting patches can be automatically tagged if so desired (but I don't recommend pushing these to nmbug without human review). How well any of this works very much depends on how accurately the patch messages are tagged. Some examples (run within a notmuch git repo, with up-to-date nmbug tags in the database): # take nmbug maybe-ready patches and apply them against origin/master $ nmfirehose # use local branch firehose and force use it even if existing $ nmfirehose -l firehose -F # keep going after conflicts without reverting whole series $ nmfirehose -k # check each series in review queue against master, and tag conflicting $ nmfirehose -q review -n -t # help $ nmfirehose -h I originally planned on putting this to cron and pushing the result (supported out-of-the-box) to some public repo, but in the end I think people can use this locally just as well, at the pace they want. The script tries not to screw up anything in your notmuch repo, but be careful nonetheless. Script attached; comments welcome. Is this worth adding to contrib? BR, Jani. [1] http://nmbug.tethera.net/status/ nmfirehose Description: nmfirehose ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 0/5] Move to --with-excluded approach to excludes
On Sat, 3 Mar 2012 13:05:13 +, Mark Walters markwalters1...@gmail.com wrote: This series implements the proposal in id:87y5riuz7v@qmul.ac.uk to move to a consistent --with-excluded approach rather than the previous --no-exclude approach. See the message there and its descendants for discussion. The main user side change is that notmuch-search no longer defaults to showing all the excluded threads with [0/n] but will do so if the user says they want all the messages (i.e., by specifying --with-excluded). However, it makes everything consistent throughout the commandline and lib interfaces. In all cases a message type search only returns the non-excluded matches (unless --with-excluded is specified) and a thread type search returns all messages (including excluded ones) in threads that match in a non-excluded message. Hi, Mark. Thanks so much for working on this. This new solution seems like a good one. It keeps the default as expected (excluded are actually excluded from all output), and the with-excluded option behaves intuitively. Looks good to me. Unfortunately, as I discussed with you on irc today, there seems to be a problem with the patch series that is preventing it from working as expected. The outputs of the following commands should agree, which they do: servo:~/src/notmuch/git [master] 0$ ./notmuch count --with-excluded tag:inbox 51171 servo:~/src/notmuch/git [master] 0$ ./notmuch search --output=messages --with-excluded tag:inbox | wc -l 51171 servo:~/src/notmuch/git [master] 0$ However, they should also agree in this case, which they don't: servo:~/src/notmuch/git [master] 0$ ./notmuch count tag:inbox 115 servo:~/src/notmuch/git [master] 0$ ./notmuch search --output=messages tag:inbox | wc -l 51169 servo:~/src/notmuch/git [master] 0$ In this last case, notmuch search is outputting (some but not all(!)) excluded messages when it shouldn't be. However, if I use a more complicated search term, everything seems to be working fine: servo:~/src/notmuch/git [master] 0$ ./notmuch count tag:inbox and tag:unread 0 servo:~/src/notmuch/git [master] 0$ ./notmuch search --output=messages tag:inbox and tag:unread | wc -l 0 servo:~/src/notmuch/git [master] 0$ ./notmuch count --with-excluded tag:inbox and tag:unread 47245 servo:~/src/notmuch/git [master] 0$ ./notmuch search --output=messages --with-excluded tag:inbox and tag:unread | wc -l 47245 servo:~/src/notmuch/git [master] 0$ It also works if I give a single from: search term instead of a single tag: search term. So it appears to be something about how the excluded query is constructed. I can't figure out where the problem is, although I'm still looking. If anyone else can figure it out, please let us know. I would really like to get this series applied so that I can get back to following master! Thanks again for all the work. jamie. pgp0APAOKswaW.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] Fix configure script to properly detect gmime-2.6 if available.
On Thu, 8 Mar 2012 08:45:01 -0800, Jameson Graef Rollins jroll...@finestructure.net wrote: Previously, the configure script would appear to detect gmime-2.6 if present. However, the binaries would end up being compiled against gmime-2.4. The addition of a break fixes things so that now gmime-2.6 will be used if available, falling back to gmime-2.4. pushed. ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] emacs: fix MML quoting in replies
On Sun, 4 Mar 2012 10:25:38 +0200, Jani Nikula j...@nikula.org wrote: The reply MML quoting added in commit ae438cc unintentionally MML quotes also the signature/encryption MML tags added via message-setup-hook, causing the reply not to be signed/encrypted. pushed, d ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] Handle errors in mime_node_open
On Tue, 6 Mar 2012 18:26:57 +, Austin Clements amdra...@mit.edu wrote: --- mime-node.c | 15 +++ 1 files changed, 15 insertions(+), 0 deletions(-) Pushed, d ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch