Download GNU Emacs Manual

Transcript
Chapter 22: Text
507
22.20 Substituting for a Character Code
The following functions replace characters within a specified region based on their character
codes.
subst-char-in-region start end old-char new-char &optional noundo
[Function]
This function replaces all occurrences of the character old-char with the character
new-char in the region of the current buffer defined by start and end.
If noundo is non-nil, then subst-char-in-region does not record the change for
undo and does not mark the buffer as modified. This was useful for controlling the
old selective display feature (see Section 11.7 [Selective Display], page 124).
subst-char-in-region does not move point and returns nil.
---------- Buffer: foo ---------This is the contents of the buffer before.
---------- Buffer: foo ---------(subst-char-in-region 1 20 ?i ?X)
⇒ nil
---------- Buffer: foo ---------ThXs Xs the contents of the buffer before.
---------- Buffer: foo ----------
translate-region start end table
[Command]
This function applies a translation table to the characters in the buffer between positions start and end.
The translation table table is a string or a char-table; (aref table ochar ) gives the
translated character corresponding to ochar. If table is a string, any characters with
codes larger than the length of table are not altered by the translation.
The return value of translate-region is the number of characters that were actually
changed by the translation. This does not count characters that were mapped into
themselves in the translation table.
22.21 Registers
A register is a sort of variable used in Emacs editing that can hold a variety of different
kinds of values. Each register is named by a single character. All ASCII characters and
their meta variants (but with the exception of C-g) can be used to name registers. Thus,
there are 255 possible registers. A register is designated in Emacs Lisp by the character
that is its name.
[Variable]
This variable is an alist of elements of the form (name . contents ). Normally, there
is one element for each Emacs register that has been used.
register-alist
The object name is a character (an integer) identifying the register.
The contents of a register can have several possible types: