# 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 2001.02.10.

## 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@aq.org`
`http://www.aq.org/~js/`

### Copyright

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

## Overview

### Procedures

`::jstools::longest_match` - find the longest common initial string in a list
`::jstools::expand_filename` - expand filename prefix as much as possible

## ::jstools::longest_match

### Usage

`::jstools::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 `::jstools::expand_filename` for filename completion, but could also be used for things like handling abbreviations.

## ::jstools::expand_filename

### Usage

`::jstools::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 `::jstools::expand_filename`.)`
  `