sponsor Vim development Vim logo Vim Book Ad

intermediate Tip #78: rotating mail signatures

 tip karma   Rating 6/5, Viewed by 2027 

Read and edit this tip on the Vim tip wiki. The wiki may have a more recent version of this tip.

created:   June 12, 2001 13:36      complexity:   intermediate
author:   Roel Vanhout      as of Vim:   5.7

For people using mutt and vim for mail, the following script will allow you to insert a new signature (and again and again if you don't like the current one) at the bottom of your mail. This is usefull eg when you don't want to send a potentially offensive quote to someone you don't know very well (or a mailing list), but are too lazy to delete the quote, open your quotes file, and cut and paste another one in. (I put it here in 'tips' and not in 'scripts' because it is imo too short to be a 'real' script)

" rotate_sig.vim
" Maintainer:  Roel Vanhout <[email protected]>
" Version:     0.1
" Last Change: Tuesday, June 12, 2001
" Mapping I use:
" nmap ,r :call RotateSig()<CR>
" Usage:
" -Make sure you delimit your sig with '-- ', or adjust the script
" -Adjust the last execute to a command that prints a sig to stdout
" Known problems:
"   - You'll get an error message when you're below the last
"     '^-- $' in your mail (nothing bad though - just an not-
"     found marker)

function! RotateSig()
    normal mQG
    execute '?^-- $'
    execute ':nohl'
    normal o<ESC>
    normal dG
    normal <CR>
    execute 'r !~/bin/autosig ~/.quotes \%'
    normal `Q
endfunction

 rate this tip  Life Changing Helpful Unfulfilling 

<< Displaying search results using folds | How to use :grep to get a clickable list of function names >>

Additional Notes

[email protected], June 13, 2001 0:55
...and ofcourse, tonight I had an idea that this could be done better & shorter:

:nmap ,t mQG:?^-- $<CR>:nohl<CR>o<ESC>dG:r !~/bin/autosig ~/.quotes \%<CR>`Q

heh :-)
[email protected], May 7, 2002 8:34
Mutt has an extensive hooks system that allows things like this.

set signature="fortune $HOME/.fortunes/other $HOME/.fortunes/computer |"
send-hook       '~t @networksolutions'  'unset signature'
send-hook       '~t @orkplace'              'set signature=~/.signature_official'

etc.


Now what I'd like to see is a thing that does a light keyword analysis on the message and select an appropriate quote emulating an extremely kind sigmonster :-)
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 [email protected] after searching the archive. Help Bram help Uganda.
   
Sponsored by Web Concept Group Inc. SourceForge.net Logo