On 09/07/10 16:10, gabriel wrote:
I wrote this function that generates toggle functions:

func! CreateToggle(name,oncode,offcode)
   exec
   \ "let g:" . a:name .  "toggle = 0 \n" .
   \ "func! " .  a:name .  "()\n" .
   \     "if g:" .  a:name .  "toggle == 0\n" .
   \         a:oncode . "\n" .
   \         "echo \"" . a:name .  " On\"\n" .
   \     "else\n" .
   \         a:offcode .  "\n" .
   \         "echo \"" .  a:name .  " Off\"\n" .
   \     "endif\n" .
   \     "let g:" .  a:name .  "toggle = ! g:" .  a:name .  "toggle
\n" .
   \ "endfunc\n"
endfunc

and I use it like so:

call CreateToggle("SpellingToggle","setlocal spell
spelllang=en_us","setlocal nospell")

map ,z :call SpellingToggle()<CR>

I have a bunch of features that I toggle on and off this way. I like
it.

The only problem is that, here at work, we have two different versions
of vim, 7.2.330 and 6.3 ( from debian sarge ), and this function only
works under 7.2

I would like to make a version that works under 6.3 but I can't quite
figure it out. I can't actually figure out why it doesn't work in 6.3
short of the fact that I can't seam to define any functions a all via
execute under vim 6.3

I've boiled the issue down to this sample code:

execute "function Foo()\n echo \"foo\"\n endfunction"
call Foo()

which works fine under 7.3 but doesn't work under 6.3

So, can anyone shed any light on how I can't get this done on 6.3? Am
I missing an obvious way to dynamically create functions?

Thanks for your attention.

Gabriel Russell
[email protected]


Built-in spell checking (and the 'spell' and 'spelllang' option) are new in Vim 7, Vim 6 didn't have them.

I think the best you can do is convince your sysadmin that Vim 6.3 is old stuff, full of bugs and lacking major features, that since then, versions 6.4, 7.0, 7.1 and 7.2 have been published, each time (except 6.4 which was released on the "then stable" branch while already making ready for 7.0) with hundreds of bugfixes, and that beta versions of the upcoming 7.3 are already available (but of course, no serious business admin would install a beta version). Maybe you could give him a copy of the version7.txt helpfile from Vim 7.2, stressing the fact that these are the release notes for "the current stable release".


Best regards,
Tony.
--
"I'd give my right arm to be ambidextrous."

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to