Go to the first, previous, next, last section, table of contents.


lid: Querying an ID Database by Token

The `lid' program accepts patterns on the command line which it matches against the tokens stored in an ID database. The interpretation of a pattern is determined by the makeup of the pattern string itself, or can be overridden by command-line options. If a pattern contains regular expression meta-characters, it is used to perform a regular-expression substring search. If no such meta-characters are present, pattern is used to perform a literal word search. (By default, all searches are sensitive to alphabetic case.) If no pattern is supplied on the command line, `lid' lists every entry in the ID database.

`lid' reads the ID database, therefore it accepts the `--file' option, and consults the `IDPATH' environment variable, as described in section Options for Programs that Read ID Databases. `lid' lists file names, therefore it accepts the `--separator' option, as described in section Options for Programs that List File Names.

In addition, lid accepts the following command-line options:

`-i'
`--ignore-case'
Ignoring differences in alphabetic case between the pattern and the tokens in the ID database.
`-l'
`--literal'
Match pattern as a literal string. Use this option if pattern contains regular-expression meta-characters, but you don't wish to perform a regular-expression search.
`-r'
`--regexp'
Match pattern as an extended regular expression(2). Use this option if no regular-expression expression meta-characters are present in pattern, but you wish to force a regular-expression search (note: in this case, a literal substring search might be faster).
`-w'
`--word'
Match pattern using a word-delimited (non substring) search. This is the default for literal searches.
`-s'
`--substring'
Match pattern using a substring (non word-delimited) search. This is the default for regular expression searches.
`-k style'
`--key=style'
Style can be one of `token', `pattern' or `none'. This option controls how the subject of the query is presented. This is best illustrated by example:
$ lid --key=token '^dest.'
destaddr       libsys/memcpy.c
destination    libsys/regex.c
destlst        libsys/rx.c
destpos        libsys/rx.c
destset        libsys/rx.h libsys/rx.c

$ lid --key=pattern '^dest.'
^dest.         libsys/rx.h libsys/{memcpy,regex,rx}.c

$ lid --key=none '^dest.'
libsys/rx.h libsys/{memcpy,regex,rx}.c
When `--key' is either `token' or `pattern', the first column of output is a token or pattern, respectively. When `--key' is `none', neither of these is printed, and the file name list begins immediately. The default is `token'.
`-R style'
`--result=style'
Style can be one of `filenames', `grep', `edit' or `none'. This option controls how the value associated with the query's key presented. When style is `filenames', a list of file names is printed (this is the default). When style is `grep', the lines that match pattern are printed in the same format as `egrep -n'. When style is `edit', the file names are passed to an editor, and if possible pattern is passed as an initial search string (see section eid: Invoking an Editor on Query Results). When style is `none', the file names are not processed in any way. This can be useful if you wish to see what tokens match a pattern, but don't care about where they reside.
`-d'
`-o'
`-x'
These options may be used in any combination to specify the radix of numeric matches. `-d' allows matching on decimal numbers, `-o' on octal numbers, and `-x' on hexadecimal numbers. Any combination of these options may be used. The default is to match all three radixes.
`-F range'
`--frequency=range'
Match tokens whose occurrence count falls in range. Range may be expressed as a single number n, or as a range n..m. Either limit of the range may be omitted (e.g., ..m, or n....). If the lower limit n is omitted, it defaults to 1. If the upper limit is omitted, it defaults in the present implementation to 65535, the maximum value of an unsigned 16-bit integer. Particularly useful queries are `lid -F1', which helps locate identifiers that are defined but never used, or are used but never defined. Similarly, lid -F2 can help find functions that possess a prototype declaration and a definition, but are never called.
`-a number'
`--ambiguous=number'
List identifiers (not numbers) that are ambiguous for the first number characters. This feature might be in useful when porting programs to ancient pea-brained compilers that don't support long identifier names. However, the best long-term option is to set such systems on fire.

Aliases for Specialized `lid' Queries

Historically, the ID utilities have provided several query interfaces which are specializations of lid (see section lid: Querying an ID Database by Token).

`gid'
(alias for `lid -R grep') lists all lines containing the requested pattern.
`eid'
(alias for `lid -R edit') invokes an editor on all files containing the requested pattern, and optionally initiates a text search for that pattern.
`aid'
(alias for `lid -ils') treats the requested pattern as a case-insensitive literal substring.

GNU Emacs query interface

The id-utils source distribution comes with a file `id-utils.el', which defines a GNU Emacs interface to gid. To install it, put `id-utils.el' somewhere that Emacs will find it (i.e., in your load-path) and put

(autoload 'gid "gid" nil t)

in one of Emacs' initialization files, e.g., `~/.emacs'. You will then be able to use M-x gid to run the command.

The gid function prompts you with the word around point. If you want to search for something else, simply delete the line and type the pattern of interest.

The function then runs the gid program in a `*compilation*' buffer, so the normal next-error function can be used to visit all the places the identifier is found (see section `Compilation' in The GNU Emacs Manual).

eid: Invoking an Editor on Query Results

`lid -R edit' is an editing interface for the ID utilities that is most commonly used with `vi'. Emacs users should use the interface defined in id-utils.el (see section GNU Emacs query interface). The ID utilities include an alias called `eid', and for the sake of brevity, we'll use this alias for the remainder of this section. `eid' performs a `lid'-style, then asks if you wish to edit the files. If your query yields more than one line of output, you will be prompted after each line. This is the prompt you'll see:

Edit? [y1-9^S/nq]

You may respond with:

`y'
Edit all files listed.
`1...9'
Edit all files starting at the @math{n + 1}'st file.
`/string or CTRL-Sregexp'
Search into the file list, and begin editing with the first file name that matches the regular expression regexp.
`n'
Don't edit any files. If another line of query output is pending, advance to that line, for which another `Edit?' prompt will appear.
`q'
Quit--don't edit any files, and don't process any more lines of query output.

Here is an example:

prompt$ eid FILE \^print
FILE           {ansi2knr,fid,filenames,idfile,idx,lid,misc,...}.c
Edit? [y1-9^S/nq] n
^print         {ansi2knr,fid,getopt,getopt1,lid,mkid,regex,scanners}.c
Edit? [y1-9^S/nq] 2

This will start editing at `getopt'.c.

eid invokes the editor defined by the environment variable `VISUAL'. If `VISUAL' is undefined, it uses the environment variable `EDITOR' instead. If `EDITOR' is undefined, it defaults to `vi'. It is possible for `eid' to pass the editor an initial search pattern so that your cursor will immediately alight on the token of interest. This feature is controlled by the following environment variables:

`EIDARG'
A printf(3) format string for the editor argument to search for the matching token. For vi, this should be `+/%s/'.
`EIDLDEL'
The regular-expression meta-character(s) for delimiting the beginning of a word (the ``eid' Left DELimiter'). eid inserts this in front of the matching token when a word-search is desired. For `vi', this should be `\<'.
`EIDRDEL'
The regular-expression meta-character(s) for delimiting the end of a word (the ``eid' Right DELimiter'). eid inserts this in end of the matching token when a word-search is desired. For `vi', this should be `\>'.


Go to the first, previous, next, last section, table of contents.