Previous Section Next Section Table of Contents Glossary Index

Chapter 6. Hemlock Programming

6.16. Utilities

This chapter describes a number of utilities for manipulating some types of objects Hemlock uses to record information. String-tables are used to store names of variables, commands, modes, and buffers. Ring lists can be used to provide a kill ring, recent command history, or other user-visible features.

6.16.1. String-table Functions

String tables are similar to Common Lisp hash tables in that they associate a value with an object. There are a few useful differences: in a string table the key is always a case insensitive string, and primitives are provided to facilitate keyword completion and recognition. Any type of string may be added to a string table, but the string table functions always return simple-string's.

A string entry in one of these tables may be thought of as being separated into fields or keywords. The interface provides keyword completion and recognition which is primarily used to implement some Echo Area commands. These routines perform a prefix match on a field-by-field basis allowing the ambiguous specification of earlier fields while going on to enter later fields. While string tables may use any string-char as a separator, the use of characters other than space may make the Echo Area commands fail or work unexpectedly.

[Function]

make-string-table

Description:

This function creates an empty string table that uses separator as the character, which must be a string-char, that distinguishes fields. Initial-contents specifies an initial set of strings and their values in the form of a dotted a-list, for example:


'(("Global" . t) ("Mode" . t) ("Buffer" . t))

[Function]

string-table-p string-table

Description:

This function returns t if string-table is a string-table object, otherwise nil.

[Function]

string-table-separator string-table

Description:

This function returns the separator character given to make-string-table.

[Function]

delete-string string table

Description:

[Function]

clrstring table

Description:

delete-string removes any entry for string from the string-table table, returning t if there was an entry. clrstring removes all entries from table.

[Function]

getstring string table

Description:

This function returns as multiple values, first the value corresponding to the string if it is found and nil if it isn't, and second t if it is found and nil if it isn't.

This may be set with setf to add a new entry or to store a new value for a string. It is an error to try to insert a string with more than one field separator character occurring contiguously.

[Function]

complete-string string tables

Description:

This function completes string as far as possible over the list of tables, returning five values. It is an error for tables to have different separator characters. The five return values are as follows:

  • The maximal completion of the string or nil if there is none.

  • An indication of the usefulness of the returned string:

:none--- There is no completion of string.

:complete--- The completion is a valid entry, but other valid completions exist too. This occurs when the supplied string is an entry as well as initial substring of another entry.

:unique--- The completion is a valid entry and unique.

:ambiguous--- The completion is invalid; get-string would return nil and nil if given the returned string.

  • The value of the string when the completion is :unique or :complete, otherwise nil.

  • An index, or nil, into the completion returned, indicating where the addition of a single field to string ends. The command Complete Field uses this when the completion contains the addition to string of more than one field.

  • An index to the separator following the first ambiguous field when the completion is :ambiguous or :complete, otherwise nil.

[Function]

find-ambiguous string table

Description:

[Function]

find-containing string table

Description:

find-ambiguous returns a list in alphabetical order of all the strings in table matching string. This considers an entry as matching if each field in string, taken in order, is an initial substring of the entry's fields; entry may have fields remaining.

find-containing is similar, but it ignores the order of the fields in string, returning all strings in table matching any permutation of the fields in string.

[Macro]

do-strings (string-var value-var table result) declaration tag statement

Description:

This macro iterates over the strings in table in alphabetical order. On each iteration, it binds string-var to an entry's string and value-var to an entry's value.

6.16.2. Ring Functions

There are various purposes in an editor for which a ring of values can be used, so Hemlock provides a general ring buffer type. It is used for maintaining a ring of killed regions, a ring of marks, or a ring of command strings which various modes and commands maintain as a history mechanism.

[Function]

make-ring length &optional delete-function

Description:

Makes an empty ring object capable of holding up to length Lisp objects. Delete-function is a function that each object is passed to before it falls off the end. Length must be greater than zero.

[Function]

ringp ring

Description:

Returns t if ring is a ring object, otherwise nil.

[Function]

ring-length ring

Description:

Returns as multiple-values the number of elements which ring currently holds and the maximum number of elements which it may hold.

[Function]

ring-ref ring index

Description:

Returns the index'th item in the ring, where zero is the index of the most recently pushed. This may be set with setf.

[Function]

ring-push object ring

Description:

Pushes object into ring, possibly causing the oldest item to go away.

[Function]

ring-pop ring

Description:

Removes the most recently pushed object from ring and returns it. If the ring contains no elements then an error is signalled.

[Function]

rotate-ring ring offset

Description:

With a positive offset, rotates ring forward that many times. In a forward rotation the index of each element is reduced by one, except the one which initially had a zero index, which is made the last element. A negative offset rotates the ring the other way.

6.16.3. Undoing commands

No API to the undo facility is provided at this time.


Previous Section Next Section Table of Contents Glossary Index