Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

gvim with tcl: interpret from within?

103 views
Skip to first unread message

Larry Gagnon

unread,
Dec 4, 2001, 2:30:39 PM12/4/01
to
I am a newbie to tcl/tk but love it so far. Am using Windows 95 with
gVIM as my editor. So far I have been editing my code with gvim then
pasting it into the wish shell. Is there any way I can call the
interpreter from within vim and it would highlight the first or all
errors???

Any help greatly appreciated...Larry Gagnon

Max Ischenko

unread,
Dec 5, 2001, 8:01:26 AM12/5/01
to

Larry Gagnon wrote:

> I am a newbie to tcl/tk but love it so far. Am using Windows 95 with
> gVIM as my editor. So far I have been editing my code with gvim then
> pasting it into the wish shell. Is there any way I can call the
> interpreter from within vim and it would highlight the first or all
> errors???

I think something like this will do, just s/ruby/tcl:

function ExecRuby()
w! /tmp/ruby_input
!ruby /tmp/ruby_input > /tmp/ruby_output 2>&1
10 sp /tmp/ruby_output
set nonumber
wincmd w
endfunction

map <C-P> :call ExecRuby()<CR><CR><CR>

More preffered way (i think) is just to update tcl script (from within
Vim) and then [source] it from wish.


PS: AFAIK vim6.0 for win32 has dynamic tcl support.
You can extend vim using tcl!


--
"Linux poses a real challenge for those with a taste for late-night
hacking (and/or conversations with God)."
(By Matt Welsh)

Neil Madden

unread,
Dec 5, 2001, 12:39:25 PM12/5/01
to
I'm not sure about calling the tcl interpreter in Vim (if you compiled
with if_tcl.c). The problem I have noticed is that it is very easy to
hang Vim if the Tcl app does something bad - for instance never
returning from a vwait, or throwing an error from the event loop with no
bgerror proc. Also, generally any Tcl script which uses vwait to enter
the event loop is liable to mess up inside Vim, for a reason I haven't
been able to track down. I wish the tcl interpreter in Vim could be
compiled to have an event loop constantly running (like wish), but I
guess this would cause problems with Vim. I imagine you could do
something with a safe interpreter:

proc evalBuffer {} {
set buf $::vim::current(buffer)
set win $::vim::current(window)
set script [$buf get top bottom]
set interp [interp create -safe]
interp share {} vimout $interp
interp share {} vimerr $interp
interp share {} stdout $interp
interp share {} stderr $interp
if {[catch {$interp eval [join $script \n]} error]} {
# something went wrong
puts vimerr $error
# Parse ::errorInfo here to determine line number
# hint [regexp] on each line will allow you to find the proc and
line
}
interp delete $interp
}

This works for simple scripts, and does everything in a safe
interpreter, to minimize the amount of damage your untested script could
do. The standard channels have to be shared with the child interpreter,
but stdin isn't supported by the embedded Tcl in Vim. For a full
functional Tcl interpreter, I would recommend using the approach
described by Max Ischenko.

Larry or Suzette

unread,
Dec 5, 2001, 7:37:12 PM12/5/01
to Larry Gagnon
Larry wrote;

> I am a newbie to tcl/tk but love it so far. Am using Windows 95 with
> gVIM as my editor.

I am a newbie also and I use textpad as my editor,
http://www.textpad.com/
under congigure->preferences->tools you can add all sorts of tools. then
from the tools menu select the one you want.

Very handy.

Larry K.

0 new messages