Inheriting tags from parent

2012-08-05 Thread Michal Nazarewicz
> Quoth Michal Nazarewicz on Aug 03 at  4:29 pm:
>> I've just started using notmuch and am wondering if there is a way to
>> make message ?inherit? some of the tags from messages they are written
>> in replay to (or in general are part of the same thread).
>> 
>> I'm mostly thinking about a ?mute? tag which I'd add to messages that
>> are completely uninteresting to me.  With the ?inheritance? mechanism,
>> I'd be able to make notmuch automatically mute all the replays within
>> the same thread.

Austin Clements  writes:
> I have a hacky and now ancient patch series that you're welcome to try
> porting to a recent notmuch on the inheritable-tags-hack branch at
>   http://awakening.csail.mit.edu/git/notmuch.git
> One general problem with this approach is dealing with threads whose
> messages arrive or are ingested out of order.  I don't think this is
> an insurmountable problem, but my patch certainly doesn't handle it
> correctly.

I'll keep that in mind, but lack of time, won't probably let me play
with it...

> There are also several other solutions to "mute" tags around.  For
> example, some people use a post-new hook to search for threads that
> contain at least one mute tag and then feed these thread IDs back in
> to notmuch tag to add the mute tag to everything in the thread.  I
> believe this is also the approach used by the afew tagging system for
> "killed" threads.

Yeah, that's what I'm doing now.  Basically ?notmuch search
--output=threads is:mute? and then join all the lines with ?or? to
finally do ?notmuch tag +mute ?.  I was, however, hoping for
something more dedicated.

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Micha? ?mina86? Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--
-- 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/20120805/dcb3192c/attachment-0001.pgp>


Release plans for 0.14

2012-08-05 Thread David Bremner

It has been a few months since we last had a release.

I'd like to to another release within the next few weeks. To this end
I'd like to take a snapshot of master next Sunday (August 12), and
release that plus urgent bugfixes a week later (August 19).

I realize this won't be time to get all of the interesting patches we
are working on reviewed and merged in, but I don't want to fall into the
trap of delaying the release indefinitely.

Discussion?

d



[PATCH 4/4] test: conform to content-length fields (text)

2012-08-05 Thread Peter Wang
Update tests to expect Content-length fields in show --format=text
output, for leaf parts with omitted body content.
---
 test/crypto|4 ++--
 test/multipart |   18 +-
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/test/crypto b/test/crypto
index 4a73dcc..8dfbfa6 100755
--- a/test/crypto
+++ b/test/crypto
@@ -161,14 +161,14 @@ Date: Sat, 01 Jan 2000 12:00:00 +
 header}
 body{
 part{ ID: 1, Content-type: multipart/encrypted
-part{ ID: 2, Content-type: application/pgp-encrypted
+part{ ID: 2, Content-type: application/pgp-encrypted, Content-length: 11
 Non-text part: application/pgp-encrypted
 part}
 part{ ID: 3, Content-type: multipart/mixed
 part{ ID: 4, Content-type: text/plain
 This is a test encrypted message.
 part}
-attachment{ ID: 5, Filename: TESTATTACHMENT, Content-type: 
application/octet-stream
+attachment{ ID: 5, Filename: TESTATTACHMENT, Content-type: 
application/octet-stream, Content-length: 28
 Non-text part: application/octet-stream
 attachment}
 part}
diff --git a/test/multipart b/test/multipart
index 0f9e113..064e91a 100755
--- a/test/multipart
+++ b/test/multipart
@@ -129,7 +129,7 @@ Date: Fri, 05 Jan 2001 15:42:57 +
 header}
 body{
 part{ ID: 4, Content-type: multipart/alternative
-part{ ID: 5, Content-type: text/html
+part{ ID: 5, Content-type: text/html, Content-length: 71
 Non-text part: text/html
 part}
 part{ ID: 6, Content-type: text/plain
@@ -147,7 +147,7 @@ And this message is signed.
 -Carl
 part}
 part}
-part{ ID: 9, Content-type: application/pgp-signature
+part{ ID: 9, Content-type: application/pgp-signature, Content-length: 197
 Non-text part: application/pgp-signature
 part}
 part}
@@ -170,7 +170,7 @@ Date: Fri, 05 Jan 2001 15:42:57 +
 header}
 body{
 part{ ID: 4, Content-type: multipart/alternative
-part{ ID: 5, Content-type: text/html
+part{ ID: 5, Content-type: text/html, Content-length: 71
 Non-text part: text/html
 part}
 part{ ID: 6, Content-type: text/plain
@@ -188,7 +188,7 @@ And this message is signed.
 -Carl
 part}
 part}
-part{ ID: 9, Content-type: application/pgp-signature
+part{ ID: 9, Content-type: application/pgp-signature, Content-length: 197
 Non-text part: application/pgp-signature
 part}
 part}
@@ -208,7 +208,7 @@ Date: Fri, 05 Jan 2001 15:42:57 +
 header}
 body{
 part{ ID: 4, Content-type: multipart/alternative
-part{ ID: 5, Content-type: text/html
+part{ ID: 5, Content-type: text/html, Content-length: 71
 Non-text part: text/html
 part}
 part{ ID: 6, Content-type: text/plain
@@ -241,7 +241,7 @@ Date: Fri, 05 Jan 2001 15:42:57 +
 header}
 body{
 part{ ID: 4, Content-type: multipart/alternative
-part{ ID: 5, Content-type: text/html
+part{ ID: 5, Content-type: text/html, Content-length: 71
 Non-text part: text/html
 part}
 part{ ID: 6, Content-type: text/plain
@@ -257,7 +257,7 @@ test_begin_subtest "--format=text --part=4, rfc822's 
multipart"
 notmuch show --format=text --part=4 'id:87liy5ap00.fsf at 
yoom.home.cworth.org' >OUTPUT
 cat OUTPUT
 cat OUTPUT
 cat 

[PATCH 3/4] show: indicate length of omitted body content (text)

2012-08-05 Thread Peter Wang
If a leaf part's body content is omitted, return the content length in
--format=text output, for parity with --format=json output.
---
 notmuch-show.c |   23 +++
 1 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index 5c54257..cde8a1e 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -488,9 +488,17 @@ format_part_text (const void *ctx, sprinter_t *sp, 
mime_node_t *node,
GMIME_OBJECT (node->envelope_part) : node->part;
 GMimeContentType *content_type = g_mime_object_get_content_type (meta);
 const notmuch_bool_t leaf = GMIME_IS_PART (node->part);
+notmuch_bool_t leaf_text_part = FALSE;
 const char *part_type;
 int i;

+if (leaf &&
+   g_mime_content_type_is_type (content_type, "text", "*") &&
+   !g_mime_content_type_is_type (content_type, "text", "html"))
+{
+   leaf_text_part = TRUE;
+}
+
 if (node->envelope_file) {
notmuch_message_t *message = node->envelope_file;

@@ -519,7 +527,16 @@ format_part_text (const void *ctx, sprinter_t *sp, 
mime_node_t *node,
printf (", Filename: %s", filename);
if (cid)
printf (", Content-id: %s", cid);
-   printf (", Content-type: %s\n", g_mime_content_type_to_string 
(content_type));
+   printf (", Content-type: %s", g_mime_content_type_to_string 
(content_type));
+   if (leaf && !leaf_text_part) {
+   GMimeDataWrapper *wrapper = g_mime_part_get_content_object 
(GMIME_PART (node->part));
+   GMimeStream *stream = g_mime_data_wrapper_get_stream (wrapper);
+   ssize_t length = g_mime_stream_length (stream);
+   if (length >= 0) {
+   printf (", Content-length: %ld", length);
+   }
+   }
+   printf ("\n");
 }

 if (GMIME_IS_MESSAGE (node->part)) {
@@ -547,9 +564,7 @@ format_part_text (const void *ctx, sprinter_t *sp, 
mime_node_t *node,
 }

 if (leaf) {
-   if (g_mime_content_type_is_type (content_type, "text", "*") &&
-   !g_mime_content_type_is_type (content_type, "text", "html"))
-   {
+   if (leaf_text_part) {
GMimeStream *stream_stdout = g_mime_stream_file_new (stdout);
g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream_stdout), 
FALSE);
show_text_part_content (node->part, stream_stdout, 0);
-- 
1.7.4.4



[PATCH 2/4] test: conform to content-length fields (json)

2012-08-05 Thread Peter Wang
Update tests to expect content-length fields in show --format=json
output, for leaf parts with omitted body content.
---
 test/crypto|   25 +
 test/json  |2 +-
 test/multipart |9 +
 3 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/test/crypto b/test/crypto
index 5dd14c4..4a73dcc 100755
--- a/test/crypto
+++ b/test/crypto
@@ -61,7 +61,8 @@ expected='[[[{"id": "X",
  "content-type": "text/plain",
  "content": "This is a test signed message.\n"},
  {"id": 3,
- "content-type": "application/pgp-signature"}]}]},
+ "content-type": "application/pgp-signature",
+ "content-length": 315}]}]},
  ['
 test_expect_equal_json \
 "$output" \
@@ -95,7 +96,8 @@ expected='[[[{"id": "X",
  "content-type": "text/plain",
  "content": "This is a test signed message.\n"},
  {"id": 3,
- "content-type": "application/pgp-signature"}]}]},
+ "content-type": "application/pgp-signature",
+ "content-length": 315}]}]},
  ['
 test_expect_equal_json \
 "$output" \
@@ -127,7 +129,8 @@ expected='[[[{"id": "X",
  "content-type": "text/plain",
  "content": "This is a test signed message.\n"},
  {"id": 3,
- "content-type": "application/pgp-signature"}]}]},
+ "content-type": "application/pgp-signature",
+ "content-length": 315}]}]},
  ['
 test_expect_equal_json \
 "$output" \
@@ -196,7 +199,8 @@ expected='[[[{"id": "X",
  "sigstatus": [],
  "content-type": "multipart/encrypted",
  "content": [{"id": 2,
- "content-type": "application/pgp-encrypted"},
+ "content-type": "application/pgp-encrypted",
+ "content-length": 11},
  {"id": 3,
  "content-type": "multipart/mixed",
  "content": [{"id": 4,
@@ -204,6 +208,7 @@ expected='[[[{"id": "X",
  "content": "This is a test encrypted message.\n"},
  {"id": 5,
  "content-type": "application/octet-stream",
+ "content-length": 28,
  "filename": "TESTATTACHMENT"}]}]}]},
  ['
 test_expect_equal_json \
@@ -249,9 +254,11 @@ expected='[[[{"id": "X",
  "encstatus": [{"status": "bad"}],
  "content-type": "multipart/encrypted",
  "content": [{"id": 2,
- "content-type": "application/pgp-encrypted"},
+ "content-type": "application/pgp-encrypted",
+ "content-length": 11},
  {"id": 3,
- "content-type": "application/octet-stream"}]}]},
+ "content-type": "application/octet-stream",
+ "content-length": 652}]}]},
  ['
 test_expect_equal_json \
 "$output" \
@@ -287,7 +294,8 @@ expected='[[[{"id": "X",
  "userid": " Notmuch Test Suite  (INSECURE!)"}],
  "content-type": "multipart/encrypted",
  "content": [{"id": 2,
- "content-type": "application/pgp-encrypted"},
+ "content-type": "application/pgp-encrypted",
+ "content-length": 11},
  {"id": 3,
  "content-type": "text/plain",
  "content": "This is another test encrypted message.\n"}]}]},
@@ -342,7 +350,8 @@ expected='[[[{"id": "X",
  "content-type": "text/plain",
  "content": "This is a test signed message.\n"},
  {"id": 3,
- "content-type": "application/pgp-signature"}]}]},
+ "content-type": "application/pgp-signature",
+ "content-length": 315}]}]},
  ['
 test_expect_equal_json \
 "$output" \
diff --git a/test/json b/test/json
index ac8fa8e..ff2287e 100755
--- a/test/json
+++ b/test/json
@@ -45,7 +45,7 @@ emacs_deliver_message \
  (insert \"Message-ID: <$id>\n\")"
 output=$(notmuch show --format=json "id:$id")
 filename=$(notmuch search --output=files "id:$id")
-test_expect_equal_json "$output" "[[[{\"id\": \"$id\", \"match\": true, 
\"excluded\": false, \"filename\": \"$filename\", \"timestamp\": 946728000, 
\"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\"], \"headers\": 
{\"Subject\": \"$subject\", \"From\": \"Notmuch Test Suite \", \"To\": \"test_suite at notmuchmail.org\", \"Date\": \"Sat, 
01 Jan 2000 12:00:00 +\"}, \"body\": [{\"id\": 1, \"content-type\": 
\"multipart/mixed\", \"content\": [{\"id\": 2, \"content-type\": 
\"text/plain\", \"content\": \"This is a test message with inline attachment 
with a filename\"}, {\"id\": 3, \"content-type\": \"application/octet-stream\", 
\"filename\": \"README\"}]}]}, ["
+test_expect_equal_json "$output" "[[[{\"id\": \"$id\", \"match\": true, 
\"excluded\": false, \"filename\": \"$filename\", \"timestamp\": 946728000, 
\"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\"], \"headers\": 
{\"Subject\": \"$subject\", \"From\": \"Notmuch Test Suite \", \"To\": \"test_suite at notmuchmail.org\", \"Date\": \"Sat, 
01 Jan 2000 12:00:00 +\"}, \"body\": [{\"id\": 1, \"content-type\": 
\"multipart/mixed\", \"content\": [{\"id\": 2, \"content-type\": 
\"text/plain\", \"content\": \"This is a test message with inline attachment 
with a filename\"}, {\"id\": 3, \"content-type\": \"application/octet-stream\", 
\"content-length\": 12392, \"filename\": \"README\"}]}]}, ["

 test_begin_subtest "Search message: json, utf-8"
 add_message "[subject]=\"json-search-utf8-body-s?bj?ct\"" "[date]=\"Sat, 01 
Jan 2000 12:00:00 -\"" "[body]=\"js?n-search-m?ssage\""
diff --git 

[PATCH 1/4] show: indicate length of omitted body content (json)

2012-08-05 Thread Peter Wang
If a leaf part's body content is omitted, return the content length in
--format=json output.  This information may be used by the consumer,
e.g. to decide whether to download a large attachment over a slow link.
---
 devel/schemata |5 -
 notmuch-show.c |8 
 2 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/devel/schemata b/devel/schemata
index 9cb25f5..3df2764 100644
--- a/devel/schemata
+++ b/devel/schemata
@@ -69,7 +69,10 @@ part = {
 # A leaf part's body content is optional, but may be included if
 # it can be correctly encoded as a string.  Consumers should use
 # this in preference to fetching the part content separately.
-content?:   string
+content?:   string,
+# If a leaf part's body content is not included, the content-length
+# may be included instead.
+content-length?: int
 }

 # The headers of a message or part (format_headers_json with reply = FALSE)
diff --git a/notmuch-show.c b/notmuch-show.c
index 3556293..5c54257 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -664,6 +664,14 @@ format_part_json (const void *ctx, sprinter_t *sp, 
mime_node_t *node,
sp->map_key (sp, "content");
sp->string_len (sp, (char *) part_content->data, part_content->len);
g_object_unref (stream_memory);
+   } else {
+   GMimeDataWrapper *wrapper = g_mime_part_get_content_object 
(GMIME_PART (node->part));
+   GMimeStream *stream = g_mime_data_wrapper_get_stream (wrapper);
+   ssize_t length = g_mime_stream_length (stream);
+   if (length >= 0) {
+   sp->map_key (sp, "content-length");
+   sp->integer (sp, length);
+   }
}
 } else if (GMIME_IS_MULTIPART (node->part)) {
sp->map_key (sp, "content");
-- 
1.7.4.4



[PATCH 3/3] test: add broken roundtrip test

2012-08-05 Thread da...@tethera.net
From: David Bremner 

The output of test_cmp is redirected because it is pretty horrible,
and tends to mess up terminals. When the test is no longer marked as
broken, this redirection should be removed.
---
 test/dump-restore |9 +
 1 file changed, 9 insertions(+)

diff --git a/test/dump-restore b/test/dump-restore
index 439e998..7979ebf 100755
--- a/test/dump-restore
+++ b/test/dump-restore
@@ -82,4 +82,13 @@ test_begin_subtest "dump outfile -- from:cworth"
 notmuch dump dump-outfile-dash-inbox.actual -- from:cworth
 test_expect_equal_file dump-cworth.expected dump-outfile-dash-inbox.actual

+test_expect_success 'roundtripping random message-ids and tags' \
+'test_subtest_known_broken &&
+${TEST_DIRECTORY}/random-corpus --config-path=${NOTMUCH_CONFIG} &&
+notmuch dump > EXPECTED.$test_count &&
+notmuch tag -random-corpus tag:random-corpus &&
+notmuch restore < EXPECTED.$test_count 2>/dev/null &&
+notmuch dump > OUTPUT.$test_count &&
+test_cmp EXPECTED.$test_count OUTPUT.$test_count 1>/dev/null'
+
 test_done
-- 
1.7.10.4



[PATCH 2/3] test: add generator for random "stub" messages

2012-08-05 Thread da...@tethera.net
From: David Bremner 

Initial use case is testing dump and restore, so we only have
message-ids and tags.

The message ID's are nothing like RFC compliant, but it doesn't seem
any harder to roundtrip random UTF-8 strings than RFC-compliant ones.

Tags are UTF-8, even though notmuch is in principle more generous than
that.
---
 test/.gitignore  |1 +
 test/Makefile.local  |   14 +++-
 test/basic   |2 +-
 test/random-corpus.c |  201 ++
 4 files changed, 216 insertions(+), 2 deletions(-)
 create mode 100644 test/random-corpus.c

diff --git a/test/.gitignore b/test/.gitignore
index e63c689..e23017b 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -3,4 +3,5 @@ corpus.mail
 smtp-dummy
 symbol-test
 arg-test
+random-corpus
 tmp.*
diff --git a/test/Makefile.local b/test/Makefile.local
index c7f1435..586efc6 100644
--- a/test/Makefile.local
+++ b/test/Makefile.local
@@ -13,6 +13,13 @@ smtp_dummy_modules = $(smtp_dummy_srcs:.c=.o)
 $(dir)/arg-test: $(dir)/arg-test.o command-line-arguments.o util/libutil.a
$(call quiet,CC) -I. $^ -o $@

+random_corpus_deps =  $(dir)/random-corpus.o  $(dir)/database-test.o \
+   notmuch-config.o command-line-arguments.o \
+   lib/libnotmuch.a util/libutil.a
+
+$(dir)/random-corpus: $(random_corpus_deps)
+   $(call quiet,CC) $(CFLAGS_FINAL) $^ -o $@ $(CONFIGURE_LDFLAGS)
+
 $(dir)/smtp-dummy: $(smtp_dummy_modules)
$(call quiet,CC) $^ -o $@

@@ -21,7 +28,12 @@ $(dir)/symbol-test: $(dir)/symbol-test.o

 .PHONY: test check

-test-binaries: $(dir)/arg-test $(dir)/smtp-dummy $(dir)/symbol-test
+TEST_BINARIES=$(dir)/arg-test \
+ $(dir)/random-corpus \
+ $(dir)/smtp-dummy \
+ $(dir)/symbol-test
+
+test-binaries: $(TEST_BINARIES)

 test:  all test-binaries
@${dir}/notmuch-test $(OPTIONS)
diff --git a/test/basic b/test/basic
index d6aed24..589c4e2 100755
--- a/test/basic
+++ b/test/basic
@@ -54,7 +54,7 @@ test_begin_subtest 'Ensure that all available tests will be 
run by notmuch-test'
 eval $(sed -n -e '/^TESTS="$/,/^"$/p' $TEST_DIRECTORY/notmuch-test)
 tests_in_suite=$(for i in $TESTS; do echo $i; done | sort)
 available=$(find "$TEST_DIRECTORY" -maxdepth 1 -type f -executable -printf 
'%f\n' | \
-sed -r -e 
"/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test)$/d"
 | \
+sed -r -e 
"/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test|random-corpus)$/d"
 | \
 sort)
 test_expect_equal "$tests_in_suite" "$available"

diff --git a/test/random-corpus.c b/test/random-corpus.c
new file mode 100644
index 000..ae900a6
--- /dev/null
+++ b/test/random-corpus.c
@@ -0,0 +1,201 @@
+/*
+ * Generate a random corpus of stub messages.
+ *
+ * Initial use case is testing dump and restore, so we only have
+ * message-ids and tags.
+ *
+ * Generated message-id's and tags are intentionally nasty.
+ *
+ * Copyright (c) 2012 David Bremner
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see http://www.gnu.org/licenses/ .
+ *
+ * Author: David Bremner 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "notmuch-client.h"
+#include "command-line-arguments.h"
+#include "database-test.h"
+
+/* Current largest UTF-32 value defined. Note that most of these will
+ * be printed as boxes in most fonts.
+ */
+
+#define GLYPH_MAX 0x10FFFE
+
+static gunichar
+random_unichar ()
+{
+int start=1, stop=GLYPH_MAX;
+int class = random() % 4;
+
+switch (class) {
+case 0:
+   /* control */
+   start=0x01;
+   stop=0x20;
+   break;
+case 1:
+   start=0x21;
+   stop=0x7E;
+   break;
+case 2:
+   start=0x41;
+   stop=0x7a;
+   break;
+case 3:
+   start=0x7F;
+   stop=GLYPH_MAX;
+}
+
+return start + (random() % (start - stop + 1));
+}
+
+static char *
+random_utf8_string (void *ctx, size_t char_count)
+{
+
+gchar *buf = NULL;
+size_t buf_size = 0;
+
+size_t offset = 0;
+
+size_t i;
+
+buf = talloc_realloc (ctx, NULL, gchar, char_count);
+buf_size = char_count;
+
+for (i = 0; i < char_count; i++) {
+   gunichar randomchar;
+   size_t written;
+
+   /* 6 for one glyph, one for null */
+   if (buf_size - offset < 8) {
+   buf_size += 16;
+ 

test infrastructure for new dump/restore

2012-08-05 Thread da...@tethera.net
This implements an old suggestion of Mark's to get wacky message-ids
into the database directly without relying on underdefined behaviour
of the gmime parser; the previous effort relied on gmime passing
literally through message-ids not delimitted according RFC.

Also compared to the previous version
(id:"1326591624-15493-10-git-send-email-david at tethera.net"), this now
uses valid UTF-8 text, rather than just ascii, although it is a bit
biased towards ascii because most of the characters that cause
problems are there.

There is a fair amount of code here, but I hope the generation of
random messages may be more useful in the future.

The high level goal here is to (re)-introduce a hex-encoding based
dump-restore that can pass this roundtrip test, and probably some
batch tagging facility that shares code.

If people don't mind things broken up into mini-series (without
obvious gain in new features) like this, I'll probably post the
hex-encoding infrastructure next.



Vim plugins

2012-08-05 Thread Sepp Tannhuber
Dear all,

I would like to check the available vim plugins. At least I found three:
- the original one
- Felipe's ruby plugin
- Anton's python plugin

First of all can you tell me where I find the files of the python plugin?
I tried
? $ git clone git://git.khirnov.net/git/notmuch
But I cannot find the python files in the vim directory. What am I doing wrong?

Then I found some information that the ruby plugin should be able to deal with
attachments. I could not find a way to attach files. Is there any additional
information how these scripts can be used? The screencast which was mentioned
in this mailing list is interesting. But it does not show how these actions can 
be
done.

I am not very familiar with coding. So any further information would be helpful.

Thanks in advance


[PATCH 1/4] show: indicate length of omitted body content (json)

2012-08-05 Thread Jameson Graef Rollins
On Sun, Aug 05 2012, Peter Wang  wrote:
> If a leaf part's body content is omitted, return the content length in
> --format=json output.  This information may be used by the consumer,
> e.g. to decide whether to download a large attachment over a slow link.
> ---
>  devel/schemata |5 -
>  notmuch-show.c |8 
>  2 files changed, 12 insertions(+), 1 deletions(-)
>
> diff --git a/devel/schemata b/devel/schemata
> index 9cb25f5..3df2764 100644
> --- a/devel/schemata
> +++ b/devel/schemata
> @@ -69,7 +69,10 @@ part = {
>  # A leaf part's body content is optional, but may be included if
>  # it can be correctly encoded as a string.  Consumers should use
>  # this in preference to fetching the part content separately.
> -content?:   string
> +content?:   string,
> +# If a leaf part's body content is not included, the content-length
> +# may be included instead.
> +content-length?: int

Hey, Peter.  Something somewhere, and probably at least here in the
schemata, should mention what the uids are (b? kB? KiB? YiB?)

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/20120805/bc63fe25/attachment.pgp>


[PATCH 2/2] test: emacs: run list-processes after accept-process-output in emacs 23.1

2012-08-05 Thread Tomi Ollila
When running emacs tests using emacs 23.1.1 the tests block (until timeout)
when emacs function (notmuch-test-wait) is called.

There is an emacs bug #2930 titled:
23.0.92; `accept-process-output' and `sleep-for' do not run sentinel

It seems this is present in emacs 23.1.

Calling list-processes after accept-process-output seems work around
this problem; in case Emacs version is 23.1 a defadvice is activated
to do just that.
---

Thanks to Austin for the comments and IRC discussions on the matter.

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

diff --git a/test/test-lib.el b/test/test-lib.el
index 52d9936..4330352 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -35,6 +35,16 @@
 "Disable yes-or-no-p before executing kill-emacs"
 (defun yes-or-no-p (prompt) t)))

+;; Emacs bug #2930:
+;; 23.0.92; `accept-process-output' and `sleep-for' do not run sentinels
+;; seems to be present in Emacs 23.1.
+;; Running `list-processes' after `accept-process-output' seems to work
+;; around this problem.
+(if (and (= emacs-major-version 23) (= emacs-minor-version 1))
+  (defadvice accept-process-output (after run-list-processes activate)
+"run list-processes after executing accept-process-output"
+(list-processes)))
+
 (defun notmuch-test-wait ()
   "Wait for process completion."
   (while (get-buffer-process (current-buffer))
-- 
1.7.1



[PATCH 1/2] test: emacs: call accept-process-output in notmuch-test-wait

2012-08-05 Thread Tomi Ollila
notmuch-test-wait called sleep-for in a loop to wait unconditionally 0.1
seconds while waiting for process to exit.
accept-process-output returns as soon as there is any data available
from process, so using it avoids unnecessary fixed delays.
Both of these functions run process sentinels.
---

This 2 patch series is an alternative to 
id:"134412-14344-1-git-send-email-tomi.ollila at iki.fi"
which speeds up execution when Emacs version is not 23.1.
(so that users of newer emacs doesn't need to suffer the
workaround made for emacs 23.1 users in second patch in
this series)

during testing of the feature I had
+(accept-process-output nil 10)))
there -- it did not wait 10 seconds.

I also tested the following function:

(defun notmuch-test-wait () t)

i.e. dropping wait altogether -- this makes tests fail in different ways...

 test/test-lib.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/test/test-lib.el b/test/test-lib.el
index 5dd6271..52d9936 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -38,7 +38,7 @@
 (defun notmuch-test-wait ()
   "Wait for process completion."
   (while (get-buffer-process (current-buffer))
-(sleep-for 0.1)))
+(accept-process-output nil 0.1)))

 (defun test-output ( filename)
   "Save current buffer to file FILENAME.  Default FILENAME is OUTPUT."
-- 
1.7.1



[PATCH 1/4] show: indicate length of omitted body content (json)

2012-08-05 Thread Tomi Ollila
On Sun, Aug 05 2012, Peter Wang  wrote:

> If a leaf part's body content is omitted, return the content length in
> --format=json output.  This information may be used by the consumer,
> e.g. to decide whether to download a large attachment over a slow link.
> ---

Code looks good to me and tests pass. So I am not against pushing...

Tomi


>  devel/schemata |5 -
>  notmuch-show.c |8 
>  2 files changed, 12 insertions(+), 1 deletions(-)
>
> diff --git a/devel/schemata b/devel/schemata
> index 9cb25f5..3df2764 100644
> --- a/devel/schemata
> +++ b/devel/schemata
> @@ -69,7 +69,10 @@ part = {
>  # A leaf part's body content is optional, but may be included if
>  # it can be correctly encoded as a string.  Consumers should use
>  # this in preference to fetching the part content separately.
> -content?:   string
> +content?:   string,
> +# If a leaf part's body content is not included, the content-length
> +# may be included instead.
> +content-length?: int
>  }
>  
>  # The headers of a message or part (format_headers_json with reply = FALSE)
> diff --git a/notmuch-show.c b/notmuch-show.c
> index 3556293..5c54257 100644
> --- a/notmuch-show.c
> +++ b/notmuch-show.c
> @@ -664,6 +664,14 @@ format_part_json (const void *ctx, sprinter_t *sp, 
> mime_node_t *node,
>   sp->map_key (sp, "content");
>   sp->string_len (sp, (char *) part_content->data, part_content->len);
>   g_object_unref (stream_memory);
> + } else {
> + GMimeDataWrapper *wrapper = g_mime_part_get_content_object 
> (GMIME_PART (node->part));
> + GMimeStream *stream = g_mime_data_wrapper_get_stream (wrapper);
> + ssize_t length = g_mime_stream_length (stream);
> + if (length >= 0) {
> + sp->map_key (sp, "content-length");
> + sp->integer (sp, length);
> + }
>   }
>  } else if (GMIME_IS_MULTIPART (node->part)) {
>   sp->map_key (sp, "content");
> -- 
> 1.7.4.4
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] NEWS: discuss changes for dump and restore syntax.

2012-08-05 Thread da...@tethera.net
From: David Bremner 

The duplication in NEWS.Debian is so that Debian users will be warned
during upgrade.
---
 NEWS   |   10 ++
 debian/NEWS.Debian |   14 ++
 2 files changed, 24 insertions(+)

diff --git a/NEWS b/NEWS
index 7b1f36c..761b2c1 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,16 @@ Maildir tag synchronization
   messages (typically causing new messages to not receive the "unread"
   tag).

+Command-Line Interface
+--
+
+  The deprecated positional output file argument to `notmuch dump` has
+  been replaced with an `--output` option. The input file positional
+  argument to `notmuch restore` has been replaced with an `--input`
+  option for consistency with dump.  These changes simplify the syntax
+  of dump/restore options and make them more consistent with other
+  notmuch commands.
+
 Emacs Interface
 ---

diff --git a/debian/NEWS.Debian b/debian/NEWS.Debian
index 6947754..bf95738 100644
--- a/debian/NEWS.Debian
+++ b/debian/NEWS.Debian
@@ -1,3 +1,17 @@
+notmuch (0.14-1) unstable; urgency=low
+
+  There is an incompatible change in option syntax for dump and restore
+  in this release. Please update your scripts.
+
+  From upstream NEWS:
+
+  The deprecated positional output file argument to notmuch dump has
+  been replaced with an --output option. The input file positional
+  argument for restore has been replaced with an --input option for
+  consistency with dump.
+
+ -- David Bremner   Sun, 05 Aug 2012 11:52:49 -0300
+
 notmuch (0.6~238) unstable; urgency=low

   The emacs user interface to notmuch is now contained in a seperate
-- 
1.7.10.4



[PATCH v2 2/7] lib: add a date/time parser module

2012-08-05 Thread David Bremner
Jani Nikula  writes:

> +
> +static enum field
> +abs_to_rel_field (enum field field)
> +{
> +assert (field <= TM_ABS_YEAR);
> +
> +/* note: depends on the enum ordering */
> +return field + (TM_REL_SEC - TM_ABS_SEC);
> +}
> +

I wonder if this would be slightly nicer of you defined a TM_FIRST_REL
or so as a synonym like TM_NONE and TM_SIZE

> +/* get zero value for field */
> +static int
> +field_zero (enum field field)
> +{
> +if (field == TM_ABS_MDAY || field == TM_ABS_MON)
> + return 1;
> +else if (field == TM_ABS_YEAR)
> + return 1970;
> +else
> + return 0;
> +}

what do you think about using the word "epoch" instead of zero here?

> +static bool
> +get_postponed_number (struct state *state, int *v, int *n, char *d)
> +{

I found the 1 letter names not quite obvious here.

At this point reading the code, I have not trouble understanding each
line/function, but I feel like I'm missing the big picture a bit. 
What is a postponed number?

> +/*
> + * REVISIT: There could be a "next_field" that would be set from
> + * "field" for the duration of the handle_postponed_number() call,
> + * so it has more information to work with.
> + */

The notmuch convention seems to be to use XXX: for this. I'm not sure
I'd bother changing, especially if we can't decide how to package this.

> +/* Time set helper. No input checking. Use UNSET (-1) to leave unset. */
> +static int
> +set_abs_time (struct state *state, int hour, int min, int sec)
> +{
> +int r;
> +
> +if (hour != UNSET) {
> + if ((r = set_field (state, TM_ABS_HOUR, hour)))
> + return r;
> +}

So for this function and the next, the first match wins? I don't really
see the motivation for this, maybe you can explain a bit.


> +/* timezone codes: offset in minutes. FIXME: add more codes. */

Did you think about trying to delegate the list of timezones to the
system?

> + * Compare strings s and keyword. Return number of matching chars on
> + * match, 0 for no match. Match must be at least n chars (n == 0 all
> + * of keyword), otherwise it's not a match. Use match_case for case
> + * sensitive matching.
> + */

I guess that's fine, and it is internal, but maybe -1 for whole string
would be slightly nicer (although I can't imagine what good matching 0
length strings is at the moment).

> + /* Minimum match length. */
> + p = strchr (keyword, '|');
> + if (p) {
> + minlen = p - keyword;
> + memmove (p, p + 1, strlen (p + 1) + 1);
> + }

Something about that memmove creeps me out, but I trust you that it's
correct. Alternatively I guess you could represent keywords as pairs of
strings, which is probably more of a pain.


> +
> +/* Parse a single number. Typically postpone parsing until later. */

OK, so I finally start to understand what a postponed number is :)
I understand the compiler likes bottom up declarations, but some
top down declarations/comments are needed I think.

> +static int
> +parse_date (struct state *state, char sep,
> + unsigned long v1, unsigned long v2, unsigned long v3,
> + size_t n1, size_t n2, size_t n3)
> +{
> +int year = UNSET, mon = UNSET, mday = UNSET;
> +
> +assert (is_date_sep (sep));
> +
> +switch (sep) {
> +case '/': /* Date: M[M]/D[D][/YY[YY]] or M[M]/ */

If I understand correctly, this chooses between American (?) month, day,
year ordering and "sensible" day, month, year ordering by delimiter. I
never thought about this as a way to tell (I often write D/M/Y), but
that could be just me. I agree it's fine as a convention.

> +/*
> + * Parse delimiter(s). Return < 0 on error, number of parsed chars on
> + * success.
> + */

So 1:-2 will parse as 1-2 ?, i.e. last delimiter wins? Maybe better to
say so explicitly.

> +/* Combine absolute and relative fields, and round. */
> +static int
> +create_output (struct state *state, time_t *t_out, const time_t *tnow,
> +int round)
> +{

It seems like most of non-obvious logic like (when is "wednesday") is
encoded here. From a maintenence point of view, it would be nice to be
able to seperate out the heuristic stuff from the mechanical, to the
degree that it is possible.

d


Remove positional arguments to dump and restore

2012-08-05 Thread Tomi Ollila
On Sat, Aug 04 2012, david at tethera.net wrote:

> The positional argument to dump was deprecated quite a while ago. For
> restore, we never formally deprecated it. It seems a bit more
> consistent this way, but I don't mind leaving restore alone if people
> feel strongly about it.


LGTM.

Tomi


[PATCH v2] test: test-lib.el: replace sleep-for with sit-for in notmuch-test-wait

2012-08-05 Thread Tomi Ollila
When running emacs tests using emacs 23.1.1 the tests block (until timeout)
when emacs function (notmuch-test-wait) is called.

There is an emacs bug #2930 titled:
23.0.92; `accept-process-output' and `sleep-for' do not run sentinels

It seems this is still active in emacs 23.1; replacing sleep-for with
sit-for makes the tests work as expected.

The other function in loop executed in notmuch-test-wait: get-buffer-process
just loops through process list, returning matching process object (or nil
if no such process found) without doing any further processing.

By comparing Emacs 23.1 and 23.2 function wait_reading_process_output ()
(changes in do_display variable usage) it seems that this bug has been
fixed in 23.2.
---
 test/test-lib.el |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/test/test-lib.el b/test/test-lib.el
index 5dd6271..30d6eb7 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -38,7 +38,11 @@
 (defun notmuch-test-wait ()
   "Wait for process completion."
   (while (get-buffer-process (current-buffer))
-(sleep-for 0.1)))
+;; It seems in Emacs 23.1 `accept-process-output' and `sleep-for' do not
+;; run sentinels (bug#2930 (bug-gnu-emacs)). `sit-for' works as documented.
+;; `sleep-for` may already work in Emacs 23.2 as function
+;; wait_reading_process_output() in src/process.c has related change.
+(sit-for 0.1)))

 (defun test-output ( filename)
   "Save current buffer to file FILENAME.  Default FILENAME is OUTPUT."
-- 
1.7.1



Re: [PATCH 1/4] show: indicate length of omitted body content (json)

2012-08-05 Thread Jameson Graef Rollins
On Sun, Aug 05 2012, Peter Wang noval...@gmail.com wrote:
 If a leaf part's body content is omitted, return the content length in
 --format=json output.  This information may be used by the consumer,
 e.g. to decide whether to download a large attachment over a slow link.
 ---
  devel/schemata |5 -
  notmuch-show.c |8 
  2 files changed, 12 insertions(+), 1 deletions(-)

 diff --git a/devel/schemata b/devel/schemata
 index 9cb25f5..3df2764 100644
 --- a/devel/schemata
 +++ b/devel/schemata
 @@ -69,7 +69,10 @@ part = {
  # A leaf part's body content is optional, but may be included if
  # it can be correctly encoded as a string.  Consumers should use
  # this in preference to fetching the part content separately.
 -content?:   string
 +content?:   string,
 +# If a leaf part's body content is not included, the content-length
 +# may be included instead.
 +content-length?: int

Hey, Peter.  Something somewhere, and probably at least here in the
schemata, should mention what the uids are (b? kB? KiB? YiB?)

jamie.


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