What's wrong with this ?...

Ian Gilmour ian.gilmour@ffei.co.uk
Wed Sep 27 02:36:00 GMT 2000

> -----Original Message-----
> From: Bruce Stephens [ mailto:bruce@cenderis.demon.co.uk ]
> Sent: 26 September 2000 20:12
> To: Ian Gilmour
> Cc: sourcenav@sources.redhat.com
> Subject: Re: What's wrong with this ?...
> Ian Gilmour <ian.gilmour@ffei.co.uk> writes:
> [...]
> > Basically all I'm trying to do is add an "Extras" menu to 
> the editor window
> > with an option to run XEmacs, vi, or indent on the 
> currently edited file. I
> > know I probably need some more checks in all of this but 
> I'm just trying to
> > get the basics working for now.
> > 
> > So I've got the following in my rc.tcl file...
> > 
> > It basically works, except that if I edit the file in 
> snavigator I need to
> > explicitely save it (via "File"->"Save" menu option or ^S) for it to
> > autoupdate the editor window when I run the indent option. 
> i.e. It saves the
> > file correctly for indent to work on it, but doesn't reload 
> the indented
> > file and refresh the display.
> > 
> > What am I doing wrong ? What do I need to do to remove the 
> need to perform
> > an explicit Save file ?
> >
> > How do it I tell it I've already performed the save and 
> force the editor
> > window to be updated ?
> Have a look at the existing Emacs stuff (emacs.tcl and sn.el).  That
> should help.  By the looks of it, calling sn_parse_uptodate with the
> name of the file that's just been saved is what you need to do.

Thanks for replying.

I probably didn't explain it very well.

I know the Xemacs and vi menu options don't refresh (that what I want at
But, looking at only the "Indent" menu option code in the following rc.tcl.
I think I am already calling sn_parse_uptodate with the file name after
invoking indent.
The problem is it doesn't work unless I've previously saved the file
explicitely (^S) first.

I feel I must be missing something that's obvious to someone more
experienced in this tcl and tk stuff.
- but I can't see what it is from the samples of code I've looked at (I've
checked out the emacs.tcl, sn.el and multiedit.tcl, etc).



-------- snippet from rc.tcl --------------------------------

proc editor_extras {symboltype view} {
    global sn_options

    set e [$view editor]
    set f [$view getfilename]
    # Select local option
    switch -- $symboltype {
	"Xemacs" {
	    if {[sn_save_file $e $f] == 1} {
		exec xemacs $f +1 &
	"vi" {
	    if {[sn_save_file $e $f] == 1} {
		exec xterm -T $f -e vi $f &
	"Reload" {
	    sn_parse_uptodate $f
	"Indent" {
	    if {[sn_save_file $e $f] == 1} {
		exec indent -npro -ts0 -l120 -lc120 -c40 -bli0 -ncs -bl
-npsl -nhnl -ncs -i2 $f
	    sn_parse_uptodate $f
	default {
	    sn_error_dialog \
		"$symboltype on $f not implemented yet."

proc sn_rc_editor {view text} {
    global tcl_platform

    set topw [winfo toplevel $view]
    set tool_frame $topw.exp
    set menu_frame $topw.menu
    set extras $menu_frame.extras

    # Create a new menu called "Extras".
    menu $extras -tearoff 0
    # Add a menu item to the menu. The second character is
    # the designated hot key. Place this menu fourth in
    # the menu bar.
    $menu_frame insert 3 cascade -label Extras -underline 1 \
	-menu $extras
    # Add items to the menu.
    $extras add command -label "Xemacs" -command \
	"editor_extras Xemacs $view" -underline 0
    $extras add command -label "vi"  -command \
	"editor_extras vi $view" -underline 0
    $extras add command -label "C-Indent" -command \
	"editor_extras Indent $view" -underline 0
    $extras add command -label "Reload file"  -command \
	"editor_extras Reload $view" -underline 0


More information about the Sourcenav mailing list