Reputation: 1833
While sending email with attachments I occasionally forget to attach the relevant files.
How do I setup mutt and vim to prompt me to attach missing files?
Upvotes: 2
Views: 357
Reputation: 591
There's config option abort_noattach for mutt and neomutt to ask You about missing attachment before sending the message if message body matches regular expression set by abort_noattach_regexp. In neomutt the option is called abort_noattach_regex without the trailing p. But the mutt config variant should work also because it's a config synonym - see the code.
You can find more about this in muttrc(5) or neomuttrc(5) manpages.
3.1. abort_noattach
Type: quadoption
Default: noWhen the body of the message matches $abort_noattach_regexp and there are no attachments, this quadoption controls whether to abort sending the message.
3.2. abort_noattach_regexp
Type: regular expression
Default: “attach”Specifies a regular expression to match against the body of the message, to determine if an attachment was mentioned but mistakenly forgotten. If it matches, $abort_noattach will be consulted to determine if message sending will be aborted.
Like other regular expressions in Mutt, the search is case sensitive if the pattern contains at least one upper case letter, and case insensitive otherwise.
3.3. abort_noattach
Type: quadoption
Default: noIf set to yes , when composing messages containing the regular expression specified by $abort_noattach_regex and no attachments are given, composition will be aborted. If set to no , composing messages as such will never be aborted.
Example:
set abort_noattach_regex = "\<attach(|ed|ments?)\>"
3.4. abort_noattach_regex
Type: regular expression
Default: “ <(attach|attached|attachments?)> ”Specifies a regular expression to match against the body of the message, to determine if an attachment was mentioned but mistakenly forgotten. If it matches, $abort_noattach will be consulted to determine if message sending will be aborted.
Like other regular expressions in NeoMutt, the search is case sensitive if the pattern contains at least one upper case letter, and case insensitive otherwise.
Upvotes: 1
Reputation: 1833
The CheckAttach vim plugin by Christian Brabandt will check for keywords in mail messages and ask you to attach the files. The plugin will not consider the quoted parts of mail messages.
The plugin will highlight the keyword(s) and prompt you for the files to attach, when you save your mail.
Which looks like this:
Attach file: (leave empty to abort):
At that prompt you can specify any file you'd like to attach. It allows
filename completion, so you can use <Tab>
to let vim complete file paths.
Additionally you can specify glob patterns and let vim attach all files, that
match the pattern. If you enter an empty value or "n" (without
the quotes), then no file will be attached.
Installation:
Get the most recent plugin package from the vim site.
Then at a command prompt run,
vim CheckAttach-0.17.vmb
and source the vimscript:
:so %
It is also possible to check the code out from GitHub.
Configuration:
edit_headers
must be set in your .muttrc
. This enables the pseudo-header :Attach
. See muttrc man page for further information.
To specify which keywords will be searched for add the following to your .vimrc
:
let g:attach_check_keywords = 'attached,attachment'
Alternative usage:
The plugin also defines the vim command :AttachFile
. This allows you to
attach any number of files using a glob pattern.
To attach all png files from ~/pictures/
:
:AttachFile ~/pictures/*.png
Upvotes: 0