sponsor Vim development Vim logo Vim Book Ad

CheckAttach.vim : Check for attachments when writing mails with mutt

 script karma  Rating 145/43, Downloaded by 4619  Comments, bugs, improvements  Vim wiki

created by
Christian Brabandt
 
script type
utility
 
description
If you like the plugin, please rate it!

You can now follow the plugin at github: http://github.com/chrisbra/CheckAttach

                                                                  *CheckAttach*
1. Functionality

When using mutt as your mail user agent, you can specify which files to attach
using the pseudo header :Attach. This only works when edit_headers is set in
your .muttrc configuration file. See the mutt manual for further information
about that topic.

A simple version of this plugin has been posted to the mutt-users list (see
http://marc.info/?i=20090116091203.GB3197%20()%20256bit%20!%20org) and
after using it for some time, I decided to make a plugin out of it.

This plugin checks, whether certain keywords exist in your mail, and if found,
you'll be asked to attach the files. This is done to prevent that you sent
mails in which you announce to attach some files but actually forget to attach
the files so that your have to write a second mail which often is quite
embarassing.

Therefore this plugin checks for the presence of keywords which indicate that
an attachment should be attached. If if finds these keywords, the plugin will
ask you for the files to attach, whenever you save your mail.

This looks like this:
Attach file: (leave empty to abbort):

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. So if you enter ~/.vim/plugin/*.vim vim would add for each
plugin it finds an Attach-header.  If you enter an empty value or "n" (without
the quotes), no file will be attached.

The plugin will by default escape blank space in your filename by using ''.
mutt before version 1.5.20 had a bug, that would not allow you to add files
whose filename contain spaces. If you are using mutt version smaller 1.5.20
this means you would have to rename those files first before attaching them.
(See mutt bug 3179: http://dev.mutt.org/trac/ticket/3179)

You can specify which keywords will be searched by setting the
g:attach_check_keywords variable. By default this variable is specified as:
let g:attach_check_keywords = 'attach,attachment,angehÃĪngt,Anhang'
so that it can handle German and English. If you would like to add the keyword
foobar, use this command:
let g:attach_check_keywords .=',foobar'

                                         *EnableCheckAttach* *DisableCheckAttach*
You can disable the plugin by issuing the command
:DisableCheckAttach
Enabling the attachment check is then again enabled by issuing
:EnableCheckAttach
You can also use the ! attribute when saving your buffer to temporarily skip
the check. So if you use :w! the buffer will not be checked for attachments,
only if you use :w it will.


==============================================================================
2. CheckAttach History                                      *CheckAttach-history*
    0.2: Sept 29, 2009     Added Documentation
    0.1: Sept 29, 2009     First working version, using simple commands

==============================================================================
vim:tw=78:ts=8:ft=help
 
install details
Open CheckAttach.vba in Vim and source the file:

:so %

This will install the plugin into your $HOME/.vim/plugin directory and the documentation into your $HOME/.vim/doc directory.

See also the help for installing Vimball-Archives (:h vimball-intro)

Take a look at :h CheckAttach.txt for the documenation
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
CheckAttach-0.17.vmb 17 2015-01-15 7.4 Christian Brabandt - Always use the full path to the attached file. Matters if the working directory of mutt and vim disagree.
   - Using :AttachFile with ranger was broken (reported by Ram-Z at https://github.com/chrisbra/CheckAttach/issues/5, thanks!)
(automatically uploaded)
CheckAttach-0.16.vmb 16 2014-03-27 7.4 Christian Brabandt - allow to specify several patterns after |:AttachFile| (issue #4, https://github.com/chrisbra/CheckAttach/issues/4 reported by AguirreIF, thanks!)
(automatically uploaded)
CheckAttach-0.15.vmb 15 2013-08-14 7.3 Christian Brabandt - don't match Attach: header when trying to look for matching attachment keywords
(automatically uploaded)
CheckAttach-0.14.vmb 14 2012-06-16 7.3 Christian Brabandt Fix issue https://github.com/chrisbra/CheckAttach/issues/2 reportedby daaugusto, thanks!
(automatically uploaded)
CheckAttach-0.13.vmb 13 2011-11-08 7.3 Christian Brabandt -allow plugin to use an external file manager
  for selecting the files (suggested by mutt-users
  mailinglist)
-Command definition will be buffer local
-Don't check for matches of the keywords in the
  quoted of the message (suggested by Sebastian
  Tramp, thanks!)
-Don't check for matches inside the header (start at
  subject line, suggested by Sebastian Tramp,
  thanks!)
-Only check as long, as no :Attach header is
  available when the g:checkattach_once variable is
  set (suggested by Sebastian Tramp, thanks!)
-Documentation update
(automatically uploaded)
CheckAttach-0.12.vmb 12 2011-10-25 7.3 Christian Brabandt Update the plugin (include some changes, that got lost with 0.11)
(automatically uploaded)
CheckAttach-0.11.vmb 11 2011-09-30 7.3 Christian Brabandt -Make a filetype plugin out of it, it does not make sense to have it as plugin, since its only use is with mutt (aka ft: mail)
-Documentation update
(automatically uploaded)
CheckAttach-0.10.vba 10 2011-01-17 7.3 Christian Brabandt Spelling fix by Scott Stevenson (Thanks!)
(automatically uploaded)
CheckAttach-0.9.vba 9 2010-12-17 7.3 Christian Brabandt include new command |:AttachFile| for attaching several files using a glob pattern
(automatically uploaded)
CheckAttach-0.8.vba 8 2010-11-30 7.3 Christian Brabandt - Make ftplugin instead of plugin (don't trigger check of filetypes)
- clear matchlist on next run
- code cleanup
(automatically uploaded)
CheckAttach-0.7.vba 0.7 2010-05-05 7.0 Christian Brabandt 0.7: May  05, 2010:
Force checking the filetype
0.6: May  05, 2010:
- Force filetype detection, which did prevent of the plugin to be working correctly
- Created a public github repository at http://github.com/chrisbra/CheckAttach
- Small changes to the documentation
(unreleased)
CheckAttach.vba 0.5 2010-03-02 6.0 Christian Brabandt Search without matching case.
This prevented CheckAttach from working correctly, which made me sent mails without attaching the files. Change default keywords a little bit
CheckAttach.vba 0.4 2010-01-26 7.0 Christian Brabandt Highlight matching keywords
use g:attach_check_ft to define for which filetypes to enable the plugin
CheckAttach.vba 0.3 2009-10-01 7.0 Christian Brabandt Fixed Copyright statement,
enabled GetLatestScripts
CheckAttach.vba 0.2 2009-09-29 7.0 Christian Brabandt Initial upload
ip used for rating: 142.132.191.50

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github