[PATCH] emacs: show: allow user to insert rfc822 parts as messages
David Edmondson
dme at dme.org
Mon May 23 05:24:28 PDT 2016
On Fri, May 20 2016, Mark Walters wrote:
> 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.
This looks useful, a couple of minor comments:
- it would be nice to have a general "add a file to the database using
insert" function rather than the current smashed together with rfc822
thing,
- the terminology and function naming confused me a lot initially - I
had no idea what support was being added. This probably stems from
notmuch-show using the term "insert" to mean "add content to the
display buffer". Could you come up with a more descriptive name for
`notmuch-show-insert-part'?
> ---
>
> I receive quite a lot of forwarded messages which include the original
> message as an rfc822 part, and have used this for quite some time
> without any problems.
>
> Best wishes
>
> Mark
>
>
> emacs/notmuch-show.el | 29 ++++++++++++++++++++++++-----
> 1 file changed, 24 insertions(+), 5 deletions(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 5d9b7b4..de41a8f 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -141,6 +141,11 @@ indentation."
> (const :tag "View interactively"
> notmuch-show-interactively-view-part)))
>
> +(defcustom notmuch-show-part-insert-folder ""
> + "Default folder to insert rfc822 parts"
> + :group 'notmuch-show
> + :type 'string)
> +
> (defcustom notmuch-show-only-matching-messages nil
> "Only matching messages are shown by default."
> :type 'boolean
> @@ -1403,6 +1408,7 @@ reset based on the original query."
> (define-key map "v" 'notmuch-show-view-part)
> (define-key map "o" 'notmuch-show-interactively-view-part)
> (define-key map "|" 'notmuch-show-pipe-part)
> + (define-key map "i" 'notmuch-show-insert-part)
> (define-key map "?" 'notmuch-subkeymap-help)
> map)
> "Submap for part commands")
> @@ -2330,11 +2336,13 @@ caller is responsible for killing this buffer as appropriate."
> (disposition (if filename `(attachment (filename . ,filename)))))
> (mm-make-handle buf (list computed-type) nil nil disposition)))
>
> -(defun notmuch-show-apply-to-current-part-handle (fn)
> +(defun notmuch-show-apply-to-current-part-handle (fn &rest args)
> "Apply FN to an mm-handle for the part containing point.
>
> -This ensures that the temporary buffer created for the mm-handle
> -is destroyed when FN returns."
> +Any ARGS are passed to the function FN as arguments after the mm-handle.
> +
> +This function ensures that the temporary buffer created for the
> +mm-handle is destroyed when FN returns."
> (let ((handle (notmuch-show-current-part-handle)))
> ;; emacs 24.3+ puts stdout/stderr into the calling buffer so we
> ;; call it from a temp-buffer, unless
> @@ -2343,9 +2351,9 @@ is destroyed when FN returns."
> (unwind-protect
> (if notmuch-show-attachment-debug
> (with-current-buffer (generate-new-buffer " *notmuch-part*")
> - (funcall fn handle))
> + (apply fn handle args))
> (with-temp-buffer
> - (funcall fn handle)))
> + (apply fn handle args)))
> (kill-buffer (mm-handle-buffer handle)))))
>
> (defun notmuch-show-part-button-default (&optional button)
> @@ -2379,6 +2387,17 @@ is destroyed when FN returns."
> (interactive)
> (notmuch-show-apply-to-current-part-handle #'mm-pipe-part))
>
> +(defun notmuch-show-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")
> + (let* ((folder (read-from-minibuffer "Folder to save part to: "
> + notmuch-show-part-insert-folder))
> + (cmd (concat notmuch-command " insert --folder=" folder)))
> + (notmuch-show-apply-to-current-part-handle #'mm-pipe-part cmd))
> + (message "Not a message/rfc822 part."))))
>
> (provide 'notmuch-show)
>
> --
> 2.1.4
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch
More information about the notmuch
mailing list