Next: , Previous: , Up: Strings and Characters   [Contents][Index]


10.12 The Case Table

You can customize case conversion by installing a special case table. A case table specifies the mapping between upper case and lower case letters. It affects both the string and character case conversion functions (see the previous section) and those that apply to text in the buffer (see Case Changes). You need a case table if you are using a language which has letters other than the standard ASCII letters.

A case table is a list of this form:

(downcase upcase canonicalize equivalences)

where each element is either nil or a string of length 256. The element downcase says how to map each character to its lower-case equivalent. The element upcase maps each character to its upper-case equivalent. If lower and upper case characters are in one-to-one correspondence, use nil for upcase; then SXEmacs deduces the upcase table from downcase.

For some languages, upper and lower case letters are not in one-to-one correspondence. There may be two different lower case letters with the same upper case equivalent. In these cases, you need to specify the maps for both directions.

The element canonicalize maps each character to a canonical equivalent; any two characters that are related by case-conversion have the same canonical equivalent character.

The element equivalences is a map that cyclicly permutes each equivalence class (of characters with the same canonical equivalent). (For ordinary ASCII, this would map ‘a’ into ‘A’ and ‘A’ into ‘a’, and likewise for each set of equivalent characters.)

When you construct a case table, you can provide nil for canonicalize; then SXEmacs fills in this string from upcase and downcase. You can also provide nil for equivalences; then SXEmacs fills in this string from canonicalize. In a case table that is actually in use, those components are non-nil. Do not try to specify equivalences without also specifying canonicalize.

Each buffer has a case table. SXEmacs also has a standard case table which is copied into each buffer when you create the buffer. Changing the standard case table doesn’t affect any existing buffers.

Here are the functions for working with case tables:

Function: case-table-p object

This predicate returns non-nil if object is a valid case table.

Function: set-standard-case-table case-table

This function makes case-table the standard case table, so that it will apply to any buffers created subsequently.

Function: standard-case-table

This returns the standard case table.

Function: current-case-table &optional buffer

This function returns the case table of buffer, which defaults to the current buffer.

Function: set-case-table case-table

This sets the current buffer’s case table to case-table.

The following three functions are convenient subroutines for packages that define non-ASCII character sets. They modify a string downcase-table provided as an argument; this should be a string to be used as the downcase part of a case table. They also modify the standard syntax table. See Syntax Tables.

Function: set-case-syntax-pair uc lc downcase-table

This function specifies a pair of corresponding letters, one upper case and one lower case.

Function: set-case-syntax-delims l r downcase-table

This function makes characters l and r a matching pair of case-invariant delimiters.

Function: set-case-syntax char syntax downcase-table

This function makes char case-invariant, with syntax syntax.

Command: describe-buffer-case-table

This command displays a description of the contents of the current buffer’s case table.

You can load the library iso-syntax to set up the standard syntax table and define a case table for the 8-bit ISO Latin 1 character set.


Next: , Previous: , Up: Strings and Characters   [Contents][Index]