2

Apologies for a lengthy title.

Websites like github, gitlab etc allow to respond to issue pages via email. I'd like mutt/vim to automatically format my responses. For instance I'd like to remove my signature from these responses and remove fixed width textwidth line as it's not appropriate when rendered on the website.

I started with this:

reply-hook [email protected] 'set signature="" ' 'source .specific_vim_format'

But this is not quite what I need. This reply hook will globally remove the signature so it will not appear on other messages and I still haven't figured out how to affect my vim session when I type in my response.

1 Answer 1

1

You need to match all messages first, then match the specific messages, because configuration changes are permanent. Remember order of reply-hooks does matter.

# This applies to all messages
send-hook ~A \
'set signature="/path/to/signature file";\
source .specific_vim_format_all'

# This hook applies only to those matching [email protected]
reply-hook [email protected] \
'set signature="";\
source .specific_vim_format'

Or you can get rid of sourcing the .specific_vim_format file by defining your default editor settings in $my_editor variable. Set editor to $my_editor value for all messages and for specific messages append additional configuration.

set my_editor="vim"
set my_editor_email_options="-c 'set syntax=mail fileencoding=utf-8 ft=mail fo+=aw'"
set my_editor_github_options="-c 'set wrap textwidth=0'"

# This applies to all messages
send-hook ~A \
'set signature="/path/to/signature file";\
set editor="$my_editor $my_editor_email_options"'

# This hook applies only to those matching [email protected]
reply-hook [email protected] \
'set signature="";\
set editor="$my_editor $my_editor_github_options"'
4
  • Thanks. Brilliant reply. I went with the second option. Should it be set my_editor instead? May 16, 2020 at 10:42
  • In the GH hook I am trying with set editor="$my_editor -c \'set wrap\'"' and it seems to break as if it wasn't reading the escape signs. I get to open "wrap" file. May 16, 2020 at 10:54
  • Sorry I didn’t test it properly. Maybe you need to double escape the the single quote since you’re inside hook and inside variable string assignment. Alternatively you can set my_vim_wrap=“-c ‘set wrap’” outside of the hook and then inside the hook set editor=“$my_editor $my_vim_wrap”. I’m afk right now feel free to edit my answer with working solution. May 16, 2020 at 13:28
  • Done. Thanks. I went with variables, but perhaps sourcing specific file, as per your initial suggestion, is cleaner. May 16, 2020 at 22:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .