[PATCH 3/3] emacs: generalize notmuch-message-mark-replied
Renamed 'notmuch-message-mark-replied' to 'notmuch-message-mod-tags'. Previously (semi)hardcoded vars are now to be provided as arguments, allowing much more flexibility re autotagging in message-mode. Paving the way towards proper draft handling? Signed-off-by: Pieter Praet --- emacs/notmuch-message.el | 27 ++- 1 files changed, 18 insertions(+), 9 deletions(-) diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el index c8b19c3..6026740 100644 --- a/emacs/notmuch-message.el +++ b/emacs/notmuch-message.el @@ -22,6 +22,8 @@ (require 'message) (require 'notmuch-mua) +(defvar notmuch-message-parent nil) + (defcustom notmuch-message-replied-tags '("replied") "Tags to be automatically added to or removed from a message when it is replied to. Any tag in the list will be added to a replied message or, @@ -33,20 +35,27 @@ the \"inbox\" and \"todo\", you would set :type 'list :group 'notmuch) -(defun notmuch-message-mark-replied () - ;; get the in-reply-to header and parse it for the message id. - (let ((rep (mail-header-parse-addresses (message-field-value "In-Reply-To" -(when (and notmuch-message-replied-tags rep) - ;; add a "+" to any tag that is doesn't already begin with a "+" - ;; or "-" +(defun notmuch-message-mod-tags (msgid tagops) +(when (and msgid tagops) + ;; prepend operator-less tags with a "+" (let ((tags (mapcar '(lambda (str) (if (not (string-match "^[+-]" str)) (concat "+" str) str)) - notmuch-message-replied-tags))) + tagops))) (apply 'notmuch-call-notmuch-process "tag" - (append tags (list (concat "id:" (car (car rep nil)) + (append tags (list (concat "id:" msgid)) nil) + +(add-hook 'message-setup-hook + (lambda () +(set (make-local-variable 'notmuch-message-parent) + ;; get the in-reply-to header and parse it for the message id. + (car (car (mail-header-parse-addresses (message-field-value "In-Reply-To"))) + +(add-hook 'message-sent-hook + (lambda () +(notmuch-message-mod-tags notmuch-message-parent + notmuch-message-replied-tags))) -(add-hook 'message-sent-hook 'notmuch-message-mark-replied) (provide 'notmuch-message) -- 1.7.4.1
[PATCH 2/3] test: emacs: add subtest "Verify that 'replied' tag is added to reply's parent message."
Signed-off-by: Pieter Praet --- test/emacs |4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/test/emacs b/test/emacs index 18d8322..c0fba52 100755 --- a/test/emacs +++ b/test/emacs @@ -142,6 +142,10 @@ On Fri, 29 Mar 1974 10:00:00 -, Notmuch Test Suite /dev/null # update message count +output=$(notmuch search 'tag:replied' | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 1974-03-29 [1/2] Notmuch Test Suite; Testing message sent via SMTP (inbox replied)" test_begin_subtest "Save attachment from within emacs" echo "./attachment" | test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a at mail.gmail.com") (notmuch-show-save-attachments)' > /dev/null 2>&1 -- 1.7.4.1
[PATCH 1/3] test: emacs: add subtest "Send reply from within Emacs"
Renamed subtest "Reply within emacs" to "Compose reply in emacs" as it doesn't really "do" a reply, but rather populates a reply buffer and then princ's it. ... and couldn't possibly justify that without writing an actual reply test. Signed-off-by: Pieter Praet --- test/emacs | 33 - 1 files changed, 32 insertions(+), 1 deletions(-) diff --git a/test/emacs b/test/emacs index 3264bf2..18d8322 100755 --- a/test/emacs +++ b/test/emacs @@ -99,7 +99,7 @@ notmuch new > /dev/null output=$(notmuch search 'subject:"testing message sent via SMTP"' | notmuch_search_sanitize) test_expect_equal "$output" "thread:XXX 1974-03-29 [1/1] Notmuch Test Suite; Testing message sent via SMTP (inbox)" -test_begin_subtest "Reply within emacs" +test_begin_subtest "Compose reply in emacs" # We sed away everything before the ^From in the output to avoid getting # confused by messages such as "Parsing /home/cworth/.mailrc... done" output=$(test_emacs '(notmuch-search "subject:\"testing message sent via SMTP\"") (notmuch-test-wait) (notmuch-search-reply-to-thread) (princ (buffer-string))' | sed -ne '/^From/,$ p' | sed -e 's/^In-Reply-To: <.*>$/In-Reply-To: /') @@ -112,6 +112,37 @@ Fcc: $(pwd)/mail/sent On Fri, 29 Mar 1974 10:00:00 -, Notmuch Test Suite wrote: > This is a test that messages are sent via SMTP" + +test_begin_subtest "Send reply from within Emacs" +../smtp-dummy sent_message & +smtp_dummy_pid=$! + +test_emacs '(setq message-send-mail-function '\''message-smtpmail-send-it) (setq smtpmail-smtp-server "localhost") (setq smtpmail-smtp-service "25025") (notmuch-search "subject:\"testing message sent via SMTP\"") (notmuch-test-wait) (notmuch-search-reply-to-thread) (message-goto-to) (message-goto-body) (end-of-buffer) (newline) (insert "Reply to a message via Emacs with fake SMTP") (message-send-and-exit)' >/dev/null 2>&1 +wait ${smtp_dummy_pid} + +output=$(sed \ +-e s',^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' \ +-e s',^Message-ID: <.*>$,Message-ID: ,' \ +-e s',^In-Reply-To: <.*>$,In-Reply-To: ,' \ +-e s',^References: <.*>$,References: ,' \ +-e s',^Date: .*$,Date: Fri\, 29 Mar 1974 10:05:00 -,' < sent_message) +test_expect_equal "$output" "From: Notmuch Test Suite +To: user at example.com +Subject: Re: Testing message sent via SMTP +In-Reply-To: +References: +User-Agent: Notmuch/XXX Emacs/XXX +Date: Fri, 29 Mar 1974 10:05:00 - +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii + +On Fri, 29 Mar 1974 10:00:00 -, Notmuch Test Suite wrote: +> This is a test that messages are sent via SMTP + +Reply to a message via Emacs with fake SMTP" + + test_begin_subtest "Save attachment from within emacs" echo "./attachment" | test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a at mail.gmail.com") (notmuch-show-save-attachments)' > /dev/null 2>&1 output=$(cat attachment) -- 1.7.4.1
[PATCH] emacs: run notmuch-message-mark-replied on message-sent-hook, not message-send-hook
Parent message is tagged "replied" prematurely. Only do so when reply is *really* sent. (describe-variable 'message-send-hook) > Hook run before sending messages. > This hook is run quite early when sending. (describe-variable 'message-sent-hook) > Hook run after sending messages. Signed-off-by: Pieter Praet --- emacs/notmuch-message.el |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el index d5c96c2..c8b19c3 100644 --- a/emacs/notmuch-message.el +++ b/emacs/notmuch-message.el @@ -47,6 +47,6 @@ the \"inbox\" and \"todo\", you would set (apply 'notmuch-call-notmuch-process "tag" (append tags (list (concat "id:" (car (car rep nil)) -(add-hook 'message-send-hook 'notmuch-message-mark-replied) +(add-hook 'message-sent-hook 'notmuch-message-mark-replied) (provide 'notmuch-message) -- 1.7.4.1
[PATCH 4/4] test: add 'Emacs' prereq to 'emacs-large-search-buffer' tests
Signed-off-by: Pieter Praet --- test/emacs-large-search-buffer |9 +++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/test/emacs-large-search-buffer b/test/emacs-large-search-buffer index 2751a32..54b1827 100755 --- a/test/emacs-large-search-buffer +++ b/test/emacs-large-search-buffer @@ -2,6 +2,11 @@ test_description="Emacs with large search results buffer" . test-lib.sh +# Emacs is a prereq. +if test_expect_success "prereq: Emacs is present" "which emacs"; then +test_set_prereq EMACS +fi + x=xx # 10 x=$x$x$x$x$x$x$x$x$x$x # 100 x=$x$x$x$x$x$x$x$x$x # 900 @@ -23,11 +28,11 @@ expected="$(notmuch search '*' | sed -e 's/^thread:[0-9a-f]* //' -e 's/;//' -e End of search results." output=$(test_emacs '(notmuch-search "*") (notmuch-test-wait) (princ (buffer-string))' | sed -e s', *, ,g' -e 's/xxx*/[BLOB]/g') -test_expect_equal "$output" "$expected" +test_expect_equal EMACS "$output" "$expected" test_begin_subtest "Ensure that emacs doesn't drop error messages" output=$(test_emacs '(notmuch-search "--this-option-does-not-exist") (notmuch-test-wait) (princ (buffer-string))') -test_expect_equal "$output" "Error: Unexpected output from notmuch search: +test_expect_equal EMACS "$output" "Error: Unexpected output from notmuch search: Unrecognized option: --this-option-does-not-exist End of search results. (process returned 1)" -- 1.7.4.1
[PATCH 3/4] test: add 'Emacs' prereq to 'emacs' tests
Signed-off-by: Pieter Praet --- test/emacs | 40 +++- 1 files changed, 23 insertions(+), 17 deletions(-) diff --git a/test/emacs b/test/emacs index 3264bf2..011deac 100755 --- a/test/emacs +++ b/test/emacs @@ -2,6 +2,12 @@ test_description="emacs interface" . test-lib.sh +# Emacs is a prereq. +if test_expect_success "prereq: Emacs is present" "which emacs"; then +test_set_prereq EMACS +fi + + EXPECTED=../emacs.expected-output add_email_corpus @@ -9,64 +15,64 @@ add_email_corpus test_begin_subtest "Basic notmuch-hello view in emacs" output=$(test_emacs '(notmuch-hello) (princ (buffer-string))') expected=$(cat $EXPECTED/notmuch-hello) -test_expect_equal "$output" "$expected" +test_expect_equal EMACS "$output" "$expected" test_begin_subtest "Saved search with 0 results" output=$(test_emacs '(setq notmuch-show-empty-saved-searches t) (setq notmuch-saved-searches '\''(("inbox" . "tag:inbox") ("unread" . "tag:unread") ("empty" . "tag:doesnotexist"))) (notmuch-hello) (princ (buffer-string))') expected=$(cat $EXPECTED/notmuch-hello-with-empty) -test_expect_equal "$output" "$expected" +test_expect_equal EMACS "$output" "$expected" test_begin_subtest "No saved searches displayed (all with 0 results)" output=$(test_emacs '(setq notmuch-saved-searches '\''(("empty" . "tag:doesnotexist"))) (notmuch-hello) (princ (buffer-string))') expected=$(cat $EXPECTED/notmuch-hello-no-saved-searches) -test_expect_equal "$output" "$expected" +test_expect_equal EMACS "$output" "$expected" test_begin_subtest "Basic notmuch-search view in emacs" output=$(test_emacs '(notmuch-search "tag:inbox") (notmuch-test-wait) (princ (buffer-string))') expected=$(cat $EXPECTED/notmuch-search-tag-inbox) -test_expect_equal "$output" "$expected" +test_expect_equal EMACS "$output" "$expected" test_begin_subtest "Navigation of notmuch-hello to search results" output=$(test_emacs '(notmuch-hello) (goto-char (point-min)) (re-search-forward "inbox") (widget-button-press (point)) (notmuch-test-wait) (princ (buffer-string))') expected=$(cat $EXPECTED/notmuch-hello-view-inbox) -test_expect_equal "$output" "$expected" +test_expect_equal EMACS "$output" "$expected" test_begin_subtest "Basic notmuch-show view in emacs" maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165 at dottiness.seas.harvard.edu) output=$(test_emacs "(notmuch-show \"$maildir_storage_thread\") (princ (buffer-string))") expected=$(cat $EXPECTED/notmuch-show-thread-maildir-storage) -test_expect_equal "$output" "$expected" +test_expect_equal EMACS "$output" "$expected" test_begin_subtest "Navigation of notmuch-search to thread view" output=$(test_emacs '(notmuch-search "tag:inbox") (notmuch-test-wait) (goto-char (point-min)) (re-search-forward "Working with Maildir") (notmuch-search-show-thread) (notmuch-test-wait) (princ (buffer-string))') -test_expect_equal "$output" "$expected" +test_expect_equal EMACS "$output" "$expected" test_begin_subtest "Add tag from search view" os_x_darwin_thread=$(notmuch search --output=threads id:ddd65cda0911171950o4eea4389v86de9525e46052d3 at mail.gmail.com) test_emacs "(notmuch-search \"$os_x_darwin_thread\") (notmuch-test-wait) (notmuch-search-add-tag \"tag-from-search-view\")" output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize) -test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-search-view unread)" +test_expect_equal EMACS "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-search-view unread)" test_begin_subtest "Remove tag from search view" test_emacs "(notmuch-search \"$os_x_darwin_thread\") (notmuch-test-wait) (notmuch-search-remove-tag \"tag-from-search-view\")" output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize) -test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)" +test_expect_equal EMACS "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)" test_begin_subtest "Add tag from notmuch-show view" test_emacs "(notmuch-show \"$os_x_darwin_thread\") (notmuch-show-add-tag \"tag-from-show-view\")" output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize) -test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-show-view unread)" +test_expect_equal EMACS "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-show-view unread)" test_begin_subtest "Remove tag from notmuch-show view" test_emacs
[PATCH 2/4] test: add 'GPG' prereq to 'crypto' tests
Signed-off-by: Pieter Praet --- test/crypto | 30 ++ 1 files changed, 18 insertions(+), 12 deletions(-) diff --git a/test/crypto b/test/crypto index 961d035..c2f381c 100755 --- a/test/crypto +++ b/test/crypto @@ -7,6 +7,12 @@ test_description='PGP/MIME signature verification and decryption' . ./test-lib.sh +# GnuPG is a prereq. +if test_expect_success "prereq: GnuPG is present" "which gpg"; then +test_set_prereq GPG +fi + + add_gnupg_home () { local output @@ -31,7 +37,7 @@ FINGERPRINT=$(gpg --no-tty --list-secret-keys --with-colons --fingerprint | grep # although I can't figure out why add_email_corpus -test_expect_success 'emacs delivery of signed message' \ +test_expect_success GPG 'emacs delivery of signed message' \ 'emacs_deliver_message \ "test signed message 001" \ "This is a test signed message." \ @@ -66,7 +72,7 @@ expected='[[[{"id": "X", "content-type": "application/pgp-signature"}]} ]}, [' -test_expect_equal \ +test_expect_equal GPG \ "$output" \ "$expected" @@ -103,7 +109,7 @@ expected='[[[{"id": "X", "content-type": "application/pgp-signature"}]} ]}, [' -test_expect_equal \ +test_expect_equal GPG \ "$output" \ "$expected" @@ -139,7 +145,7 @@ expected='[[[{"id": "X", "content-type": "application/pgp-signature"}]} ]}, [' -test_expect_equal \ +test_expect_equal GPG \ "$output" \ "$expected" mv "${GNUPGHOME}"{.bak,} @@ -148,7 +154,7 @@ mv "${GNUPGHOME}"{.bak,} catOUTPUT -test_expect_equal_file OUTPUT TESTATTACHMENT +test_expect_equal_file GPG OUTPUT TESTATTACHMENT test_begin_subtest "decryption failure with missing key" mv "${GNUPGHOME}"{,.bak} @@ -224,12 +230,12 @@ expected='[[[{"id": "X", "content-type": "application/octet-stream"}]} ]}, [' -test_expect_equal \ +test_expect_equal GPG \ "$output" \ "$expected" mv "${GNUPGHOME}"{.bak,} -test_expect_success 'emacs delivery of encrypted/signed message' \ +test_expect_success GPG 'emacs delivery of encrypted/signed message' \ 'emacs_deliver_message \ "test encrypted message 002" \ "This is a test encrypted message." \ @@ -263,7 +269,7 @@ expected='[[[{"id": "X", "content-type": "text/plain", "content": "This is a test encrypted message.\n"}]}]}, [' -test_expect_equal \ +test_expect_equal GPG \ "$output" \ "$expected" @@ -275,7 +281,7 @@ Subject: Re: test encrypted message 002 On 01 Jan 2000 12:00:00 -, Notmuch Test Suite wrote: > This is a test encrypted message.' -test_expect_equal \ +test_expect_equal GPG \ "$output" \ "$expected" @@ -319,7 +325,7 @@ expected='[[[{"id": "X", "content-type": "application/pgp-signature"}]} ]}, [' -test_expect_equal \ +test_expect_equal GPG \ "$output" \ "$expected" -- 1.7.4.1
[PATCH 1/4] test: add 'GDB' prereq to 'atomicity' tests
Signed-off-by: Pieter Praet --- test/atomicity | 10 -- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/test/atomicity b/test/atomicity index cd58c4c..78280b2 100755 --- a/test/atomicity +++ b/test/atomicity @@ -7,6 +7,12 @@ test_description='atomicity' # final database contents should be the same regardless of when (or # if) it is killed and restarted. +# GDB is a prereq. +if test_expect_success "prereq: GDB is present" "which gdb"; then +test_set_prereq GDB +fi + + # Create a maildir structure to also stress flag synchronization mkdir $MAIL_DIR/cur mkdir $MAIL_DIR/new @@ -89,8 +95,8 @@ for ((i = 0; i < $outcount; i++)); do i=$(expr $end - 1) fi done -test_expect_equal "$(cat searchall)" "$(cat expectall)" +test_expect_equal GDB "$(cat searchall)" "$(cat expectall)" -test_expect_success "detected $outcount>10 abort points" "test $outcount -gt 10" +test_expect_success GDB "detected $outcount>10 abort points" "test $outcount -gt 10" test_done -- 1.7.4.1
[PATCH 0/4] set test prereqs (Emacs, GDB, GPG)
The atomicity tests were failing here because I didn't have GDB installed, so I've added it as a prereq. While I was at it, I "fixed" the crypto and emacs tests as well. Thank Austin for providing me with a hammer (I was using a brick) [1]. (!) Depends: - "[PATCH] test: Fix message when skipping test_expect_equal* tests" [2] - "[PATCH] test: Report test failures from test_expect_*" [3] Pieter Praet (4): test: add 'GDB' prereq to 'atomicity' tests test: add 'GPG' prereq to 'crypto' tests test: add 'Emacs' prereq to 'emacs' tests test: add 'Emacs' prereq to 'emacs-large-search-buffer' tests test/atomicity | 10 -- test/crypto| 30 ++ test/emacs | 40 +++- test/emacs-large-search-buffer |9 +++-- 4 files changed, 56 insertions(+), 33 deletions(-) -- 1.7.4.1 [1] id:"BANLkTi=iz6F+1-WQ5KDno6N-MF=dQeTbEA at mail.gmail.com" [2] id:"1305206080-17461-1-git-send-email-amdragon at mit.edu" [3] id:"1305206110-17511-1-git-send-email-amdragon at mit.edu"
[PATCH] test: do folder-based search with a single-term path after moving message
When moving mail to a different folder, there appear to be residual incorrect "folder:" terms. This test exposes an existing bug, so is currently failing. Signed-off-by: Pieter Praet --- test/search-by-folder |4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/test/search-by-folder b/test/search-by-folder index 162158c..62767fb 100755 --- a/test/search-by-folder +++ b/test/search-by-folder @@ -35,6 +35,10 @@ notmuch new output=$(notmuch search folder:bad/news | notmuch_search_sanitize) test_expect_equal "$output" "" +test_begin_subtest "After rename, old single-term path returns nothing" +output=$(notmuch search folder:news | notmuch_search_sanitize) +test_expect_equal_failure "$output" "" + test_begin_subtest "After rename, new path returns result" output=$(notmuch search folder:bad/olds | notmuch_search_sanitize) test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Bears (inbox unread)" -- 1.7.4.1
release-candidate/0.6
On Thu, 12 May 2011 15:36:43 -0700, Carl Worth wrote: > Does anyone want to attempt to fix up this first patch? (It doesn't > necessarily have to be David). Hi, Carl. I went through dme's multipart patch series and cleaned things up. I split up that first commit into a couple of separate ones, and then combined a couple of patches together and cherry-picked through the rest of the series to make the overall series a little cleaner. I also let out some stuff that was in the originally series (ie. extraneous json newlines). I then cherry-picked the entire rest of the release-candidate/0.6 branch on top of that. The result is the new release-candidate/0.6+mpmfix branch, which I have pushed to my repo. jamie.[!] [!] yes, it's been a year! -- next part -- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 835 bytes Desc: not available URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20110513/cd3cbe1b/attachment.pgp>
Re: release-candidate/0.6
On Thu, 12 May 2011 15:36:43 -0700, Carl Worth cwo...@cworth.org wrote: Does anyone want to attempt to fix up this first patch? (It doesn't necessarily have to be David). Hi, Carl. I went through dme's multipart patch series and cleaned things up. I split up that first commit into a couple of separate ones, and then combined a couple of patches together and cherry-picked through the rest of the series to make the overall series a little cleaner. I also let out some stuff that was in the originally series (ie. extraneous json newlines). I then cherry-picked the entire rest of the release-candidate/0.6 branch on top of that. The result is the new release-candidate/0.6+mpmfix branch, which I have pushed to my repo. jamie.[!] [!] yes, it's been a year! pgp2rO99CwgpA.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] test: do folder-based search with a single-term path after moving message
When moving mail to a different folder, there appear to be residual incorrect folder: terms. This test exposes an existing bug, so is currently failing. Signed-off-by: Pieter Praet pie...@praet.org --- test/search-by-folder |4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/test/search-by-folder b/test/search-by-folder index 162158c..62767fb 100755 --- a/test/search-by-folder +++ b/test/search-by-folder @@ -35,6 +35,10 @@ notmuch new output=$(notmuch search folder:bad/news | notmuch_search_sanitize) test_expect_equal $output +test_begin_subtest After rename, old single-term path returns nothing +output=$(notmuch search folder:news | notmuch_search_sanitize) +test_expect_equal_failure $output + test_begin_subtest After rename, new path returns result output=$(notmuch search folder:bad/olds | notmuch_search_sanitize) test_expect_equal $output thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Bears (inbox unread) -- 1.7.4.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 0/4] set test prereqs (Emacs, GDB, GPG)
The atomicity tests were failing here because I didn't have GDB installed, so I've added it as a prereq. While I was at it, I fixed the crypto and emacs tests as well. Thank Austin for providing me with a hammer (I was using a brick) [1]. (!) Depends: - [PATCH] test: Fix message when skipping test_expect_equal* tests [2] - [PATCH] test: Report test failures from test_expect_* [3] Pieter Praet (4): test: add 'GDB' prereq to 'atomicity' tests test: add 'GPG' prereq to 'crypto' tests test: add 'Emacs' prereq to 'emacs' tests test: add 'Emacs' prereq to 'emacs-large-search-buffer' tests test/atomicity | 10 -- test/crypto| 30 ++ test/emacs | 40 +++- test/emacs-large-search-buffer |9 +++-- 4 files changed, 56 insertions(+), 33 deletions(-) -- 1.7.4.1 [1] id:BANLkTi=iz6F+1-WQ5KDno6N-MF=dqet...@mail.gmail.com [2] id:1305206080-17461-1-git-send-email-amdra...@mit.edu [3] id:1305206110-17511-1-git-send-email-amdra...@mit.edu ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 1/4] test: add 'GDB' prereq to 'atomicity' tests
Signed-off-by: Pieter Praet pie...@praet.org --- test/atomicity | 10 -- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/test/atomicity b/test/atomicity index cd58c4c..78280b2 100755 --- a/test/atomicity +++ b/test/atomicity @@ -7,6 +7,12 @@ test_description='atomicity' # final database contents should be the same regardless of when (or # if) it is killed and restarted. +# GDB is a prereq. +if test_expect_success prereq: GDB is present which gdb; then +test_set_prereq GDB +fi + + # Create a maildir structure to also stress flag synchronization mkdir $MAIL_DIR/cur mkdir $MAIL_DIR/new @@ -89,8 +95,8 @@ for ((i = 0; i $outcount; i++)); do i=$(expr $end - 1) fi done -test_expect_equal $(cat searchall) $(cat expectall) +test_expect_equal GDB $(cat searchall) $(cat expectall) -test_expect_success detected $outcount10 abort points test $outcount -gt 10 +test_expect_success GDB detected $outcount10 abort points test $outcount -gt 10 test_done -- 1.7.4.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 2/4] test: add 'GPG' prereq to 'crypto' tests
Signed-off-by: Pieter Praet pie...@praet.org --- test/crypto | 30 ++ 1 files changed, 18 insertions(+), 12 deletions(-) diff --git a/test/crypto b/test/crypto index 961d035..c2f381c 100755 --- a/test/crypto +++ b/test/crypto @@ -7,6 +7,12 @@ test_description='PGP/MIME signature verification and decryption' . ./test-lib.sh +# GnuPG is a prereq. +if test_expect_success prereq: GnuPG is present which gpg; then +test_set_prereq GPG +fi + + add_gnupg_home () { local output @@ -31,7 +37,7 @@ FINGERPRINT=$(gpg --no-tty --list-secret-keys --with-colons --fingerprint | grep # although I can't figure out why add_email_corpus -test_expect_success 'emacs delivery of signed message' \ +test_expect_success GPG 'emacs delivery of signed message' \ 'emacs_deliver_message \ test signed message 001 \ This is a test signed message. \ @@ -66,7 +72,7 @@ expected='[[[{id: X, content-type: application/pgp-signature}]} ]}, [' -test_expect_equal \ +test_expect_equal GPG \ $output \ $expected @@ -103,7 +109,7 @@ expected='[[[{id: X, content-type: application/pgp-signature}]} ]}, [' -test_expect_equal \ +test_expect_equal GPG \ $output \ $expected @@ -139,7 +145,7 @@ expected='[[[{id: X, content-type: application/pgp-signature}]} ]}, [' -test_expect_equal \ +test_expect_equal GPG \ $output \ $expected mv ${GNUPGHOME}{.bak,} @@ -148,7 +154,7 @@ mv ${GNUPGHOME}{.bak,} cat EOF TESTATTACHMENT This is a test file. EOF -test_expect_success 'emacs delivery of encrypted message with attachment' \ +test_expect_success GPG 'emacs delivery of encrypted message with attachment' \ 'emacs_deliver_message \ test encrypted message 001 \ This is a test encrypted message. \ @@ -186,7 +192,7 @@ expected='[[[{id: X, filename: TESTATTACHMENT}]} ]}]}, [' -test_expect_equal \ +test_expect_equal GPG \ $output \ $expected @@ -195,7 +201,7 @@ notmuch show \ --format=part --part=4 \ --decrypt \ subject:test encrypted message 001 OUTPUT -test_expect_equal_file OUTPUT TESTATTACHMENT +test_expect_equal_file GPG OUTPUT TESTATTACHMENT test_begin_subtest decryption failure with missing key mv ${GNUPGHOME}{,.bak} @@ -224,12 +230,12 @@ expected='[[[{id: X, content-type: application/octet-stream}]} ]}, [' -test_expect_equal \ +test_expect_equal GPG \ $output \ $expected mv ${GNUPGHOME}{.bak,} -test_expect_success 'emacs delivery of encrypted/signed message' \ +test_expect_success GPG 'emacs delivery of encrypted/signed message' \ 'emacs_deliver_message \ test encrypted message 002 \ This is a test encrypted message. \ @@ -263,7 +269,7 @@ expected='[[[{id: X, content-type: text/plain, content: This is a test encrypted message.\n}]}]}, [' -test_expect_equal \ +test_expect_equal GPG \ $output \ $expected @@ -275,7 +281,7 @@ Subject: Re: test encrypted message 002 On 01 Jan 2000 12:00:00 -, Notmuch Test Suite test_su...@notmuchmail.org wrote: This is a test encrypted message.' -test_expect_equal \ +test_expect_equal GPG \ $output \ $expected @@ -319,7 +325,7 @@ expected='[[[{id: X, content-type: application/pgp-signature}]} ]}, [' -test_expect_equal \ +test_expect_equal GPG \ $output \ $expected -- 1.7.4.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 3/4] test: add 'Emacs' prereq to 'emacs' tests
Signed-off-by: Pieter Praet pie...@praet.org --- test/emacs | 40 +++- 1 files changed, 23 insertions(+), 17 deletions(-) diff --git a/test/emacs b/test/emacs index 3264bf2..011deac 100755 --- a/test/emacs +++ b/test/emacs @@ -2,6 +2,12 @@ test_description=emacs interface . test-lib.sh +# Emacs is a prereq. +if test_expect_success prereq: Emacs is present which emacs; then +test_set_prereq EMACS +fi + + EXPECTED=../emacs.expected-output add_email_corpus @@ -9,64 +15,64 @@ add_email_corpus test_begin_subtest Basic notmuch-hello view in emacs output=$(test_emacs '(notmuch-hello) (princ (buffer-string))') expected=$(cat $EXPECTED/notmuch-hello) -test_expect_equal $output $expected +test_expect_equal EMACS $output $expected test_begin_subtest Saved search with 0 results output=$(test_emacs '(setq notmuch-show-empty-saved-searches t) (setq notmuch-saved-searches '\''((inbox . tag:inbox) (unread . tag:unread) (empty . tag:doesnotexist))) (notmuch-hello) (princ (buffer-string))') expected=$(cat $EXPECTED/notmuch-hello-with-empty) -test_expect_equal $output $expected +test_expect_equal EMACS $output $expected test_begin_subtest No saved searches displayed (all with 0 results) output=$(test_emacs '(setq notmuch-saved-searches '\''((empty . tag:doesnotexist))) (notmuch-hello) (princ (buffer-string))') expected=$(cat $EXPECTED/notmuch-hello-no-saved-searches) -test_expect_equal $output $expected +test_expect_equal EMACS $output $expected test_begin_subtest Basic notmuch-search view in emacs output=$(test_emacs '(notmuch-search tag:inbox) (notmuch-test-wait) (princ (buffer-string))') expected=$(cat $EXPECTED/notmuch-search-tag-inbox) -test_expect_equal $output $expected +test_expect_equal EMACS $output $expected test_begin_subtest Navigation of notmuch-hello to search results output=$(test_emacs '(notmuch-hello) (goto-char (point-min)) (re-search-forward inbox) (widget-button-press (point)) (notmuch-test-wait) (princ (buffer-string))') expected=$(cat $EXPECTED/notmuch-hello-view-inbox) -test_expect_equal $output $expected +test_expect_equal EMACS $output $expected test_begin_subtest Basic notmuch-show view in emacs maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.gu3...@dottiness.seas.harvard.edu) output=$(test_emacs (notmuch-show \$maildir_storage_thread\) (princ (buffer-string))) expected=$(cat $EXPECTED/notmuch-show-thread-maildir-storage) -test_expect_equal $output $expected +test_expect_equal EMACS $output $expected test_begin_subtest Navigation of notmuch-search to thread view output=$(test_emacs '(notmuch-search tag:inbox) (notmuch-test-wait) (goto-char (point-min)) (re-search-forward Working with Maildir) (notmuch-search-show-thread) (notmuch-test-wait) (princ (buffer-string))') -test_expect_equal $output $expected +test_expect_equal EMACS $output $expected test_begin_subtest Add tag from search view os_x_darwin_thread=$(notmuch search --output=threads id:ddd65cda0911171950o4eea4389v86de9525e4605...@mail.gmail.com) test_emacs (notmuch-search \$os_x_darwin_thread\) (notmuch-test-wait) (notmuch-search-add-tag \tag-from-search-view\) output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize) -test_expect_equal $output thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-search-view unread) +test_expect_equal EMACS $output thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-search-view unread) test_begin_subtest Remove tag from search view test_emacs (notmuch-search \$os_x_darwin_thread\) (notmuch-test-wait) (notmuch-search-remove-tag \tag-from-search-view\) output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize) -test_expect_equal $output thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread) +test_expect_equal EMACS $output thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread) test_begin_subtest Add tag from notmuch-show view test_emacs (notmuch-show \$os_x_darwin_thread\) (notmuch-show-add-tag \tag-from-show-view\) output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize) -test_expect_equal $output thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-show-view unread) +test_expect_equal EMACS $output thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-show-view unread) test_begin_subtest Remove tag from notmuch-show view test_emacs (notmuch-show \$os_x_darwin_thread\) (notmuch-show-remove-tag \tag-from-show-view\) output=$(notmuch search $os_x_darwin_thread |
[PATCH] emacs: run notmuch-message-mark-replied on message-sent-hook, not message-send-hook
Parent message is tagged replied prematurely. Only do so when reply is *really* sent. (describe-variable 'message-send-hook) Hook run before sending messages. This hook is run quite early when sending. (describe-variable 'message-sent-hook) Hook run after sending messages. Signed-off-by: Pieter Praet pie...@praet.org --- emacs/notmuch-message.el |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el index d5c96c2..c8b19c3 100644 --- a/emacs/notmuch-message.el +++ b/emacs/notmuch-message.el @@ -47,6 +47,6 @@ the \inbox\ and \todo\, you would set (apply 'notmuch-call-notmuch-process tag (append tags (list (concat id: (car (car rep nil)) -(add-hook 'message-send-hook 'notmuch-message-mark-replied) +(add-hook 'message-sent-hook 'notmuch-message-mark-replied) (provide 'notmuch-message) -- 1.7.4.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 1/3] test: emacs: add subtest Send reply from within Emacs
Renamed subtest Reply within emacs to Compose reply in emacs as it doesn't really do a reply, but rather populates a reply buffer and then princ's it. ... and couldn't possibly justify that without writing an actual reply test. Signed-off-by: Pieter Praet pie...@praet.org --- test/emacs | 33 - 1 files changed, 32 insertions(+), 1 deletions(-) diff --git a/test/emacs b/test/emacs index 3264bf2..18d8322 100755 --- a/test/emacs +++ b/test/emacs @@ -99,7 +99,7 @@ notmuch new /dev/null output=$(notmuch search 'subject:testing message sent via SMTP' | notmuch_search_sanitize) test_expect_equal $output thread:XXX 1974-03-29 [1/1] Notmuch Test Suite; Testing message sent via SMTP (inbox) -test_begin_subtest Reply within emacs +test_begin_subtest Compose reply in emacs # We sed away everything before the ^From in the output to avoid getting # confused by messages such as Parsing /home/cworth/.mailrc... done output=$(test_emacs '(notmuch-search subject:\testing message sent via SMTP\) (notmuch-test-wait) (notmuch-search-reply-to-thread) (princ (buffer-string))' | sed -ne '/^From/,$ p' | sed -e 's/^In-Reply-To: .*$/In-Reply-To: XXX/') @@ -112,6 +112,37 @@ Fcc: $(pwd)/mail/sent On Fri, 29 Mar 1974 10:00:00 -, Notmuch Test Suite test_su...@notmuchmail.org wrote: This is a test that messages are sent via SMTP + +test_begin_subtest Send reply from within Emacs +../smtp-dummy sent_message +smtp_dummy_pid=$! + +test_emacs '(setq message-send-mail-function '\''message-smtpmail-send-it) (setq smtpmail-smtp-server localhost) (setq smtpmail-smtp-service 25025) (notmuch-search subject:\testing message sent via SMTP\) (notmuch-test-wait) (notmuch-search-reply-to-thread) (message-goto-to) (message-goto-body) (end-of-buffer) (newline) (insert Reply to a message via Emacs with fake SMTP) (message-send-and-exit)' /dev/null 21 +wait ${smtp_dummy_pid} + +output=$(sed \ +-e s',^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' \ +-e s',^Message-ID: .*$,Message-ID: XXX,' \ +-e s',^In-Reply-To: .*$,In-Reply-To: XXX,' \ +-e s',^References: .*$,References: XXX,' \ +-e s',^Date: .*$,Date: Fri\, 29 Mar 1974 10:05:00 -,' sent_message) +test_expect_equal $output From: Notmuch Test Suite test_su...@notmuchmail.org +To: u...@example.com +Subject: Re: Testing message sent via SMTP +In-Reply-To: XXX +References: XXX +User-Agent: Notmuch/XXX Emacs/XXX +Date: Fri, 29 Mar 1974 10:05:00 - +Message-ID: XXX +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii + +On Fri, 29 Mar 1974 10:00:00 -, Notmuch Test Suite test_su...@notmuchmail.org wrote: + This is a test that messages are sent via SMTP + +Reply to a message via Emacs with fake SMTP + + test_begin_subtest Save attachment from within emacs echo ./attachment | test_emacs '(notmuch-show id:cf0c4d610911171136h1713aa59w9cf9aa31f052a...@mail.gmail.com) (notmuch-show-save-attachments)' /dev/null 21 output=$(cat attachment) -- 1.7.4.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 2/3] test: emacs: add subtest Verify that 'replied' tag is added to reply's parent message.
Signed-off-by: Pieter Praet pie...@praet.org --- test/emacs |4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/test/emacs b/test/emacs index 18d8322..c0fba52 100755 --- a/test/emacs +++ b/test/emacs @@ -142,6 +142,10 @@ On Fri, 29 Mar 1974 10:00:00 -, Notmuch Test Suite test_suite@notmuchmail.o Reply to a message via Emacs with fake SMTP +test_begin_subtest Verify that 'replied' tag is added to reply's parent message. +notmuch new /dev/null # update message count +output=$(notmuch search 'tag:replied' | notmuch_search_sanitize) +test_expect_equal $output thread:XXX 1974-03-29 [1/2] Notmuch Test Suite; Testing message sent via SMTP (inbox replied) test_begin_subtest Save attachment from within emacs echo ./attachment | test_emacs '(notmuch-show id:cf0c4d610911171136h1713aa59w9cf9aa31f052a...@mail.gmail.com) (notmuch-show-save-attachments)' /dev/null 21 -- 1.7.4.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 3/3] emacs: generalize notmuch-message-mark-replied
Renamed 'notmuch-message-mark-replied' to 'notmuch-message-mod-tags'. Previously (semi)hardcoded vars are now to be provided as arguments, allowing much more flexibility re autotagging in message-mode. Paving the way towards proper draft handling? Signed-off-by: Pieter Praet pie...@praet.org --- emacs/notmuch-message.el | 27 ++- 1 files changed, 18 insertions(+), 9 deletions(-) diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el index c8b19c3..6026740 100644 --- a/emacs/notmuch-message.el +++ b/emacs/notmuch-message.el @@ -22,6 +22,8 @@ (require 'message) (require 'notmuch-mua) +(defvar notmuch-message-parent nil) + (defcustom notmuch-message-replied-tags '(replied) Tags to be automatically added to or removed from a message when it is replied to. Any tag in the list will be added to a replied message or, @@ -33,20 +35,27 @@ the \inbox\ and \todo\, you would set :type 'list :group 'notmuch) -(defun notmuch-message-mark-replied () - ;; get the in-reply-to header and parse it for the message id. - (let ((rep (mail-header-parse-addresses (message-field-value In-Reply-To -(when (and notmuch-message-replied-tags rep) - ;; add a + to any tag that is doesn't already begin with a + - ;; or - +(defun notmuch-message-mod-tags (msgid tagops) +(when (and msgid tagops) + ;; prepend operator-less tags with a + (let ((tags (mapcar '(lambda (str) (if (not (string-match ^[+-] str)) (concat + str) str)) - notmuch-message-replied-tags))) + tagops))) (apply 'notmuch-call-notmuch-process tag - (append tags (list (concat id: (car (car rep nil)) + (append tags (list (concat id: msgid)) nil) + +(add-hook 'message-setup-hook + (lambda () +(set (make-local-variable 'notmuch-message-parent) + ;; get the in-reply-to header and parse it for the message id. + (car (car (mail-header-parse-addresses (message-field-value In-Reply-To))) + +(add-hook 'message-sent-hook + (lambda () +(notmuch-message-mod-tags notmuch-message-parent + notmuch-message-replied-tags))) -(add-hook 'message-sent-hook 'notmuch-message-mark-replied) (provide 'notmuch-message) -- 1.7.4.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: Warning when GMime is parsing broken email addresses
On Wed, 27 Apr 2011 21:59:09 +0200, Pieter Praet pie...@praet.org wrote: On Wed, 27 Apr 2011 18:30:09 +0200, Xavier Maillard xav...@maillard.im wrote: On Mon, 25 Apr 2011 15:23:41 -0700, Carl Worth cwo...@cworth.org wrote: On Wed, 17 Nov 2010 23:20:26 +0100, Matthieu Lemerre ra...@free.fr wrote: Maybe it would also be interesting to add a warning/assertion to check that all email adresses added to the database are correct email addresses? I.e. check that the `addr' variable in _index_address_mailbox always has a @. This check is in fact already done using the function strchr, but a bad value is explicitly ignored... Since GMime is fixed upstream (as of version 2.4.18) another option would be to simply make the notmuch build system require a sufficiently new version of GMime in order to build. What do you think? I'd say both. Unfortunately, regressions are not uncommon, and regardless, it'd be nice to be notified when what we stuff in the db is not sane. It would however be a good idea IMHO to check email address more thorougly [1] than simply verifying whether an @ is present. I agree with that, unless it is undesirable to add a dependency to a regex library to notmuch? If so, the @ check could still be done (and is _already_ present). I don't see the warnings either, but maybe with proper differentiation between stdout and stderr, I could arrange to print stderr and see the warning messages in emacs when I explicitely launch my mail synchronization script. Matthieu ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch