* [PATCH] emacs: run notmuch-message-mark-replied on message-sent-hook, not message-send-hook
@ 2011-05-13 8:34 Pieter Praet
2011-05-13 15:07 ` [PATCH 1/3] test: emacs: add subtest "Send reply from within Emacs" Pieter Praet
0 siblings, 1 reply; 4+ messages in thread
From: Pieter Praet @ 2011-05-13 8:34 UTC (permalink / raw)
To: Notmuch Mail
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 <pieter@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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 1/3] test: emacs: add subtest "Send reply from within Emacs"
2011-05-13 8:34 [PATCH] emacs: run notmuch-message-mark-replied on message-sent-hook, not message-send-hook Pieter Praet
@ 2011-05-13 15:07 ` Pieter Praet
2011-05-13 15:07 ` [PATCH 2/3] test: emacs: add subtest "Verify that 'replied' tag is added to reply's parent message." Pieter Praet
2011-05-13 15:07 ` [PATCH 3/3] emacs: generalize notmuch-message-mark-replied Pieter Praet
0 siblings, 2 replies; 4+ messages in thread
From: Pieter Praet @ 2011-05-13 15:07 UTC (permalink / raw)
To: Notmuch Mail
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 <pieter@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 -0000, Notmuch Test Suite <test_suite@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 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: <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 -0000,' < sent_message)
+test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
+To: user@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 -0000
+Message-ID: <XXX>
+MIME-Version: 1.0
+Content-Type: text/plain; charset=us-ascii
+
+On Fri, 29 Mar 1974 10:00:00 -0000, Notmuch Test Suite <test_suite@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:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com") (notmuch-show-save-attachments)' > /dev/null 2>&1
output=$(cat attachment)
--
1.7.4.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] test: emacs: add subtest "Verify that 'replied' tag is added to reply's parent message."
2011-05-13 15:07 ` [PATCH 1/3] test: emacs: add subtest "Send reply from within Emacs" Pieter Praet
@ 2011-05-13 15:07 ` Pieter Praet
2011-05-13 15:07 ` [PATCH 3/3] emacs: generalize notmuch-message-mark-replied Pieter Praet
1 sibling, 0 replies; 4+ messages in thread
From: Pieter Praet @ 2011-05-13 15:07 UTC (permalink / raw)
To: Notmuch Mail
Signed-off-by: Pieter Praet <pieter@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 -0000, 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:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com") (notmuch-show-save-attachments)' > /dev/null 2>&1
--
1.7.4.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] emacs: generalize notmuch-message-mark-replied
2011-05-13 15:07 ` [PATCH 1/3] test: emacs: add subtest "Send reply from within Emacs" Pieter Praet
2011-05-13 15:07 ` [PATCH 2/3] test: emacs: add subtest "Verify that 'replied' tag is added to reply's parent message." Pieter Praet
@ 2011-05-13 15:07 ` Pieter Praet
1 sibling, 0 replies; 4+ messages in thread
From: Pieter Praet @ 2011-05-13 15:07 UTC (permalink / raw)
To: Notmuch Mail
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 <pieter@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
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-05-13 15:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-13 8:34 [PATCH] emacs: run notmuch-message-mark-replied on message-sent-hook, not message-send-hook Pieter Praet
2011-05-13 15:07 ` [PATCH 1/3] test: emacs: add subtest "Send reply from within Emacs" Pieter Praet
2011-05-13 15:07 ` [PATCH 2/3] test: emacs: add subtest "Verify that 'replied' tag is added to reply's parent message." Pieter Praet
2011-05-13 15:07 ` [PATCH 3/3] emacs: generalize notmuch-message-mark-replied Pieter Praet
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).