Possible bug in gpg signing replies

2012-03-01 Thread James Vasile

When using 'mml-secure-sign-pgpmime to sign one part of an email, valid
sigs get attached to new emails but not to replies.  Instead, when I
reply to a message, the signing directive seems to be inserted as plain
text and is not processed.

Switching to the 'mml-secure-message-sign-pgpmime, which signs the whole
message, appears to work for both replies and new messages.

I'm content to use the form that works, but I thought others might want
to confirm the bug and fix it if it is real.

Regards,
James
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120301/3836db07/attachment.pgp>


[PATCH] NEWS: add entry for `notmuch-show-stash-mlarchive-link{, -and-go}'

2012-03-01 Thread Pieter Praet
---
 NEWS |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/NEWS b/NEWS
index 8fb2f24..a739914 100644
--- a/NEWS
+++ b/NEWS
@@ -80,6 +80,12 @@ Attachment buttons can be used to view or save attachments.
   button 1 saves the attachment but this is customisable (option
   Notmuch Show Part Button Default Action).

+New functions
+
+  `notmuch-show-stash-mlarchive-link{,-and-go}' allow stashing and
+  optionally visiting a URI to the current message at one of a number
+  of Mailing List Archives.
+
 Library changes
 ---

-- 
1.7.8.1



[PATCH 2/2] test: add new test file for mime parsing.

2012-03-01 Thread David Bremner
From: David Bremner 

For now, just tests one message currently causing notmuch to segfault.
---
 test/mime |   67 +
 test/notmuch-test |1 +
 2 files changed, 68 insertions(+), 0 deletions(-)
 create mode 100755 test/mime

diff --git a/test/mime b/test/mime
new file mode 100755
index 000..5b2d77f
--- /dev/null
+++ b/test/mime
@@ -0,0 +1,67 @@
+#!/usr/bin/env bash
+
+test_description="mime parsing"
+. test-lib.sh
+
+add_rfc822_message <
+Envelope-to: bobafett at archangel.wmdcantina.org
+Delivery-date: Wed, 09 Feb 2011 10:06:54 -0400
+Received: from fiero.its.cantina.org ([131.202.1.10])
+   by archangel.wmdcantina.org with esmtps 
(TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
+   (Exim 4.69)
+   (envelope-from )
+   id 1PnAh4-AX-DH
+   for bobafett at archangel.wmdcantina.org; Wed, 09 Feb 2011 10:06:54 
-0400
+Received: from mx3.nbpei-ecn.ca (mx3.nbpei-ecn.ca [198.164.163.196])
+   by fiero.its.cantina.org (8.13.8/8.13.8) with ESMTP id p19E6lst014693
+   for ; Wed, 9 Feb 2011 10:06:47 -0400
+Received: from mx3.nbpei-ecn.ca (localhost.localdomain [127.0.0.1])
+   by localhost (Postfix) with SMTP id EC0C04B8002
+   for ; Wed,  9 Feb 2011 10:06:47 -0400 (AST)
+Received: from cibc.ca (mail4.cibc.ca [199.198.251.34])
+   by mx3.nbpei-ecn.ca (Postfix) with ESMTP id A80824B8003
+   for ; Wed,  9 Feb 2011 10:06:47 -0400 (AST)
+From: "Smith, Bob" 
+To: "'BOBAFETT at CANTINA.ORG'" 
+Disposition-Notification-To: "Smith, Bob" 
+Return-Receipt-To: 
+Date: Wed, 9 Feb 2011 09:06:43 -0500
+Subject: 
+Thread-Index: AcvIYpRcEJX82QtpQSacs5hsY+i4SQ==
+Message-ID: <5BB75198A4300643A295D4678B10F0503BDDF7CEB1 at 
CBMCC-X7-MBX09.ad.fbi.gov>
+Accept-Language: en-US
+Content-Language: en-US
+X-MS-Has-Attach: 
+X-MS-TNEF-Correlator: 
+acceptlanguage: en-US
+Content-Type: multipart/alternative;
+   boundary="_000_5BB75198A4300643A295D4678B10F0503BDDF7CEB1CBMCCX7MBX09a_"
+MIME-Version: 1.0
+X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 
2011.2.9.135719
+X-PerlMx-Spam: Gauge=I, Probability=9%, Report='
+ BLANK_SUBJECT 0.1, HTML_NO_HTTP 0.1, SUPERLONG_LINE 0.05, 
BODYTEXTH_SIZE_1_LESS 0, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_4000_4999 0, 
BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DATE_TZ_NA 0, __C230066_P5 0, 
__CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __CTYPE_MULTIPART_ALT 0, 
__FRAUD_CONTACT_NUM 0, __HAS_HTML 0, __HAS_MSGID 0, __MIME_HTML 0, 
__MIME_VERSION 0, __PHISH_FROM 0, __PHISH_FROM1 0, __PHISH_FROM_C 0, 
__SANE_MSGID 0, __STOCK_PHRASE_8 0, __TAG_EXISTS_HTML 0, __TO_MALFORMED_2 0, 
__TO_NO_NAME 0'
+X-Sender-Verified: bob.smith at fbi.gov
+
+--_000_5BB75198A4300643A295D4678B10F0503BDDF7CEB1CBMCCX7MBX09a_
+Content-Type: text/plain; charset="iso-8859-1"
+Content-Transfer-Encoding: quoted-printable
+
+quoted printable stuff.
+
+
+--_000_5BB75198A4300643A295D4678B10F0503BDDF7CEB1CBMCCX7MBX09a_
+Content-Type: text/html; charset="iso-8859-1"
+Content-Transfer-Encoding: quoted-printable
+
+
+some other stuff
+
+
+--_000_5BB75198A4300643A295D4678B10F0503BDDF7CEB1CBMCCX7MBX09a_--
+
+
+EOF
+test_expect_success 'output message as json' "notmuch show --format=json 
id:5BB75198A4300643A295D4678B10F0503BDDF7CEB1 at CBMCC-X7-MBX09.ad.fbi.gov > 
/dev/null"
+test_done
diff --git a/test/notmuch-test b/test/notmuch-test
index f03b594..b572f1c 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -56,6 +56,7 @@ TESTS="
   emacs-address-cleaning
   emacs-hello
   emacs-show
+  mime
 "
 TESTS=${NOTMUCH_TESTS:=$TESTS}

-- 
1.7.9



[PATCH 1/2] test: utility function to add a pre-generated message to the database.

2012-03-01 Thread David Bremner
From: David Bremner 

For various "nasty" messages, it is easier to ship a message rather
than try to generate a message which causes a failure.
---
 test/test-lib.sh |   15 +++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index 2781506..17d0e48 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -376,6 +376,21 @@ ${template[body]}
 EOF
 }

+# Add an existing message to the notmuch database.
+#
+# expects a message on stdin.
+#
+# uses the variable gen_msg_cnt from generate_message.
+
+add_rfc822_message ()
+{
+gen_msg_cnt=$((gen_msg_cnt + 1))
+gen_msg_name="msg-$(printf "%03d" $gen_msg_cnt)"
+gen_msg_filename="${MAIL_DIR}/$gen_msg_name"
+cat >$gen_msg_filename
+notmuch new > /dev/null
+}
+
 # Generate a new message and add it to the database.
 #
 # All of the arguments and return values supported by generate_message
-- 
1.7.9



No subject

2012-03-01 Thread David Bremner
Probably both of these patches could use some polishing; Austin asked
for a test to help debug the crash I found today.



[Patch v7 13/13] emacs: notmuch.el ignore excluded matches

2012-03-01 Thread Mark Walters
This is a small change to make notmuch.el ignore excluded matches.  In
the future it could do something better like add a button for
rerunning the search with the excludes (particularly if nothing
matches with the excludes) or having them invisible and allowing the
visibility to be toggled.
---
 emacs/notmuch.el |   22 --
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f851c6f..99e0c93 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -872,16 +872,18 @@ non-authors is found, assume that all of the authors 
match."
  (goto-char (point-max))
  (if (/= (match-beginning 1) line)
  (insert (concat "Error: Unexpected output from 
notmuch search:\n" (substring string line (match-beginning 1)) "\n")))
- (let ((beg (point)))
-   (notmuch-search-show-result date count authors
-   (notmuch-prettify-subject 
subject) tags)
-   (notmuch-search-color-line beg (point) tag-list)
-   (put-text-property beg (point) 
'notmuch-search-thread-id thread-id)
-   (put-text-property beg (point) 'notmuch-search-authors 
authors)
-   (put-text-property beg (point) 'notmuch-search-subject 
subject)
-   (when (string= thread-id notmuch-search-target-thread)
- (set 'found-target beg)
- (set 'notmuch-search-target-thread "found")))
+ ;; We currently just throw away excluded matches.
+ (unless (eq (aref count 1) ?0)
+   (let ((beg (point)))
+ (notmuch-search-show-result date count authors
+ (notmuch-prettify-subject 
subject) tags)
+ (notmuch-search-color-line beg (point) tag-list)
+ (put-text-property beg (point) 
'notmuch-search-thread-id thread-id)
+ (put-text-property beg (point) 
'notmuch-search-authors authors)
+ (put-text-property beg (point) 
'notmuch-search-subject subject)
+ (when (string= thread-id notmuch-search-target-thread)
+   (set 'found-target beg)
+   (set 'notmuch-search-target-thread "found"
  (set 'line (match-end 0)))
  (set 'more nil)
  (while (and (< line (length string)) (= (elt string line) 
?\n))
-- 
1.7.2.3



[Patch v7 12/13] emacs: show: recognize the exclude flag.

2012-03-01 Thread Mark Walters
Show mode will recognize the exclude flag by not opening excluding
messages by default, and will start at the first matching non-excluded
message. If there are no matching non-excluded messages it will go to
the first matching (necessarily excluded) message.
---
 emacs/notmuch-show.el |   36 +++-
 1 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 7c4c0be..4a60631 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -981,7 +981,8 @@ current buffer, if possible."

 ;; Message visibility depends on whether it matched the search
 ;; criteria.
-(notmuch-show-message-visible msg (plist-get msg :match
+(notmuch-show-message-visible msg (and (plist-get msg :match)
+  (not (plist-get msg :excluded))

 (defun notmuch-show-toggle-process-crypto ()
   "Toggle the processing of cryptographic MIME parts."
@@ -1081,11 +1082,7 @@ function is used."
  notmuch-show-parent-buffer parent-buffer
  notmuch-show-query-context query-context)
 (notmuch-show-build-buffer)
-
-;; Move to the first open message and mark it read
-(if (notmuch-show-message-visible-p)
-   (notmuch-show-mark-read)
-  (notmuch-show-next-open-message
+(notmuch-show-goto-first-wanted-message)))

 (defun notmuch-show-build-buffer ()
   (let ((inhibit-read-only t))
@@ -1167,9 +1164,7 @@ reset based on the original query."
(notmuch-show-apply-state state)
   ;; We're resetting state, so navigate to the first open message
   ;; and mark it read, just like opening a new show buffer.
-  (if (notmuch-show-message-visible-p)
- (notmuch-show-mark-read)
-   (notmuch-show-next-open-message)
+  (notmuch-show-goto-first-wanted-message

 (defvar notmuch-show-stash-map
   (let ((map (make-sparse-keymap)))
@@ -1601,6 +1596,29 @@ to show, nil otherwise."
(goto-char (point-max
 r))

+(defun notmuch-show-next-matching-message ()
+  "Show the next matching message."
+  (interactive)
+  (let (r)
+(while (and (setq r (notmuch-show-goto-message-next))
+   (not (notmuch-show-get-prop :match
+(if r
+   (progn
+ (notmuch-show-mark-read)
+ (notmuch-show-message-adjust))
+  (goto-char (point-max)
+
+(defun notmuch-show-goto-first-wanted-message ()
+  "Move to the first open message and mark it read"
+  (goto-char (point-min))
+  (if (notmuch-show-message-visible-p)
+  (notmuch-show-mark-read)
+(notmuch-show-next-open-message))
+  (when (eobp)
+(goto-char (point-min))
+(unless (notmuch-show-get-prop :match)
+  (notmuch-show-next-matching-message
+
 (defun notmuch-show-previous-open-message ()
   "Show the previous open message."
   (interactive)
-- 
1.7.2.3



[Patch v7 11/13] cli: omit excluded messages in results where appropriate.

2012-03-01 Thread Mark Walters
In all cases of notmuch count/search/show where the results returned
cannot reflect the exclude flag return just the matched not-excluded
results. If the caller wishes to have all the matched results (i.e.,
including the excluded ones) they should call with the
--no-exclude option.

The relevant cases are
count: both threads and messages
search: all cases except the summary view
show: mbox format
---
 notmuch-count.c  |2 ++
 notmuch-search.c |9 +
 notmuch-show.c   |6 ++
 3 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/notmuch-count.c b/notmuch-count.c
index 5364507..46b76ae 100644
--- a/notmuch-count.c
+++ b/notmuch-count.c
@@ -88,6 +88,8 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
 }

+notmuch_query_set_omit_excluded_messages (query, TRUE);
+
 switch (output) {
 case OUTPUT_MESSAGES:
printf ("%u\n", notmuch_query_count_messages (query));
diff --git a/notmuch-search.c b/notmuch-search.c
index 6d6c0e6..f6061e4 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -210,6 +210,9 @@ do_search_threads (const search_format_t *format,
 int first_thread = 1;
 int i;

+if (output == OUTPUT_THREADS)
+   notmuch_query_set_omit_excluded_messages (query, TRUE);
+
 if (offset < 0) {
offset += notmuch_query_count_threads (query);
if (offset < 0)
@@ -300,6 +303,8 @@ do_search_messages (const search_format_t *format,
 int first_message = 1;
 int i;

+notmuch_query_set_omit_excluded_messages (query, TRUE);
+
 if (offset < 0) {
offset += notmuch_query_count_messages (query);
if (offset < 0)
@@ -371,6 +376,10 @@ do_search_tags (notmuch_database_t *notmuch,
 const char *tag;
 int first_tag = 1;

+notmuch_query_set_omit_excluded_messages (query, TRUE);
+/* should the following only special case if no excluded terms
+ * specified? */
+
 /* Special-case query of "*" for better performance. */
 if (strcmp (notmuch_query_get_query_string (query), "*") == 0) {
tags = notmuch_database_get_all_tags (notmuch);
diff --git a/notmuch-show.c b/notmuch-show.c
index 8c0b925..05d51b2 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -1030,6 +1030,7 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
fprintf (stderr, "Error: specifying parts is incompatible with mbox 
output format.\n");
return 1;
}
+
format = &format_mbox;
break;
 case NOTMUCH_FORMAT_RAW:
@@ -1087,6 +1088,11 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
return 1;
 }

+/* if format=mbox then we can not output excluded messages as
+ * there is no way to make the exclude flag available */
+if (format_sel == NOTMUCH_FORMAT_MBOX)
+   notmuch_query_set_omit_excluded_messages (query, TRUE);
+
 /* If a single message is requested we do not use search_excludes. */
 if (params.part >= 0)
ret = do_show_single (ctx, query, format, ¶ms);
-- 
1.7.2.3



[Patch v7 10/13] man: update manpage for notmuch-show --no-exclude option

2012-03-01 Thread Mark Walters
---
 man/man1/notmuch-show.1 |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/man/man1/notmuch-show.1 b/man/man1/notmuch-show.1
index 4c5db94..d75d971 100644
--- a/man/man1/notmuch-show.1
+++ b/man/man1/notmuch-show.1
@@ -128,6 +128,13 @@ multipart/encrypted part will be replaced by the decrypted
 content.
 .RE

+.RS 4
+.TP 4
+.B \-\-no-exclude
+
+Do not exclude the messages matching search.exclude_tags in the config file.
+.RE
+
 A common use of
 .B notmuch show
 is to display a single thread of email messages. For this, use a
-- 
1.7.2.3



[Patch v7 09/13] test: update tests to reflect the exclude flag

2012-03-01 Thread Mark Walters
notmuch show outputs the exclude flag so many tests using notmuch
show failed. This commit adds "excluded:0" or "excluded: false" to
the expected outputs. After this commit there should be no failing
tests.
---
 test/crypto|9 -
 test/encoding  |2 +-
 test/json  |6 +++---
 test/maildir-sync  |1 +
 test/multipart |6 +++---
 test/thread-naming |   16 
 6 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/test/crypto b/test/crypto
index 7e774c8..4de4d2b 100755
--- a/test/crypto
+++ b/test/crypto
@@ -43,6 +43,7 @@ output=$(notmuch show --format=json --verify subject:"test 
signed message 001" \
 | sed -e 's|"created": [1234567890]*|"created": 946728000|')
 expected='[[[{"id": "X",
  "match": true,
+ "excluded": false,
  "filename": "Y",
  "timestamp": 946728000,
  "date_relative": "2000-01-01",
@@ -76,6 +77,7 @@ output=$(notmuch show --format=json --verify subject:"test 
signed message 001" \
 | sed -e 's|"created": [1234567890]*|"created": 946728000|')
 expected='[[[{"id": "X",
  "match": true,
+ "excluded": false,
  "filename": "Y",
  "timestamp": 946728000,
  "date_relative": "2000-01-01",
@@ -111,6 +113,7 @@ output=$(notmuch show --format=json --verify subject:"test 
signed message 001" \
 | sed -e 's|"created": [1234567890]*|"created": 946728000|')
 expected='[[[{"id": "X",
  "match": true,
+ "excluded": false,
  "filename": "Y",
  "timestamp": 946728000,
  "date_relative": "2000-01-01",
@@ -150,7 +153,7 @@ test_begin_subtest "decryption, --format=text"
 output=$(notmuch show --format=text --decrypt subject:"test encrypted message 
001" \
 | notmuch_show_sanitize_all \
 | sed -e 's|"created": [1234567890]*|"created": 946728000|')
-expected='message{ id:X depth:0 match:1 filename:X
+expected='message{ id:X depth:0 match:1 excluded:0 filename:X
 header{
 Notmuch Test Suite  (2000-01-01) (encrypted 
inbox)
 Subject: test encrypted message 001
@@ -184,6 +187,7 @@ output=$(notmuch show --format=json --decrypt subject:"test 
encrypted message 00
 | sed -e 's|"created": [1234567890]*|"created": 946728000|')
 expected='[[[{"id": "X",
  "match": true,
+ "excluded": false,
  "filename": "Y",
  "timestamp": 946728000,
  "date_relative": "2000-01-01",
@@ -238,6 +242,7 @@ output=$(notmuch show --format=json --decrypt subject:"test 
encrypted message 00
 | sed -e 's|"created": [1234567890]*|"created": 946728000|')
 expected='[[[{"id": "X",
  "match": true,
+ "excluded": false,
  "filename": "Y",
  "timestamp": 946728000,
  "date_relative": "2000-01-01",
@@ -272,6 +277,7 @@ output=$(notmuch show --format=json --decrypt subject:"test 
encrypted message 00
 | sed -e 's|"created": [1234567890]*|"created": 946728000|')
 expected='[[[{"id": "X",
  "match": true,
+ "excluded": false,
  "filename": "Y",
  "timestamp": 946728000,
  "date_relative": "2000-01-01",
@@ -326,6 +332,7 @@ output=$(notmuch show --format=json --verify subject:"test 
signed message 001" \
 | sed -e 's|"created": [1234567890]*|"created": 946728000|')
 expected='[[[{"id": "X",
  "match": true,
+ "excluded": false,
  "filename": "Y",
  "timestamp": 946728000,
  "date_relative": "2000-01-01",
diff --git a/test/encoding b/test/encoding
index f0d073c..98abf77 100755
--- a/test/encoding
+++ b/test/encoding
@@ -6,7 +6,7 @@ test_begin_subtest "Message with text of unknown charset"
 add_message '[content-type]="text/plain; charset=unknown-8bit"' \
"[body]=irrelevant"
 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 filename:/XXX/mail/msg-001
+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
diff --git a/test/json b/test/json
index 1bdffd2..6439788 100755
--- a/test/json
+++ b/test/json
@@ -5,7 +5,7 @@ test_description="--format=json output"
 test_begin_subtest "Show message: json"
 add_message "[subject]=\"json-show-subject\"" "[date]=\"Sat, 01 Jan 2000 
12:00:00 -\"" "[body]=\"json-show-message\""
 output=$(notmuch show --format=json "json-show-message")
-test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, 
\"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, 
\"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], 
\"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Notmuch Test 
Suite \", \"To\": \"Notmuch Test Suite 
\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 
+\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": 
\"json-show-message\n\"}]}, ["
+test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, 
\"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 
94672

[Patch v7 08/13] cli: Make notmuch-show respect excludes.

2012-03-01 Thread Mark Walters
This adds the excludes to notmuch-show.c. We do not exclude when only
a single message (or part) is requested. notmuch-show will output the
exclude information when either text or json format is requested. As
this changes the output from notmuch-show it breaks many tests (in a
trivial and expected fashion).
---
 notmuch-show.c |   25 +
 1 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index 6a171a4..8c0b925 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -143,9 +143,10 @@ format_message_json (const void *ctx, notmuch_message_t 
*message)
 date = notmuch_message_get_date (message);
 relative_date = notmuch_time_relative_date (ctx, date);

-printf ("\"id\": %s, \"match\": %s, \"filename\": %s, \"timestamp\": %ld, 
\"date_relative\": \"%s\", \"tags\": [",
+printf ("\"id\": %s, \"match\": %s, \"excluded\": %s, \"filename\": %s, 
\"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [",
json_quote_str (ctx_quote, notmuch_message_get_message_id 
(message)),
notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? 
"true" : "false",
+   notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? 
"true" : "false",
json_quote_str (ctx_quote, notmuch_message_get_filename (message)),
date, relative_date);

@@ -579,11 +580,12 @@ format_part_text (const void *ctx, mime_node_t *node,
notmuch_message_t *message = node->envelope_file;

part_type = "message";
-   printf ("\f%s{ id:%s depth:%d match:%d filename:%s\n",
+   printf ("\f%s{ id:%s depth:%d match:%d excluded:%d filename:%s\n",
part_type,
notmuch_message_get_message_id (message),
indent,
-   notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH),
+   notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) 
? 1 : 0,
+   notmuch_message_get_flag (message, 
NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? 1 : 0,
notmuch_message_get_filename (message));
 } else {
GMimeContentDisposition *disposition = 
g_mime_object_get_content_disposition (meta);
@@ -984,6 +986,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused 
(char *argv[]))
 notmuch_show_params_t params = { .part = -1 };
 int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
 notmuch_bool_t verify = FALSE;
+notmuch_bool_t no_exclude = FALSE;

 notmuch_opt_desc_t options[] = {
{ NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',
@@ -996,6 +999,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused 
(char *argv[]))
{ NOTMUCH_OPT_BOOLEAN, ¶ms.entire_thread, "entire-thread", 't', 0 },
{ NOTMUCH_OPT_BOOLEAN, ¶ms.decrypt, "decrypt", 'd', 0 },
{ NOTMUCH_OPT_BOOLEAN, &verify, "verify", 'v', 0 },
+   { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'n', 0 },
{ 0, 0, 0, 0, 0 }
 };

@@ -1083,10 +1087,23 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
return 1;
 }

+/* If a single message is requested we do not use search_excludes. */
 if (params.part >= 0)
ret = do_show_single (ctx, query, format, ¶ms);
-else
+else {
+   if (!no_exclude) {
+   const char **search_exclude_tags;
+   size_t search_exclude_tags_length;
+   unsigned int i;
+
+   search_exclude_tags = notmuch_config_get_search_exclude_tags
+   (config, &search_exclude_tags_length);
+   for (i = 0; i < search_exclude_tags_length; i++)
+   notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
+   }
ret = do_show (ctx, query, format, ¶ms);
+}
+

 notmuch_query_destroy (query);
 notmuch_database_close (notmuch);
-- 
1.7.2.3



[Patch v7 07/13] test: update search test to reflect exclude flag

2012-03-01 Thread Mark Walters
notmuch-search.c now returns all matching threads even if it the
match is a search.tag_excluded message (but with a mark indicating
this). Update the test to reflect this.
---
 test/search |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/test/search b/test/search
index 3da5d17..081f60c 100755
--- a/test/search
+++ b/test/search
@@ -136,7 +136,8 @@ generate_message '[subject]="Deleted"'
 notmuch new > /dev/null
 notmuch tag +deleted id:$gen_msg_id
 output=$(notmuch search subject:deleted | notmuch_search_sanitize)
-test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; 
Not deleted (inbox unread)"
+test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; 
Not deleted (inbox unread)
+thread:XXX   2001-01-05 [0/1] Notmuch Test Suite; Deleted (deleted inbox 
unread)"

 test_begin_subtest "Exclude \"deleted\" messages from search, overridden"
 output=$(notmuch search subject:deleted and tag:deleted | 
notmuch_search_sanitize)
-- 
1.7.2.3



[Patch v7 06/13] lib: Add the exclude flag to notmuch_query_search_threads

2012-03-01 Thread Mark Walters
Add the NOTMUCH_MESSAGE_FLAG_EXCLUDED flag to
notmuch_query_search_threads. Implemented by inspecting the tags
directly in _notmuch_thread_create/_thread_add_message rather than as
a Xapian query for speed reasons.

Note notmuch_thread_get_matched_messages now returns the number of
non-excluded matching messages. This API is not totally desirable but
fixing it means breaking binary compatibility so we delay that.
---
 lib/notmuch-private.h |7 +--
 lib/notmuch.h |6 --
 lib/query.cc  |1 +
 lib/thread.cc |   18 +++---
 4 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index e791bb0..ea836f7 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -148,6 +148,8 @@ typedef enum _notmuch_private_status {

 typedef struct _notmuch_doc_id_set notmuch_doc_id_set_t;

+typedef struct _notmuch_string_list notmuch_string_list_t;
+
 /* database.cc */

 /* Lookup a prefix value by name.
@@ -216,6 +218,7 @@ _notmuch_thread_create (void *ctx,
notmuch_database_t *notmuch,
unsigned int seed_doc_id,
notmuch_doc_id_set_t *match_set,
+   notmuch_string_list_t *excluded_terms,
notmuch_sort_t sort);

 /* message.cc */
@@ -459,11 +462,11 @@ typedef struct _notmuch_string_node {
 struct _notmuch_string_node *next;
 } notmuch_string_node_t;

-typedef struct visible _notmuch_string_list {
+struct visible _notmuch_string_list {
 int length;
 notmuch_string_node_t *head;
 notmuch_string_node_t **tail;
-} notmuch_string_list_t;
+};

 notmuch_string_list_t *
 _notmuch_string_list_create (const void *ctx);
diff --git a/lib/notmuch.h b/lib/notmuch.h
index f75afae..babd208 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -672,8 +672,10 @@ notmuch_thread_get_toplevel_messages (notmuch_thread_t 
*thread);
 /* Get the number of messages in 'thread' that matched the search.
  *
  * This count includes only the messages in this thread that were
- * matched by the search from which the thread was created. Contrast
- * with notmuch_thread_get_total_messages() .
+ * matched by the search from which the thread was created and were
+ * not excluded by any exclude tags passed in with the query (see
+ * notmuch_query_add_tag_exclude). Contrast with
+ * notmuch_thread_get_total_messages() .
  */
 int
 notmuch_thread_get_matched_messages (notmuch_thread_t *thread);
diff --git a/lib/query.cc b/lib/query.cc
index ef2a11f..ab18fbc 100644
--- a/lib/query.cc
+++ b/lib/query.cc
@@ -475,6 +475,7 @@ notmuch_threads_get (notmuch_threads_t *threads)
   threads->query->notmuch,
   doc_id,
   &threads->match_set,
+  threads->query->exclude_terms,
   threads->query->sort);
 }

diff --git a/lib/thread.cc b/lib/thread.cc
index 0435ee6..e976d64 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -214,7 +214,8 @@ _thread_cleanup_author (notmuch_thread_t *thread,
  */
 static void
 _thread_add_message (notmuch_thread_t *thread,
-notmuch_message_t *message)
+notmuch_message_t *message,
+notmuch_string_list_t *exclude_terms)
 {
 notmuch_tags_t *tags;
 const char *tag;
@@ -262,6 +263,15 @@ _thread_add_message (notmuch_thread_t *thread,
 notmuch_tags_move_to_next (tags))
 {
tag = notmuch_tags_get (tags);
+   /* Mark excluded messages. */
+   for (notmuch_string_node_t *term = exclude_terms->head; term;
+term = term->next) {
+   /* We ignore initial 'K'. */
+   if (strcmp(tag, (term->string + 1)) == 0) {
+   notmuch_message_set_flag (message, 
NOTMUCH_MESSAGE_FLAG_EXCLUDED, TRUE);
+   break;
+   }
+   }
g_hash_table_insert (thread->tags, xstrdup (tag), NULL);
 }
 }
@@ -321,7 +331,8 @@ _thread_add_matched_message (notmuch_thread_t *thread,
_thread_set_subject_from_message (thread, message);
 }

-thread->matched_messages++;
+if (!notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED))
+   thread->matched_messages++;

 if (g_hash_table_lookup_extended (thread->message_hash,
notmuch_message_get_message_id (message), NULL,
@@ -392,6 +403,7 @@ _notmuch_thread_create (void *ctx,
notmuch_database_t *notmuch,
unsigned int seed_doc_id,
notmuch_doc_id_set_t *match_set,
+   notmuch_string_list_t *exclude_terms,
notmuch_sort_t sort)
 {
 notmuch_thread_t *thread;
@@ -467,7 +479,7 @@ _notmuch_thread_create (void *ctx,
if (doc_id == seed_doc_id)
message = seed_message;

-   _thread_add_message (thread, me

[Patch v7 05/13] lib: Make notmuch_query_search_messages set the exclude flag

2012-03-01 Thread Mark Walters
Add a flag NOTMUCH_MESSAGE_FLAG_EXCLUDED which is set by
notmuch_query_search_messages for excluded messages. Also add an
option omit_excluded_messages to the search that we do not want the
excludes at all.

This exclude flag will be added to notmuch_query_search threads in the
next patch.
---
 lib/notmuch-private.h |1 +
 lib/notmuch.h |   10 +++-
 lib/query.cc  |   59 -
 3 files changed, 63 insertions(+), 7 deletions(-)

diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index 7bf153e..e791bb0 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -401,6 +401,7 @@ typedef struct _notmuch_message_list {
  */
 struct visible _notmuch_messages {
 notmuch_bool_t is_of_list_type;
+notmuch_doc_id_set_t *excluded_doc_ids;
 notmuch_message_node_t *iterator;
 };

diff --git a/lib/notmuch.h b/lib/notmuch.h
index 7929fe7..f75afae 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -449,6 +449,13 @@ typedef enum {
 const char *
 notmuch_query_get_query_string (notmuch_query_t *query);

+/* Specify whether to results should omit the excluded results rather
+ * than just marking them excluded. This is useful for passing a
+ * notmuch_messages_t not containing the excluded messages to other
+ * functions. */
+void
+notmuch_query_set_omit_excluded_messages (notmuch_query_t *query, 
notmuch_bool_t omit);
+
 /* Specify the sorting desired for this query. */
 void
 notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort);
@@ -895,7 +902,8 @@ notmuch_message_get_filenames (notmuch_message_t *message);

 /* Message flags */
 typedef enum _notmuch_message_flag {
-NOTMUCH_MESSAGE_FLAG_MATCH
+NOTMUCH_MESSAGE_FLAG_MATCH,
+NOTMUCH_MESSAGE_FLAG_EXCLUDED
 } notmuch_message_flag_t;

 /* Get a value of a flag for the email corresponding to 'message'. */
diff --git a/lib/query.cc b/lib/query.cc
index c25b301..ef2a11f 100644
--- a/lib/query.cc
+++ b/lib/query.cc
@@ -28,6 +28,7 @@ struct _notmuch_query {
 const char *query_string;
 notmuch_sort_t sort;
 notmuch_string_list_t *exclude_terms;
+notmuch_bool_t omit_excluded_messages;
 };

 typedef struct _notmuch_mset_messages {
@@ -57,6 +58,12 @@ struct visible _notmuch_threads {
 notmuch_doc_id_set_t match_set;
 };

+/* We need this in the message functions so forward declare. */
+static notmuch_bool_t
+_notmuch_doc_id_set_init (void *ctx,
+ notmuch_doc_id_set_t *doc_ids,
+ GArray *arr);
+
 notmuch_query_t *
 notmuch_query_create (notmuch_database_t *notmuch,
  const char *query_string)
@@ -79,6 +86,8 @@ notmuch_query_create (notmuch_database_t *notmuch,

 query->exclude_terms = _notmuch_string_list_create (query);

+query->omit_excluded_messages = FALSE;
+
 return query;
 }

@@ -89,6 +98,12 @@ notmuch_query_get_query_string (notmuch_query_t *query)
 }

 void
+notmuch_query_set_omit_excluded_messages (notmuch_query_t *query, 
notmuch_bool_t omit)
+{
+query->omit_excluded_messages = omit;
+}
+
+void
 notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort)
 {
 query->sort = sort;
@@ -124,8 +139,9 @@ _notmuch_messages_destructor (notmuch_mset_messages_t 
*messages)

 /* Return a query that matches messages with the excluded tags
  * registered with query.  Any tags that explicitly appear in xquery
- * will not be excluded. The caller of this function has to combine
- * the returned query appropriately.*/
+ * will not be excluded, and will be removed from the list of exclude
+ * tags.  The caller of this function has to combine the returned
+ * query appropriately.*/
 static Xapian::Query
 _notmuch_exclude_tags (notmuch_query_t *query, Xapian::Query xquery)
 {
@@ -142,6 +158,8 @@ _notmuch_exclude_tags (notmuch_query_t *query, 
Xapian::Query xquery)
if (it == end)
exclude_query = Xapian::Query (Xapian::Query::OP_OR,
exclude_query, Xapian::Query 
(term->string));
+   else
+   term->string = talloc_strdup (query, "");
 }
 return exclude_query;
 }
@@ -173,6 +191,7 @@ notmuch_query_search_messages (notmuch_query_t *query)
   "mail"));
Xapian::Query string_query, final_query, exclude_query;
Xapian::MSet mset;
+   Xapian::MSetIterator iterator;
unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN |
  Xapian::QueryParser::FLAG_PHRASE |
  Xapian::QueryParser::FLAG_LOVEHATE |
@@ -190,11 +209,35 @@ notmuch_query_search_messages (notmuch_query_t *query)
final_query = Xapian::Query (Xapian::Query::OP_AND,
 mail_query, string_query);
}
+   messages->base.excluded_doc_ids = NULL;
+
+   if (query->exclude_terms) {
+   exclude_query = _notmuch_exclude_tags (query, final_query);
+

[Patch v7 04/13] lib: Rearrange the exclude code in query.cc

2012-03-01 Thread Mark Walters
Slightly refactor the exclude code to give the callers access to the
exclude query itself. There should be no functional change.
---
 lib/query.cc |   29 +++--
 1 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/lib/query.cc b/lib/query.cc
index 0b36602..c25b301 100644
--- a/lib/query.cc
+++ b/lib/query.cc
@@ -122,12 +122,15 @@ _notmuch_messages_destructor (notmuch_mset_messages_t 
*messages)
 return 0;
 }

-/* Return a query that does not match messages with the excluded tags
- * registered with the query.  Any tags that explicitly appear in
- * xquery will not be excluded. */
+/* Return a query that matches messages with the excluded tags
+ * registered with query.  Any tags that explicitly appear in xquery
+ * will not be excluded. The caller of this function has to combine
+ * the returned query appropriately.*/
 static Xapian::Query
 _notmuch_exclude_tags (notmuch_query_t *query, Xapian::Query xquery)
 {
+Xapian::Query exclude_query = Xapian::Query::MatchNothing;
+
 for (notmuch_string_node_t *term = query->exclude_terms->head; term;
 term = term->next) {
Xapian::TermIterator it = xquery.get_terms_begin ();
@@ -137,10 +140,10 @@ _notmuch_exclude_tags (notmuch_query_t *query, 
Xapian::Query xquery)
break;
}
if (it == end)
-   xquery = Xapian::Query (Xapian::Query::OP_AND_NOT,
-   xquery, Xapian::Query (term->string));
+   exclude_query = Xapian::Query (Xapian::Query::OP_OR,
+   exclude_query, Xapian::Query 
(term->string));
 }
-return xquery;
+return exclude_query;
 }

 notmuch_messages_t *
@@ -168,7 +171,7 @@ notmuch_query_search_messages (notmuch_query_t *query)
Xapian::Query mail_query (talloc_asprintf (query, "%s%s",
   _find_prefix ("type"),
   "mail"));
-   Xapian::Query string_query, final_query;
+   Xapian::Query string_query, final_query, exclude_query;
Xapian::MSet mset;
unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN |
  Xapian::QueryParser::FLAG_PHRASE |
@@ -188,7 +191,10 @@ notmuch_query_search_messages (notmuch_query_t *query)
 mail_query, string_query);
}

-   final_query = _notmuch_exclude_tags (query, final_query);
+   exclude_query = _notmuch_exclude_tags (query, final_query);
+
+   final_query = Xapian::Query (Xapian::Query::OP_AND_NOT,
+final_query, exclude_query);

enquire.set_weighting_scheme (Xapian::BoolWeight());

@@ -449,7 +455,7 @@ notmuch_query_count_messages (notmuch_query_t *query)
Xapian::Query mail_query (talloc_asprintf (query, "%s%s",
   _find_prefix ("type"),
   "mail"));
-   Xapian::Query string_query, final_query;
+   Xapian::Query string_query, final_query, exclude_query;
Xapian::MSet mset;
unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN |
  Xapian::QueryParser::FLAG_PHRASE |
@@ -469,7 +475,10 @@ notmuch_query_count_messages (notmuch_query_t *query)
 mail_query, string_query);
}

-   final_query = _notmuch_exclude_tags (query, final_query);
+   exclude_query = _notmuch_exclude_tags (query, final_query);
+
+   final_query = Xapian::Query (Xapian::Query::OP_AND_NOT,
+final_query, exclude_query);

enquire.set_weighting_scheme(Xapian::BoolWeight());
enquire.set_docid_order(Xapian::Enquire::ASCENDING);
-- 
1.7.2.3



[Patch v7 03/13] test: add tests for new cli --no-exclude option

2012-03-01 Thread Mark Walters
The tests test the new --no-exclude option to search and count.
There were no existing tests for the exclude behaviour for count so
added these too.
---
 test/count  |   21 +
 test/search |5 +
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/test/count b/test/count
index 300b171..976fff1 100755
--- a/test/count
+++ b/test/count
@@ -37,4 +37,25 @@ test_expect_equal \
 "0" \
 "`notmuch count --output=threads ${SEARCH}`"

+test_begin_subtest "count excluding \"deleted\" messages"
+notmuch config set search.exclude_tags = deleted
+generate_message '[subject]="Not deleted"'
+generate_message '[subject]="Another not deleted"'
+generate_message '[subject]="Deleted"'
+notmuch new > /dev/null
+notmuch tag +deleted id:$gen_msg_id
+test_expect_equal \
+"2" \
+"`notmuch count subject:deleted`"
+
+test_begin_subtest "count \"deleted\" messages, exclude overridden"
+test_expect_equal \
+"1" \
+"`notmuch count subject:deleted and tag:deleted`"
+
+test_begin_subtest "count \"deleted\" messages, with --no-exclude"
+test_expect_equal \
+"3" \
+"`notmuch count --no-exclude subject:deleted`"
+
 test_done
diff --git a/test/search b/test/search
index 414be35..3da5d17 100755
--- a/test/search
+++ b/test/search
@@ -148,6 +148,11 @@ output=$(notmuch search subject:deleted | 
notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; 
Not deleted (inbox unread)
 thread:XXX   2001-01-05 [1/2] Notmuch Test Suite; Not deleted reply (deleted 
inbox unread)"

+test_begin_subtest "Don't exclude \"deleted\" messages when --no-exclude 
specified"
+output=$(notmuch search --no-exclude subject:deleted | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; 
Not deleted (inbox unread)
+thread:XXX   2001-01-05 [2/2] Notmuch Test Suite; Deleted (deleted inbox 
unread)"
+
 test_begin_subtest "Don't exclude \"deleted\" messages from search if not 
configured"
 notmuch config set search.exclude_tags
 output=$(notmuch search subject:deleted | notmuch_search_sanitize)
-- 
1.7.2.3



[Patch v7 02/13] cli: Add --no-exclude to the man pages for search and count

2012-03-01 Thread Mark Walters
---
 man/man1/notmuch-count.1  |7 +++
 man/man1/notmuch-search.1 |7 +++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/man/man1/notmuch-count.1 b/man/man1/notmuch-count.1
index 0d0ab5d..805a8ae 100644
--- a/man/man1/notmuch-count.1
+++ b/man/man1/notmuch-count.1
@@ -38,6 +38,13 @@ Output the number of matching messages. This is the default.
 Output the number of matching threads.
 .RE
 .RE
+
+.RS 4
+.TP 4
+.BR \-\-no\-exclude
+
+Do not exclude the messages matching search.exclude_tags in the config file.
+.RE
 .RE
 .RE

diff --git a/man/man1/notmuch-search.1 b/man/man1/notmuch-search.1
index 19d85df..8426aa3 100644
--- a/man/man1/notmuch-search.1
+++ b/man/man1/notmuch-search.1
@@ -112,6 +112,13 @@ result from the end.
 Limit the number of displayed results to N.
 .RE

+.RS 4
+.TP 4
+.BR \-\-no\-exclude
+
+Do not exclude the messages matching search.exclude_tags in the config file.
+.RE
+
 .SH SEE ALSO

 \fBnotmuch\fR(1), \fBnotmuch-config\fR(1), \fBnotmuch-count\fR(1),
-- 
1.7.2.3



[Patch v7 01/13] cli: add --no-exclude option to count and search.

2012-03-01 Thread Mark Walters
This option turns off the exclusion so all matching messages are
returned. We do not need to add this to notmuch-show as that does not
(yet) exclude.
---
 notmuch-count.c  |   17 +++--
 notmuch-search.c |   17 +++--
 2 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/notmuch-count.c b/notmuch-count.c
index 63459fb..5364507 100644
--- a/notmuch-count.c
+++ b/notmuch-count.c
@@ -35,8 +35,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
 char *query_str;
 int opt_index;
 int output = OUTPUT_MESSAGES;
-const char **search_exclude_tags;
-size_t search_exclude_tags_length;
+notmuch_bool_t no_exclude = FALSE;
 unsigned int i;

 notmuch_opt_desc_t options[] = {
@@ -44,6 +43,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
  (notmuch_keyword_t []){ { "threads", OUTPUT_THREADS },
  { "messages", OUTPUT_MESSAGES },
  { 0, 0 } } },
+   { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 },
{ 0, 0, 0, 0, 0 }
 };

@@ -78,10 +78,15 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
return 1;
 }

-search_exclude_tags = notmuch_config_get_search_exclude_tags
-   (config, &search_exclude_tags_length);
-for (i = 0; i < search_exclude_tags_length; i++)
-   notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
+if (!no_exclude) {
+   const char **search_exclude_tags;
+   size_t search_exclude_tags_length;
+
+   search_exclude_tags = notmuch_config_get_search_exclude_tags
+   (config, &search_exclude_tags_length);
+   for (i = 0; i < search_exclude_tags_length; i++)
+   notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
+}

 switch (output) {
 case OUTPUT_MESSAGES:
diff --git a/notmuch-search.c b/notmuch-search.c
index 92ce38a..6d6c0e6 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -426,8 +426,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
 output_t output = OUTPUT_SUMMARY;
 int offset = 0;
 int limit = -1; /* unlimited */
-const char **search_exclude_tags;
-size_t search_exclude_tags_length;
+notmuch_bool_t no_exclude = FALSE;
 unsigned int i;

 enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT }
@@ -449,6 +448,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
  { "files", OUTPUT_FILES },
  { "tags", OUTPUT_TAGS },
  { 0, 0 } } },
+   { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 },
{ NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 },
{ NOTMUCH_OPT_INT, &limit, "limit", 'L', 0  },
{ 0, 0, 0, 0, 0 }
@@ -496,10 +496,15 @@ notmuch_search_command (void *ctx, int argc, char *argv[])

 notmuch_query_set_sort (query, sort);

-search_exclude_tags = notmuch_config_get_search_exclude_tags
-   (config, &search_exclude_tags_length);
-for (i = 0; i < search_exclude_tags_length; i++)
-   notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
+if (!no_exclude) {
+   const char **search_exclude_tags;
+   size_t search_exclude_tags_length;
+
+   search_exclude_tags = notmuch_config_get_search_exclude_tags
+   (config, &search_exclude_tags_length);
+   for (i = 0; i < search_exclude_tags_length; i++)
+   notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
+}

 switch (output) {
 default:
-- 
1.7.2.3



[Patch v7 00/13] Add NOTMUCH_MESSAGE_FLAG_EXCLUDED flag

2012-03-01 Thread Mark Walters
This is essentially the same as
id:"1330157204-26094-1-git-send-email-markwalters1009 at gmail.com" but
has been rebased against master. The changes are to patch 12/13 for
notmuch-show.el (which was posted as a followup to the previous series)
and to the tests (patch 9/13) which changed in Austin's JSON show
rewrite.

Best wishes

Mark

Mark Walters (13):
  cli: add --no-exclude option to count and search.
  cli: Add --no-exclude to the man pages for search and count
  test: add tests for new cli --no-exclude option
  lib: Rearrange the exclude code in query.cc
  lib: Make notmuch_query_search_messages set the exclude flag
  lib: Add the exclude flag to notmuch_query_search_threads
  test: update search test to reflect exclude flag
  cli: Make notmuch-show respect excludes.
  test: update tests to reflect the exclude flag
  man: update manpage for notmuch-show --no-exclude option
  cli: omit excluded messages in results where appropriate.
  emacs: show: recognize the exclude flag.
  emacs: notmuch.el ignore excluded matches

 emacs/notmuch-show.el |   36 -
 emacs/notmuch.el  |   22 +++--
 lib/notmuch-private.h |8 +++-
 lib/notmuch.h |   16 +++--
 lib/query.cc  |   77 +++--
 lib/thread.cc |   18 +--
 man/man1/notmuch-count.1  |7 
 man/man1/notmuch-search.1 |7 
 man/man1/notmuch-show.1   |7 
 notmuch-count.c   |   19 +++---
 notmuch-search.c  |   26 ---
 notmuch-show.c|   31 --
 test/count|   21 
 test/crypto   |9 +-
 test/encoding |2 +-
 test/json |6 ++--
 test/maildir-sync |1 +
 test/multipart|6 ++--
 test/search   |8 -
 test/thread-naming|   16 +-
 20 files changed, 273 insertions(+), 70 deletions(-)

-- 
1.7.2.3



plans for 0.12

2012-03-01 Thread Pieter Praet
On Sat, 25 Feb 2012 10:27:02 -0400, David Bremner  wrote:
> 
> I would like to start a freeze (i.e. merge master to release) for 0.12
> within the next week, say March 1 for an easy to remember date.
> 
> If you have suggestions for things that "should really go in", feel free
> to follow up. The main point here is bug fixes, or features which are
> there in a kindof half baked way.
>

Some of the features added/refactored post-0.11.1 don't have any
test coverage yet.  Should they, before wrapping up 0.12 ?
(not a rhetorical question, I'm genuinely asking for opinions)


Anyways, I've taken the liberty of tagging the following patches '0.12':

- test: emacs: toggle processing of cryptographic MIME parts in `notmuch-show'
  - id:"1329684990-12504-2-git-send-email-pieter at praet.org"
- test: emacs: toggle eliding of non-matching messages in `notmuch-show'
  - id:"1329684990-12504-3-git-send-email-pieter at praet.org"
- test: emacs: toggle thread content indentation in `notmuch-show'
  - id:"1329684990-12504-4-git-send-email-pieter at praet.org"

- test: emacs: new tests "notmuch-show: {add,remove} multiple tags {to,from} 
single message"
  - id:"1330122640-18895-2-git-send-email-pieter at praet.org"
- test: emacs: new test "notmuch-show: change tags of all messages in current 
buffer"
  - id:"1330122640-18895-3-git-send-email-pieter at praet.org"

- test: emacs: new test "notmuch-search: change tags of all matching messages"
  - id:"1329936867-923-1-git-send-email-pieter at praet.org"

If applied in that order, the last one needs to be applied with the
`--3way' option, which results in an easily resolved merge conflict,
but if needed, I'll rebase it.


> Bug fix wise, I know about 
>   
>   id:"1330068983-4483-1-git-send-email-sojkam1 at fel.cvut.cz"
> 
> This could use some review.
> 
> It has also been some chatter that either (the next iteration of)
> 
>id:"1329296619-7463-1-git-send-email-markwalters1009 at gmail.com" 
> 
> Should go in, or we should revert amdragon's exclude stuff. 
> 
> I don't have strong feelings either way, except it is somewhat late in
> the day for a large(ish) and complicated series.
> 
> There are several other patch series that look ready from a review point
> of view, but I'd rather have them pushed earlier in the release cycle
> (or at least I don't see a hurry). For example 
> 
>id:"1329490088-8323-2-git-send-email-dmitry.kurochkin at gmail.com"
>id:"1329697590-7404-1-git-send-email-amdragon at mit.edu"
> 
> My (tentative) plan is to push those once I have branched for release.
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


Peace

-- 
Pieter


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

2012-03-01 Thread Mark Walters
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.
> ---
>  emacs/notmuch-hello.el |   20 ++--
>  1 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> index aad373d..e9caade 100644
> --- a/emacs/notmuch-hello.el
> +++ b/emacs/notmuch-hello.el
> @@ -695,16 +695,16 @@ Supports the following entries in OPTIONS as a plist:
>   (notmuch-hello-update))
>"hide"))
>  (widget-insert "\n")
> -(let (target-pos
> -   (searches (apply 'notmuch-hello-query-counts query-alist options)))
> -  (when (and (not is-hidden)
> -(or (not (plist-get options :hide-if-empty))
> -   searches))
> - (widget-insert "\n")
> - (setq target-pos
> -   (notmuch-hello-insert-buttons searches))
> - (indent-rigidly start (point) notmuch-hello-indent)
> - target-pos
> +(let (target-pos)
> +  (when (not is-hidden)
> + (let ((searches (apply 'notmuch-hello-query-counts query-alist 
> options)))
> +   (when (or (not (plist-get options :hide-if-empty))
> + searches)
> + (widget-insert "\n")
> + (setq target-pos
> +   (notmuch-hello-insert-buttons searches))
> + (indent-rigidly start (point) notmuch-hello-indent
> +  target-pos)))
>  
>  (defun notmuch-hello-insert-tags-section (&optional title &rest options)
>"Insert a section displaying all tags with message counts.


This looks fine to me and does speed things up when the "All tags"
section is hidden (are there other sections I can hide?)

Best wishes

Mark


[PATCH v2] emacs: Pass a copy to notmuch-saved-search-sort-function

2012-03-01 Thread Daniel Schoepe
notmuch-saved-search-sort-function might destructively modify its
input (`sort' does that, for instance), so it should not be given
notmuch-saved-searches directly.
---
 emacs/notmuch-hello.el |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index aad373d..e089290 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -575,7 +575,10 @@ Complete list of currently available key bindings:
   (let ((searches (notmuch-hello-query-counts
   (if notmuch-saved-search-sort-function
   (funcall notmuch-saved-search-sort-function
-   notmuch-saved-searches)
+   ;; Use a copy, since the sorting
+   ;; function may have side effects,
+   ;; e.g. if it just `sort's the input.
+   (copy-sequence notmuch-saved-searches))
 notmuch-saved-searches)
   :show-empty-searches notmuch-show-empty-saved-searches))
found-target-pos)
-- 
1.7.9.1



[PATCH v2 0/1] emacs: Pass a copy to notmuch-saved-search-sort-function

2012-03-01 Thread Daniel Schoepe
I overlooked that copy-seq is from cl.el. This version uses copy-sequence 
instead.



[PATCH] Actually close the xapian database in notmuch_database_close

2012-03-01 Thread Olly Betts
On Thu, Mar 01, 2012 at 07:59:30AM +0100, Justus Winter wrote:
> Olly wrote:
> >It is hard to say if calling close() is actually useful here from just
> >seeing the patch.
> 
> Huh? I provided a test case...

I only saw the part of the patch Austin quoted in the mail he cc-ed to
me.

> Quoting Austin Clements (2012-02-29 23:17:54)
> >Also, since close could throw an exception, it should get wrapped in a
> >try/catch like flush currently is.
> 
> My interpretation of [0] was that Xapian::Database::close() does not
> throw any exceptions.

Sadly there's not full documentation of exceptions which can be thrown 
by a particular method.

Cheers,
Olly


Possible bug in gpg signing replies

2012-03-01 Thread James Vasile

When using 'mml-secure-sign-pgpmime to sign one part of an email, valid
sigs get attached to new emails but not to replies.  Instead, when I
reply to a message, the signing directive seems to be inserted as plain
text and is not processed.

Switching to the 'mml-secure-message-sign-pgpmime, which signs the whole
message, appears to work for both replies and new messages.

I'm content to use the form that works, but I thought others might want
to confirm the bug and fix it if it is real.

Regards,
James


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


[PATCH v10 1/2] emacs: User-defined sections in notmuch-hello

2012-03-01 Thread Dmitry Kurochkin
Hi Michal.

On Thu, 01 Mar 2012 15:57:32 +0100, Michal Sojka  wrote:
> On Thu, 01 Mar 2012, David Bremner wrote:
> > 
> > Pushed, finally. Thanks for both of your hard work on this.
> 
> Hi,
> 
> is anybody willing to review
> id:"1329603149-6047-1-git-send-email-sojkam1 at fel.cvut.cz"?

I plan to review it soon.

Regards,
  Dmitry

> I'd like to
> see it merged togetger with these patches as it makes my work with
> notmuch-hello much more pleasant. And others
> (id:"8762f7etfo.fsf at qmul.ac.uk") would probably like this patch too.
> 
> -Michal


plans for 0.12

2012-03-01 Thread David Bremner
On Thu, 01 Mar 2012 22:21:29 +0100, Pieter Praet  wrote:
> 
> Some of the features added/refactored post-0.11.1 don't have any
> test coverage yet.  Should they, before wrapping up 0.12 ?
> (not a rhetorical question, I'm genuinely asking for opinions)
> 

Hi Pieter;

My initial answer is probably not. I see the tests as mainly useful
during development, for detecting regressions. I think most people doing
development will be working from git, rather than the distribution
tarballs we ship.   

On the other hand, adding tests is also not that risky, so if the
concensus is strongly in favour of integrating them pre 0.12, and
somebody wants to review them all, then I'm willing to consider it.

d


[PATCH 2/2] test: add new test file for mime parsing.

2012-03-01 Thread David Bremner
From: David Bremner 

For now, just tests one message currently causing notmuch to segfault.
---
 test/mime |   67 +
 test/notmuch-test |1 +
 2 files changed, 68 insertions(+), 0 deletions(-)
 create mode 100755 test/mime

diff --git a/test/mime b/test/mime
new file mode 100755
index 000..5b2d77f
--- /dev/null
+++ b/test/mime
@@ -0,0 +1,67 @@
+#!/usr/bin/env bash
+
+test_description="mime parsing"
+. test-lib.sh
+
+add_rfc822_message <
+Envelope-to: bobaf...@archangel.wmdcantina.org
+Delivery-date: Wed, 09 Feb 2011 10:06:54 -0400
+Received: from fiero.its.cantina.org ([131.202.1.10])
+   by archangel.wmdcantina.org with esmtps 
(TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
+   (Exim 4.69)
+   (envelope-from )
+   id 1PnAh4-AX-DH
+   for bobaf...@archangel.wmdcantina.org; Wed, 09 Feb 2011 10:06:54 -0400
+Received: from mx3.nbpei-ecn.ca (mx3.nbpei-ecn.ca [198.164.163.196])
+   by fiero.its.cantina.org (8.13.8/8.13.8) with ESMTP id p19E6lst014693
+   for ; Wed, 9 Feb 2011 10:06:47 -0400
+Received: from mx3.nbpei-ecn.ca (localhost.localdomain [127.0.0.1])
+   by localhost (Postfix) with SMTP id EC0C04B8002
+   for ; Wed,  9 Feb 2011 10:06:47 -0400 (AST)
+Received: from cibc.ca (mail4.cibc.ca [199.198.251.34])
+   by mx3.nbpei-ecn.ca (Postfix) with ESMTP id A80824B8003
+   for ; Wed,  9 Feb 2011 10:06:47 -0400 (AST)
+From: "Smith, Bob" 
+To: "'bobaf...@cantina.org'" 
+Disposition-Notification-To: "Smith, Bob" 
+Return-Receipt-To: 
+Date: Wed, 9 Feb 2011 09:06:43 -0500
+Subject: 
+Thread-Index: AcvIYpRcEJX82QtpQSacs5hsY+i4SQ==
+Message-ID: 
<5bb75198a4300643a295d4678b10f0503bddf7c...@cbmcc-x7-mbx09.ad.fbi.gov>
+Accept-Language: en-US
+Content-Language: en-US
+X-MS-Has-Attach: 
+X-MS-TNEF-Correlator: 
+acceptlanguage: en-US
+Content-Type: multipart/alternative;
+   boundary="_000_5BB75198A4300643A295D4678B10F0503BDDF7CEB1CBMCCX7MBX09a_"
+MIME-Version: 1.0
+X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 
2011.2.9.135719
+X-PerlMx-Spam: Gauge=I, Probability=9%, Report='
+ BLANK_SUBJECT 0.1, HTML_NO_HTTP 0.1, SUPERLONG_LINE 0.05, 
BODYTEXTH_SIZE_1_LESS 0, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_4000_4999 0, 
BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DATE_TZ_NA 0, __C230066_P5 0, 
__CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __CTYPE_MULTIPART_ALT 0, 
__FRAUD_CONTACT_NUM 0, __HAS_HTML 0, __HAS_MSGID 0, __MIME_HTML 0, 
__MIME_VERSION 0, __PHISH_FROM 0, __PHISH_FROM1 0, __PHISH_FROM_C 0, 
__SANE_MSGID 0, __STOCK_PHRASE_8 0, __TAG_EXISTS_HTML 0, __TO_MALFORMED_2 0, 
__TO_NO_NAME 0'
+X-Sender-Verified: bob.sm...@fbi.gov
+
+--_000_5BB75198A4300643A295D4678B10F0503BDDF7CEB1CBMCCX7MBX09a_
+Content-Type: text/plain; charset="iso-8859-1"
+Content-Transfer-Encoding: quoted-printable
+
+quoted printable stuff.
+
+
+--_000_5BB75198A4300643A295D4678B10F0503BDDF7CEB1CBMCCX7MBX09a_
+Content-Type: text/html; charset="iso-8859-1"
+Content-Transfer-Encoding: quoted-printable
+
+
+some other stuff
+
+
+--_000_5BB75198A4300643A295D4678B10F0503BDDF7CEB1CBMCCX7MBX09a_--
+
+
+EOF
+test_expect_success 'output message as json' "notmuch show --format=json 
id:5bb75198a4300643a295d4678b10f0503bddf7c...@cbmcc-x7-mbx09.ad.fbi.gov > 
/dev/null"
+test_done
diff --git a/test/notmuch-test b/test/notmuch-test
index f03b594..b572f1c 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -56,6 +56,7 @@ TESTS="
   emacs-address-cleaning
   emacs-hello
   emacs-show
+  mime
 "
 TESTS=${NOTMUCH_TESTS:=$TESTS}
 
-- 
1.7.9

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


[PATCH 1/2] test: utility function to add a pre-generated message to the database.

2012-03-01 Thread David Bremner
From: David Bremner 

For various "nasty" messages, it is easier to ship a message rather
than try to generate a message which causes a failure.
---
 test/test-lib.sh |   15 +++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index 2781506..17d0e48 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -376,6 +376,21 @@ ${template[body]}
 EOF
 }
 
+# Add an existing message to the notmuch database.
+#
+# expects a message on stdin.
+#
+# uses the variable gen_msg_cnt from generate_message.
+
+add_rfc822_message ()
+{
+gen_msg_cnt=$((gen_msg_cnt + 1))
+gen_msg_name="msg-$(printf "%03d" $gen_msg_cnt)"
+gen_msg_filename="${MAIL_DIR}/$gen_msg_name"
+cat >$gen_msg_filename
+notmuch new > /dev/null
+}
+
 # Generate a new message and add it to the database.
 #
 # All of the arguments and return values supported by generate_message
-- 
1.7.9

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


[no subject]

2012-03-01 Thread David Bremner
Probably both of these patches could use some polishing; Austin asked
for a test to help debug the crash I found today.

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


[RFC] Smart replying

2012-03-01 Thread Nicolás Reynolds
On Thu, 01 Mar 2012 18:02:09 -0300, Nicol?s Reynolds  
wrote:
> 
> I'll try it, it's been bothering me also on reply-to-list lists :)
> 
> (There's also C-c C-l but it doesn't work for me)

he.

https://www.gnu.org/software/emacs/manual/html_mono/message.html#Mailing-Lists
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120301/b0b10b84/attachment.pgp>


[PATCH] emacs: Mention race condition safety in user visible documentation

2012-03-01 Thread Pieter Praet
On Wed, 29 Feb 2012 22:49:46 -0400, David Bremner  wrote:
> On Tue, 21 Feb 2012 10:15:08 +0100, Michal Sojka  
> wrote:
> > -- >8 --
> > Subject: [PATCH] emacs: Clarify description of thread manipulating functions
> > 
> > It is not clear whether the term "thread" refers to the thread in the
> > database or to the thread currently shown in a buffer. Those two
> > meanings may refer to different sets of messages, e.g. when a new email
> > is added to the database while the buffer shows the state before the new
> > email arrived.
> 
> (will be) pushed.
> 
> For future reference, it's slightly inconvenient for me to use "git am
> -c". Not a big deal, but a sequence of those would make me cry...
>

Something like this might help save you some time:
(assuming you'd rather not leave Emacs to apply patches)

  #+begin_src emacs-lisp
(defvar praet/projects
  '(("notmuch at notmuchmail.org" . "~/src/dev/notmuch/")
("foo at bar.org" . "~/src/dev/foobar/")))

(defun praet/notmuch-patch-apply (&optional all-open)
  "Apply a patch from `notmuch-show-mode' using git-am(1).
If ALL-OPEN is non-nil, (try to) apply all open messages."
  (interactive "P")
  (let* ((msg (notmuch-show-get-message-id t))
 (rcpts (concat (notmuch-show-get-to)
(notmuch-show-get-cc)))
 (projs (loop for project in praet/projects
  if (string-match (car project) rcpts)
  collect (cdr project)))
 (proj (if (> (length projs) 1)
   (ido-completing-read "Apply in: " projs)
 (car projs)))
 (cmd "git am --abort ; git am")
 (optargs '("--signoff" "--3way" "--scissors"))
 (args (read-string "Args: " nil '(optargs . 0
(message "Applying in '%s': '%s' (using '%s %s')"
 proj msg cmd args)
(notmuch-show-pipe-message all-open
 (concat "(cd " proj " && (" cmd " " args ")" ")"

(define-key notmuch-show-mode-map (kbd "C-c p a")
  'praet/notmuch-patch-apply)
  #+end_src


> d
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


Peace

-- 
Pieter


[PATCH v6 1/3] emacs: `notmuch-show-get-message-id': optionally return Message-Id sans prefix

2012-03-01 Thread Pieter Praet
On Wed, 29 Feb 2012 08:19:34 -0400, David Bremner  wrote:
> On Tue, 28 Feb 2012 19:40:04 +0100, Pieter Praet  wrote:
> > 
> > Though I couldn't help but notice (it's a curse...) that patch #3
> > seems to have gained an extra space in its commit message subject:
> > 
> >   Original (id:"1329684627-10708-4-git-send-email-pieter at praet.org"):
> > emacs: add `notmuch-show-stash-mlarchive-link{,-and-go}'
> >   ^
> 
> I don't have any applypatch-msg hook. I am using 
>   "notmuch show --format=raw $messageid | git am -" to
> apply the patch.  
> 
> I looked at the file on disk, and something is wrapping the subject
> there.  Perhaps somebody's unwrapping code is buggy? I'm not sure what's
> at fault here; [...]

TL;DR:  Doesn't seem like there's much we can do about it...


According to RFC 2822 section 2.2.3 [1], header fields should be folded
by inserting a CRLF right before the last whitespace char before the
line exceeds 78 characters, and when a field contains comma-separated
values (which is somewhat applicable in this case), it should be folded
by inserting a CRLF right after a comma.

Now, the issue is that unfolding is accomplished by simply removing any
CRLF that is immediately followed by a whitespace char:

If the subject headers of those patches were folded by simply inserting
a CRLF, they couldn't possibly be unfolded again as there wouldn't be a
whitespace char right after the CRLF, so Mailman seems to have helpfully
inserted a tab...


Here's one of those patches at a number of archives:

- http://notmuchmail.org/pipermail/notmuch/2012/009575.html
- http://mid.gmane.org/1329684627-10708-4-git-send-email-pieter at praet.org
- 
http://mail-archive.com/search?l=mid&q=1329684627-10708-4-git-send-email-pieter 
at praet.org

As you can see (in the source of those pages), both Pipermail and Gmane
unfold the subject header by simply removing the line break, and at The
Mail Archive, the tab is also replaced by a space.  I assume the latter
also happens in gmime ?


So, I guess I'll just have to learn to live with it... :)


> [...] maybe you could experiment with applying the the patches
> from the list and let me know if e.g. going from files is better than
> using "notmuch show --format=raw".
>

Based on my (admittedly very superficial) analysis of the problem,
that won't do us any good wrt this issue, unfortunately...

But it *would* buy us a (slight) performance increase, so if/when my
patch to `notmuch-show-mapc' [2] goes in, we might want to consider
making `notmuch-show-pipe-message' use `notmuch-show-get-filename'
instead of `notmuch-show-get-message-{id,ids-for-open-messages}'.


> d
> 
> 


Peace

-- 
Pieter

[1] http://tools.ietf.org/html/rfc2822.html#section-2.2.3
[2] id:"1330122640-18895-5-git-send-email-pieter at praet.org"


[RFC] Smart replying

2012-03-01 Thread Nicolás Reynolds
On Thu, 01 Mar 2012 15:35:13 -0500, Jesse Rosenthal  
wrote:
> Dear All,
> 
> I know that folks recently got done haggling over reply bindings, but
> there's something I've been using for a little while, and I was curious
> about whether it's something people would be interested in. Forgive me
> if this functionality was already discussed and I missed it.
> 
> The problem is that I often forget to reply-all to list mails and write
> out half a message, and then have to cut and paste. So, as usual, my
> solution is to try and have emacs figure it out for me.
> 
> Pretty simple: have a variable `reply-all-list'. If an address in the
> `To' or `CC' fields is in that list, 'r' replies-all. If not, it
> replies-sender. CTRL-r (or whatever) forces `reply-sender', on the rare
> occasion I want to take a conversation offline.
> 
> The nice thing about this is, if `reply-all-list' is nil, then it acts
> as normal, so it wouldn't make a difference to most users.
> 
> The implementation that's been sitting in my .emacs is below. I'm not
> offering it as a patch, because I don't quite understand the current
> relation of notmuch-show.el and notmuch-mua.el. 
> 
> If people are interested, though, I could make it into a patch. And, if
> not, I hope it's a snippet that someone finds useful.

I'll try it, it's been bothering me also on reply-to-list lists :)

(There's also C-c C-l but it doesn't work for me)
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120301/ce4395ba/attachment.pgp>


Internal error on line 296 of mime-node.c

2012-03-01 Thread David Bremner

In the current master (4fa77d031) I get a sort-of double crash on the 
attached message.

The internal error on line 296 is reached, indicating some kind of bug,
but then the G_OBJECT_TYPE crashes becase parent->part is null.

The message is probably crap, I created it from another "real" message
from some business that causes the same problem.

(gdb) bt
#0  0x00416850 in mime_node_child (parent=0x8425fa0, child=0)
at mime-node.c:296
#1  0x004137f1 in format_part_json (ctx=0x8425f10, node=0x8425fa0, 
first=1) at notmuch-show.c:669
#2  0x00413e54 in format_part_json_entry (ctx=0x8425f10, 
node=0x8425fa0, indent=0, params=0x7ff000470) at notmuch-show.c:758
#3  0x00413f0f in show_message (ctx=0x8367680, format=0x6327e0, message=
0x83e9830, indent=0, params=0x7ff000470) at notmuch-show.c:776
#4  0x00414165 in show_messages (ctx=0x8367680, format=0x6327e0, 
messages=0x8425e70, indent=0, params=0x7ff000470) at notmuch-show.c:835
#5  0x004145f5 in do_show (ctx=0x8367680, query=0x83b36b0, 
format=0x6327e0, params=0x7ff000470) at notmuch-show.c:956
#6  0x00414ba7 in notmuch_show_command (ctx=0x8367680, argc=3, 
argv=0x7ff000660) at notmuch-show.c:1089
#7  0x0040a9fe in main (argc=4, argv=0x7ff000658) at notmuch.c:294
(gdb) print *parent
$3 = {part = 0x0, envelope_file = 0x83e9830, envelope_part = 0x0, 
  nchildren = 1, parent = 0x0, part_num = 0, decrypt_attempted = 0, 
  decrypt_success = 0, verify_attempted = 0, sig_list = 0x0, ctx = 0x8426090, 
  decrypted_child = 0x0, next_child = 0, next_part_num = 1}

-- next part --
An embedded message was scrubbed...
From: "Smith, Bob" 
Subject: 
Date: Wed, 9 Feb 2011 09:06:43 -0500
Size: 2766
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120301/b09b801a/attachment-0001.eml>


Internal error on line 296 of mime-node.c

2012-03-01 Thread Austin Clements
Quoth David Bremner on Mar 01 at  5:39 pm:
> 
> In the current master (4fa77d031) I get a sort-of double crash on the 
> attached message.
> 
> The internal error on line 296 is reached, indicating some kind of bug,
> but then the G_OBJECT_TYPE crashes becase parent->part is null.
> 
> The message is probably crap, I created it from another "real" message
> from some business that causes the same problem.
> 
> (gdb) bt
> #0  0x00416850 in mime_node_child (parent=0x8425fa0, child=0)
> at mime-node.c:296
> #1  0x004137f1 in format_part_json (ctx=0x8425f10, node=0x8425fa0, 
> first=1) at notmuch-show.c:669
> #2  0x00413e54 in format_part_json_entry (ctx=0x8425f10, 
> node=0x8425fa0, indent=0, params=0x7ff000470) at notmuch-show.c:758
> #3  0x00413f0f in show_message (ctx=0x8367680, format=0x6327e0, 
> message=
> 0x83e9830, indent=0, params=0x7ff000470) at notmuch-show.c:776
> #4  0x00414165 in show_messages (ctx=0x8367680, format=0x6327e0, 
> messages=0x8425e70, indent=0, params=0x7ff000470) at notmuch-show.c:835
> #5  0x004145f5 in do_show (ctx=0x8367680, query=0x83b36b0, 
> format=0x6327e0, params=0x7ff000470) at notmuch-show.c:956
> #6  0x00414ba7 in notmuch_show_command (ctx=0x8367680, argc=3, 
> argv=0x7ff000660) at notmuch-show.c:1089
> #7  0x0040a9fe in main (argc=4, argv=0x7ff000658) at notmuch.c:294
> (gdb) print *parent
> $3 = {part = 0x0, envelope_file = 0x83e9830, envelope_part = 0x0, 
>   nchildren = 1, parent = 0x0, part_num = 0, decrypt_attempted = 0, 
>   decrypt_success = 0, verify_attempted = 0, sig_list = 0x0, ctx = 0x8426090, 
>   decrypted_child = 0x0, next_child = 0, next_part_num = 1}

For the record, this is because g_mime_parser_construct_message in
mime_node_open is returning NULL.  mime_node_open should be checking
for this as well as errors from the other GMime functions it calls.
(Unfortunately, there appears to be no way to ask GMime *what* went
wrong; it just returns NULL.)


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

2012-03-01 Thread Daniel Schoepe
On Fri, 02 Mar 2012 01:34:03 +0100, Daniel Schoepe  wrote:
> You can define other section that you can then hide, which was the main
> point of the original patch.

The defining other sections thing that is, not that you have more
things to hide.. :)


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


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

2012-03-01 Thread Daniel Schoepe
On Thu, 01 Mar 2012 22:18:04 +, Mark Walters  
wrote:
> This looks fine to me and does speed things up when the "All tags"
> section is hidden (are there other sections I can hide?)

You can define other section that you can then hide, which was the main
point of the original patch.

Michal, your patch looks good to me too. Now that my two patches have
been pushed, I think this should go in as well.

Cheers,
Daniel


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


[PATCH v10 1/2] emacs: User-defined sections in notmuch-hello

2012-03-01 Thread Michal Sojka
On Thu, 01 Mar 2012, David Bremner wrote:
> 
> Pushed, finally. Thanks for both of your hard work on this.

Hi,

is anybody willing to review
id:"1329603149-6047-1-git-send-email-sojkam1 at fel.cvut.cz"? I'd like to
see it merged togetger with these patches as it makes my work with
notmuch-hello much more pleasant. And others
(id:"8762f7etfo.fsf at qmul.ac.uk") would probably like this patch too.

-Michal


[PATCH] emacs: Pass a copy to notmuch-saved-search-sort-function

2012-03-01 Thread Daniel Schoepe
notmuch-saved-search-sort-function might destructively modify its
input (`sort' does that, for instance), so it should not be given
notmuch-saved-searches directly.
---
 emacs/notmuch-hello.el |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index aad373d..b2b22df 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -575,7 +575,10 @@ Complete list of currently available key bindings:
   (let ((searches (notmuch-hello-query-counts
   (if notmuch-saved-search-sort-function
   (funcall notmuch-saved-search-sort-function
-   notmuch-saved-searches)
+   ;; Use a copy, since the sorting
+   ;; function may have side effects,
+   ;; e.g. if it just `sort's the input.
+   (copy-seq notmuch-saved-searches))
 notmuch-saved-searches)
   :show-empty-searches notmuch-show-empty-saved-searches))
found-target-pos)
-- 
1.7.9.1



[PATCH 0/1] emacs: Pass a copy to notmuch-saved-search-sort-function

2012-03-01 Thread Daniel Schoepe
As Jani discovered, `sort' modifies its input list, leading to deleted
saved searches when using notmuch-sort-saved-searches.



[RFC] Smart replying

2012-03-01 Thread Jesse Rosenthal
Dear All,

I know that folks recently got done haggling over reply bindings, but
there's something I've been using for a little while, and I was curious
about whether it's something people would be interested in. Forgive me
if this functionality was already discussed and I missed it.

The problem is that I often forget to reply-all to list mails and write
out half a message, and then have to cut and paste. So, as usual, my
solution is to try and have emacs figure it out for me.

Pretty simple: have a variable `reply-all-list'. If an address in the
`To' or `CC' fields is in that list, 'r' replies-all. If not, it
replies-sender. CTRL-r (or whatever) forces `reply-sender', on the rare
occasion I want to take a conversation offline.

The nice thing about this is, if `reply-all-list' is nil, then it acts
as normal, so it wouldn't make a difference to most users.

The implementation that's been sitting in my .emacs is below. I'm not
offering it as a patch, because I don't quite understand the current
relation of notmuch-show.el and notmuch-mua.el. 

If people are interested, though, I could make it into a patch. And, if
not, I hope it's a snippet that someone finds useful.

Best,
Jesse

~
(defvar reply-all-list nil)

(defun jkr/notmuch-show-check-to-cc (address-list)
  (let* ((to-cc-list (apply 'append 
(mapcar 'mail-header-parse-addresses 
(list (notmuch-show-get-to) 
  (notmuch-show-get-cc)
 (to-cc-addr-list (mapcar 'car to-cc-list)))
(intersection address-list to-cc-addr-list :test 'equal)))

(defun jkr/notmuch-show-smart-reply-all ()
  "Reply to sender, unless address is on reply-all list"
  (interactive)
  (if (jkr/notmuch-show-check-to-cc reply-all-list)
  (notmuch-show-reply)
(notmuch-show-reply-sender)))

(defun jkr/notmuch-show-force-reply-sender ()
  "Reply to sender only, regardless of reply-all list"
  (interactive)
  (notmuch-show-reply-sender))

(define-key notmuch-show-mode-map "r" 'jkr/notmuch-show-smart-reply-all)

(define-key notmuch-show-mode-map "\C-r" 'jkr/notmuch-show-force-reply-sender)

; (setq reply-all-list '("notmuch at notmuchmail.org"))




[PATCH 2/2] Spelling fix

2012-03-01 Thread Tomi Ollila
Retreive is spelled as r e t r i e v e .
---
 emacs/notmuch-crypto.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index e916d66..83e5d37 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -101,7 +101,7 @@ mode."
   (let ((keyid (concat "0x" (plist-get sigstatus :keyid
(setq label (concat "Unknown key ID " keyid " or unsupported 
algorithm"))
(setq button-action 'notmuch-crypto-sigstatus-error-callback)
-   (setq help-msg (concat "Click to retreive key ID " keyid " from 
keyserver and redisplay."
+   (setq help-msg (concat "Click to retrieve key ID " keyid " from 
keyserver and redisplay."
  ((string= status "bad")
   (let ((keyid (concat "0x" (plist-get sigstatus :keyid
(setq label (concat "Bad signature (claimed key ID " keyid ")"))
-- 
1.7.8.2



[PATCH 1/2] emacs: retain show buffer state after retrieving gpg key

2012-03-01 Thread Tomi Ollila
After retrieving gpg key retain show buffer state like in
all other operations (i.e. no other calls to notmuch-show-refresh-view
provides optional reset-state argument).
Emacs MUA keeps current message under cursor instead of going first
open message(possibly marking it read).
---
 emacs/notmuch-crypto.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index 94da325..e916d66 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -145,7 +145,7 @@ mode."
(insert "\n")
(call-process "gpg" nil t t "--list-keys" keyid))
   (recenter -1))
-(notmuch-show-refresh-view t)))
+(notmuch-show-refresh-view)))

 (defun notmuch-crypto-insert-encstatus-button (encstatus)
   (let* ((status (plist-get encstatus :status))
-- 
1.7.8.2



Re: [PATCH 1/2] test: remove "Generate some messages" test from raw

2012-03-01 Thread Dmitry Kurochkin
Hi David.

On Wed, 15 Feb 2012 22:33:51 +0400, Dmitry Kurochkin 
 wrote:
> Hi all.
> 
> Are there any objections to these changes?
> 
> Otherwise, I would ask David to push it as "minor, boring and trivial"
> changes.
> 

Since there are no objections, I removed the needs-review tag from these
patches.

David, I believe the patches are good to be pushed.

Regards,
  Dmitry

> Regards,
>   Dmitry
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: plans for 0.12

2012-03-01 Thread David Bremner
On Thu, 01 Mar 2012 22:21:29 +0100, Pieter Praet  wrote:
> 
> Some of the features added/refactored post-0.11.1 don't have any
> test coverage yet.  Should they, before wrapping up 0.12 ?
> (not a rhetorical question, I'm genuinely asking for opinions)
> 

Hi Pieter;

My initial answer is probably not. I see the tests as mainly useful
during development, for detecting regressions. I think most people doing
development will be working from git, rather than the distribution
tarballs we ship.   

On the other hand, adding tests is also not that risky, so if the
concensus is strongly in favour of integrating them pre 0.12, and
somebody wants to review them all, then I'm willing to consider it.

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


[Patch v7 13/13] emacs: notmuch.el ignore excluded matches

2012-03-01 Thread Mark Walters
This is a small change to make notmuch.el ignore excluded matches.  In
the future it could do something better like add a button for
rerunning the search with the excludes (particularly if nothing
matches with the excludes) or having them invisible and allowing the
visibility to be toggled.
---
 emacs/notmuch.el |   22 --
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f851c6f..99e0c93 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -872,16 +872,18 @@ non-authors is found, assume that all of the authors 
match."
  (goto-char (point-max))
  (if (/= (match-beginning 1) line)
  (insert (concat "Error: Unexpected output from 
notmuch search:\n" (substring string line (match-beginning 1)) "\n")))
- (let ((beg (point)))
-   (notmuch-search-show-result date count authors
-   (notmuch-prettify-subject 
subject) tags)
-   (notmuch-search-color-line beg (point) tag-list)
-   (put-text-property beg (point) 
'notmuch-search-thread-id thread-id)
-   (put-text-property beg (point) 'notmuch-search-authors 
authors)
-   (put-text-property beg (point) 'notmuch-search-subject 
subject)
-   (when (string= thread-id notmuch-search-target-thread)
- (set 'found-target beg)
- (set 'notmuch-search-target-thread "found")))
+ ;; We currently just throw away excluded matches.
+ (unless (eq (aref count 1) ?0)
+   (let ((beg (point)))
+ (notmuch-search-show-result date count authors
+ (notmuch-prettify-subject 
subject) tags)
+ (notmuch-search-color-line beg (point) tag-list)
+ (put-text-property beg (point) 
'notmuch-search-thread-id thread-id)
+ (put-text-property beg (point) 
'notmuch-search-authors authors)
+ (put-text-property beg (point) 
'notmuch-search-subject subject)
+ (when (string= thread-id notmuch-search-target-thread)
+   (set 'found-target beg)
+   (set 'notmuch-search-target-thread "found"
  (set 'line (match-end 0)))
  (set 'more nil)
  (while (and (< line (length string)) (= (elt string line) 
?\n))
-- 
1.7.2.3

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


[Patch v7 09/13] test: update tests to reflect the exclude flag

2012-03-01 Thread Mark Walters
notmuch show outputs the exclude flag so many tests using notmuch
show failed. This commit adds "excluded:0" or "excluded: false" to
the expected outputs. After this commit there should be no failing
tests.
---
 test/crypto|9 -
 test/encoding  |2 +-
 test/json  |6 +++---
 test/maildir-sync  |1 +
 test/multipart |6 +++---
 test/thread-naming |   16 
 6 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/test/crypto b/test/crypto
index 7e774c8..4de4d2b 100755
--- a/test/crypto
+++ b/test/crypto
@@ -43,6 +43,7 @@ output=$(notmuch show --format=json --verify subject:"test 
signed message 001" \
 | sed -e 's|"created": [1234567890]*|"created": 946728000|')
 expected='[[[{"id": "X",
  "match": true,
+ "excluded": false,
  "filename": "Y",
  "timestamp": 946728000,
  "date_relative": "2000-01-01",
@@ -76,6 +77,7 @@ output=$(notmuch show --format=json --verify subject:"test 
signed message 001" \
 | sed -e 's|"created": [1234567890]*|"created": 946728000|')
 expected='[[[{"id": "X",
  "match": true,
+ "excluded": false,
  "filename": "Y",
  "timestamp": 946728000,
  "date_relative": "2000-01-01",
@@ -111,6 +113,7 @@ output=$(notmuch show --format=json --verify subject:"test 
signed message 001" \
 | sed -e 's|"created": [1234567890]*|"created": 946728000|')
 expected='[[[{"id": "X",
  "match": true,
+ "excluded": false,
  "filename": "Y",
  "timestamp": 946728000,
  "date_relative": "2000-01-01",
@@ -150,7 +153,7 @@ test_begin_subtest "decryption, --format=text"
 output=$(notmuch show --format=text --decrypt subject:"test encrypted message 
001" \
 | notmuch_show_sanitize_all \
 | sed -e 's|"created": [1234567890]*|"created": 946728000|')
-expected='message{ id:X depth:0 match:1 filename:X
+expected='message{ id:X depth:0 match:1 excluded:0 filename:X
 header{
 Notmuch Test Suite  (2000-01-01) (encrypted inbox)
 Subject: test encrypted message 001
@@ -184,6 +187,7 @@ output=$(notmuch show --format=json --decrypt subject:"test 
encrypted message 00
 | sed -e 's|"created": [1234567890]*|"created": 946728000|')
 expected='[[[{"id": "X",
  "match": true,
+ "excluded": false,
  "filename": "Y",
  "timestamp": 946728000,
  "date_relative": "2000-01-01",
@@ -238,6 +242,7 @@ output=$(notmuch show --format=json --decrypt subject:"test 
encrypted message 00
 | sed -e 's|"created": [1234567890]*|"created": 946728000|')
 expected='[[[{"id": "X",
  "match": true,
+ "excluded": false,
  "filename": "Y",
  "timestamp": 946728000,
  "date_relative": "2000-01-01",
@@ -272,6 +277,7 @@ output=$(notmuch show --format=json --decrypt subject:"test 
encrypted message 00
 | sed -e 's|"created": [1234567890]*|"created": 946728000|')
 expected='[[[{"id": "X",
  "match": true,
+ "excluded": false,
  "filename": "Y",
  "timestamp": 946728000,
  "date_relative": "2000-01-01",
@@ -326,6 +332,7 @@ output=$(notmuch show --format=json --verify subject:"test 
signed message 001" \
 | sed -e 's|"created": [1234567890]*|"created": 946728000|')
 expected='[[[{"id": "X",
  "match": true,
+ "excluded": false,
  "filename": "Y",
  "timestamp": 946728000,
  "date_relative": "2000-01-01",
diff --git a/test/encoding b/test/encoding
index f0d073c..98abf77 100755
--- a/test/encoding
+++ b/test/encoding
@@ -6,7 +6,7 @@ test_begin_subtest "Message with text of unknown charset"
 add_message '[content-type]="text/plain; charset=unknown-8bit"' \
"[body]=irrelevant"
 output=$(notmuch show id:${gen_msg_id} 2>&1 | notmuch_show_sanitize)
-test_expect_equal "$output" "message{ id:msg-001@notmuch-test-suite depth:0 
match:1 filename:/XXX/mail/msg-001
+test_expect_equal "$output" "message{ id:msg-001@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
diff --git a/test/json b/test/json
index 1bdffd2..6439788 100755
--- a/test/json
+++ b/test/json
@@ -5,7 +5,7 @@ test_description="--format=json output"
 test_begin_subtest "Show message: json"
 add_message "[subject]=\"json-show-subject\"" "[date]=\"Sat, 01 Jan 2000 
12:00:00 -\"" "[body]=\"json-show-message\""
 output=$(notmuch show --format=json "json-show-message")
-test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, 
\"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, 
\"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], 
\"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Notmuch Test 
Suite \", \"To\": \"Notmuch Test Suite 
\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +\"}, 
\"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": 
\"json-show-message\n\"}]}, ["
+test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, 
\"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 
946728000, \

[Patch v7 12/13] emacs: show: recognize the exclude flag.

2012-03-01 Thread Mark Walters
Show mode will recognize the exclude flag by not opening excluding
messages by default, and will start at the first matching non-excluded
message. If there are no matching non-excluded messages it will go to
the first matching (necessarily excluded) message.
---
 emacs/notmuch-show.el |   36 +++-
 1 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 7c4c0be..4a60631 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -981,7 +981,8 @@ current buffer, if possible."
 
 ;; Message visibility depends on whether it matched the search
 ;; criteria.
-(notmuch-show-message-visible msg (plist-get msg :match
+(notmuch-show-message-visible msg (and (plist-get msg :match)
+  (not (plist-get msg :excluded))
 
 (defun notmuch-show-toggle-process-crypto ()
   "Toggle the processing of cryptographic MIME parts."
@@ -1081,11 +1082,7 @@ function is used."
  notmuch-show-parent-buffer parent-buffer
  notmuch-show-query-context query-context)
 (notmuch-show-build-buffer)
-
-;; Move to the first open message and mark it read
-(if (notmuch-show-message-visible-p)
-   (notmuch-show-mark-read)
-  (notmuch-show-next-open-message
+(notmuch-show-goto-first-wanted-message)))
 
 (defun notmuch-show-build-buffer ()
   (let ((inhibit-read-only t))
@@ -1167,9 +1164,7 @@ reset based on the original query."
(notmuch-show-apply-state state)
   ;; We're resetting state, so navigate to the first open message
   ;; and mark it read, just like opening a new show buffer.
-  (if (notmuch-show-message-visible-p)
- (notmuch-show-mark-read)
-   (notmuch-show-next-open-message)
+  (notmuch-show-goto-first-wanted-message
 
 (defvar notmuch-show-stash-map
   (let ((map (make-sparse-keymap)))
@@ -1601,6 +1596,29 @@ to show, nil otherwise."
(goto-char (point-max
 r))
 
+(defun notmuch-show-next-matching-message ()
+  "Show the next matching message."
+  (interactive)
+  (let (r)
+(while (and (setq r (notmuch-show-goto-message-next))
+   (not (notmuch-show-get-prop :match
+(if r
+   (progn
+ (notmuch-show-mark-read)
+ (notmuch-show-message-adjust))
+  (goto-char (point-max)
+
+(defun notmuch-show-goto-first-wanted-message ()
+  "Move to the first open message and mark it read"
+  (goto-char (point-min))
+  (if (notmuch-show-message-visible-p)
+  (notmuch-show-mark-read)
+(notmuch-show-next-open-message))
+  (when (eobp)
+(goto-char (point-min))
+(unless (notmuch-show-get-prop :match)
+  (notmuch-show-next-matching-message
+
 (defun notmuch-show-previous-open-message ()
   "Show the previous open message."
   (interactive)
-- 
1.7.2.3

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


[Patch v7 11/13] cli: omit excluded messages in results where appropriate.

2012-03-01 Thread Mark Walters
In all cases of notmuch count/search/show where the results returned
cannot reflect the exclude flag return just the matched not-excluded
results. If the caller wishes to have all the matched results (i.e.,
including the excluded ones) they should call with the
--no-exclude option.

The relevant cases are
count: both threads and messages
search: all cases except the summary view
show: mbox format
---
 notmuch-count.c  |2 ++
 notmuch-search.c |9 +
 notmuch-show.c   |6 ++
 3 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/notmuch-count.c b/notmuch-count.c
index 5364507..46b76ae 100644
--- a/notmuch-count.c
+++ b/notmuch-count.c
@@ -88,6 +88,8 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
 }
 
+notmuch_query_set_omit_excluded_messages (query, TRUE);
+
 switch (output) {
 case OUTPUT_MESSAGES:
printf ("%u\n", notmuch_query_count_messages (query));
diff --git a/notmuch-search.c b/notmuch-search.c
index 6d6c0e6..f6061e4 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -210,6 +210,9 @@ do_search_threads (const search_format_t *format,
 int first_thread = 1;
 int i;
 
+if (output == OUTPUT_THREADS)
+   notmuch_query_set_omit_excluded_messages (query, TRUE);
+
 if (offset < 0) {
offset += notmuch_query_count_threads (query);
if (offset < 0)
@@ -300,6 +303,8 @@ do_search_messages (const search_format_t *format,
 int first_message = 1;
 int i;
 
+notmuch_query_set_omit_excluded_messages (query, TRUE);
+
 if (offset < 0) {
offset += notmuch_query_count_messages (query);
if (offset < 0)
@@ -371,6 +376,10 @@ do_search_tags (notmuch_database_t *notmuch,
 const char *tag;
 int first_tag = 1;
 
+notmuch_query_set_omit_excluded_messages (query, TRUE);
+/* should the following only special case if no excluded terms
+ * specified? */
+
 /* Special-case query of "*" for better performance. */
 if (strcmp (notmuch_query_get_query_string (query), "*") == 0) {
tags = notmuch_database_get_all_tags (notmuch);
diff --git a/notmuch-show.c b/notmuch-show.c
index 8c0b925..05d51b2 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -1030,6 +1030,7 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
fprintf (stderr, "Error: specifying parts is incompatible with mbox 
output format.\n");
return 1;
}
+
format = &format_mbox;
break;
 case NOTMUCH_FORMAT_RAW:
@@ -1087,6 +1088,11 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
return 1;
 }
 
+/* if format=mbox then we can not output excluded messages as
+ * there is no way to make the exclude flag available */
+if (format_sel == NOTMUCH_FORMAT_MBOX)
+   notmuch_query_set_omit_excluded_messages (query, TRUE);
+
 /* If a single message is requested we do not use search_excludes. */
 if (params.part >= 0)
ret = do_show_single (ctx, query, format, ¶ms);
-- 
1.7.2.3

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


[Patch v7 10/13] man: update manpage for notmuch-show --no-exclude option

2012-03-01 Thread Mark Walters
---
 man/man1/notmuch-show.1 |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/man/man1/notmuch-show.1 b/man/man1/notmuch-show.1
index 4c5db94..d75d971 100644
--- a/man/man1/notmuch-show.1
+++ b/man/man1/notmuch-show.1
@@ -128,6 +128,13 @@ multipart/encrypted part will be replaced by the decrypted
 content.
 .RE
 
+.RS 4
+.TP 4
+.B \-\-no-exclude
+
+Do not exclude the messages matching search.exclude_tags in the config file.
+.RE
+
 A common use of
 .B notmuch show
 is to display a single thread of email messages. For this, use a
-- 
1.7.2.3

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


[Patch v7 08/13] cli: Make notmuch-show respect excludes.

2012-03-01 Thread Mark Walters
This adds the excludes to notmuch-show.c. We do not exclude when only
a single message (or part) is requested. notmuch-show will output the
exclude information when either text or json format is requested. As
this changes the output from notmuch-show it breaks many tests (in a
trivial and expected fashion).
---
 notmuch-show.c |   25 +
 1 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index 6a171a4..8c0b925 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -143,9 +143,10 @@ format_message_json (const void *ctx, notmuch_message_t 
*message)
 date = notmuch_message_get_date (message);
 relative_date = notmuch_time_relative_date (ctx, date);
 
-printf ("\"id\": %s, \"match\": %s, \"filename\": %s, \"timestamp\": %ld, 
\"date_relative\": \"%s\", \"tags\": [",
+printf ("\"id\": %s, \"match\": %s, \"excluded\": %s, \"filename\": %s, 
\"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [",
json_quote_str (ctx_quote, notmuch_message_get_message_id 
(message)),
notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? 
"true" : "false",
+   notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? 
"true" : "false",
json_quote_str (ctx_quote, notmuch_message_get_filename (message)),
date, relative_date);
 
@@ -579,11 +580,12 @@ format_part_text (const void *ctx, mime_node_t *node,
notmuch_message_t *message = node->envelope_file;
 
part_type = "message";
-   printf ("\f%s{ id:%s depth:%d match:%d filename:%s\n",
+   printf ("\f%s{ id:%s depth:%d match:%d excluded:%d filename:%s\n",
part_type,
notmuch_message_get_message_id (message),
indent,
-   notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH),
+   notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) 
? 1 : 0,
+   notmuch_message_get_flag (message, 
NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? 1 : 0,
notmuch_message_get_filename (message));
 } else {
GMimeContentDisposition *disposition = 
g_mime_object_get_content_disposition (meta);
@@ -984,6 +986,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused 
(char *argv[]))
 notmuch_show_params_t params = { .part = -1 };
 int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
 notmuch_bool_t verify = FALSE;
+notmuch_bool_t no_exclude = FALSE;
 
 notmuch_opt_desc_t options[] = {
{ NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',
@@ -996,6 +999,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused 
(char *argv[]))
{ NOTMUCH_OPT_BOOLEAN, ¶ms.entire_thread, "entire-thread", 't', 0 },
{ NOTMUCH_OPT_BOOLEAN, ¶ms.decrypt, "decrypt", 'd', 0 },
{ NOTMUCH_OPT_BOOLEAN, &verify, "verify", 'v', 0 },
+   { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'n', 0 },
{ 0, 0, 0, 0, 0 }
 };
 
@@ -1083,10 +1087,23 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
return 1;
 }
 
+/* If a single message is requested we do not use search_excludes. */
 if (params.part >= 0)
ret = do_show_single (ctx, query, format, ¶ms);
-else
+else {
+   if (!no_exclude) {
+   const char **search_exclude_tags;
+   size_t search_exclude_tags_length;
+   unsigned int i;
+
+   search_exclude_tags = notmuch_config_get_search_exclude_tags
+   (config, &search_exclude_tags_length);
+   for (i = 0; i < search_exclude_tags_length; i++)
+   notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
+   }
ret = do_show (ctx, query, format, ¶ms);
+}
+
 
 notmuch_query_destroy (query);
 notmuch_database_close (notmuch);
-- 
1.7.2.3

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


[Patch v7 07/13] test: update search test to reflect exclude flag

2012-03-01 Thread Mark Walters
notmuch-search.c now returns all matching threads even if it the
match is a search.tag_excluded message (but with a mark indicating
this). Update the test to reflect this.
---
 test/search |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/test/search b/test/search
index 3da5d17..081f60c 100755
--- a/test/search
+++ b/test/search
@@ -136,7 +136,8 @@ generate_message '[subject]="Deleted"'
 notmuch new > /dev/null
 notmuch tag +deleted id:$gen_msg_id
 output=$(notmuch search subject:deleted | notmuch_search_sanitize)
-test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; 
Not deleted (inbox unread)"
+test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; 
Not deleted (inbox unread)
+thread:XXX   2001-01-05 [0/1] Notmuch Test Suite; Deleted (deleted inbox 
unread)"
 
 test_begin_subtest "Exclude \"deleted\" messages from search, overridden"
 output=$(notmuch search subject:deleted and tag:deleted | 
notmuch_search_sanitize)
-- 
1.7.2.3

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


[Patch v7 06/13] lib: Add the exclude flag to notmuch_query_search_threads

2012-03-01 Thread Mark Walters
Add the NOTMUCH_MESSAGE_FLAG_EXCLUDED flag to
notmuch_query_search_threads. Implemented by inspecting the tags
directly in _notmuch_thread_create/_thread_add_message rather than as
a Xapian query for speed reasons.

Note notmuch_thread_get_matched_messages now returns the number of
non-excluded matching messages. This API is not totally desirable but
fixing it means breaking binary compatibility so we delay that.
---
 lib/notmuch-private.h |7 +--
 lib/notmuch.h |6 --
 lib/query.cc  |1 +
 lib/thread.cc |   18 +++---
 4 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index e791bb0..ea836f7 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -148,6 +148,8 @@ typedef enum _notmuch_private_status {
 
 typedef struct _notmuch_doc_id_set notmuch_doc_id_set_t;
 
+typedef struct _notmuch_string_list notmuch_string_list_t;
+
 /* database.cc */
 
 /* Lookup a prefix value by name.
@@ -216,6 +218,7 @@ _notmuch_thread_create (void *ctx,
notmuch_database_t *notmuch,
unsigned int seed_doc_id,
notmuch_doc_id_set_t *match_set,
+   notmuch_string_list_t *excluded_terms,
notmuch_sort_t sort);
 
 /* message.cc */
@@ -459,11 +462,11 @@ typedef struct _notmuch_string_node {
 struct _notmuch_string_node *next;
 } notmuch_string_node_t;
 
-typedef struct visible _notmuch_string_list {
+struct visible _notmuch_string_list {
 int length;
 notmuch_string_node_t *head;
 notmuch_string_node_t **tail;
-} notmuch_string_list_t;
+};
 
 notmuch_string_list_t *
 _notmuch_string_list_create (const void *ctx);
diff --git a/lib/notmuch.h b/lib/notmuch.h
index f75afae..babd208 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -672,8 +672,10 @@ notmuch_thread_get_toplevel_messages (notmuch_thread_t 
*thread);
 /* Get the number of messages in 'thread' that matched the search.
  *
  * This count includes only the messages in this thread that were
- * matched by the search from which the thread was created. Contrast
- * with notmuch_thread_get_total_messages() .
+ * matched by the search from which the thread was created and were
+ * not excluded by any exclude tags passed in with the query (see
+ * notmuch_query_add_tag_exclude). Contrast with
+ * notmuch_thread_get_total_messages() .
  */
 int
 notmuch_thread_get_matched_messages (notmuch_thread_t *thread);
diff --git a/lib/query.cc b/lib/query.cc
index ef2a11f..ab18fbc 100644
--- a/lib/query.cc
+++ b/lib/query.cc
@@ -475,6 +475,7 @@ notmuch_threads_get (notmuch_threads_t *threads)
   threads->query->notmuch,
   doc_id,
   &threads->match_set,
+  threads->query->exclude_terms,
   threads->query->sort);
 }
 
diff --git a/lib/thread.cc b/lib/thread.cc
index 0435ee6..e976d64 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -214,7 +214,8 @@ _thread_cleanup_author (notmuch_thread_t *thread,
  */
 static void
 _thread_add_message (notmuch_thread_t *thread,
-notmuch_message_t *message)
+notmuch_message_t *message,
+notmuch_string_list_t *exclude_terms)
 {
 notmuch_tags_t *tags;
 const char *tag;
@@ -262,6 +263,15 @@ _thread_add_message (notmuch_thread_t *thread,
 notmuch_tags_move_to_next (tags))
 {
tag = notmuch_tags_get (tags);
+   /* Mark excluded messages. */
+   for (notmuch_string_node_t *term = exclude_terms->head; term;
+term = term->next) {
+   /* We ignore initial 'K'. */
+   if (strcmp(tag, (term->string + 1)) == 0) {
+   notmuch_message_set_flag (message, 
NOTMUCH_MESSAGE_FLAG_EXCLUDED, TRUE);
+   break;
+   }
+   }
g_hash_table_insert (thread->tags, xstrdup (tag), NULL);
 }
 }
@@ -321,7 +331,8 @@ _thread_add_matched_message (notmuch_thread_t *thread,
_thread_set_subject_from_message (thread, message);
 }
 
-thread->matched_messages++;
+if (!notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED))
+   thread->matched_messages++;
 
 if (g_hash_table_lookup_extended (thread->message_hash,
notmuch_message_get_message_id (message), NULL,
@@ -392,6 +403,7 @@ _notmuch_thread_create (void *ctx,
notmuch_database_t *notmuch,
unsigned int seed_doc_id,
notmuch_doc_id_set_t *match_set,
+   notmuch_string_list_t *exclude_terms,
notmuch_sort_t sort)
 {
 notmuch_thread_t *thread;
@@ -467,7 +479,7 @@ _notmuch_thread_create (void *ctx,
if (doc_id == seed_doc_id)
message = seed_message;
 
-   _thread_add_message (

[Patch v7 05/13] lib: Make notmuch_query_search_messages set the exclude flag

2012-03-01 Thread Mark Walters
Add a flag NOTMUCH_MESSAGE_FLAG_EXCLUDED which is set by
notmuch_query_search_messages for excluded messages. Also add an
option omit_excluded_messages to the search that we do not want the
excludes at all.

This exclude flag will be added to notmuch_query_search threads in the
next patch.
---
 lib/notmuch-private.h |1 +
 lib/notmuch.h |   10 +++-
 lib/query.cc  |   59 -
 3 files changed, 63 insertions(+), 7 deletions(-)

diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index 7bf153e..e791bb0 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -401,6 +401,7 @@ typedef struct _notmuch_message_list {
  */
 struct visible _notmuch_messages {
 notmuch_bool_t is_of_list_type;
+notmuch_doc_id_set_t *excluded_doc_ids;
 notmuch_message_node_t *iterator;
 };
 
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 7929fe7..f75afae 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -449,6 +449,13 @@ typedef enum {
 const char *
 notmuch_query_get_query_string (notmuch_query_t *query);
 
+/* Specify whether to results should omit the excluded results rather
+ * than just marking them excluded. This is useful for passing a
+ * notmuch_messages_t not containing the excluded messages to other
+ * functions. */
+void
+notmuch_query_set_omit_excluded_messages (notmuch_query_t *query, 
notmuch_bool_t omit);
+
 /* Specify the sorting desired for this query. */
 void
 notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort);
@@ -895,7 +902,8 @@ notmuch_message_get_filenames (notmuch_message_t *message);
 
 /* Message flags */
 typedef enum _notmuch_message_flag {
-NOTMUCH_MESSAGE_FLAG_MATCH
+NOTMUCH_MESSAGE_FLAG_MATCH,
+NOTMUCH_MESSAGE_FLAG_EXCLUDED
 } notmuch_message_flag_t;
 
 /* Get a value of a flag for the email corresponding to 'message'. */
diff --git a/lib/query.cc b/lib/query.cc
index c25b301..ef2a11f 100644
--- a/lib/query.cc
+++ b/lib/query.cc
@@ -28,6 +28,7 @@ struct _notmuch_query {
 const char *query_string;
 notmuch_sort_t sort;
 notmuch_string_list_t *exclude_terms;
+notmuch_bool_t omit_excluded_messages;
 };
 
 typedef struct _notmuch_mset_messages {
@@ -57,6 +58,12 @@ struct visible _notmuch_threads {
 notmuch_doc_id_set_t match_set;
 };
 
+/* We need this in the message functions so forward declare. */
+static notmuch_bool_t
+_notmuch_doc_id_set_init (void *ctx,
+ notmuch_doc_id_set_t *doc_ids,
+ GArray *arr);
+
 notmuch_query_t *
 notmuch_query_create (notmuch_database_t *notmuch,
  const char *query_string)
@@ -79,6 +86,8 @@ notmuch_query_create (notmuch_database_t *notmuch,
 
 query->exclude_terms = _notmuch_string_list_create (query);
 
+query->omit_excluded_messages = FALSE;
+
 return query;
 }
 
@@ -89,6 +98,12 @@ notmuch_query_get_query_string (notmuch_query_t *query)
 }
 
 void
+notmuch_query_set_omit_excluded_messages (notmuch_query_t *query, 
notmuch_bool_t omit)
+{
+query->omit_excluded_messages = omit;
+}
+
+void
 notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort)
 {
 query->sort = sort;
@@ -124,8 +139,9 @@ _notmuch_messages_destructor (notmuch_mset_messages_t 
*messages)
 
 /* Return a query that matches messages with the excluded tags
  * registered with query.  Any tags that explicitly appear in xquery
- * will not be excluded. The caller of this function has to combine
- * the returned query appropriately.*/
+ * will not be excluded, and will be removed from the list of exclude
+ * tags.  The caller of this function has to combine the returned
+ * query appropriately.*/
 static Xapian::Query
 _notmuch_exclude_tags (notmuch_query_t *query, Xapian::Query xquery)
 {
@@ -142,6 +158,8 @@ _notmuch_exclude_tags (notmuch_query_t *query, 
Xapian::Query xquery)
if (it == end)
exclude_query = Xapian::Query (Xapian::Query::OP_OR,
exclude_query, Xapian::Query 
(term->string));
+   else
+   term->string = talloc_strdup (query, "");
 }
 return exclude_query;
 }
@@ -173,6 +191,7 @@ notmuch_query_search_messages (notmuch_query_t *query)
   "mail"));
Xapian::Query string_query, final_query, exclude_query;
Xapian::MSet mset;
+   Xapian::MSetIterator iterator;
unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN |
  Xapian::QueryParser::FLAG_PHRASE |
  Xapian::QueryParser::FLAG_LOVEHATE |
@@ -190,11 +209,35 @@ notmuch_query_search_messages (notmuch_query_t *query)
final_query = Xapian::Query (Xapian::Query::OP_AND,
 mail_query, string_query);
}
+   messages->base.excluded_doc_ids = NULL;
+
+   if (query->exclude_terms) {
+   exclude_query = _notmuch_exclude_tags (query, final_query)

[Patch v7 04/13] lib: Rearrange the exclude code in query.cc

2012-03-01 Thread Mark Walters
Slightly refactor the exclude code to give the callers access to the
exclude query itself. There should be no functional change.
---
 lib/query.cc |   29 +++--
 1 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/lib/query.cc b/lib/query.cc
index 0b36602..c25b301 100644
--- a/lib/query.cc
+++ b/lib/query.cc
@@ -122,12 +122,15 @@ _notmuch_messages_destructor (notmuch_mset_messages_t 
*messages)
 return 0;
 }
 
-/* Return a query that does not match messages with the excluded tags
- * registered with the query.  Any tags that explicitly appear in
- * xquery will not be excluded. */
+/* Return a query that matches messages with the excluded tags
+ * registered with query.  Any tags that explicitly appear in xquery
+ * will not be excluded. The caller of this function has to combine
+ * the returned query appropriately.*/
 static Xapian::Query
 _notmuch_exclude_tags (notmuch_query_t *query, Xapian::Query xquery)
 {
+Xapian::Query exclude_query = Xapian::Query::MatchNothing;
+
 for (notmuch_string_node_t *term = query->exclude_terms->head; term;
 term = term->next) {
Xapian::TermIterator it = xquery.get_terms_begin ();
@@ -137,10 +140,10 @@ _notmuch_exclude_tags (notmuch_query_t *query, 
Xapian::Query xquery)
break;
}
if (it == end)
-   xquery = Xapian::Query (Xapian::Query::OP_AND_NOT,
-   xquery, Xapian::Query (term->string));
+   exclude_query = Xapian::Query (Xapian::Query::OP_OR,
+   exclude_query, Xapian::Query 
(term->string));
 }
-return xquery;
+return exclude_query;
 }
 
 notmuch_messages_t *
@@ -168,7 +171,7 @@ notmuch_query_search_messages (notmuch_query_t *query)
Xapian::Query mail_query (talloc_asprintf (query, "%s%s",
   _find_prefix ("type"),
   "mail"));
-   Xapian::Query string_query, final_query;
+   Xapian::Query string_query, final_query, exclude_query;
Xapian::MSet mset;
unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN |
  Xapian::QueryParser::FLAG_PHRASE |
@@ -188,7 +191,10 @@ notmuch_query_search_messages (notmuch_query_t *query)
 mail_query, string_query);
}
 
-   final_query = _notmuch_exclude_tags (query, final_query);
+   exclude_query = _notmuch_exclude_tags (query, final_query);
+
+   final_query = Xapian::Query (Xapian::Query::OP_AND_NOT,
+final_query, exclude_query);
 
enquire.set_weighting_scheme (Xapian::BoolWeight());
 
@@ -449,7 +455,7 @@ notmuch_query_count_messages (notmuch_query_t *query)
Xapian::Query mail_query (talloc_asprintf (query, "%s%s",
   _find_prefix ("type"),
   "mail"));
-   Xapian::Query string_query, final_query;
+   Xapian::Query string_query, final_query, exclude_query;
Xapian::MSet mset;
unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN |
  Xapian::QueryParser::FLAG_PHRASE |
@@ -469,7 +475,10 @@ notmuch_query_count_messages (notmuch_query_t *query)
 mail_query, string_query);
}
 
-   final_query = _notmuch_exclude_tags (query, final_query);
+   exclude_query = _notmuch_exclude_tags (query, final_query);
+
+   final_query = Xapian::Query (Xapian::Query::OP_AND_NOT,
+final_query, exclude_query);
 
enquire.set_weighting_scheme(Xapian::BoolWeight());
enquire.set_docid_order(Xapian::Enquire::ASCENDING);
-- 
1.7.2.3

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


[Patch v7 03/13] test: add tests for new cli --no-exclude option

2012-03-01 Thread Mark Walters
The tests test the new --no-exclude option to search and count.
There were no existing tests for the exclude behaviour for count so
added these too.
---
 test/count  |   21 +
 test/search |5 +
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/test/count b/test/count
index 300b171..976fff1 100755
--- a/test/count
+++ b/test/count
@@ -37,4 +37,25 @@ test_expect_equal \
 "0" \
 "`notmuch count --output=threads ${SEARCH}`"
 
+test_begin_subtest "count excluding \"deleted\" messages"
+notmuch config set search.exclude_tags = deleted
+generate_message '[subject]="Not deleted"'
+generate_message '[subject]="Another not deleted"'
+generate_message '[subject]="Deleted"'
+notmuch new > /dev/null
+notmuch tag +deleted id:$gen_msg_id
+test_expect_equal \
+"2" \
+"`notmuch count subject:deleted`"
+
+test_begin_subtest "count \"deleted\" messages, exclude overridden"
+test_expect_equal \
+"1" \
+"`notmuch count subject:deleted and tag:deleted`"
+
+test_begin_subtest "count \"deleted\" messages, with --no-exclude"
+test_expect_equal \
+"3" \
+"`notmuch count --no-exclude subject:deleted`"
+
 test_done
diff --git a/test/search b/test/search
index 414be35..3da5d17 100755
--- a/test/search
+++ b/test/search
@@ -148,6 +148,11 @@ output=$(notmuch search subject:deleted | 
notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; 
Not deleted (inbox unread)
 thread:XXX   2001-01-05 [1/2] Notmuch Test Suite; Not deleted reply (deleted 
inbox unread)"
 
+test_begin_subtest "Don't exclude \"deleted\" messages when --no-exclude 
specified"
+output=$(notmuch search --no-exclude subject:deleted | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; 
Not deleted (inbox unread)
+thread:XXX   2001-01-05 [2/2] Notmuch Test Suite; Deleted (deleted inbox 
unread)"
+
 test_begin_subtest "Don't exclude \"deleted\" messages from search if not 
configured"
 notmuch config set search.exclude_tags
 output=$(notmuch search subject:deleted | notmuch_search_sanitize)
-- 
1.7.2.3

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


[Patch v7 02/13] cli: Add --no-exclude to the man pages for search and count

2012-03-01 Thread Mark Walters
---
 man/man1/notmuch-count.1  |7 +++
 man/man1/notmuch-search.1 |7 +++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/man/man1/notmuch-count.1 b/man/man1/notmuch-count.1
index 0d0ab5d..805a8ae 100644
--- a/man/man1/notmuch-count.1
+++ b/man/man1/notmuch-count.1
@@ -38,6 +38,13 @@ Output the number of matching messages. This is the default.
 Output the number of matching threads.
 .RE
 .RE
+
+.RS 4
+.TP 4
+.BR \-\-no\-exclude
+
+Do not exclude the messages matching search.exclude_tags in the config file.
+.RE
 .RE
 .RE
 
diff --git a/man/man1/notmuch-search.1 b/man/man1/notmuch-search.1
index 19d85df..8426aa3 100644
--- a/man/man1/notmuch-search.1
+++ b/man/man1/notmuch-search.1
@@ -112,6 +112,13 @@ result from the end.
 Limit the number of displayed results to N.
 .RE
 
+.RS 4
+.TP 4
+.BR \-\-no\-exclude
+
+Do not exclude the messages matching search.exclude_tags in the config file.
+.RE
+
 .SH SEE ALSO
 
 \fBnotmuch\fR(1), \fBnotmuch-config\fR(1), \fBnotmuch-count\fR(1),
-- 
1.7.2.3

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


[Patch v7 01/13] cli: add --no-exclude option to count and search.

2012-03-01 Thread Mark Walters
This option turns off the exclusion so all matching messages are
returned. We do not need to add this to notmuch-show as that does not
(yet) exclude.
---
 notmuch-count.c  |   17 +++--
 notmuch-search.c |   17 +++--
 2 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/notmuch-count.c b/notmuch-count.c
index 63459fb..5364507 100644
--- a/notmuch-count.c
+++ b/notmuch-count.c
@@ -35,8 +35,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
 char *query_str;
 int opt_index;
 int output = OUTPUT_MESSAGES;
-const char **search_exclude_tags;
-size_t search_exclude_tags_length;
+notmuch_bool_t no_exclude = FALSE;
 unsigned int i;
 
 notmuch_opt_desc_t options[] = {
@@ -44,6 +43,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
  (notmuch_keyword_t []){ { "threads", OUTPUT_THREADS },
  { "messages", OUTPUT_MESSAGES },
  { 0, 0 } } },
+   { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 },
{ 0, 0, 0, 0, 0 }
 };
 
@@ -78,10 +78,15 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
return 1;
 }
 
-search_exclude_tags = notmuch_config_get_search_exclude_tags
-   (config, &search_exclude_tags_length);
-for (i = 0; i < search_exclude_tags_length; i++)
-   notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
+if (!no_exclude) {
+   const char **search_exclude_tags;
+   size_t search_exclude_tags_length;
+
+   search_exclude_tags = notmuch_config_get_search_exclude_tags
+   (config, &search_exclude_tags_length);
+   for (i = 0; i < search_exclude_tags_length; i++)
+   notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
+}
 
 switch (output) {
 case OUTPUT_MESSAGES:
diff --git a/notmuch-search.c b/notmuch-search.c
index 92ce38a..6d6c0e6 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -426,8 +426,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
 output_t output = OUTPUT_SUMMARY;
 int offset = 0;
 int limit = -1; /* unlimited */
-const char **search_exclude_tags;
-size_t search_exclude_tags_length;
+notmuch_bool_t no_exclude = FALSE;
 unsigned int i;
 
 enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT }
@@ -449,6 +448,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
  { "files", OUTPUT_FILES },
  { "tags", OUTPUT_TAGS },
  { 0, 0 } } },
+   { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 },
{ NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 },
{ NOTMUCH_OPT_INT, &limit, "limit", 'L', 0  },
{ 0, 0, 0, 0, 0 }
@@ -496,10 +496,15 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
 
 notmuch_query_set_sort (query, sort);
 
-search_exclude_tags = notmuch_config_get_search_exclude_tags
-   (config, &search_exclude_tags_length);
-for (i = 0; i < search_exclude_tags_length; i++)
-   notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
+if (!no_exclude) {
+   const char **search_exclude_tags;
+   size_t search_exclude_tags_length;
+
+   search_exclude_tags = notmuch_config_get_search_exclude_tags
+   (config, &search_exclude_tags_length);
+   for (i = 0; i < search_exclude_tags_length; i++)
+   notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
+}
 
 switch (output) {
 default:
-- 
1.7.2.3

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


[Patch v7 00/13] Add NOTMUCH_MESSAGE_FLAG_EXCLUDED flag

2012-03-01 Thread Mark Walters
This is essentially the same as
id:"1330157204-26094-1-git-send-email-markwalters1...@gmail.com" but
has been rebased against master. The changes are to patch 12/13 for
notmuch-show.el (which was posted as a followup to the previous series)
and to the tests (patch 9/13) which changed in Austin's JSON show
rewrite.

Best wishes

Mark

Mark Walters (13):
  cli: add --no-exclude option to count and search.
  cli: Add --no-exclude to the man pages for search and count
  test: add tests for new cli --no-exclude option
  lib: Rearrange the exclude code in query.cc
  lib: Make notmuch_query_search_messages set the exclude flag
  lib: Add the exclude flag to notmuch_query_search_threads
  test: update search test to reflect exclude flag
  cli: Make notmuch-show respect excludes.
  test: update tests to reflect the exclude flag
  man: update manpage for notmuch-show --no-exclude option
  cli: omit excluded messages in results where appropriate.
  emacs: show: recognize the exclude flag.
  emacs: notmuch.el ignore excluded matches

 emacs/notmuch-show.el |   36 -
 emacs/notmuch.el  |   22 +++--
 lib/notmuch-private.h |8 +++-
 lib/notmuch.h |   16 +++--
 lib/query.cc  |   77 +++--
 lib/thread.cc |   18 +--
 man/man1/notmuch-count.1  |7 
 man/man1/notmuch-search.1 |7 
 man/man1/notmuch-show.1   |7 
 notmuch-count.c   |   19 +++---
 notmuch-search.c  |   26 ---
 notmuch-show.c|   31 --
 test/count|   21 
 test/crypto   |9 +-
 test/encoding |2 +-
 test/json |6 ++--
 test/maildir-sync |1 +
 test/multipart|6 ++--
 test/search   |8 -
 test/thread-naming|   16 +-
 20 files changed, 273 insertions(+), 70 deletions(-)

-- 
1.7.2.3

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


[PATCH] emacs: Mention race condition safety in user visible documentation

2012-03-01 Thread David Bremner
On Thu, 01 Mar 2012 14:21:26 -0400, David Bremner  wrote:
> On Thu, 01 Mar 2012 18:13:27 +0100, Pieter Praet  wrote:
> > Something like this might help save you some time:
> > (assuming you'd rather not leave Emacs to apply patches)
> 
> Thanks, I already have a one line git alias ;).
> 

err, in the interests of completeness

[alias]
nmam = "!f() { notmuch show --format=raw $1 | git am -; }; f"

d


[PATCH] emacs: Mention race condition safety in user visible documentation

2012-03-01 Thread David Bremner
On Thu, 01 Mar 2012 18:13:27 +0100, Pieter Praet  wrote:
> Something like this might help save you some time:
> (assuming you'd rather not leave Emacs to apply patches)

Thanks, I already have a one line git alias ;).

d


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

2012-03-01 Thread Mark Walters
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.
> ---
>  emacs/notmuch-hello.el |   20 ++--
>  1 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> index aad373d..e9caade 100644
> --- a/emacs/notmuch-hello.el
> +++ b/emacs/notmuch-hello.el
> @@ -695,16 +695,16 @@ Supports the following entries in OPTIONS as a plist:
>   (notmuch-hello-update))
>"hide"))
>  (widget-insert "\n")
> -(let (target-pos
> -   (searches (apply 'notmuch-hello-query-counts query-alist options)))
> -  (when (and (not is-hidden)
> -(or (not (plist-get options :hide-if-empty))
> -   searches))
> - (widget-insert "\n")
> - (setq target-pos
> -   (notmuch-hello-insert-buttons searches))
> - (indent-rigidly start (point) notmuch-hello-indent)
> - target-pos
> +(let (target-pos)
> +  (when (not is-hidden)
> + (let ((searches (apply 'notmuch-hello-query-counts query-alist 
> options)))
> +   (when (or (not (plist-get options :hide-if-empty))
> + searches)
> + (widget-insert "\n")
> + (setq target-pos
> +   (notmuch-hello-insert-buttons searches))
> + (indent-rigidly start (point) notmuch-hello-indent
> +  target-pos)))
>  
>  (defun notmuch-hello-insert-tags-section (&optional title &rest options)
>"Insert a section displaying all tags with message counts.


This looks fine to me and does speed things up when the "All tags"
section is hidden (are there other sections I can hide?)

Best wishes

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


Re: Internal error on line 296 of mime-node.c

2012-03-01 Thread Austin Clements
Quoth David Bremner on Mar 01 at  5:39 pm:
> 
> In the current master (4fa77d031) I get a sort-of double crash on the 
> attached message.
> 
> The internal error on line 296 is reached, indicating some kind of bug,
> but then the G_OBJECT_TYPE crashes becase parent->part is null.
> 
> The message is probably crap, I created it from another "real" message
> from some business that causes the same problem.
> 
> (gdb) bt
> #0  0x00416850 in mime_node_child (parent=0x8425fa0, child=0)
> at mime-node.c:296
> #1  0x004137f1 in format_part_json (ctx=0x8425f10, node=0x8425fa0, 
> first=1) at notmuch-show.c:669
> #2  0x00413e54 in format_part_json_entry (ctx=0x8425f10, 
> node=0x8425fa0, indent=0, params=0x7ff000470) at notmuch-show.c:758
> #3  0x00413f0f in show_message (ctx=0x8367680, format=0x6327e0, 
> message=
> 0x83e9830, indent=0, params=0x7ff000470) at notmuch-show.c:776
> #4  0x00414165 in show_messages (ctx=0x8367680, format=0x6327e0, 
> messages=0x8425e70, indent=0, params=0x7ff000470) at notmuch-show.c:835
> #5  0x004145f5 in do_show (ctx=0x8367680, query=0x83b36b0, 
> format=0x6327e0, params=0x7ff000470) at notmuch-show.c:956
> #6  0x00414ba7 in notmuch_show_command (ctx=0x8367680, argc=3, 
> argv=0x7ff000660) at notmuch-show.c:1089
> #7  0x0040a9fe in main (argc=4, argv=0x7ff000658) at notmuch.c:294
> (gdb) print *parent
> $3 = {part = 0x0, envelope_file = 0x83e9830, envelope_part = 0x0, 
>   nchildren = 1, parent = 0x0, part_num = 0, decrypt_attempted = 0, 
>   decrypt_success = 0, verify_attempted = 0, sig_list = 0x0, ctx = 0x8426090, 
>   decrypted_child = 0x0, next_child = 0, next_part_num = 1}

For the record, this is because g_mime_parser_construct_message in
mime_node_open is returning NULL.  mime_node_open should be checking
for this as well as errors from the other GMime functions it calls.
(Unfortunately, there appears to be no way to ask GMime *what* went
wrong; it just returns NULL.)
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] NEWS: add entry for `notmuch-show-stash-mlarchive-link{, -and-go}'

2012-03-01 Thread Pieter Praet
---
 NEWS |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/NEWS b/NEWS
index 8fb2f24..a739914 100644
--- a/NEWS
+++ b/NEWS
@@ -80,6 +80,12 @@ Attachment buttons can be used to view or save attachments.
   button 1 saves the attachment but this is customisable (option
   Notmuch Show Part Button Default Action).
 
+New functions
+
+  `notmuch-show-stash-mlarchive-link{,-and-go}' allow stashing and
+  optionally visiting a URI to the current message at one of a number
+  of Mailing List Archives.
+
 Library changes
 ---
 
-- 
1.7.8.1

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


Internal error on line 296 of mime-node.c

2012-03-01 Thread David Bremner

In the current master (4fa77d031) I get a sort-of double crash on the 
attached message.

The internal error on line 296 is reached, indicating some kind of bug,
but then the G_OBJECT_TYPE crashes becase parent->part is null.

The message is probably crap, I created it from another "real" message
from some business that causes the same problem.

(gdb) bt
#0  0x00416850 in mime_node_child (parent=0x8425fa0, child=0)
at mime-node.c:296
#1  0x004137f1 in format_part_json (ctx=0x8425f10, node=0x8425fa0, 
first=1) at notmuch-show.c:669
#2  0x00413e54 in format_part_json_entry (ctx=0x8425f10, 
node=0x8425fa0, indent=0, params=0x7ff000470) at notmuch-show.c:758
#3  0x00413f0f in show_message (ctx=0x8367680, format=0x6327e0, message=
0x83e9830, indent=0, params=0x7ff000470) at notmuch-show.c:776
#4  0x00414165 in show_messages (ctx=0x8367680, format=0x6327e0, 
messages=0x8425e70, indent=0, params=0x7ff000470) at notmuch-show.c:835
#5  0x004145f5 in do_show (ctx=0x8367680, query=0x83b36b0, 
format=0x6327e0, params=0x7ff000470) at notmuch-show.c:956
#6  0x00414ba7 in notmuch_show_command (ctx=0x8367680, argc=3, 
argv=0x7ff000660) at notmuch-show.c:1089
#7  0x0040a9fe in main (argc=4, argv=0x7ff000658) at notmuch.c:294
(gdb) print *parent
$3 = {part = 0x0, envelope_file = 0x83e9830, envelope_part = 0x0, 
  nchildren = 1, parent = 0x0, part_num = 0, decrypt_attempted = 0, 
  decrypt_success = 0, verify_attempted = 0, sig_list = 0x0, ctx = 0x8426090, 
  decrypted_child = 0x0, next_child = 0, next_part_num = 1}

--- Begin Message ---
quoted printable stuff.

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


Re: plans for 0.12

2012-03-01 Thread Pieter Praet
On Sat, 25 Feb 2012 10:27:02 -0400, David Bremner  wrote:
> 
> I would like to start a freeze (i.e. merge master to release) for 0.12
> within the next week, say March 1 for an easy to remember date.
> 
> If you have suggestions for things that "should really go in", feel free
> to follow up. The main point here is bug fixes, or features which are
> there in a kindof half baked way.
>

Some of the features added/refactored post-0.11.1 don't have any
test coverage yet.  Should they, before wrapping up 0.12 ?
(not a rhetorical question, I'm genuinely asking for opinions)


Anyways, I've taken the liberty of tagging the following patches '0.12':

- test: emacs: toggle processing of cryptographic MIME parts in `notmuch-show'
  - id:"1329684990-12504-2-git-send-email-pie...@praet.org"
- test: emacs: toggle eliding of non-matching messages in `notmuch-show'
  - id:"1329684990-12504-3-git-send-email-pie...@praet.org"
- test: emacs: toggle thread content indentation in `notmuch-show'
  - id:"1329684990-12504-4-git-send-email-pie...@praet.org"

- test: emacs: new tests "notmuch-show: {add,remove} multiple tags {to,from} 
single message"
  - id:"1330122640-18895-2-git-send-email-pie...@praet.org"
- test: emacs: new test "notmuch-show: change tags of all messages in current 
buffer"
  - id:"1330122640-18895-3-git-send-email-pie...@praet.org"

- test: emacs: new test "notmuch-search: change tags of all matching messages"
  - id:"1329936867-923-1-git-send-email-pie...@praet.org"

If applied in that order, the last one needs to be applied with the
`--3way' option, which results in an easily resolved merge conflict,
but if needed, I'll rebase it.


> Bug fix wise, I know about 
>   
>   id:"1330068983-4483-1-git-send-email-sojk...@fel.cvut.cz"
> 
> This could use some review.
> 
> It has also been some chatter that either (the next iteration of)
> 
>id:"1329296619-7463-1-git-send-email-markwalters1...@gmail.com" 
> 
> Should go in, or we should revert amdragon's exclude stuff. 
> 
> I don't have strong feelings either way, except it is somewhat late in
> the day for a large(ish) and complicated series.
> 
> There are several other patch series that look ready from a review point
> of view, but I'd rather have them pushed earlier in the release cycle
> (or at least I don't see a hurry). For example 
> 
>id:"1329490088-8323-2-git-send-email-dmitry.kuroch...@gmail.com"
>id:"1329697590-7404-1-git-send-email-amdra...@mit.edu"
> 
> My (tentative) plan is to push those once I have branched for release.
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


Peace

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


Re: [PATCH] Actually close the xapian database in notmuch_database_close

2012-03-01 Thread Olly Betts
On Thu, Mar 01, 2012 at 07:59:30AM +0100, Justus Winter wrote:
> Olly wrote:
> >It is hard to say if calling close() is actually useful here from just
> >seeing the patch.
> 
> Huh? I provided a test case...

I only saw the part of the patch Austin quoted in the mail he cc-ed to
me.

> Quoting Austin Clements (2012-02-29 23:17:54)
> >Also, since close could throw an exception, it should get wrapped in a
> >try/catch like flush currently is.
> 
> My interpretation of [0] was that Xapian::Database::close() does not
> throw any exceptions.

Sadly there's not full documentation of exceptions which can be thrown 
by a particular method.

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


Re: [RFC] Smart replying

2012-03-01 Thread Nicolás Reynolds
On Thu, 01 Mar 2012 18:02:09 -0300, Nicolás Reynolds  
wrote:
> 
> I'll try it, it's been bothering me also on reply-to-list lists :)
> 
> (There's also C-c C-l but it doesn't work for me)

he.

https://www.gnu.org/software/emacs/manual/html_mono/message.html#Mailing-Lists


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


[PATCH] Actually close the xapian database in notmuch_database_close

2012-03-01 Thread Austin Clements
Quoth Justus Winter on Mar 01 at  7:59 am:
> Quoting Austin Clements (2012-02-29 23:17:54)
> >Quoth Olly Betts on Feb 29 at  9:19 pm:
> >> On Wed, Feb 29, 2012 at 10:48:33AM -0500, Austin Clements wrote:
> >> > Quoth Justus Winter on Feb 29 at 10:19 am:
> >> > > Formerly the xapian database object was deleted and closed in its
> >> > > destructor once the object was garbage collected. Explicitly call
> >> > > close() so that the database and the associated lock is released
> >> > > immediately.
> >> > 
> >> > Interesting.  Is this a bug in Xapian?  According to the docs,
> >> > ~Database is supposed to close the database (if there are no other
> >> > copies, which there shouldn't be), so this should be redundant with
> >> > the delete notmuch->xapian_db a few lines down, but your experience
> >> > obviously suggests that it isn't and I can't find the code path in
> >> > Xapian that would close it in the destructor.
> >> 
> >> Most Xapian API classes (including Database and WritableDatabase) just
> >> hold a reference-counted pointer, and so it's the destructor of the
> >> reference-counted object which closes the database.  If "PIMPL" means
> >> anything to you, that's what we have here.
> >> 
> >> Some other API classes objects (such as PostingIterator) internally hold
> >> a reference to the database they are using, so calling close()
> >> explicitly is useful if you don't want to have to worry about such
> >> objects still existing and holding onto references which keep the
> >> database open.
> >
> >Makes sense.  Justus, could you add a comment to your patch explaining
> >that we explicitly close the database because there may be other
> >objects with references to it that would keep it open?
> 
> I thought I did, I'm not a native speaker though, so if you want to
> reword my message be my guest ;)

Sorry, I meant a code comment.  Perhaps something like,

/* Many Xapian objects (and thus notmuch objects) hold references to
 * the database, so merely deleting the database may not suffice to
 * close it.  Thus, we explicitly close it here. */

> >Also, since close could throw an exception, it should get wrapped in a
> >try/catch like flush currently is.
> 
> My interpretation of [0] was that Xapian::Database::close() does not
> throw any exceptions.

Olly mentioned on IRC that it can throw an exception (because, for
example, close calls flush).

> Cheers,
> Justus
> 
> 0: 
> http://xapian.org/docs/apidoc/html/classXapian_1_1Database.html#59f5f8b137723dcaaabdbdccbc0cf1eb


Re: [RFC] Smart replying

2012-03-01 Thread Nicolás Reynolds
On Thu, 01 Mar 2012 15:35:13 -0500, Jesse Rosenthal  wrote:
> Dear All,
> 
> I know that folks recently got done haggling over reply bindings, but
> there's something I've been using for a little while, and I was curious
> about whether it's something people would be interested in. Forgive me
> if this functionality was already discussed and I missed it.
> 
> The problem is that I often forget to reply-all to list mails and write
> out half a message, and then have to cut and paste. So, as usual, my
> solution is to try and have emacs figure it out for me.
> 
> Pretty simple: have a variable `reply-all-list'. If an address in the
> `To' or `CC' fields is in that list, 'r' replies-all. If not, it
> replies-sender. CTRL-r (or whatever) forces `reply-sender', on the rare
> occasion I want to take a conversation offline.
> 
> The nice thing about this is, if `reply-all-list' is nil, then it acts
> as normal, so it wouldn't make a difference to most users.
> 
> The implementation that's been sitting in my .emacs is below. I'm not
> offering it as a patch, because I don't quite understand the current
> relation of notmuch-show.el and notmuch-mua.el. 
> 
> If people are interested, though, I could make it into a patch. And, if
> not, I hope it's a snippet that someone finds useful.

I'll try it, it's been bothering me also on reply-to-list lists :)

(There's also C-c C-l but it doesn't work for me)


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


[RFC] Smart replying

2012-03-01 Thread Jesse Rosenthal
Dear All,

I know that folks recently got done haggling over reply bindings, but
there's something I've been using for a little while, and I was curious
about whether it's something people would be interested in. Forgive me
if this functionality was already discussed and I missed it.

The problem is that I often forget to reply-all to list mails and write
out half a message, and then have to cut and paste. So, as usual, my
solution is to try and have emacs figure it out for me.

Pretty simple: have a variable `reply-all-list'. If an address in the
`To' or `CC' fields is in that list, 'r' replies-all. If not, it
replies-sender. CTRL-r (or whatever) forces `reply-sender', on the rare
occasion I want to take a conversation offline.

The nice thing about this is, if `reply-all-list' is nil, then it acts
as normal, so it wouldn't make a difference to most users.

The implementation that's been sitting in my .emacs is below. I'm not
offering it as a patch, because I don't quite understand the current
relation of notmuch-show.el and notmuch-mua.el. 

If people are interested, though, I could make it into a patch. And, if
not, I hope it's a snippet that someone finds useful.

Best,
Jesse

~
(defvar reply-all-list nil)

(defun jkr/notmuch-show-check-to-cc (address-list)
  (let* ((to-cc-list (apply 'append 
(mapcar 'mail-header-parse-addresses 
(list (notmuch-show-get-to) 
  (notmuch-show-get-cc)
 (to-cc-addr-list (mapcar 'car to-cc-list)))
(intersection address-list to-cc-addr-list :test 'equal)))

(defun jkr/notmuch-show-smart-reply-all ()
  "Reply to sender, unless address is on reply-all list"
  (interactive)
  (if (jkr/notmuch-show-check-to-cc reply-all-list)
  (notmuch-show-reply)
(notmuch-show-reply-sender)))

(defun jkr/notmuch-show-force-reply-sender ()
  "Reply to sender only, regardless of reply-all list"
  (interactive)
  (notmuch-show-reply-sender))

(define-key notmuch-show-mode-map "r" 'jkr/notmuch-show-smart-reply-all)

(define-key notmuch-show-mode-map "\C-r" 'jkr/notmuch-show-force-reply-sender)

; (setq reply-all-list '("notmuch@notmuchmail.org"))


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


[PATCH v2] emacs: Pass a copy to notmuch-saved-search-sort-function

2012-03-01 Thread Daniel Schoepe
notmuch-saved-search-sort-function might destructively modify its
input (`sort' does that, for instance), so it should not be given
notmuch-saved-searches directly.
---
 emacs/notmuch-hello.el |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index aad373d..e089290 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -575,7 +575,10 @@ Complete list of currently available key bindings:
   (let ((searches (notmuch-hello-query-counts
   (if notmuch-saved-search-sort-function
   (funcall notmuch-saved-search-sort-function
-   notmuch-saved-searches)
+   ;; Use a copy, since the sorting
+   ;; function may have side effects,
+   ;; e.g. if it just `sort's the input.
+   (copy-sequence notmuch-saved-searches))
 notmuch-saved-searches)
   :show-empty-searches notmuch-show-empty-saved-searches))
found-target-pos)
-- 
1.7.9.1

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


[PATCH v2 0/1] emacs: Pass a copy to notmuch-saved-search-sort-function

2012-03-01 Thread Daniel Schoepe
I overlooked that copy-seq is from cl.el. This version uses copy-sequence 
instead.

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


[PATCH 0/5] Disable search.exclude_tags for 0.12

2012-03-01 Thread Tomi Ollila
On Wed, 29 Feb 2012 18:13:04 +, Mark Walters  
wrote:
> As requested by David (Bremner) on irc here is a patch series
> disabling the search.exclude_tags feature as a temporary measure for
> the 0.12 release.
> 
> There are two options:
> 
> The first is to disable the addition of the new search.exclude_tags
> item to the config file and stop setup from asking for it.
> 
> The second is to do the above and also disable the functionality in
> notmuch-search.c and notmuch-count.c.

I first thought that "full" revert would be best in order to reduce
confusion, but now I'd vote for just disabling the addition but leaving
the feature there.
This way the bleeding edge users who already use this feature could
test the release branch version in daily use. As the feature is there
some brave future 0.12 users can start experimenting with it earlyer
and potentially provide feedback. Finally, as the delta is smaller
there is less management activities to be done.
Marking the feature as 'experimental' in namual page & other documentation
would be good idea.

Tomi

> The idea is that this these are minimal (and thus relatively safe)
> changes to make.  With the first option users who have configured the
> functionality for themselves (while using git) will still get the
> feature: it just won't be pushed on users. With the second option the
> festure will be completely disabled.
> 
> Essentially patch 1 implements the first option and patch 4 the second
> option.  The other patches in the series update the NEWS file, the man
> page and the tests. If going for the first option then I would suggest
> applying (in addition to patch 1) patch 2 (NEWS) and probably patch 3
> (man) although as the functionality remains the latter is not strictly
> necessary. The test patch (patch 5) is not necessary as the tests set
> search.exclude_tags directly.
> 
> If going for the second option then all the patches are needed.
> 
> Finally, please could someone familiar with the config/setup code
> check patch 1 carefully. I have never looked at that code before and
> could easily have done something stupid.
> 
> Best wishes
> 
> Mark
> 
> Mark Walters (5):
>   config: disable addition of exclude tags for 0.12
>   NEWS: revert NEWS item for exclude tags for 0.12
>   man: remove search.exclude_tags from notmuch-config.1 for 0.12
>   cli: temporarily remove exclude tag support for 0.12
>   test: mark exclude tests broken for 0.12
> 
>  NEWS  |   18 --
>  man/man1/notmuch-config.1 |8 
>  notmuch-config.c  |3 +--
>  notmuch-count.c   |8 +---
>  notmuch-search.c  |8 +---
>  notmuch-setup.c   |   19 +--
>  test/search   |2 ++
>  7 files changed, 6 insertions(+), 60 deletions(-)
> 
> -- 
> 1.7.2.3
> 
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
> 


[alot] howto multiple selections

2012-03-01 Thread Philippe LeCavalier

Hi.

Is it possible to select more than one msg in search-mode to retag?

Phil


Re: [PATCH] emacs: Mention race condition safety in user visible documentation

2012-03-01 Thread David Bremner
On Thu, 01 Mar 2012 14:21:26 -0400, David Bremner  wrote:
> On Thu, 01 Mar 2012 18:13:27 +0100, Pieter Praet  wrote:
> > Something like this might help save you some time:
> > (assuming you'd rather not leave Emacs to apply patches)
> 
> Thanks, I already have a one line git alias ;).
> 

err, in the interests of completeness

[alias]
nmam = "!f() { notmuch show --format=raw $1 | git am -; }; f"

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


Re: [PATCH] emacs: Mention race condition safety in user visible documentation

2012-03-01 Thread David Bremner
On Thu, 01 Mar 2012 18:13:27 +0100, Pieter Praet  wrote:
> Something like this might help save you some time:
> (assuming you'd rather not leave Emacs to apply patches)

Thanks, I already have a one line git alias ;).

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


Re: [PATCH] Actually close the xapian database in notmuch_database_close

2012-03-01 Thread Austin Clements
Quoth Justus Winter on Mar 01 at  7:59 am:
> Quoting Austin Clements (2012-02-29 23:17:54)
> >Quoth Olly Betts on Feb 29 at  9:19 pm:
> >> On Wed, Feb 29, 2012 at 10:48:33AM -0500, Austin Clements wrote:
> >> > Quoth Justus Winter on Feb 29 at 10:19 am:
> >> > > Formerly the xapian database object was deleted and closed in its
> >> > > destructor once the object was garbage collected. Explicitly call
> >> > > close() so that the database and the associated lock is released
> >> > > immediately.
> >> > 
> >> > Interesting.  Is this a bug in Xapian?  According to the docs,
> >> > ~Database is supposed to close the database (if there are no other
> >> > copies, which there shouldn't be), so this should be redundant with
> >> > the delete notmuch->xapian_db a few lines down, but your experience
> >> > obviously suggests that it isn't and I can't find the code path in
> >> > Xapian that would close it in the destructor.
> >> 
> >> Most Xapian API classes (including Database and WritableDatabase) just
> >> hold a reference-counted pointer, and so it's the destructor of the
> >> reference-counted object which closes the database.  If "PIMPL" means
> >> anything to you, that's what we have here.
> >> 
> >> Some other API classes objects (such as PostingIterator) internally hold
> >> a reference to the database they are using, so calling close()
> >> explicitly is useful if you don't want to have to worry about such
> >> objects still existing and holding onto references which keep the
> >> database open.
> >
> >Makes sense.  Justus, could you add a comment to your patch explaining
> >that we explicitly close the database because there may be other
> >objects with references to it that would keep it open?
> 
> I thought I did, I'm not a native speaker though, so if you want to
> reword my message be my guest ;)

Sorry, I meant a code comment.  Perhaps something like,

/* Many Xapian objects (and thus notmuch objects) hold references to
 * the database, so merely deleting the database may not suffice to
 * close it.  Thus, we explicitly close it here. */

> >Also, since close could throw an exception, it should get wrapped in a
> >try/catch like flush currently is.
> 
> My interpretation of [0] was that Xapian::Database::close() does not
> throw any exceptions.

Olly mentioned on IRC that it can throw an exception (because, for
example, close calls flush).

> Cheers,
> Justus
> 
> 0: 
> http://xapian.org/docs/apidoc/html/classXapian_1_1Database.html#59f5f8b137723dcaaabdbdccbc0cf1eb
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Replacing my name/email with "me" (or similar) in author lists

2012-03-01 Thread Jesse Rosenthal
On Wed, 29 Feb 2012 17:47:46 -0500, Austin Clements  wrote:
> > On Wed, 29 Feb 2012 10:36:57 -0500, Austin Clements  
> > wrote:
> > > What if the output of search (say, specifically the JSON format)
> > > included information on each message in the thread such as the
> > > 'message' production from devel/schemata minus the body field?  
> [...]
> I was suggesting just using notmuch_thread_get_toplevel_messages in
> search (essentially, mixing a bit of show into search).  No library
> changes necessary.

In any event, I'd really love to see something like this. Because I work
remotely, over an ssh tunnel, and it's nice to have various scripts
local. However, things like notmuch_addresses and my recipient_search
script have to run on the server, since they need bindings-level access
to the database. If I could get the JSON you describe over the wire, I
could probably just make one remote call and then confine my local work
to JSON parsing. A niche need, I realize.


Re: [PATCH] emacs: Mention race condition safety in user visible documentation

2012-03-01 Thread Pieter Praet
On Wed, 29 Feb 2012 22:49:46 -0400, David Bremner  wrote:
> On Tue, 21 Feb 2012 10:15:08 +0100, Michal Sojka  wrote:
> > -- >8 --
> > Subject: [PATCH] emacs: Clarify description of thread manipulating functions
> > 
> > It is not clear whether the term "thread" refers to the thread in the
> > database or to the thread currently shown in a buffer. Those two
> > meanings may refer to different sets of messages, e.g. when a new email
> > is added to the database while the buffer shows the state before the new
> > email arrived.
> 
> (will be) pushed.
> 
> For future reference, it's slightly inconvenient for me to use "git am
> -c". Not a big deal, but a sequence of those would make me cry...
>

Something like this might help save you some time:
(assuming you'd rather not leave Emacs to apply patches)

  #+begin_src emacs-lisp
(defvar praet/projects
  '(("notmuch@notmuchmail.org" . "~/src/dev/notmuch/")
("f...@bar.org" . "~/src/dev/foobar/")))

(defun praet/notmuch-patch-apply (&optional all-open)
  "Apply a patch from `notmuch-show-mode' using git-am(1).
If ALL-OPEN is non-nil, (try to) apply all open messages."
  (interactive "P")
  (let* ((msg (notmuch-show-get-message-id t))
 (rcpts (concat (notmuch-show-get-to)
(notmuch-show-get-cc)))
 (projs (loop for project in praet/projects
  if (string-match (car project) rcpts)
  collect (cdr project)))
 (proj (if (> (length projs) 1)
   (ido-completing-read "Apply in: " projs)
 (car projs)))
 (cmd "git am --abort ; git am")
 (optargs '("--signoff" "--3way" "--scissors"))
 (args (read-string "Args: " nil '(optargs . 0
(message "Applying in '%s': '%s' (using '%s %s')"
 proj msg cmd args)
(notmuch-show-pipe-message all-open
 (concat "(cd " proj " && (" cmd " " args ")" ")"

(define-key notmuch-show-mode-map (kbd "C-c p a")
  'praet/notmuch-patch-apply)
  #+end_src


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


Peace

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


Re: [PATCH v6 1/3] emacs: `notmuch-show-get-message-id': optionally return Message-Id sans prefix

2012-03-01 Thread Pieter Praet
On Wed, 29 Feb 2012 08:19:34 -0400, David Bremner  wrote:
> On Tue, 28 Feb 2012 19:40:04 +0100, Pieter Praet  wrote:
> > 
> > Though I couldn't help but notice (it's a curse...) that patch #3
> > seems to have gained an extra space in its commit message subject:
> > 
> >   Original (id:"1329684627-10708-4-git-send-email-pie...@praet.org"):
> > emacs: add `notmuch-show-stash-mlarchive-link{,-and-go}'
> >   ^
> 
> I don't have any applypatch-msg hook. I am using 
>   "notmuch show --format=raw $messageid | git am -" to
> apply the patch.  
> 
> I looked at the file on disk, and something is wrapping the subject
> there.  Perhaps somebody's unwrapping code is buggy? I'm not sure what's
> at fault here; [...]

TL;DR:  Doesn't seem like there's much we can do about it...


According to RFC 2822 section 2.2.3 [1], header fields should be folded
by inserting a CRLF right before the last whitespace char before the
line exceeds 78 characters, and when a field contains comma-separated
values (which is somewhat applicable in this case), it should be folded
by inserting a CRLF right after a comma.

Now, the issue is that unfolding is accomplished by simply removing any
CRLF that is immediately followed by a whitespace char:

If the subject headers of those patches were folded by simply inserting
a CRLF, they couldn't possibly be unfolded again as there wouldn't be a
whitespace char right after the CRLF, so Mailman seems to have helpfully
inserted a tab...


Here's one of those patches at a number of archives:

- http://notmuchmail.org/pipermail/notmuch/2012/009575.html
- http://mid.gmane.org/1329684627-10708-4-git-send-email-pie...@praet.org
- 
http://mail-archive.com/search?l=mid&q=1329684627-10708-4-git-send-email-pie...@praet.org

As you can see (in the source of those pages), both Pipermail and Gmane
unfold the subject header by simply removing the line break, and at The
Mail Archive, the tab is also replaced by a space.  I assume the latter
also happens in gmime ?


So, I guess I'll just have to learn to live with it... :)


> [...] maybe you could experiment with applying the the patches
> from the list and let me know if e.g. going from files is better than
> using "notmuch show --format=raw".
>

Based on my (admittedly very superficial) analysis of the problem,
that won't do us any good wrt this issue, unfortunately...

But it *would* buy us a (slight) performance increase, so if/when my
patch to `notmuch-show-mapc' [2] goes in, we might want to consider
making `notmuch-show-pipe-message' use `notmuch-show-get-filename'
instead of `notmuch-show-get-message-{id,ids-for-open-messages}'.


> d
> 
> 


Peace

-- 
Pieter

[1] http://tools.ietf.org/html/rfc2822.html#section-2.2.3
[2] id:"1330122640-18895-5-git-send-email-pie...@praet.org"
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[alot] nottoomuch-addresses.sh config

2012-03-01 Thread Patrick Totzke

Sorry, forgot to finish this *caught*:

>> should I be creating a key binding to invoke the completion command?
>No: this is used when you are prompted for recipients when composing a mail:
>Hit `m`, select your account if you have more than one, and when the prompt 
>says
>"To:" you 

... use `tab` to complete names/addresses using the command from your config.

If you're using abook (http://abook.sourceforge.net/) consider using the
type "abook" address books directly instead of "shellcommand":
http://alot.readthedocs.org/en/latest/configuration/index.html#contacts-completion

best,
/p


[RFC PATCH 00/13] Modular message store code

2012-03-01 Thread Ethan Glasser-Camp
On 02/15/2012 07:56 PM, Mark Walters wrote:
> Obviously I have not looked at the patch set in detail yet but I have a
> quick question. Since you are allowing more general filenames anyway
> couldn't you encode mailstore in filename? Eg
> mbox://some-path[:byte-postion], or "imap://server..."
>
> This would allow lots of different types of mailstore to be used
> concurrently, and would push all the mailstore knowledge down into the
> file handling functions and away from the callers of file handling
> functions.
>
> Of course there may be lots of good reasons why this doesn't work.
>
Hi, sorry for the delay.

As far as I can tell, currently notmuch stores message filenames in 
Xapian as paths relative to the top-level maildir. I think this is done 
so that the maildir can be moved and, if the .notmuch-config is updated, 
mails are correctly detected and not duplicated. This would be 
especially important when you're talking about changing IMAP servers or 
CouchDB instances.

If I wanted to preserve this feature, the URIs stored as filenames would 
have to be relative to a given mailstore. For example, 
maildir://maildir-1/INBOX/some-filename could mean the file 
INBOX/some-filename in a maildir at /home/user/some-maildir. But then 
this raises the two following issues:

- How does information about mailstores -- for example, that maildir-1 
=> /home/user/some-maildir -- enter the library? Do we stick all of that 
information in notmuch_database_t, and then pass a reference to it in 
notmuch_message_file_open? Perhaps a global 
notmuch_mailstore_register(name, parameters..) registry? Or maybe a 
notmuch_mailstore_info type that gets passed around similarly to the 
mailstore type in this patch set?

- Do we mandate that all the filenames in the database be updated or do 
we just assume non-URI-style filenames are relative to some "default" 
mailstore?

All of which is a fancy way of saying I haven't had the time to write 
the code necessary to explore this idea but think something like it will 
be necessary to support the obviously-valuable feature of multiple 
mailstores. Depending on your answer to the first question, I guess the 
patch series might or might not be a useful starting point.

Thanks for your feedback,

Ethan



[PATCH v10 1/2] emacs: User-defined sections in notmuch-hello

2012-03-01 Thread David Bremner

Pushed, finally. Thanks for both of your hard work on this.

d


[PATCH v2 2/8] show: Convert JSON format to the new self-recursive style

2012-03-01 Thread David Bremner
On Sun, 19 Feb 2012 19:26:24 -0500, Austin Clements  wrote:
> As before, this is all code movement and a smidgen of glue.  This
> moves the existing JSON formatter code into one self-recursive
> function, but doesn't change any of the logic to take advantage of the
> new structure.

Pushed the remainder of the series.

d


[PATCH] Actually close the xapian database in notmuch_database_close

2012-03-01 Thread Justus Winter
Hi :)

Olly wrote:
>It is hard to say if calling close() is actually useful here from just
>seeing the patch.

Huh? I provided a test case...

Quoting Austin Clements (2012-02-29 23:17:54)
>Quoth Olly Betts on Feb 29 at  9:19 pm:
>> On Wed, Feb 29, 2012 at 10:48:33AM -0500, Austin Clements wrote:
>> > Quoth Justus Winter on Feb 29 at 10:19 am:
>> > > Formerly the xapian database object was deleted and closed in its
>> > > destructor once the object was garbage collected. Explicitly call
>> > > close() so that the database and the associated lock is released
>> > > immediately.
>> > 
>> > Interesting.  Is this a bug in Xapian?  According to the docs,
>> > ~Database is supposed to close the database (if there are no other
>> > copies, which there shouldn't be), so this should be redundant with
>> > the delete notmuch->xapian_db a few lines down, but your experience
>> > obviously suggests that it isn't and I can't find the code path in
>> > Xapian that would close it in the destructor.
>> 
>> Most Xapian API classes (including Database and WritableDatabase) just
>> hold a reference-counted pointer, and so it's the destructor of the
>> reference-counted object which closes the database.  If "PIMPL" means
>> anything to you, that's what we have here.
>> 
>> Some other API classes objects (such as PostingIterator) internally hold
>> a reference to the database they are using, so calling close()
>> explicitly is useful if you don't want to have to worry about such
>> objects still existing and holding onto references which keep the
>> database open.
>
>Makes sense.  Justus, could you add a comment to your patch explaining
>that we explicitly close the database because there may be other
>objects with references to it that would keep it open?

I thought I did, I'm not a native speaker though, so if you want to
reword my message be my guest ;)

>Also, since close could throw an exception, it should get wrapped in a
>try/catch like flush currently is.

My interpretation of [0] was that Xapian::Database::close() does not
throw any exceptions.

Cheers,
Justus

0: 
http://xapian.org/docs/apidoc/html/classXapian_1_1Database.html#59f5f8b137723dcaaabdbdccbc0cf1eb


[alot] howto multiple selections

2012-03-01 Thread Philippe LeCavalier

Hi.

Is it possible to select more than one msg in search-mode to retag?

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


Re: [PATCH v10 1/2] emacs: User-defined sections in notmuch-hello

2012-03-01 Thread Dmitry Kurochkin
Hi Michal.

On Thu, 01 Mar 2012 15:57:32 +0100, Michal Sojka  wrote:
> On Thu, 01 Mar 2012, David Bremner wrote:
> > 
> > Pushed, finally. Thanks for both of your hard work on this.
> 
> Hi,
> 
> is anybody willing to review
> id:"1329603149-6047-1-git-send-email-sojk...@fel.cvut.cz"?

I plan to review it soon.

Regards,
  Dmitry

> I'd like to
> see it merged togetger with these patches as it makes my work with
> notmuch-hello much more pleasant. And others
> (id:"8762f7etfo@qmul.ac.uk") would probably like this patch too.
> 
> -Michal
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v10 1/2] emacs: User-defined sections in notmuch-hello

2012-03-01 Thread Michal Sojka
On Thu, 01 Mar 2012, David Bremner wrote:
> 
> Pushed, finally. Thanks for both of your hard work on this.

Hi,

is anybody willing to review
id:"1329603149-6047-1-git-send-email-sojk...@fel.cvut.cz"? I'd like to
see it merged togetger with these patches as it makes my work with
notmuch-hello much more pleasant. And others
(id:"8762f7etfo@qmul.ac.uk") would probably like this patch too.

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


[PATCH] emacs: Pass a copy to notmuch-saved-search-sort-function

2012-03-01 Thread Daniel Schoepe
notmuch-saved-search-sort-function might destructively modify its
input (`sort' does that, for instance), so it should not be given
notmuch-saved-searches directly.
---
 emacs/notmuch-hello.el |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index aad373d..b2b22df 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -575,7 +575,10 @@ Complete list of currently available key bindings:
   (let ((searches (notmuch-hello-query-counts
   (if notmuch-saved-search-sort-function
   (funcall notmuch-saved-search-sort-function
-   notmuch-saved-searches)
+   ;; Use a copy, since the sorting
+   ;; function may have side effects,
+   ;; e.g. if it just `sort's the input.
+   (copy-seq notmuch-saved-searches))
 notmuch-saved-searches)
   :show-empty-searches notmuch-show-empty-saved-searches))
found-target-pos)
-- 
1.7.9.1

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


[PATCH 0/1] emacs: Pass a copy to notmuch-saved-search-sort-function

2012-03-01 Thread Daniel Schoepe
As Jani discovered, `sort' modifies its input list, leading to deleted
saved searches when using notmuch-sort-saved-searches.

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


Re: Replacing my name/email with "me" (or similar) in author lists

2012-03-01 Thread Jesse Rosenthal
On Wed, 29 Feb 2012 17:47:46 -0500, Austin Clements  wrote:
> > On Wed, 29 Feb 2012 10:36:57 -0500, Austin Clements  
> > wrote:
> > > What if the output of search (say, specifically the JSON format)
> > > included information on each message in the thread such as the
> > > 'message' production from devel/schemata minus the body field?  
> [...]
> I was suggesting just using notmuch_thread_get_toplevel_messages in
> search (essentially, mixing a bit of show into search).  No library
> changes necessary.

In any event, I'd really love to see something like this. Because I work
remotely, over an ssh tunnel, and it's nice to have various scripts
local. However, things like notmuch_addresses and my recipient_search
script have to run on the server, since they need bindings-level access
to the database. If I could get the JSON you describe over the wire, I
could probably just make one remote call and then confine my local work
to JSON parsing. A niche need, I realize.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [RFC PATCH 00/13] Modular message store code

2012-03-01 Thread Ethan Glasser-Camp

On 02/15/2012 07:56 PM, Mark Walters wrote:

Obviously I have not looked at the patch set in detail yet but I have a
quick question. Since you are allowing more general filenames anyway
couldn't you encode mailstore in filename? Eg
mbox://some-path[:byte-postion], or "imap://server..."

This would allow lots of different types of mailstore to be used
concurrently, and would push all the mailstore knowledge down into the
file handling functions and away from the callers of file handling
functions.

Of course there may be lots of good reasons why this doesn't work.


Hi, sorry for the delay.

As far as I can tell, currently notmuch stores message filenames in 
Xapian as paths relative to the top-level maildir. I think this is done 
so that the maildir can be moved and, if the .notmuch-config is updated, 
mails are correctly detected and not duplicated. This would be 
especially important when you're talking about changing IMAP servers or 
CouchDB instances.


If I wanted to preserve this feature, the URIs stored as filenames would 
have to be relative to a given mailstore. For example, 
maildir://maildir-1/INBOX/some-filename could mean the file 
INBOX/some-filename in a maildir at /home/user/some-maildir. But then 
this raises the two following issues:


- How does information about mailstores -- for example, that maildir-1 
=> /home/user/some-maildir -- enter the library? Do we stick all of that 
information in notmuch_database_t, and then pass a reference to it in 
notmuch_message_file_open? Perhaps a global 
notmuch_mailstore_register(name, parameters..) registry? Or maybe a 
notmuch_mailstore_info type that gets passed around similarly to the 
mailstore type in this patch set?


- Do we mandate that all the filenames in the database be updated or do 
we just assume non-URI-style filenames are relative to some "default" 
mailstore?


All of which is a fancy way of saying I haven't had the time to write 
the code necessary to explore this idea but think something like it will 
be necessary to support the obviously-valuable feature of multiple 
mailstores. Depending on your answer to the first question, I guess the 
patch series might or might not be a useful starting point.


Thanks for your feedback,

Ethan

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


[PATCH 2/2] Spelling fix

2012-03-01 Thread Tomi Ollila
Retreive is spelled as r e t r i e v e .
---
 emacs/notmuch-crypto.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index e916d66..83e5d37 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -101,7 +101,7 @@ mode."
   (let ((keyid (concat "0x" (plist-get sigstatus :keyid
(setq label (concat "Unknown key ID " keyid " or unsupported 
algorithm"))
(setq button-action 'notmuch-crypto-sigstatus-error-callback)
-   (setq help-msg (concat "Click to retreive key ID " keyid " from 
keyserver and redisplay."
+   (setq help-msg (concat "Click to retrieve key ID " keyid " from 
keyserver and redisplay."
  ((string= status "bad")
   (let ((keyid (concat "0x" (plist-get sigstatus :keyid
(setq label (concat "Bad signature (claimed key ID " keyid ")"))
-- 
1.7.8.2

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


[PATCH 1/2] emacs: retain show buffer state after retrieving gpg key

2012-03-01 Thread Tomi Ollila
After retrieving gpg key retain show buffer state like in
all other operations (i.e. no other calls to notmuch-show-refresh-view
provides optional reset-state argument).
Emacs MUA keeps current message under cursor instead of going first
open message(possibly marking it read).
---
 emacs/notmuch-crypto.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index 94da325..e916d66 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -145,7 +145,7 @@ mode."
(insert "\n")
(call-process "gpg" nil t t "--list-keys" keyid))
   (recenter -1))
-(notmuch-show-refresh-view t)))
+(notmuch-show-refresh-view)))
 
 (defun notmuch-crypto-insert-encstatus-button (encstatus)
   (let* ((status (plist-get encstatus :status))
-- 
1.7.8.2

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


Re: [PATCH v10 1/2] emacs: User-defined sections in notmuch-hello

2012-03-01 Thread David Bremner

Pushed, finally. Thanks for both of your hard work on this.

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


Re: [PATCH v2 2/8] show: Convert JSON format to the new self-recursive style

2012-03-01 Thread David Bremner
On Sun, 19 Feb 2012 19:26:24 -0500, Austin Clements  wrote:
> As before, this is all code movement and a smidgen of glue.  This
> moves the existing JSON formatter code into one self-recursive
> function, but doesn't change any of the logic to take advantage of the
> new structure.

Pushed the remainder of the series.

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


Re: [alot] nottoomuch-addresses.sh config

2012-03-01 Thread Patrick Totzke

Sorry, forgot to finish this *caught*:

>> should I be creating a key binding to invoke the completion command?
>No: this is used when you are prompted for recipients when composing a mail:
>Hit `m`, select your account if you have more than one, and when the prompt 
>says
>"To:" you 

... use `tab` to complete names/addresses using the command from your config.

If you're using abook (http://abook.sourceforge.net/) consider using the
type "abook" address books directly instead of "shellcommand":
http://alot.readthedocs.org/en/latest/configuration/index.html#contacts-completion

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


Re: [PATCH 0/5] Disable search.exclude_tags for 0.12

2012-03-01 Thread Tomi Ollila
On Wed, 29 Feb 2012 18:13:04 +, Mark Walters  
wrote:
> As requested by David (Bremner) on irc here is a patch series
> disabling the search.exclude_tags feature as a temporary measure for
> the 0.12 release.
> 
> There are two options:
> 
> The first is to disable the addition of the new search.exclude_tags
> item to the config file and stop setup from asking for it.
> 
> The second is to do the above and also disable the functionality in
> notmuch-search.c and notmuch-count.c.

I first thought that "full" revert would be best in order to reduce
confusion, but now I'd vote for just disabling the addition but leaving
the feature there.
This way the bleeding edge users who already use this feature could
test the release branch version in daily use. As the feature is there
some brave future 0.12 users can start experimenting with it earlyer
and potentially provide feedback. Finally, as the delta is smaller
there is less management activities to be done.
Marking the feature as 'experimental' in namual page & other documentation
would be good idea.

Tomi

> The idea is that this these are minimal (and thus relatively safe)
> changes to make.  With the first option users who have configured the
> functionality for themselves (while using git) will still get the
> feature: it just won't be pushed on users. With the second option the
> festure will be completely disabled.
> 
> Essentially patch 1 implements the first option and patch 4 the second
> option.  The other patches in the series update the NEWS file, the man
> page and the tests. If going for the first option then I would suggest
> applying (in addition to patch 1) patch 2 (NEWS) and probably patch 3
> (man) although as the functionality remains the latter is not strictly
> necessary. The test patch (patch 5) is not necessary as the tests set
> search.exclude_tags directly.
> 
> If going for the second option then all the patches are needed.
> 
> Finally, please could someone familiar with the config/setup code
> check patch 1 carefully. I have never looked at that code before and
> could easily have done something stupid.
> 
> Best wishes
> 
> Mark
> 
> Mark Walters (5):
>   config: disable addition of exclude tags for 0.12
>   NEWS: revert NEWS item for exclude tags for 0.12
>   man: remove search.exclude_tags from notmuch-config.1 for 0.12
>   cli: temporarily remove exclude tag support for 0.12
>   test: mark exclude tests broken for 0.12
> 
>  NEWS  |   18 --
>  man/man1/notmuch-config.1 |8 
>  notmuch-config.c  |3 +--
>  notmuch-count.c   |8 +---
>  notmuch-search.c  |8 +---
>  notmuch-setup.c   |   19 +--
>  test/search   |2 ++
>  7 files changed, 6 insertions(+), 60 deletions(-)
> 
> -- 
> 1.7.2.3
> 
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
> 
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


  1   2   >