On 23Aug2016 19:47, Jethro Tull <heavyt...@hotmail.com> wrote:
On 16Aug2016 19:58, Jethro Tull <heavyt...@hotmail.com> wrote:
>I'm using vim as editor in mutt. I would like to find a way to dump the
>content of another email or part to a new message while being composed. Of
>course without running a new instance of mutt.

Why not by running a new instance of mutt?

Without that, you need some kind of tool that _vim_ can invoke to access
message content. How are you intending to designate that message from inside
vim? [...]

sometimes while composing I could spontaneously need to put all or part of
another email or many others.

So I could save and close the current composition, then from that point I would
need to browse my emails and edit the ones I want to select what I want and
dump the selection into the email I was composing before without a copy/paste
process which would complicate things if I need the content of many emails.

The tricky thing I'm searching about is how to select the right file which
corresponds to the email I was composing. I could of course browse the files in
my maildir repo from within vim, but it doesn't look like a right way because,
first, the files in the maildir repo seem to be named randomly, second, what if
my emails were stored in an mbox format? It's a complicated thing because
edition is made from within vim and email browing is done with mutt.

Firstly, it sounds like you're doing this in a single window; is there any special reason for that?

Secondly, regarding the collection of these extra messages, I suggest getting them from mutt itself, and copying them into a separate file (even a scratch mbox file). More on that later.

It sound to me like you proposed workflow needs:

 a way to suspend your composition

a way to browse you email to find relevant messages, and to save their content for later use in your composition

 a way to resume your composition and incorporate your saved message text

The first thing to point out is that _outside_ the editing phase of composition, mutt has a "postpone" action normally bound to "P". So you can quit the editor and instead of sending or aborting your message, postpone it. Have a visit to the manual:

 http://www.mutt.org/doc/manual/

and check out the settings for $postpone and $postponed, and the section on Postponing Mail:

 http://www.mutt.org/doc/manual/#postponing-mail

I confess I don't use this, but it seems almost purpose built for your needs.

My approach is a little different (I really must write this up properly in the mutt wiki): I use these settings in my muttrc:

 set autoedit=yes
 set edit_headers=yes
 set editor=$EDITOR
 macro index g "<sync-mailbox>:set editor=muttedit<enter><group-reply>:set 
editor=$EDITOR<enter>" "group reply"

and this script:

 https://bitbucket.org/cameron_simpson/css/src/tip/bin/muttedit

$EDITOR is vim, as I imagine it is for you. But when I reply to a message (I always use "g" for this, hence the macro) I replace mutt's default $editor setting with "muttedit". This is a special script which is used in place of the editor, saving the new message temp file and starting a tmux or screen session containing a new "mutt -H" to compose a message based on a copy of that temp file.

The benefit here is that now your composition is in a tmux or screen session, and you can detach from it (returning to your original mutt session) and reattach later. To illustrate, this is in action right now while I write my message, and if I go "tmux list-sessions" it shows this line:

 mutt-24aug2016-19_02-Re__add_the_content_of_another_email_to_new_message: 1 
windows (created Wed Aug 24 19:02:19 2016) [178x24] (attached)

which is fairly descriptive; if I detached now, I could resume later by opening that session.

The mutt settings above are to provide a seamless feel to this. Using autoedit and edit_headers means the complete message text is in the temp file and the edit (the muttedit wrapper script) is started immediately. It copies the temp file and spawns the tmux session, running a mutt in compose-new-message mode using the temp file as a template.

The nifty bit is this: in a normal mutt, if you quit comoposition without having changes the temp file at all, mutt silently returns to your reading mode without complaint. Because "muttedit" just takes a copy and spawns a separate session, regardless of whether you finish and send, or detach and resume later, as far as your main mutt is concerned the temp file was untouched and you're back in mutt.

Anyway, as a first cut I suggest you try mutt's postpone mechanism. I can help you with muttedit later if you want to try that too.

To your "find other messages" issue, that should now be much easier ecause you can abandon your composition and return to it.

With that I'd be inclined to locate the other messages in mutt after you postpone/suspend your current message. Two methods suggest themselves for collecting these other messages: <copy-message> the message to a scratch mbox file; you will end up with a nice flat mbox with all the text you want for use later

<edit-message> each message, and copy text out using vim into a scratch file without changing the original (:w >>scratch_file I think).

Having stashed the text you want, return to the original message and continue composition.

Cheers,
Cameron Simpson <c...@zip.com.au>

Reply via email to