unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Edmondson <dme@dme.org>
To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org
Subject: Re: [PATCH 2/2] emacs: show: allow user to insert rfc822 parts as messages
Date: Mon, 28 Aug 2017 11:26:07 +0100	[thread overview]
Message-ID: <cunmv6kng3k.fsf@dme.org> (raw)
In-Reply-To: <1503905542-19961-3-git-send-email-markwalters1009@gmail.com>

On Monday, 2017-08-28 at 08:32:22 +0100, 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.
>
> 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

See previous comments.

> +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

Missing a period.

> +  (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))))

Why this? It would be nice to have a comment explaining it.

> +
> +(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

dme.
-- 
All those lines and circles, to me, a mystery.

  reply	other threads:[~2017-08-28 10:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-28  7:32 [PATCH 0/2] emacs: allow message/rfc822 to be inserted in the mailstore Mark Walters
2017-08-28  7:32 ` [PATCH 1/2] emacs: maildir fcc make insert more flexible Mark Walters
2017-08-28 10:23   ` David Edmondson
2017-08-28 11:27     ` Mark Walters
2017-08-28 13:40       ` David Edmondson
2017-09-07 11:23         ` David Bremner
2017-08-28  7:32 ` [PATCH 2/2] emacs: show: allow user to insert rfc822 parts as messages Mark Walters
2017-08-28 10:26   ` David Edmondson [this message]
2017-08-28 11:29     ` Mark Walters

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cunmv6kng3k.fsf@dme.org \
    --to=dme@dme.org \
    --cc=markwalters1009@gmail.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).