Tk Source Code

View Ticket
Login
Ticket UUID: 1517768
Title: wish does not know about tcl_wordchars
Type: Bug Version: obsolete: 8.4.13
Submitter: fvogel Created on: 2006-07-05 20:00:47
Subsystem: 99. Other Assigned To: fvogel
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2016-04-08 11:38:14
Resolution: Invalid Closed By: jan.nijtmans
    Closed on: 2016-04-08 11:38:14
Description:
tcl_wordchars and tcl_nonwordchars are unknown to 
wish:

1 % info patchlevel
8.4.13
2 % puts $tcl_wordchars
can't read "tcl_wordchars": no such variable
3 % catch {tcl_endOfWord}
1
4 % puts $tcl_wordchars
\S


Though catch {tcl_endOfWord} make wish aware of these 
variables, this is only a workaround. These variables 
should be auto-loaded along with the commands they 
control.

See also:
http://groups.google.fr/group/comp.lang.tcl/browse_thr
ead/thread/659fd6c1f41d9a81/4a3c30d2c97604cc

Francois
User Comments: jan.nijtmans added on 2016-04-08 11:38:14:

Related: TIP 122


dgp added on 2016-03-22 17:36:33:
I believe there is a more radical but also more correct
solution available.  Get these routines out of Tcl and
into Tk where they have always belonged.  More detail
to come when I get caught up.

fvogel added on 2016-03-21 21:31:34:
Since this really is a Tcl issue, I have opened a ticket in the Tcl tracker:

    http://core.tcl.tk/tcl/tktview/f1253530cdd83e66fd7c023540df68cfbfb51e98

I'm closing this one therefore.

fvogel added on 2016-03-21 07:26:17:
Better in TclpSetVariables().

fvogel added on 2016-03-21 07:18:01:
Tcl_CreateInterp() must be the correct place.

fvogel added on 2016-03-20 20:43:13:
Or is the bug precisely that Tcl is made aware of tcl_wordchars only when one of the commands using it is auto_loaded, i.e. that tcl_wordchars in contrast should not be auto-loaded but always known to Tcl? Could make more sense to me.

Then, what is the fix? Move the definition of tcl_wordchars from word.tcl to some initialization code of the Tcl interp? Where, more precisely?

fvogel added on 2016-03-20 20:36:16:
I had a look at this and now I understand (I think) the machinery behind this, especially how calling for instance [tcl_endOfWord] makes the interpreter aware of the tcl_wordchars variable.

A few comments:

1. This is a Tcl bug, not a Tk bug. Should not be in this tracker.

2. Any of the following three commands will do the job:
    catch {tcl_endOfWord}
    tcl_endOfWord "Hello world" 2  ; # or any parameters
    source [file join [info library] word.tcl]

3. It is easy to make a new command foobar auto-loaded from the Tcl library: just add it in, say word.tcl, and call auto_mkindex to update the tclIndex file.

--> But how can I have *variables* (not commands) auto-loaded?

fvogel added on 2015-01-23 07:16:46:
See also:

http://core.tcl.tk/tk/tktview?name=1517768

http://wiki.tcl.tk/1655


Another issue (IMO) is what Tk considers as words, for instance when in a text widget .t one calls:
  .t index "$ind wordend"
  .t index "$ind wordstart"

In this situation tcl_wordchars and tcl_nonwordchars are not considered in order to get the "word" boundaries (that's an observation based on reading the text widget source code).