On 2/8/2018 3:25 AM, stefan wrote:
>> Would this trivial extension (patch attached) to the 'package' command
>> be worth considering?
>
> You would have to mind the various restrictions of [package names], I am afraid. For instance, it is cold without a prior [package require] on an unknown pkg.
>
> See
https://wiki.tcl.tk/9883 for the combined records.
>
> You would have to verify how to best warm up the [package] repo (incl. Tcl modules). One option might be to run an explicit:
>
> {*}[package unknown] "" or [package require ""]
>
> After that, [package names] will appear populated.
I'm sure I don't understand all the ramifications discussed in the above
reference.
My Tcl installation is on win7x64. I compile the latest Tcl/Tk and copy
it into my old 8.6.4 activestate installation folder with init.tcl
patched to include the activestate changes. This preserves the teapot
and the stuff it has installed.
You are correct that a "package require {}" is needed. I was testing on
windows via tkcon which somewhere along the line populated all packages.
As far as modules go, I searched the modules installed by teapot:
MSYS2 /c/program files1/tcl/lib/teapot/package/tcl/teapot/tcl8
$ fgrep package */textutil/* | fgrep provide | uniq
8.2/textutil/adjust-0.7.3.tm:package provide textutil::adjust 0.7.3
8.2/textutil/repeat-0.7.tm:package provide textutil::repeat 0.7
8.2/textutil/split-0.7.tm:package provide textutil::split 0.7
8.2/textutil/split-0.7.tm:if {[package vsatisfies [package provide
Tcl]8.3]} {
8.2/textutil/split-0.7.tm:package provide textutil::split 0.7
8.2/textutil/string-0.8.tm:package provide textutil::string 0.8
8.2/textutil/tabify-0.7.tm:package provide textutil::tabify 0.7
8.2/textutil/trim-0.7.tm:package provide textutil::trim 0.7
8.4/textutil/expander-1.3.1.tm:package provide textutil::expander 1.3.1
I then ran:
c:\users\imdave\appdata\local\temp>type t.tcl
catch {package require ""}
puts [llength [package names]]
foreach a $::argv {
puts "$a: [package search $a]"
}
c:\users\imdave\appdata\local\temp>where tclsh
C:\Program Files\Tcl\bin\tclsh.exe
c:\users\imdave\appdata\local\temp>tclsh t.tcl rim plit
630
rim: textutil::trim
plit: dtplite textutil::split
It seems to me that the packages provided via modules are included.
>
> Beyond that point, whether a dedicated [package search] delivers anything beyond a on-liner [lsearch ...] (even in interactive mode), is a matter of taste, IMHO.
>
You're right there. The line(s) required would be something like
lsearch -glob -all -nocase [package names] *what*
followed by
lindex [package names] x
where 'x' is one of the values returned by lsearch.
Not only would I invariably make a mistake while typing but I have to do
it every time I forget an exact package name.
Anyway, thanks for the feedback. I will just patch my local installation
and be happy. :-)