This adds a part-handler function that uses notmuch-insert to insert an rfc822 part as a message in its own right. This allows the user to reply directly to that message.
We use notmuch-maildir-fcc-with-notmuch-insert as that has builtin error handling/retry functionality, and it allows the user to specify tags to identify the inserted message. The format of the folder/tags line is the same as for Fcc: headers when using notmuch insert. --- emacs/notmuch-show.el | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index cd901e4..b3717d0 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -143,6 +143,20 @@ indentation." (const :tag "View interactively" notmuch-show-interactively-view-part))) +(defcustom notmuch-show-part-notmuch-insert-folder "" + "Default folder/tags to use when inserting rfc822 parts into the database. + +It should be of the form \"folder +tag1 -tag2\" where folder is +the folder (relative to the notmuch mailstore) to store the +message in, and tag1 and tag2 are tag changes to apply to the +stored message. This string is split using +`split-string-and-unquote', so a folder name containing spaces +can be specified by quoting each space with an immediately +preceding backslash or surrounding the entire folder name in +double quotes." + :group 'notmuch-show + :type 'string) + (defcustom notmuch-show-only-matching-messages nil "Only matching messages are shown by default." :type 'boolean @@ -1448,6 +1462,7 @@ reset based on the original query." (define-key map "o" 'notmuch-show-interactively-view-part) (define-key map "|" 'notmuch-show-pipe-part) (define-key map "m" 'notmuch-show-choose-mime-of-part) + (define-key map "i" 'notmuch-show-notmuch-insert-part) (define-key map "?" 'notmuch-subkeymap-help) map) "Submap for part commands") @@ -2463,6 +2478,26 @@ part to be treated as if it had that mime-type." (interactive) (notmuch-show-apply-to-current-part-handle #'mm-pipe-part)) +(defun notmuch-show--notmuch-insert-handle (handle) + "Notmuch insert the part associated with HANDLE." + ;; This is based on mm-pipe-part + (let* ((folder + (read-from-minibuffer "Folder/tags to insert part to: " + notmuch-show-part-notmuch-insert-folder))) + (mm-with-unibyte-buffer + (mm-insert-part handle) + (notmuch-maildir-fcc-with-notmuch-insert folder nil "Folder/tags to insert part to") + (message nil)))) + +(defun notmuch-show-notmuch-insert-part () + "If the current part is rfc822 then insert into the mailstore" + (interactive) + (let* ((part (notmuch-show-get-part-properties)) + (computed-type (plist-get part :computed-type))) + (if (notmuch-match-content-type computed-type "message/rfc822") + (notmuch-show-apply-to-current-part-handle + #'notmuch-show--notmuch-insert-handle) + (message "Not a message/rfc822 part.")))) (defun notmuch-show--mm-display-part (handle) "Use mm-display-part to display HANDLE in a new buffer. -- 2.1.4 _______________________________________________ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch