aboutsummaryrefslogtreecommitdiff
path: root/initjimsh.tcl
diff options
context:
space:
mode:
authorHummyPkg <af123@hummypkg.org.uk>2016-10-09 11:54:39 +0100
committerSteve Bennett <steveb@workware.net.au>2016-10-11 08:37:32 +1000
commit4a1c8a88a655af89bb963e34f467d7f71c4a507e (patch)
treef4243f2f23c22692083ba0d13f435ae5e2f52646 /initjimsh.tcl
parent3d31b6fe9b1144adaf9127ccde69cefa77316268 (diff)
downloadjimtcl-4a1c8a88a655af89bb963e34f467d7f71c4a507e.zip
jimtcl-4a1c8a88a655af89bb963e34f467d7f71c4a507e.tar.gz
jimtcl-4a1c8a88a655af89bb963e34f467d7f71c4a507e.tar.bz2
improve example autocompletion function to complete partially typed arguments
Diffstat (limited to 'initjimsh.tcl')
-rw-r--r--initjimsh.tcl6
1 files changed, 4 insertions, 2 deletions
diff --git a/initjimsh.tcl b/initjimsh.tcl
index e0bb011..1aab707 100644
--- a/initjimsh.tcl
+++ b/initjimsh.tcl
@@ -49,11 +49,13 @@ set tcl::autocomplete_commands {info tcl::prefix socket namespace array clock fi
# Simple interactive command line completion callback
# Explicitly knows about some commands that support "-commands"
proc tcl::autocomplete {prefix} {
- if {[string match "* " $prefix]} {
- set cmd [string range $prefix 0 end-1]
+ if {[set space [string first " " $prefix]] != -1} {
+ set cmd [string range $prefix 0 $space-1]
if {$cmd in $::tcl::autocomplete_commands || [info channel $cmd] ne ""} {
+ set arg [string range $prefix $space+1 end]
# Add any results from -commands
return [lmap p [$cmd -commands] {
+ if {![string match "${arg}*" $p]} continue
function "$cmd $p"
}]
}