{jprefixmatch.tcl

Introduction
The jprefixmatch.tcl library is distributed as part of the jstools package.  It contains procedures to do prefix expansion like that done for filename completion by tcsh(1) and Emacs, or for command disambiguation under VMS.

This document describes jprefixmatch.tcl version 4.0/4.0.

Usage
Accessing the Library
In order to use the jprefixmatch.tcl library, it (and any other libraries it depends on) must be in your Tcl auto_path, described in tclvars(n).  Information about how to arrange that, and other conventions common to the jstools libraries, is in the Usage section of The jstools Libraries.

Credits and Copyright
Author
Jay Sekora 
js@calumet.org
http://shore.net/~js/

Copyright
The library is copyright © 1992-1995 by Jay Sekora, but may be freely redistributed under the conditions at the top of the file.

Overview
Procedures
j:longest_match - find the longest common initial string in a list
j:expand_filename - expand filename prefix as much as possible

j:longest_match
Usage
	j:longest_match l
Argument
	l - list of strings

Description
This procedure finds and returns the longest common initial string in list l.  If there's no common initial string, it returs the empty list {}.  It's used by j:expand_filename for filename completion, but could also be used for things like handling abbreviations.

j:expand_filename
Usage
	j:expand_filename f
Argument
	f - initial filename prefix to be expanded

Description
This procedure tries to do filename completion on the prefix f, as in Emacs and tcsh.  It returns the longest initial substring common to those filenames in the current directory that match f.  It also can be used for globbing; if f contains globbing metacharacters (`*', `?', initial `~', or `[...]'), they will be expanded as in the shell.

Bugs and Limitations
* The expansion of globbing metacharacters, while occasionally useful, is unlikely to be intuitive to a user.  (You might want to check for these in your code before calling j:expand_filename.)
} {{{jdoc:xref:link {4.59 4.66 10.217 10.238 10.246 10.263 10.267 10.288 23.0 23.15 24.0 24.17 33.159 33.176}} {jdoc:xref:manpage {4.165 4.169 4.177 4.182 10.133 10.140 42.70 42.75 42.80 42.84}} {jdoc:anchor:anchorname {3.0 4.0 8.0 9.0 12.0 13.0 21.0 22.0 26.0 27.0 35.0 36.0}} {richtext:font:roman {2.0 3.0 4.0 4.4 4.20 4.59 4.66 4.165 4.169 6.24 6.40 8.0 10.0 10.20 10.36 10.109 10.118 10.133 10.140 10.221 10.228 10.250 10.255 10.267 10.288 12.0 14.0 15.0 15.14 16.0 16.21 18.0 19.0 21.0 23.15 24.0 24.17 26.0 28.18 29.0 30.0 30.1 30.2 32.0 33.0 33.75 33.76 33.141 33.143 33.159 33.176 35.0 37.20 38.0 39.0 39.1 39.2 41.0 42.0 42.61 42.62 42.80 42.84 42.190 42.191 42.231 42.232 42.268 42.269 42.273 42.274 42.286 42.287 42.294 42.295 42.298 42.299 44.0 45.0 45.174 45.191 46.0}} {richtext:font:italic {28.17 28.18 30.1 30.2 33.75 33.76 37.19 37.20 39.1 39.2 42.61 42.62 42.190 42.191 42.231 42.232}} {richtext:font:bold {4.4 4.20 4.59 4.66 6.24 6.40 10.20 10.36 10.221 10.228}} {richtext:font:bolditalic {10.250 10.255 10.267 10.288}} {richtext:font:typewriter {4.165 4.169 10.109 10.118 10.133 10.140 15.0 15.14 16.0 16.21 23.0 23.15 24.0 24.17 28.0 28.17 33.141 33.143 33.159 33.176 37.0 37.19 42.80 42.84 42.268 42.269 42.273 42.274 42.286 42.287 42.294 42.295 42.298 42.299 45.174 45.191}} {richtext:font:heading0 {1.0 2.0}} {richtext:font:heading1 {3.0 4.0 8.0 9.0 12.0 13.0 21.0 22.0 26.0 27.0 35.0 36.0 44.0 45.0}} {richtext:font:heading2 {9.0 10.0 13.0 14.0 18.0 19.0 22.0 23.0 27.0 28.0 29.0 30.0 32.0 33.0 36.0 37.0 38.0 39.0 41.0 42.0}} {jdoc:anchorname:Introduction {3.0 4.0}} {jdoc:link:jstools.jdoc {4.59 4.66}} {jdoc:anchorname:Usage {8.0 9.0}} {jdoc:manpage:tclvars {10.133 10.140}} {jdoc:link:jslibraries.tcl {10.217 10.238}} {jdoc:link:jslibraries.jdoc#Usage {10.246 10.263}} {jdoc:link:jslibraries.jdoc {10.267 10.288}} {{} {12.0 19.0 22.0 22.10}} {jdoc:anchorname:Credits_and_Copyright {12.0 13.0}} {jdoc:anchorname:Overview {21.0 22.0}} {jdoc:manpage:tcsh {4.165 4.169 42.80 42.84}} {jdoc:manpage:emacs {4.177 4.182 42.70 42.75}} {jdoc:link:#j:longest_match {23.0 23.15}} {jdoc:link:#j:expand_filename {24.0 24.17 33.159 33.176}} {jdoc:anchorname:j:longest_match {26.0 27.0}} {jdoc:anchorname:j:expand_filename {35.0 36.0}}} {{matchend 6.36} {abbrevstart 42.284} {abbrevend 42.284} {insert 1.0} {matchstart 6.24} {anchor 1.0} {current 1.0}}}