Re: notmuch-crypto.el: "‘notmuch-show-get-message-id’ is not known to be defined"
Daniel Kahn Gillmor writes: > When building the current version of notmuch on debian testing/unstable, > i see the following warning: > > ``` > EMACS emacs/notmuch-crypto.elc > > In end of data: > emacs/notmuch-crypto.el:266:1:Warning: the function > ‘notmuch-show-get-message-id’ is not known to be defined. > ``` > > No part of the test suite fails so i assume it's not a problem, but > having spurious warnings makes it harder to notice real warnings in the > future. > > I don't know what the warning means exactly, but maybe someone who is > better with elisp than i am could take a look at it and try to resolve > it? Adding this line in notmuch-crypto.el solves this: (declare-function notmuch-show-get-message-id "notmuch-show" ( bare)) As a matter of style, I am not sure where to put it. Normally, these declarations are put in the beginning of the file; right after the require-statements. In notmuch-crypto.el, however, the only other declaration is put just in front of where the function is called. /Örjan ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: performance in emacs displaying a huge thread
Hi Alan, Alan Schmitt writes: > > September 07 [13/5767] > > It takes forever to display (I've waited a few minutes and it was still > stuck). I know it's a lot of messages, so is there a way to just display > the 13 that match? Or to limit the total number of messages displayed? I think opening the thread with C-U RET instead of RET does exactly that, i.e. only shows the matching messages. In less extreme cases, using tree view (ALT-RET) may be an option since it does not have to format the contents of the entire thread. I have a vague recollection that someone pointed out that it is the indentation that takes most of the time and that turning off indentation speeds up the display of huge threads. /Örjan ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: proposing "notmuch purge"
While I like the idea of making it easy to prune away old junk messages from the mail store, I find it dangerously disruptive to suddenly change the semantics of the deleted tag. To me, the deleted tag has always meant something like "I do not want to see this message again; unless it reappears in a thread or I explicitly search for it". The possibility to undelete also means that deleting messages is not such a big deal. What do you think about introducing a new tag, e.g. purge, and let "notmuch purge" destructively remove the messages with this tag set? Hopefully, nobody is using that particular tag for a different purpose. Purging would then become a two-stage process; first tagging which messages should be purged, before doing the actual non-reversible removal. This makes it simpler to check what would be purged before actually doing it. A dangerous but flexible way of configuration would be to have a pre-purge-hook which could, for example, do things like: notmuch tag +purge "(" tag:deleted OR tag:spam ")" AND date:..30days The downside of this is of course that hooks are not that easy to set up and can easily backfire and possibly remove your entire mail collection. /Örjan ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: script to move messages according to tags
Alan Schmitt writes: > Has someone written such a script that I could copy and > adapt? > > My use cases are: > - find files with a deleted flag not in the Trash and move them to > the > Trash > - find files with an archive flag in my active mail store and move > them > to my local mail store Hi Alan, Below is the script that I use which does more-or-less what you are asking for. The only "magic" here is the function safeMove which strips the identifier number and flags from the filename when a file is moved. These identifier numbers are added by mbsync which is the program I use to synchronise my folders with our webmail server, and keeping the numbers when moving the files proved to interfere with its synchronisation logic. Cheers, Örjan === 8< === #!/bin/bash MAILDIR=$HOME/MyMail # Move a message file while removing its UID-part function safeMove { s=${1##*/}; s=${s%%,*}; mv -f $1 $2/$s; } # Move all deleted messages to the Trash folder echo Moving $(notmuch count --output=files --exclude=false tag:deleted AND NOT folder:Trash) \ deleted messages to the Trash folder for i in $(notmuch search --exclude=false --output=files tag:deleted AND NOT folder:Trash); do safeMove $i ${MAILDIR}/Trash/cur done # Move all spam messages to the Spam folder echo Moving $(notmuch count --output=files tag:spam AND NOT folder:Spam) \ spam-marked messages to the Spam folder for i in $(notmuch search --output=files tag:spam AND NOT folder:Spam); do safeMove $i ${MAILDIR}/Spam/cur done # Move all archived messages from Inbox to Archive folder echo Moving $(notmuch count --output=files folder:Inbox AND NOT tag:inbox) \ archived messages from Inbox to Archive folder for i in $(notmuch search --output=files folder:Inbox AND NOT tag:inbox); do safeMove $i ${MAILDIR}/Arkiv/cur done echo Syncing with Webmail mbsync twoway echo Updating notmuch database notmuch new --no-hooks === 8< === ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: feature request: caching message arrival time
Daniel Kahn Gillmor writes: > Sure, assuming that you trust the closest MTA in the chain of MTAs that > handed the message off to you, since an adversarial proximal MTA could > manipulate all the existing Received: headers as well. > > But I'm a bit uncomfortable with it: this sort of protection actually > opens up a new attack vector that didn't exist before -- any MTA in the > chain can now make the message seem like it was actually from the > *past*, just by setting its own Received: header. As far as I understand the autocrypt protocol (i.e. not much;-) ), the vulnerability is that an incoming message with a later time-stamp than the locally saved autocrypt status can update the stored state (e.g. turn off encryption). Manipulating the time-stamp to make the message appear to be *older* than it really is should only mean that it is less likely to update the saved state? If this is correct, using the oldest of all the time-stamps seen in the Date-header and any of the Received-headers should be the most defensive. /Örjan ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: notmuch-message-mark-replied
"Rollins, Jameson" writes: > I have the following in my emacs config: > > '(message-send-hook >(quote > (notmuch-message-mark-replied notmuch-fcc-header-setup))) > > I'm wondering what if anything I should replace this with. You should probably remove this altogether. notmuch-message-mark-replied used to be the default value for this hook, but has now been replaced by notmuch-message-apply-queued-tag-changes. notmuch-fcc-header-setup is called already when composing a message, so it no longer is needed to call is from the hook. /Örjan ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: notmuch-message-mark-replied
David Bremner writes: > In d9800c8 we deleted the function notmuch-message-mark-replied. > > Should we make a deprecated-alias for > notmuch-message-apply-queued-tag-changes? The two functions are not interchangeable, so it may not be appropriate to mark it as an alias. notmuch-message-mark-replied looked for a In-Reply-To: header while notmuch-message-apply-queued-tag-changes checks if the message has notmuch-message-queued-tag-changes set (it is set when composing a reply). On the other hand; if a user has code which explicitly sets the message-send-hook, the new function will serve as the natural replacement for the deleted one. /Örjan ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: feature request: caching message arrival time
Daniel Kahn Gillmor writes: > So Autocrypt defines the "effective date" of a message as the *earliest* > of two dates: the date that the message is first seen, and the Date: > header itself. So we want our augmented Autocrypt header ingestion > routine to search for all other messages we know about from the sender > that have both a later firstseen= property *and* a later Date: header. Would it be possible to use the earliest date seen in any of the Received: headers as a safeguard against future-dated messages? /Örjan ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[BUG] emacs: notmuch-mua-attachment-check finds triggering string inside forwarded messages
Hi all, I have found what seems to be a bug, or at least a misbehaviour of the "missing attachment warning" implemented by the otherwise so nice notmuch-mua-attachment-check. It works fine to detect the regexp for attachments in simple messages. The problem is that it also triggers the warning if a matching string is present inside a forwarded message. This is particularly annoying when forwarding messages originating from MS-Exchange since those seem to always include a hidden header "X-MS-Has-Attach" where the word "Attach" constantly leads to false missing-attachment warnings. Would it be possible to somehow restrict the regexp search to the part of the message actually being authored? Would it be too simplistic to end the search at the first occurrence of "\n\n<#" ? /Örjan ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] emacs: hint that notmuch-mua-attachment-regexp is a regular expression
This addresses the same issue, and therefore overlaps with the patch I submitted a week ago. (id:20190415133519.4532-1-ekeb...@kth.se) /Örjan Daniel Kahn Gillmor writes: > Without this change, we see the following warnings during the build: > > ``` > In toplevel form: > emacs/notmuch-mua.el:119:1:Warning: defcustom for > ‘notmuch-mua-attachment-regexp’ fails to specify type > emacs/notmuch-mua.el:119:1:Warning: defcustom for > ‘notmuch-mua-attachment-regexp’ fails to specify type > EMACS emacs/notmuch-show.elc > ``` > --- > emacs/notmuch-mua.el | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el > index 94fa19d7..b1a31034 100644 > --- a/emacs/notmuch-mua.el > +++ b/emacs/notmuch-mua.el > @@ -121,7 +121,8 @@ multiple parts get a header." >"Message body text indicating that an attachment is expected. > > This is not used unless `notmuch-mua-attachment-check' is added > -to `notmuch-mua-send-hook'.") > +to `notmuch-mua-send-hook'." > + :type '(regexp)) > > ;; > > -- > 2.20.1 > > ___ > notmuch mailing list > notmuch@notmuchmail.org > https://notmuchmail.org/mailman/listinfo/notmuch ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] emacs: Add missing type and group to defcustom variable
Added the type 'regexp and group 'notmuch-send as properties to the customizable variable notmuch-mua-attachment-regexp. --- emacs/notmuch-mua.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 94fa19d7..7fdd76bc 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -121,7 +121,9 @@ multiple parts get a header." "Message body text indicating that an attachment is expected. This is not used unless `notmuch-mua-attachment-check' is added -to `notmuch-mua-send-hook'.") +to `notmuch-mua-send-hook'." + :type 'regexp + :group 'notmuch-send) ;; -- 2.20.1 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v4 4/4] test: add test for checking forwarded messages
Add test of forwarding messages from within emacs. The first test checks that a references header is properly added to the new message. The second test checks that the send-hook of the forwarding message adds a forwarded-tag to the original message. --- test/T730-emacs-forwarding.sh | 41 +++ 1 file changed, 41 insertions(+) create mode 100755 test/T730-emacs-forwarding.sh diff --git a/test/T730-emacs-forwarding.sh b/test/T730-emacs-forwarding.sh new file mode 100755 index ..45e61568 --- /dev/null +++ b/test/T730-emacs-forwarding.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +test_description="emacs forwarding" +. $(dirname "$0")/test-lib.sh || exit 1 + +test_begin_subtest "Forward setting the correct references header" +# Check that, when forwarding a message, the new message has +# a References-header pointing to the original (forwarded) message. + +message_id='originalmess...@notmuchmail.org' +add_message \ +[id]="$message_id" \ +'[from]="u...@example.com"' \ +'[subject]="This is the original message"' \ +'[body]="Dummy text."' + +test_emacs_expect_t " + (let ((message-send-mail-function (lambda () t))) +(notmuch-show \"id:$message_id\") +(notmuch-show-forward-message) +(save-restriction + (message-narrow-to-headers) + (message-remove-header \"Fcc\") + (message-remove-header \"To\") + (message-add-header \"To: nob...@example.com\")) + +(notmuch-mua-send) +(notmuch-test-expect-equal +(message-field-value \"References\") \"<$message_id>\")) +" + +test_begin_subtest "Forwarding adding the forwarded tag" +# Check that sending the forwarding message in the previous +# subtest did add the forwarded-tag to the message that was forwarded. + +test_expect_equal "$(notmuch search --output=tags id:$message_id | sort)" \ +"forwarded +inbox +unread" + +test_done -- 2.20.1 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v4 1/4] emacs: Add References header to forwarded messages
Include the message-id of forwarded messages in the new message. This ensures that the new (forwarding) message is linked to the same thread as the message being forwarded. --- emacs/notmuch-mua.el | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 708db248..23f3d8b1 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -470,8 +470,9 @@ the From: address." (let* ((other-headers (when (or prompt-for-sender notmuch-always-prompt-for-sender) (list (cons 'From (notmuch-mua-prompt-for-sender) -forward-subject) ;; Comes from the first message and is +forward-subject ;; Comes from the first message and is ;; applied later. +forward-references) ;; List of accumulated message-references of forwarded messages ;; Generate the template for the outgoing message. (notmuch-mua-mail nil "" other-headers nil (notmuch-mua-get-switch-function)) @@ -489,7 +490,8 @@ the From: address." ;; Because we process the messages in reverse order, ;; always generate a forwarded subject, then use the ;; last (i.e. first) one. - (setq forward-subject (message-make-forward-subject))) + (setq forward-subject (message-make-forward-subject)) + (push (message-fetch-field "Message-ID") forward-references)) ;; Make a copy ready to be forwarded in the ;; composition buffer. (message-forward-make-body temp-buffer) @@ -503,7 +505,10 @@ the From: address." (save-restriction (message-narrow-to-headers) (message-remove-header "Subject") - (message-add-header (concat "Subject: " forward-subject))) + (message-add-header (concat "Subject: " forward-subject)) + (message-remove-header "References") + (message-add-header (concat "References: " + (mapconcat 'identity forward-references " " ;; `message-forward-make-body' shows the User-agent header. Hide ;; it again. -- 2.20.1 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v4 2/4] emacs: Use a buffer-local variable to update tags when sending replies
Instead of relying on the "In-Reply-To" header, use a buffer-local variable, notmuch-message-queued-tag-changes, to add and remove tags to affected messages when the message-send-hook is triggered. --- emacs/notmuch-message.el | 25 - emacs/notmuch-mua.el | 6 ++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el index 55e4cfee..0d4a8eee 100644 --- a/emacs/notmuch-message.el +++ b/emacs/notmuch-message.el @@ -23,7 +23,6 @@ (require 'message) (require 'notmuch-tag) -(require 'notmuch-mua) (defcustom notmuch-message-replied-tags '("+replied") "List of tag changes to apply to a message when it has been replied to. @@ -34,18 +33,26 @@ will be removed from the message being replied to. For example, if you wanted to add a \"replied\" tag and remove the \"inbox\" and \"todo\" tags, you would set: -(\"+replied\" \"-inbox\" \"-todo\"\)" +(\"+replied\" \"-inbox\" \"-todo\")" :type '(repeat string) :group 'notmuch-send) -(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) - (notmuch-tag (notmuch-id-to-query (car (car rep))) - (notmuch-tag-change-list notmuch-message-replied-tags) +(defconst notmuch-message-queued-tag-changes nil + "List of messages and corresponding tag-changes to be applied when sending a message. -(add-hook 'message-send-hook 'notmuch-message-mark-replied) +This variable is overridden by buffer-local versions in message +buffers where tag changes should be triggered when sending off +the message. Each item in this list is a list of strings, where +the first is a notmuch query and the rest are the tag changes to +be applied to the matching messages.") + +(defun notmuch-message-apply-queued-tag-changes () + ;; Apply the tag changes queued in the buffer-local variable notmuch-message-queued-tag-changes. + (dolist (query-and-tags notmuch-message-queued-tag-changes) +(notmuch-tag (car query-and-tags) +(cdr query-and-tags + +(add-hook 'message-send-hook 'notmuch-message-apply-queued-tag-changes) (provide 'notmuch-message) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 23f3d8b1..2f0de92c 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -28,6 +28,7 @@ (require 'notmuch-lib) (require 'notmuch-address) (require 'notmuch-draft) +(require 'notmuch-message) (eval-when-compile (require 'cl)) @@ -259,6 +260,11 @@ Typically this is added to `notmuch-mua-send-hook'." (notmuch-headers-plist-to-alist reply-headers) nil (notmuch-mua-get-switch-function + ;; Create a buffer-local queue for tag changes triggered when sending the reply + (when notmuch-message-replied-tags + (setq-local notmuch-message-queued-tag-changes + (list (cons query-string notmuch-message-replied-tags + ;; Insert the message body - but put it in front of the signature ;; if one is present, and after any other content ;; message*setup-hooks may have added to the message body already. -- 2.20.1 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v4 3/4] emacs: Tag forwarded messages with +forwarded (customizable)
Use the buffer-local variable notmuch-message-queued-tag-changes to change tags when the forwarding message is sent. --- emacs/notmuch-message.el | 13 + emacs/notmuch-mua.el | 14 -- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el index 0d4a8eee..0164472f 100644 --- a/emacs/notmuch-message.el +++ b/emacs/notmuch-message.el @@ -37,6 +37,19 @@ the \"inbox\" and \"todo\" tags, you would set: :type '(repeat string) :group 'notmuch-send) +(defcustom notmuch-message-forwarded-tags '("+forwarded") + "List of tag changes to apply to a message when it has been forwarded. + +Tags starting with \"+\" (or not starting with either \"+\" or +\"-\") in the list will be added, and tags starting with \"-\" +will be removed from the message being forwarded. + +For example, if you wanted to add a \"forwarded\" tag and remove +the \"inbox\" tag, you would set: +(\"+forwarded\" \"-inbox\")" + :type '(repeat string) + :group 'notmuch-send) + (defconst notmuch-message-queued-tag-changes nil "List of messages and corresponding tag-changes to be applied when sending a message. diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 2f0de92c..94fa19d7 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -478,7 +478,8 @@ the From: address." (list (cons 'From (notmuch-mua-prompt-for-sender) forward-subject ;; Comes from the first message and is ;; applied later. -forward-references) ;; List of accumulated message-references of forwarded messages +forward-references ;; List of accumulated message-references of forwarded messages +forward-queries) ;; List of corresponding message-query ;; Generate the template for the outgoing message. (notmuch-mua-mail nil "" other-headers nil (notmuch-mua-get-switch-function)) @@ -497,7 +498,8 @@ the From: address." ;; always generate a forwarded subject, then use the ;; last (i.e. first) one. (setq forward-subject (message-make-forward-subject)) - (push (message-fetch-field "Message-ID") forward-references)) + (push (message-fetch-field "Message-ID") forward-references) + (push id forward-queries)) ;; Make a copy ready to be forwarded in the ;; composition buffer. (message-forward-make-body temp-buffer) @@ -516,6 +518,14 @@ the From: address." (message-add-header (concat "References: " (mapconcat 'identity forward-references " " + ;; Create a buffer-local queue for tag changes triggered when sending the message + (when notmuch-message-forwarded-tags + (setq-local notmuch-message-queued-tag-changes + (loop for id in forward-queries + collect + (cons id + notmuch-message-forwarded-tags + ;; `message-forward-make-body' shows the User-agent header. Hide ;; it again. (message-hide-headers) -- 2.20.1 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Updated version of the patch-set for tagging forwarded messages
This is a new (final?) version of the patch set for adding reference links to forwarded messages, and tags to forwarded and replied messages. Thanks for all the comments and suggesions for improvements. Apart from cleaning up the test code, the only change from the last posted version is that I have reversed the dependency so that notmuch-mua.el requires notmuch-message.el. This change was needed to make the code emacs-compile cleanly since the code in notmuch-mua uses the variables defined in notmuch-message. Örjan Ekeberg (4): emacs: Add References header to forwarded messages emacs: Use a buffer-local variable to update tags when sending replies emacs: Tag forwarded messages with +forwarded (customizable) test: add test for checking forwarded messages emacs/notmuch-message.el | 38 emacs/notmuch-mua.el | 27 --- test/T730-emacs-forwarding.sh | 41 +++ 3 files changed, 94 insertions(+), 12 deletions(-) create mode 100755 test/T730-emacs-forwarding.sh -- 2.20.1 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH v3 4/4] test: add test for checking forwarded messages
Tomi Ollila writes: > > good stuff -- comments inline Yes, the test suite in general could benefit from more comments, since there are quite a lot of "smart things" going on. >> +test_emacs_expect_t " >> + (progn >> +(notmuch-show \"id:$message_id\") >> +(notmuch-show-forward-message) >> +(run-hooks 'notmuch-mua-send-hook) > > Would instead (run-hooks...) in the above, embedding: > > (let ((message-send-mail-function (lambda () t)) > (mail-host-address \"example.com\")) > and > (notmuch-mua-send) > > work (that is what we do in emacs_fcc_message () in test-lib.sh > > ? I agree that it is more straightforward to call notmuch-mua-send than to only call the send hooks. Thanks for your tip on how to make this work. In addition to your suggestion, I had to remove the automatically added Fcc-header and add a proper To-address for the send machinery to accept the message. This seems to work: test_emacs_expect_t " (let ((message-send-mail-function (lambda () t))) (notmuch-show \"id:$message_id\") (notmuch-show-forward-message) (save-restriction (message-narrow-to-headers) (message-remove-header \"Fcc\") (message-remove-header \"To\") (message-add-header \"To: nob...@example.com\")) (notmuch-mua-send) (notmuch-test-expect-equal (message-field-value \"References\") \"<$message_id>\")) " >> +(notmuch-test-expect-equal (message-field-value \"References\") >> + \"<$message_id>\"))" > > You probably had tabs and spaces "correct" last time, but I got confused by > the extra line and forgot to drop indentation to see better. To be > consistent with other rests these lines do need to have tabs (width 8) and > rest spaces Ok. >> +test_begin_subtest "Forwarding adding the forwarded tag" >> +# Check that the send hook called in the previous subtest did add the >> forwarded-tag >> + >> +test_expect_equal $(notmuch search --output=messages tag:forwarded) >> id:$message_id > > I'd still do something like: > > test_expect_equal "$(notmuch search --output=tags id:$message_id)" \ > $'forwarded\ninbox\nunread\n' > > (note: quoting aroung first arg and $'dollar-single' in second, but did not > test that this is what exactly works (newlines could be clearer, though) :) > > ... to ensure (and show visibility) that just "forwarded" were added. if > anyone(tm) ever changes system so that default tags change, many other > tests also need updating... Fair enough. I agree that it is more logical to analyse the tags of the specific message, than to first search for the tag itself. One worry though. Your suggested code depends on that the order in which "notmuch search" lists the tags is stable. Since the tags is a set, it seems fragile to rely on the order of the individual tags. What about this variant? I have tried it and it seems to work. test_expect_equal "$(notmuch search --output=tags id:$message_id | sort)" \ "forwarded inbox unread" /Örjan ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v3 4/4] test: add test for checking forwarded messages
Add test of forwarding messages from within emacs. The first test checks that a references header is properly added to the new message. The second test checks that the send-hook of the forwarding message adds a forwarded-tag to the original message. --- test/T730-emacs-forwarding.sh | 30 ++ 1 file changed, 30 insertions(+) create mode 100755 test/T730-emacs-forwarding.sh diff --git a/test/T730-emacs-forwarding.sh b/test/T730-emacs-forwarding.sh new file mode 100755 index ..d1a573fb --- /dev/null +++ b/test/T730-emacs-forwarding.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +test_description="emacs forwarding" +. $(dirname "$0")/test-lib.sh || exit 1 + +test_begin_subtest "Forward setting the correct references header" +# Check that, when forwarding a message, the new message has +# a References-header pointing to the original (forwarded) message. + +message_id='originalmess...@notmuchmail.org' +add_message \ +[id]="$message_id" \ +'[from]="u...@example.com"' \ +'[subject]="This is the original message"' \ +'[body]="Dummy text."' + +test_emacs_expect_t " + (progn +(notmuch-show \"id:$message_id\") +(notmuch-show-forward-message) +(run-hooks 'notmuch-mua-send-hook) +(notmuch-test-expect-equal (message-field-value \"References\") + \"<$message_id>\"))" + +test_begin_subtest "Forwarding adding the forwarded tag" +# Check that the send hook called in the previous subtest did add the forwarded-tag + +test_expect_equal $(notmuch search --output=messages tag:forwarded) id:$message_id + +test_done -- 2.20.1 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Updated testing script
Based on the feedback from Tomi and David (thanks!), here is a updated and cleaner version of the test associated with the patch-set for forwarding. Örjan Ekeberg (4): emacs: Add References header to forwarded messages emacs: Use a buffer-local variable to update tags when sending replies emacs: Tag forwarded messages with +forwarded (customizable) test: add test for checking forwarded messages emacs/notmuch-message.el | 37 +++ emacs/notmuch-mua.el | 26 +--- test/T730-emacs-forwarding.sh | 30 3 files changed, 82 insertions(+), 11 deletions(-) create mode 100755 test/T730-emacs-forwarding.sh -- 2.20.1 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH v2 4/4] test: add test for checking forwarded messages
Tomi Ollila writes: > On Fri, Apr 05 2019, Örjan Ekeberg wrote: > >> +test_begin_subtest "Forward setting the correct references header" >> +message_id='originalmess...@notmuchmail.org' >> +add_message \ >> +[id]="$message_id" \ >> +'[from]="u...@example.com"' \ >> +'[subject]="This is the original message"' \ >> +'[body]="-Original Message- >> +Text here."' >> + >> +test_emacs "(let ((message-hidden-headers ()) >> + (notmuch-fcc-dirs ())) >> + (notmuch-show \"id:$message_id\") >> + (notmuch-show-forward-message) >> + (run-hooks 'notmuch-mua-send-hook) >> + (message-narrow-to-headers) >> + (test-visible-output)) >> +(run-hooks 'notmuch-mua-send-hook)" > > Cannot fully understand the above (or, actually not much of it), perhaps > someone else(tm). Short walkthrough: - create a small message in the database (add_message) - set message-hidden-headers to nil so that we can verify them - set notmuch-fcc-dirs to nil to avoid including the fcc-header - get the message we just created (notmuch-show) - create a forwarding message (forwarding the current one) - compare the headers to the expected output - run the send hooks to emulate sending The double run-hooks lines is an error; only the second one is needed. > anyway, it looks like tabs and 8-spaces are used for indenting. Yes. This seems to be common in the emacs code for notmuch, so I did not untabify. > then, instead of only checking forwarded tag was added, checking > checking all tags should be done, so that there is nothing extra > (that check twice, first after add_message, and then at the end) The test was only supposed to check that the forwarded tag was properly added when forwarding. If other tags are added elsewhere in future code, this is not really an error and should not be flagged by the test, should it? > Tomi Thanks for your feedback. /Örjan ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] emacs: Make first documentation line distinct for "a" and "x" commands.
Since only the first line of the documentation is shown by the help command, it is confusing when "x" and "a" seem to have the same binding in show-mode. This commit makes the two function documentations first lines different and (hopefully) clearer. --- emacs/notmuch-show.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 49fc779d..e13ca3d7 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -2256,7 +2256,7 @@ message will be \"unarchived\", i.e. the tag changes in (notmuch-tag-change-list notmuch-archive-tags unarchive (defun notmuch-show-archive-message-then-next-or-exit () - "Archive the current message, then show the next open message in the current thread. + "Archive current message, then show next open message in current thread. If at the last open message in the current thread, then exit back to search results." @@ -2265,7 +2265,7 @@ to search results." (notmuch-show-next-open-message t)) (defun notmuch-show-archive-message-then-next-or-next-thread () - "Archive the current message, then show the next open message in the current thread. + "Archive current message, then show next open message in current or next thread. If at the last open message in the current thread, then show next thread from search." -- 2.20.1 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2 4/4] test: add test for checking forwarded messages
Add test of forwarding messages from within emacs. The first test checks that a references header is properly added to the new message. The second test checks that the send-hook of the forwarding message adds a forwarded-tag to the original message. --- test/T730-emacs-forwarding.sh | 35 +++ 1 file changed, 35 insertions(+) create mode 100755 test/T730-emacs-forwarding.sh diff --git a/test/T730-emacs-forwarding.sh b/test/T730-emacs-forwarding.sh new file mode 100755 index ..0bdd197f --- /dev/null +++ b/test/T730-emacs-forwarding.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +test_description="emacs forwarding" +. $(dirname "$0")/test-lib.sh || exit 1 + +test_begin_subtest "Forward setting the correct references header" +message_id='originalmess...@notmuchmail.org' +add_message \ +[id]="$message_id" \ +'[from]="u...@example.com"' \ +'[subject]="This is the original message"' \ +'[body]="-Original Message- +Text here."' + +test_emacs "(let ((message-hidden-headers ()) + (notmuch-fcc-dirs ())) +(notmuch-show \"id:$message_id\") +(notmuch-show-forward-message) + (run-hooks 'notmuch-mua-send-hook) +(message-narrow-to-headers) +(test-visible-output)) +(run-hooks 'notmuch-mua-send-hook)" + +cat+EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "Forwarding adding the forwarded tag" +test_expect_equal $(notmuch search --output=messages tag:forwarded) id:$message_id + +test_done -- 2.20.1 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2 3/4] emacs: Tag forwarded messages with +forwarded (customizable)
Use the buffer-local variable notmuch-message-queued-tag-changes to change tags when the forwarding message is sent. --- emacs/notmuch-message.el | 13 + emacs/notmuch-mua.el | 14 -- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el index e7615998..d3b09501 100644 --- a/emacs/notmuch-message.el +++ b/emacs/notmuch-message.el @@ -38,6 +38,19 @@ the \"inbox\" and \"todo\" tags, you would set: :type '(repeat string) :group 'notmuch-send) +(defcustom notmuch-message-forwarded-tags '("+forwarded") + "List of tag changes to apply to a message when it has been forwarded. + +Tags starting with \"+\" (or not starting with either \"+\" or +\"-\") in the list will be added, and tags starting with \"-\" +will be removed from the message being forwarded. + +For example, if you wanted to add a \"forwarded\" tag and remove +the \"inbox\" tag, you would set: +(\"+forwarded\" \"-inbox\")" + :type '(repeat string) + :group 'notmuch-send) + (defconst notmuch-message-queued-tag-changes nil "List of messages and corresponding tag-changes to be applied when sending a message. diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 0af9c71b..ab271b27 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -477,7 +477,8 @@ the From: address." (list (cons 'From (notmuch-mua-prompt-for-sender) forward-subject ;; Comes from the first message and is ;; applied later. -forward-references) ;; List of accumulated message-references of forwarded messages +forward-references ;; List of accumulated message-references of forwarded messages +forward-queries) ;; List of corresponding message-query ;; Generate the template for the outgoing message. (notmuch-mua-mail nil "" other-headers nil (notmuch-mua-get-switch-function)) @@ -496,7 +497,8 @@ the From: address." ;; always generate a forwarded subject, then use the ;; last (i.e. first) one. (setq forward-subject (message-make-forward-subject)) - (push (message-fetch-field "Message-ID") forward-references)) + (push (message-fetch-field "Message-ID") forward-references) + (push id forward-queries)) ;; Make a copy ready to be forwarded in the ;; composition buffer. (message-forward-make-body temp-buffer) @@ -515,6 +517,14 @@ the From: address." (message-add-header (concat "References: " (mapconcat 'identity forward-references " " + ;; Create a buffer-local queue for tag changes triggered when sending the message + (when notmuch-message-forwarded-tags + (setq-local notmuch-message-queued-tag-changes + (loop for id in forward-queries + collect + (cons id + notmuch-message-forwarded-tags + ;; `message-forward-make-body' shows the User-agent header. Hide ;; it again. (message-hide-headers) -- 2.20.1 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Updating tags when replying or forwarding via a buffer-local variable
Updated version of the patches that add references to forwarded messages, and tags to the messages being forwarded. This version has some cleanups and adds code for testing the functionality for forwarded messages. Örjan Ekeberg (4): emacs: Add References header to forwarded messages emacs: Use a buffer-local variable to update tags when sending replies emacs: Tag forwarded messages with +forwarded (customizable) test: add test for checking forwarded messages emacs/notmuch-message.el | 37 +++ emacs/notmuch-mua.el | 26 +--- test/T730-emacs-forwarding.sh | 35 + 3 files changed, 87 insertions(+), 11 deletions(-) create mode 100755 test/T730-emacs-forwarding.sh -- 2.20.1 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2 2/4] emacs: Use a buffer-local variable to update tags when sending replies
Instead of relying on the "In-Reply-To" header, use a buffer-local variable, notmuch-message-queued-tag-changes, to add and remove tags to affected messages when the message-send-hook is triggered. --- emacs/notmuch-message.el | 24 emacs/notmuch-mua.el | 5 + 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el index 55e4cfee..e7615998 100644 --- a/emacs/notmuch-message.el +++ b/emacs/notmuch-message.el @@ -34,18 +34,26 @@ will be removed from the message being replied to. For example, if you wanted to add a \"replied\" tag and remove the \"inbox\" and \"todo\" tags, you would set: -(\"+replied\" \"-inbox\" \"-todo\"\)" +(\"+replied\" \"-inbox\" \"-todo\")" :type '(repeat string) :group 'notmuch-send) -(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) - (notmuch-tag (notmuch-id-to-query (car (car rep))) - (notmuch-tag-change-list notmuch-message-replied-tags) +(defconst notmuch-message-queued-tag-changes nil + "List of messages and corresponding tag-changes to be applied when sending a message. -(add-hook 'message-send-hook 'notmuch-message-mark-replied) +This variable is overridden by buffer-local versions in message +buffers where tag changes should be triggered when sending off +the message. Each item in this list is a list of strings, where +the first is a notmuch query and the rest are the tag changes to +be applied to the matching messages.") + +(defun notmuch-message-apply-queued-tag-changes () + ;; Apply the tag changes queued in the buffer-local variable notmuch-message-queued-tag-changes. + (dolist (query-and-tags notmuch-message-queued-tag-changes) +(notmuch-tag (car query-and-tags) +(cdr query-and-tags + +(add-hook 'message-send-hook 'notmuch-message-apply-queued-tag-changes) (provide 'notmuch-message) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 23f3d8b1..0af9c71b 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -259,6 +259,11 @@ Typically this is added to `notmuch-mua-send-hook'." (notmuch-headers-plist-to-alist reply-headers) nil (notmuch-mua-get-switch-function + ;; Create a buffer-local queue for tag changes triggered when sending the reply + (when notmuch-message-replied-tags + (setq-local notmuch-message-queued-tag-changes + (list (cons query-string notmuch-message-replied-tags + ;; Insert the message body - but put it in front of the signature ;; if one is present, and after any other content ;; message*setup-hooks may have added to the message body already. -- 2.20.1 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2 1/4] emacs: Add References header to forwarded messages
Include the message-id of forwarded messages in the new message. This ensures that the new (forwarding) message is linked to the same thread as the message being forwarded. --- emacs/notmuch-mua.el | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 708db248..23f3d8b1 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -470,8 +470,9 @@ the From: address." (let* ((other-headers (when (or prompt-for-sender notmuch-always-prompt-for-sender) (list (cons 'From (notmuch-mua-prompt-for-sender) -forward-subject) ;; Comes from the first message and is +forward-subject ;; Comes from the first message and is ;; applied later. +forward-references) ;; List of accumulated message-references of forwarded messages ;; Generate the template for the outgoing message. (notmuch-mua-mail nil "" other-headers nil (notmuch-mua-get-switch-function)) @@ -489,7 +490,8 @@ the From: address." ;; Because we process the messages in reverse order, ;; always generate a forwarded subject, then use the ;; last (i.e. first) one. - (setq forward-subject (message-make-forward-subject))) + (setq forward-subject (message-make-forward-subject)) + (push (message-fetch-field "Message-ID") forward-references)) ;; Make a copy ready to be forwarded in the ;; composition buffer. (message-forward-make-body temp-buffer) @@ -503,7 +505,10 @@ the From: address." (save-restriction (message-narrow-to-headers) (message-remove-header "Subject") - (message-add-header (concat "Subject: " forward-subject))) + (message-add-header (concat "Subject: " forward-subject)) + (message-remove-header "References") + (message-add-header (concat "References: " + (mapconcat 'identity forward-references " " ;; `message-forward-make-body' shows the User-agent header. Hide ;; it again. -- 2.20.1 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 0/2] Updating tags when replying or forwarding via a buffer-local variable
Tomi Ollila writes: > two things > > - I wonder whether we could drop (defun notmuch-message-mark-replied ()...) > - why is it needed for backward compatibility ? Yes, it would be cleaner to simply remove it. My thought was that there is a slight risk that someone is explicitly using or manipulating this function in some personal code. This is probably very unlikely, so I am more than happy to drop it. > > - A test of a few would be nice to see how this behaves -- and we can see > that this still works e.g. on emacs 24... Indeed. I did consider this, but since I am not at all familiar with how to write such tests, I did not proceed with this. /Örjan ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] emacs: Add References header to forwarded messages
Daniel Kahn Gillmor writes: > This seems reasonable to me. I'd personally like forwarded messages to > show up connected to the same thread os the originals, and i don't see a > downside to it. From what I can see, GMail and Outlook already does this (include a references-header in forwarding messages), so it seems unlikely that notmuch/emacs behaving the same would cause incompatibility issues. /Örjan ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 2/2] emacs: Tag forwarded messages with +forwarded (customizable)
Use the buffer-local variable notmuch-message-queued-tag-changes to change tags when the forwarding message is sent. --- emacs/notmuch-message.el | 13 + emacs/notmuch-mua.el | 21 ++--- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el index 513bbe66..f6466de8 100644 --- a/emacs/notmuch-message.el +++ b/emacs/notmuch-message.el @@ -38,6 +38,19 @@ the \"inbox\" and \"todo\" tags, you would set: :type '(repeat string) :group 'notmuch-send) +(defcustom notmuch-message-forwarded-tags '("+forwarded") + "List of tag changes to apply to a message when it has been forwarded. + +Tags starting with \"+\" (or not starting with either \"+\" or +\"-\") in the list will be added, and tags starting with \"-\" +will be removed from the message being forwarded. + +For example, if you wanted to add a \"forwarded\" tag and remove +the \"inbox\" tag, you would set: +(\"+forwarded\" \"-inbox\")" + :type '(repeat string) + :group 'notmuch-send) + ;; This function is not used by default, but kept for backward compatibility (defun notmuch-message-mark-replied () ;; get the in-reply-to header and parse it for the message id. diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index b23a8c2d..4030399e 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -477,7 +477,8 @@ the From: address." (list (cons 'From (notmuch-mua-prompt-for-sender) forward-subject ;; Comes from the first message and is ;; applied later. -forward-references) ;; Accumulated message-ids of forwarded messages +forward-references ;; List of accumulated message-references of forwarded messages +forward-queries) ;; List of corresponding message-query ;; Generate the template for the outgoing message. (notmuch-mua-mail nil "" other-headers nil (notmuch-mua-get-switch-function)) @@ -496,11 +497,8 @@ the From: address." ;; always generate a forwarded subject, then use the ;; last (i.e. first) one. (setq forward-subject (message-make-forward-subject)) - (if forward-references - (setq forward-references - (concat forward-references ", " - (message-fetch-field "Message-ID"))) - (setq forward-references (message-fetch-field "Message-ID" + (push (message-fetch-field "Message-ID") forward-references) + (push id forward-queries)) ;; Make a copy ready to be forwarded in the ;; composition buffer. (message-forward-make-body temp-buffer) @@ -516,7 +514,16 @@ the From: address." (message-remove-header "Subject") (message-add-header (concat "Subject: " forward-subject)) (message-remove-header "References") - (message-add-header (concat "References: " forward-references))) + (message-add-header (concat "References: " + (mapconcat 'identity forward-references ", " + + ;; Create a buffer-local queue for tag changes triggered when sending the message + (when notmuch-message-forwarded-tags + (setq-local notmuch-message-queued-tag-changes + (loop for id in forward-queries + collect + (cons id + notmuch-message-forwarded-tags ;; `message-forward-make-body' shows the User-agent header. Hide ;; it again. -- 2.20.1 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 0/2] Updating tags when replying or forwarding via a buffer-local variable
These patches implement a message-send-hook which uses a buffer-local variable to tag replied and forwarded messages. The first patch replaces the current heuristic hook for detecting reply messages with an explicit setting when the reply is composed. The second patch adds the corresponding mechanism for forwarded messages. This patch is on top of a previously submitted patch (for adding a References header), and will not apply cleanly without that. Örjan Ekeberg (2): emacs: Use a buffer-local variable to update tags when sending replies emacs: Tag forwarded messages with +forwarded (customizable) emacs/notmuch-message.el | 34 -- emacs/notmuch-mua.el | 26 +++--- 2 files changed, 51 insertions(+), 9 deletions(-) -- 2.20.1 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 1/2] emacs: Use a buffer-local variable to update tags when sending replies
Instead of relying on the "In-Reply-To" header, use a buffer-local variable, notmuch-message-queued-tag-changes, to add and remove tags to affected messages when the message-send-hook is triggered. --- emacs/notmuch-message.el | 21 +++-- emacs/notmuch-mua.el | 5 + 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el index 55e4cfee..513bbe66 100644 --- a/emacs/notmuch-message.el +++ b/emacs/notmuch-message.el @@ -34,10 +34,11 @@ will be removed from the message being replied to. For example, if you wanted to add a \"replied\" tag and remove the \"inbox\" and \"todo\" tags, you would set: -(\"+replied\" \"-inbox\" \"-todo\"\)" +(\"+replied\" \"-inbox\" \"-todo\")" :type '(repeat string) :group 'notmuch-send) +;; This function is not used by default, but kept for backward compatibility (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" @@ -45,7 +46,23 @@ the \"inbox\" and \"todo\" tags, you would set: (notmuch-tag (notmuch-id-to-query (car (car rep))) (notmuch-tag-change-list notmuch-message-replied-tags) -(add-hook 'message-send-hook 'notmuch-message-mark-replied) + +(defconst notmuch-message-queued-tag-changes nil + "List of messages and corresponding tag-changes to be applied when sending a message. + +This variable is overridden by buffer-local versions in message +buffers where tag changes should be triggered when sending off +the message. Each item in this list is a list of strings, where +the first is a notmuch query and the rest are the tag changes to +be applied to the matching messages.") + +(defun notmuch-message-apply-queued-tag-changes () + ;; Apply the tag changes queued in the buffer-local variable notmuch-message-queued-tag-changes. + (dolist (query-and-tags notmuch-message-queued-tag-changes) +(notmuch-tag (car query-and-tags) +(cdr query-and-tags + +(add-hook 'message-send-hook 'notmuch-message-apply-queued-tag-changes) (provide 'notmuch-message) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index ed15bbb2..b23a8c2d 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -259,6 +259,11 @@ Typically this is added to `notmuch-mua-send-hook'." (notmuch-headers-plist-to-alist reply-headers) nil (notmuch-mua-get-switch-function + ;; Create a buffer-local queue for tag changes triggered when sending the reply + (when notmuch-message-replied-tags + (setq-local notmuch-message-queued-tag-changes + (list (cons query-string notmuch-message-replied-tags + ;; Insert the message body - but put it in front of the signature ;; if one is present, and after any other content ;; message*setup-hooks may have added to the message body already. -- 2.20.1 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[RFC PATCH] forward: Add References header to forwarded messages
Include the message-id of forwarded messages in the new message. This ensures that the new message is linked to the same thread. --- emacs/notmuch-mua.el | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index e205fa4c..1ba9317e 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -433,8 +433,9 @@ the From: address." (let* ((other-headers (when (or prompt-for-sender notmuch-always-prompt-for-sender) (list (cons 'From (notmuch-mua-prompt-for-sender) -forward-subject) ;; Comes from the first message and is +forward-subject ;; Comes from the first message and is ;; applied later. +forward-references) ;; Accumulated message-ids of forwarded messages ;; Generate the template for the outgoing message. (notmuch-mua-mail nil "" other-headers nil (notmuch-mua-get-switch-function)) @@ -452,7 +453,12 @@ the From: address." ;; Because we process the messages in reverse order, ;; always generate a forwarded subject, then use the ;; last (i.e. first) one. - (setq forward-subject (message-make-forward-subject))) + (setq forward-subject (message-make-forward-subject)) + (if forward-references + (setq forward-references + (concat forward-references ", " + (message-fetch-field "Message-ID"))) + (setq forward-references (message-fetch-field "Message-ID" ;; Make a copy ready to be forwarded in the ;; composition buffer. (message-forward-make-body temp-buffer) @@ -466,7 +472,9 @@ the From: address." (save-restriction (message-narrow-to-headers) (message-remove-header "Subject") - (message-add-header (concat "Subject: " forward-subject))) + (message-add-header (concat "Subject: " forward-subject)) + (message-remove-header "References") + (message-add-header (concat "References: " forward-references))) ;; `message-forward-make-body' shows the User-agent header. Hide ;; it again. -- 2.20.1 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: Threading of forwarded messages
Tomi Ollila writes: > notmuch-mua-new-forward-messages would be the place adding message-id's > to the references header (perhaps where 'appropriate subject' is added) > probably not much work but SMOP anyway ;/ Indeed. Here is an attempt that seems to do the trick. This is a modified version of notmuch-mua-new-forward-messages (extracted from notmuch-mua-el). Sorry for not posting it as a patch. Changes are the lines involving the variable forward-references. Please check if this is the right approach. (defun notmuch-mua-new-forward-messages (messages prompt-for-sender) "Compose a new message forwarding MESSAGES. If PROMPT-FOR-SENDER is non-nil, the user will be prompteed for the From: address." (let* ((other-headers (when (or prompt-for-sender notmuch-always-prompt-for-sender) (list (cons 'From (notmuch-mua-prompt-for-sender) forward-subject ;; Comes from the first message and is ;; applied later. forward-references) ;; Accumulated message-ids of forwarded messages ;; Generate the template for the outgoing message. (notmuch-mua-mail nil "" other-headers nil (notmuch-mua-get-switch-function)) (save-excursion ;; Insert all of the forwarded messages. (mapc (lambda (id) (let ((temp-buffer (get-buffer-create (concat "*notmuch-fwd-raw-" id "*" ;; Get the raw version of this message in the buffer. (with-current-buffer temp-buffer (erase-buffer) (let ((coding-system-for-read 'no-conversion)) (call-process notmuch-command nil t nil "show" "--format=raw" id)) ;; Because we process the messages in reverse order, ;; always generate a forwarded subject, then use the ;; last (i.e. first) one. (setq forward-subject (message-make-forward-subject)) (if forward-references (setq forward-references (concat forward-references ", " (message-fetch-field "Message-ID"))) (setq forward-references (message-fetch-field "Message-ID" ;; Make a copy ready to be forwarded in the ;; composition buffer. (message-forward-make-body temp-buffer) ;; Kill the temporary buffer. (kill-buffer temp-buffer))) ;; `message-forward-make-body' always puts the message at ;; the top, so do them in reverse order. (reverse messages)) ;; Add in the appropriate subject. (save-restriction (message-narrow-to-headers) (message-remove-header "Subject") (message-add-header (concat "Subject: " forward-subject)) (message-remove-header "References") (message-add-header (concat "References: " forward-references))) ;; `message-forward-make-body' shows the User-agent header. Hide ;; it again. (message-hide-headers) (set-buffer-modified-p nil ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Threading of forwarded messages
Hi, Let me first say that I am a very happy user of notmuch+emacs. Once the initial setup and configuration was done, usage has been a very pleasant experience. It daily saves me from getting lost in the constant torrent of incoming e-mail, where most need replies or to be forwarded to others to deal with. One thing that I have not been able to configure is the handling of forwarded messages. Forwarded messages are archived as new messages, not linked to the messages being forwarded. This makes it hard to keep track of which messages I have forwarded (and therefore is in the hands of someone else). I would like the messages to be linked into the same thread. From what I understand, it would be sufficient if notmuch-mua-new-forward-messages (or something further down the call chain) would add the Message-Id of the forwarded message to the References header line of the new message. This is what happens when using reply instead of forward. Manually adding such a references-head before sending seems to have the desired effect of linking them into the same thread. Also, from what I can see, gmail does indeed include such a Refrerences-head when doing forward. Adding to the wishlist; it would be nice if forwarded messages could also be tagged as "forwarded", much like how replied messages are tagged "replied". I guess this could be done via some sort of forward-hook, but I can not find anything like this. /Örjan ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch