Hi,

Here is a small patch for AsNeeded that eliminates the need to call AN(X) for commands. It creates a file called ~/.vim/AsNeeded/ANautoload that contains lines like:

command! -range -nargs=* Command delcommand Command | ANX Command

Regards,
Thomas.
--- AsNeeded.vim        2006-05-10 20:48:42.442003200 +0200
+++ /cygdrive/f/.vim/plugin/AsNeeded.vim        2006-05-10 20:45:13.381388800 
+0200
@@ -227,6 +227,14 @@
   return -1
 endfun
 
+fun! <SID>AutoloadFilename(vimfiles)
+    return substitute(a:vimfiles,'AsNeeded.*','AsNeeded/ANautoload','e')
+endf
+
+fun! <SID>Vimfiles()
+    return substitute(globpath(&rtp,"AsNeeded/*.vim"),'\n',',',"ge")
+endf
+
 " ---------------------------------------------------------------------
 " MakeANtags: makes the (optional) ANtags file {{{1
 fun! MakeANtags()
@@ -265,8 +273,9 @@
   " ---------------------------------------------
   " search for all commands, maps, and functions: {{{2
   " ---------------------------------------------
-  let vimfiles= substitute(globpath(&rtp,"AsNeeded/*.vim"),'\n',',',"ge")
+  let vimfiles= <SID>Vimfiles()
   let ANtags  = substitute(vimfiles,'AsNeeded.*','AsNeeded/ANtags','e')
+  let ANautoloads = <SID>AutoloadFilename(vimfiles)
   let first   = 1
 "  call Decho("ANtags<".ANtags.">")
 
@@ -323,7 +332,12 @@
 
    let vimfile= ""
   endwhile
+  exec 'silent edit '. ANtags
+  silent v/^c\t/d
+  silent %s/^c\t\(.\{-}\)\t.*$/command! -range -nargs=* \1 delcommand \1 | ANX 
\1/
+  exe 'silent w! '. ANautoloads
   q!
+  exec 'silent source '. ANautoloads
 
   " ------------------------------
   " restore registers and settings {{{2
@@ -336,6 +350,11 @@
 "  call Dret("MakeANtags")
 endfun
 
+let s:autoloads = <SID>AutoloadFilename(<SID>Vimfiles())
+if filereadable(s:autoloads)
+    exec 'silent source '. s:autoloads
+endif
+
 " ---------------------------------------------------------------------
 " SaveSettings: {{{1
 fun! s:SaveSettings()

Reply via email to