Wikia

Vim Tips Wiki

Changes: Rotating mail signatures

Edit

Back to page

(Move categories to tip template)
(Remove html character entities)
 
Line 16: Line 16:
 
<pre>
 
<pre>
 
" rotate_sig.vim
 
" rotate_sig.vim
" Maintainer: Roel Vanhout &lt;roel@2e-systems.com&gt;
+
" Maintainer: Roel Vanhout
 
" Version: 0.1
 
" Version: 0.1
 
" Last Change: Tuesday, June 12, 2001
 
" Last Change: Tuesday, June 12, 2001
 
" Mapping I use:
 
" Mapping I use:
" nnoremap ,r :call RotateSig()&lt;CR&gt;
+
" nnoremap ,r :call RotateSig()<CR>
 
" Usage:
 
" Usage:
 
" -Make sure you delimit your sig with '-- ', or adjust the script
 
" -Make sure you delimit your sig with '-- ', or adjust the script
Line 28: Line 28:
 
" '^-- $' in your mail (nothing bad though - just an not-
 
" '^-- $' in your mail (nothing bad though - just an not-
 
" found marker)
 
" found marker)
 
 
function! RotateSig()
 
function! RotateSig()
normal! mQG
+
normal! mQG
execute '?^-- $'
+
execute '?^-- $'
execute ':nohl'
+
execute ':nohl'
normal! o&lt;ESC&gt;
+
normal! o<Esc>
normal! dG
+
normal! dG
normal! &lt;CR&gt;
+
normal! <CR>
execute 'r !~/bin/autosig ~/.quotes \%'
+
execute 'r !~/bin/autosig ~/.quotes \%'
normal! `Q
+
normal! `Q
 
endfunction
 
endfunction
 
</pre>
 
</pre>
Line 43: Line 42:
 
==Comments==
 
==Comments==
 
I had an idea that this could be done better and shorter:
 
I had an idea that this could be done better and shorter:
+
<pre>
:nmap ,t mQG:?^-- $&lt;CR&gt;:nohl&lt;CR&gt;o&lt;ESC&gt;dG:r !~/bin/autosig ~/.quotes \%&lt;CR&gt;`Q
+
:nmap ,t mQG:?^-- $<CR>:nohl<CR>o<Esc>dG:r !~/bin/autosig ~/.quotes \%<CR>`Q
  +
</pre>
   
 
----
 
----

Latest revision as of 08:25, September 28, 2008

Tip 78 Printable Monobook Previous Next

created June 12, 2001 · complexity intermediate · author Roel Vanhout · version 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
" Version: 0.1
" Last Change: Tuesday, June 12, 2001
" Mapping I use:
" nnoremap ,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

CommentsEdit

I had an idea that this could be done better and shorter:

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

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 :-)


Around Wikia's network

Random Wiki