vim as editor
Cameron Simpson
cs at cskk.id.au
Fri Mar 14 23:53:51 UTC 2025
On 13Mar2025 15:25, hable at hs-bit.de <hable at hs-bit.de> wrote:
>As editor I set a script that calls the vim-editor in a new
>tmux-window,
>so I can jump back to my INBOX independently of creating some messages
>in the background 👍
>But this solution works ONLY if I create a new message! If I want to
>open a existing message in the background I can not jump back to the
>INBOX because mutt is blocking till I close the vim editor.
>In my settings I have the line:
> set editor='/home/schule/.config/mutt/bgedit-tmux.sh vim'
>for calling the vim in a new tmux window.
>Is there a difference how mutt calls the external editor when I create a
>new message and when I only edit a existing message?
I do something similar.
The return-to-the-inbox-from-tmux approach relies on a (very useful)
quirk of mutt - if you quit a new message _unchanged_ it quietly doesn't
send.
I haven't looked at bgedit-tmux.sh itself, but I have a script of my own
for exactly the same purpose.
So the flow with making a new message goes:
- ordinary mutt edit-new-message
- the script runs as the editor, making a copy of the original temp file
- it starts a new mutt in the tmux composing a message from the copy, to
send when complete
When you leave tmux, the _original_ temp file is unchanged and mutt
quietly returns to the index view, sending nothing.
It is the distinct mutt in the tmux session which does any sending.
Editing a message in the inbox is rather different - it just runs an
editor on the message and rereads the modified message file when you're
done.
To make this a detachable thing in mutt you'd need the editor to know
how to independently open the message file. FOr a Maildir or MH folder
that might be feasible, as each message lives in its own file. For an
mbox file this isn't feasible because the entire folder is in one big
mbox format file.
For this reason, I only set editor to the tmux-mediated editor script
for replies or new messages with this cumbersome macro:
macro index g ":set my_old_editor=\$editor<enter>:set editor=muttedit<enter><group-reply>:set editor=\$my_old_editor<enter><set-flag>r<enter><sync-mailbox>" "group reply"
If you want to dispatch per-message edits or view in a detachable tmux
you probably need to invoke mutt in a special way for the tmux session.
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Mutt-users
mailing list