" ------------------------------------------- " Commands for quoting URIs in emails " Copyright (c) 2001 Hugo Haas " 10 September 2001 version " I hereby put this code in the public domain. " Documentation at: http://larve.net/people/hugo/2001/02/email-uri-refs/ " -------------------------------------------- " Insert a reference at the cursor position function InsertRef() let ref = input("Reference: ") call AskNumber() if (col(".") == 1) execute "normal i[\r]\" else execute "normal a[\r]\" endif normal G set paste ?^-- $ execute "normal O " . @r . ". " . ref . "\`rf]" set nopaste let a = col(".") normal $ let b = col(".") if ( a == b ) startinsert! else normal `rf]l startinsert endif endfuntion " Convert into a reference function ConvertToRef() call AskNumber() execute "normal cf>[\r]\G" ?^-- $ set paste execute "normal O \" execute "normal a\r. \px0f.2 x`r" set nopaste endfunction " Ask a reference number function AskNumber() if (@r == "") call FindRefHiNumber() endif let @r = @r + 1 let number = input("Reference number (" . @r . "): ") if ( number != "" ) let @r = number endif endfunction " Find the highest number in the text function FindRefHiNumber() normal 1G /^$ let body = line(".") let cur = body + 1 let found = 0 let @/="\\[[0-9]\\+\\]" while ( cur <= line("$") ) if (match(getline(cur), @/) != -1) let found = 1 break endif let cur = cur + 1 endwhile if ( found == 0 ) let @r = 0 normal `r return endif " Find the highest number normal n let l = line(".") let c = col(".") while (1) if ( line(".") > body ) normal f]mqF[ly`qf] if ((@0 + 0) > @r) let @r = @0 endif normal n endif if ( (line(".") < body) || ((l == line(".")) && (c == col("."))) ) break endif endwhile normal `r endfunction map! mr:call InsertRef() map F