* [PATCH 0/2] emacs: allow message/rfc822 to be inserted in the mailstore @ 2017-08-28 7:32 Mark Walters 2017-08-28 7:32 ` [PATCH 1/2] emacs: maildir fcc make insert more flexible Mark Walters 2017-08-28 7:32 ` [PATCH 2/2] emacs: show: allow user to insert rfc822 parts as messages Mark Walters 0 siblings, 2 replies; 9+ messages in thread From: Mark Walters @ 2017-08-28 7:32 UTC (permalink / raw) To: notmuch Several people including id:87bmnlko2o.fsf@len have asked to be able to reply directly to message/rfc822 messages from the emacs frontend. Doing that in emacs would be likely to be a little fragile as all other replies are generated by the cli code. This pair of patches provide an alternative approach: let the user insert the attached message directly into the mailstore. Once it is there, the user can reply as normal. I have been running something like this for a long time (see id:1463744295-12533-1-git-send-email-markwalters1009@gmail.com for my earlier version) with no problems. This new version includes some better error checking, and allows the user to specify tags for the inserted message. The new version is not heavily tested but seems to work. Best wishes Mark Mark Walters (2): emacs: maildir fcc make insert more flexible emacs: show: allow user to insert rfc822 parts as messages emacs/notmuch-maildir-fcc.el | 16 ++++++++++------ emacs/notmuch-show.el | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 6 deletions(-) -- 2.1.4 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] emacs: maildir fcc make insert more flexible 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 ` Mark Walters 2017-08-28 10:23 ` David Edmondson 2017-08-28 7:32 ` [PATCH 2/2] emacs: show: allow user to insert rfc822 parts as messages Mark Walters 1 sibling, 1 reply; 9+ messages in thread From: Mark Walters @ 2017-08-28 7:32 UTC (permalink / raw) To: notmuch This changeset makes the function notmuch-maildir-fcc-with-notmuch-insert slightly more flexible by allowing some of the prompts to be controlled by the caller. --- emacs/notmuch-maildir-fcc.el | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el index 1551e8b..acff24d 100644 --- a/emacs/notmuch-maildir-fcc.el +++ b/emacs/notmuch-maildir-fcc.el @@ -227,7 +227,7 @@ should be a list of tag changes to apply to the inserted message." (apply 'notmuch-call-notmuch-process :stdin-string (buffer-string) "insert" args))) -(defun notmuch-maildir-fcc-with-notmuch-insert (fcc-header &optional create) +(defun notmuch-maildir-fcc-with-notmuch-insert (fcc-header &optional create header-name) "Store message with notmuch insert. The fcc-header should be of the form \"folder +tag1 -tag2\" where @@ -239,7 +239,8 @@ quoting each space with an immediately preceding backslash or surrounding the entire folder name in double quotes. If CREATE is non-nil then create the folder if necessary." - (let* ((args (split-string-and-unquote fcc-header)) + (let* ((header-name (or header-name "Fcc header")) + (args (split-string-and-unquote fcc-header)) (folder (car args)) (tags (cdr args))) (condition-case nil @@ -250,14 +251,17 @@ If CREATE is non-nil then create the folder if necessary." ;; how to deal with it. (error (let ((response (notmuch-read-char-choice - "Insert failed: (r)etry, (c)reate folder, (i)gnore, or (e)dit the header? " + (concat + "Insert failed: (r)etry, (c)reate folder, (i)gnore, or (e)dit the " + header-name "? ") '(?r ?c ?i ?e)))) (case response - (?r (notmuch-maildir-fcc-with-notmuch-insert fcc-header)) - (?c (notmuch-maildir-fcc-with-notmuch-insert fcc-header 't)) + (?r (notmuch-maildir-fcc-with-notmuch-insert fcc-header nil header-name)) + (?c (notmuch-maildir-fcc-with-notmuch-insert fcc-header 't header-name)) (?i 't) (?e (notmuch-maildir-fcc-with-notmuch-insert - (read-from-minibuffer "Fcc header: " fcc-header))))))))) + (read-from-minibuffer (concat header-name ": ") fcc-header) + nil header-name)))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -- 2.1.4 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] emacs: maildir fcc make insert more flexible 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 0 siblings, 1 reply; 9+ messages in thread From: David Edmondson @ 2017-08-28 10:23 UTC (permalink / raw) To: Mark Walters, notmuch On Monday, 2017-08-28 at 08:32:21 +0100, Mark Walters wrote: > This changeset makes the function > notmuch-maildir-fcc-with-notmuch-insert slightly more flexible by > allowing some of the prompts to be controlled by the caller. > --- > emacs/notmuch-maildir-fcc.el | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) > > diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el > index 1551e8b..acff24d 100644 > --- a/emacs/notmuch-maildir-fcc.el > +++ b/emacs/notmuch-maildir-fcc.el > @@ -227,7 +227,7 @@ should be a list of tag changes to apply to the inserted message." > (apply 'notmuch-call-notmuch-process > :stdin-string (buffer-string) "insert" args))) > > -(defun notmuch-maildir-fcc-with-notmuch-insert (fcc-header &optional create) > +(defun notmuch-maildir-fcc-with-notmuch-insert (fcc-header &optional create header-name) Given that this is not FCC specific, perhaps rename it? > "Store message with notmuch insert. > > The fcc-header should be of the form \"folder +tag1 -tag2\" where I realise that this patch set didn't add this string, but it is mildly ridiculous. There's no reason that we couldn't use a list, where a leading “+” or “-” indicates a tag and anything else is a folder. Even two variables (one for folder and another for tags) would be an improvement > @@ -239,7 +239,8 @@ quoting each space with an immediately preceding backslash > or surrounding the entire folder name in double quotes. > > If CREATE is non-nil then create the folder if necessary." > - (let* ((args (split-string-and-unquote fcc-header)) > + (let* ((header-name (or header-name "Fcc header")) > + (args (split-string-and-unquote fcc-header)) > (folder (car args)) > (tags (cdr args))) > (condition-case nil > @@ -250,14 +251,17 @@ If CREATE is non-nil then create the folder if necessary." > ;; how to deal with it. > (error > (let ((response (notmuch-read-char-choice > - "Insert failed: (r)etry, (c)reate folder, (i)gnore, or (e)dit the header? " > + (concat > + "Insert failed: (r)etry, (c)reate folder, (i)gnore, or (e)dit the " > + header-name "? ") > '(?r ?c ?i ?e)))) > (case response > - (?r (notmuch-maildir-fcc-with-notmuch-insert fcc-header)) > - (?c (notmuch-maildir-fcc-with-notmuch-insert fcc-header 't)) > + (?r (notmuch-maildir-fcc-with-notmuch-insert fcc-header nil header-name)) > + (?c (notmuch-maildir-fcc-with-notmuch-insert fcc-header 't header-name)) > (?i 't) > (?e (notmuch-maildir-fcc-with-notmuch-insert > - (read-from-minibuffer "Fcc header: " fcc-header))))))))) > + (read-from-minibuffer (concat header-name ": ") fcc-header) > + nil header-name)))))))) > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > -- > 2.1.4 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > https://notmuchmail.org/mailman/listinfo/notmuch dme. -- Walk without rhythm and it won't attract the worm. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] emacs: maildir fcc make insert more flexible 2017-08-28 10:23 ` David Edmondson @ 2017-08-28 11:27 ` Mark Walters 2017-08-28 13:40 ` David Edmondson 0 siblings, 1 reply; 9+ messages in thread From: Mark Walters @ 2017-08-28 11:27 UTC (permalink / raw) To: David Edmondson, notmuch Hi Thanks for the review. On Mon, 28 Aug 2017, David Edmondson <dme@dme.org> wrote: > On Monday, 2017-08-28 at 08:32:21 +0100, Mark Walters wrote: > >> This changeset makes the function >> notmuch-maildir-fcc-with-notmuch-insert slightly more flexible by >> allowing some of the prompts to be controlled by the caller. >> --- >> emacs/notmuch-maildir-fcc.el | 16 ++++++++++------ >> 1 file changed, 10 insertions(+), 6 deletions(-) >> >> diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el >> index 1551e8b..acff24d 100644 >> --- a/emacs/notmuch-maildir-fcc.el >> +++ b/emacs/notmuch-maildir-fcc.el >> @@ -227,7 +227,7 @@ should be a list of tag changes to apply to the inserted message." >> (apply 'notmuch-call-notmuch-process >> :stdin-string (buffer-string) "insert" args))) >> >> -(defun notmuch-maildir-fcc-with-notmuch-insert (fcc-header &optional create) >> +(defun notmuch-maildir-fcc-with-notmuch-insert (fcc-header &optional create header-name) > > Given that this is not FCC specific, perhaps rename it? Yes that might make sense. > >> "Store message with notmuch insert. >> >> The fcc-header should be of the form \"folder +tag1 -tag2\" where > > I realise that this patch set didn't add this string, but it is mildly > ridiculous. There's no reason that we couldn't use a list, where a > leading “+” or “-” indicates a tag and anything else is a folder. > > Even two variables (one for folder and another for tags) would be an > improvement The reason for this choice is that, when writing the postpone code, I wanted to keep within the message mode compose world, which has the fcc header as a string. I think I would also only like to be queried once when inserting. Or are you suggesting that the user types in a lisp list? Best wishes Mark ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] emacs: maildir fcc make insert more flexible 2017-08-28 11:27 ` Mark Walters @ 2017-08-28 13:40 ` David Edmondson 2017-09-07 11:23 ` David Bremner 0 siblings, 1 reply; 9+ messages in thread From: David Edmondson @ 2017-08-28 13:40 UTC (permalink / raw) To: Mark Walters, notmuch On Monday, 2017-08-28 at 12:27:03 +0100, Mark Walters wrote: >>> The fcc-header should be of the form \"folder +tag1 -tag2\" where >> >> I realise that this patch set didn't add this string, but it is mildly >> ridiculous. There's no reason that we couldn't use a list, where a >> leading “+” or “-” indicates a tag and anything else is a folder. >> >> Even two variables (one for folder and another for tags) would be an >> improvement > > The reason for this choice is that, when writing the postpone code, I > wanted to keep within the message mode compose world, which has the fcc > header as a string. You could add whatever headers you like. > I think I would also only like to be queried once when inserting. Or are > you suggesting that the user types in a lisp list? If we prompt for it then we could do multiple prompts - we already have a completion-capable reader for tags. dme. -- I'm catching up with myself! ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] emacs: maildir fcc make insert more flexible 2017-08-28 13:40 ` David Edmondson @ 2017-09-07 11:23 ` David Bremner 0 siblings, 0 replies; 9+ messages in thread From: David Bremner @ 2017-09-07 11:23 UTC (permalink / raw) To: David Edmondson, Mark Walters, notmuch David Edmondson <dme@dme.org> writes: > On Monday, 2017-08-28 at 12:27:03 +0100, Mark Walters wrote: > >>>> The fcc-header should be of the form \"folder +tag1 -tag2\" where >>> >>> I realise that this patch set didn't add this string, but it is mildly >>> ridiculous. There's no reason that we couldn't use a list, where a >>> leading “+” or “-” indicates a tag and anything else is a folder. >>> >>> Even two variables (one for folder and another for tags) would be an >>> improvement >> >> The reason for this choice is that, when writing the postpone code, I >> wanted to keep within the message mode compose world, which has the fcc >> header as a string. > > You could add whatever headers you like. > >> I think I would also only like to be queried once when inserting. Or are >> you suggesting that the user types in a lisp list? > > If we prompt for it then we could do multiple prompts - we already have > a completion-capable reader for tags. > There was in fact a request for this feature in id:87shgtgiux.fsf@len. OTOH, it seems like a lot of this discussion talks about enhancing or re-factoring the existing draft/fcc handling. Would it be possible to seperate that out, even if it means a list of pre-requisite changes before this feature is added? d ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/2] emacs: show: allow user to insert rfc822 parts as messages 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 7:32 ` Mark Walters 2017-08-28 10:26 ` David Edmondson 1 sibling, 1 reply; 9+ messages in thread From: Mark Walters @ 2017-08-28 7:32 UTC (permalink / raw) To: notmuch 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 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] emacs: show: allow user to insert rfc822 parts as messages 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 2017-08-28 11:29 ` Mark Walters 0 siblings, 1 reply; 9+ messages in thread From: David Edmondson @ 2017-08-28 10:26 UTC (permalink / raw) To: Mark Walters, notmuch 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. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] emacs: show: allow user to insert rfc822 parts as messages 2017-08-28 10:26 ` David Edmondson @ 2017-08-28 11:29 ` Mark Walters 0 siblings, 0 replies; 9+ messages in thread From: Mark Walters @ 2017-08-28 11:29 UTC (permalink / raw) To: David Edmondson, notmuch > >> + (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. Assuming you mean the message nil bit, This is actually me being dim. I want to remove things like the retry message. But it would be much better to make the insert-part function return something saying whether it succeeded or not, and then give a useful message. Best wishes Mark ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-09-07 11:24 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 2017-08-28 11:29 ` Mark Walters
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).