Linux debsam 2.6.18-6-k7 #1 SMP Mon Aug 18 09:20:26 UTC 2008 i686 GNU/Linux
Tcl: 8.6a3
auto_mkindex don't detect ensembles.
a patch perhaps:
diff auto.tcl auto.tcl.BAK
586,602d585
< ensemble {
< variable parser
< variable index
< variable scriptFile
<
< set subcommand [lindex $args 0]
< if {$subcommand eq "create"} {
< set script [list _%@namespace ensemble {*}$args]
< if {[catch {$parser eval $script} command] == 0} {
< append index [list set auto_index($command)] \
< [format { [list source [file join $dir %s]]} \
< [file split $scriptFile]] "\n"
< }
< } else {
< $parser eval [list _%@namespace ensemble {*}$args]
< }
< }
The proposed patch does not work for me. This patch does work for me:
$ p4 diff -dc auto.tcl
==== //dvt/mti/prod/src/tcltk/8.5.8/tcl/tcl/library/auto.tcl#1 - /home/bgriffin/dev/devm2_backup/prod/src/tcltk/8.5.8/tcl/tcl/library/auto.tcl ====
***************
*** 604,609 ****
--- 604,618 ----
}
catch {$parser eval "_%@namespace import $args"}
}
+ ensemble {
+ variable parser
+ variable contextStack
+ if {[lindex $args 0] eq "create"} {
+ set name ::[join [lreverse $contextStack] ::]
+ # create artifical proc to force a command entry in the tclIndex
+ $parser eval [list proc $name {} {}]
+ }
+ }
}
}
Anything we can put in the test suite for this one?
How's this:
$ .x/tcl/tcl/tests/autoMkindex.test <
==== //dvt/mti/prod/src/tcltk/8.5.x/tcl/tcl/tests/autoMkindex.test#1 - /home/bgriffin/dev/devm2_backup/prod/src/tcltk/8.5.x/tcl/tcl/tests/autoMkindex.test ====
***************
*** 251,256 ****
--- 251,289 ----
list [lvalue $::result *mycmd4*] [lvalue $::result *mycmd5*] [lvalue $::result *mycmd6*]
} "{::buried::mycmd4 $element} {::buried::mycmd5 $element} {mycmd6 $element}"
+ makeFile {
+
+ namespace eval wok {
+ namespace ensemble create -subcommands {commands vars}
+
+ proc commands {{pattern *}} {
+ puts [join [lsort -dictionary [info commands $pattern]] \n]
+ }
+
+ proc vars {{pattern *}} {
+ puts [join [lsort -dictionary [info vars $pattern]] \n]
+ }
+
+ }
+
+ } ensemblecommands.tcl
+
+ test autoMkindex-3.3 {ensemble commands in tclIndex} {
+ file delete tclIndex
+ auto_mkindex . ensemblecommands.tcl
+ set f [open tclIndex r]
+ set dat [list]
+ foreach r [split [string trim [read $f]] "\n"] {
+ if {[string match {set auto_index*} $r]} {
+ lappend dat $r
+ }
+ }
+ set result [lsort $dat]
+ close $f
+ set result
+ } {{set auto_index(::wok::commands) [list source [file join $dir ensemblecommands.tcl]]} {set auto_index(::wok::vars) [list source [file join $dir ensemblecommands.tcl]]} {set auto_index(wok) [list source [file join $dir ensemblecommands.tcl]]}}
+
+ removeFile ensemblecommands.tcl
makeDirectory pkg
makeFile {
patches accepted.