Next: , Previous: , Up: Altering and Searching Text   [Contents][Index]


4.1 Altering Text

A note on marks and text alteration: :temporary marks are invalid after any change has been made to the text the mark points to; it is an error to use a temporary mark after such a change has been made. If text is deleted which has permanent marks pointing into it then they are left pointing to the position where the text was.

Function: insert-character mark character
Function: insert-string mark string
Function: insert-region mark region

Inserts character, string or region at mark. insert-character signals an error if character is not string-char-p. If string or region is empty, and mark is in some buffer, then Hemlock leaves buffer-modified of mark’s buffer unaffected.

Function: ninsert-region mark region

Like insert-region, inserts the region at the mark’s position, destroying the source region. This must be used with caution, since if anyone else can refer to the source region bad things will happen. In particular, one should make sure the region is not linked into any existing buffer. If region is empty, and mark is in some buffer, then Hemlock leaves buffer-modified of mark’s buffer unaffected.

Function: delete-characters mark n

This deletes n characters after the mark (or -n before if n is negative). If n characters after (or -n before) the mark do not exist, then this returns nil; otherwise, it returns t. If n is zero, and mark is in some buffer, then Hemlock leaves buffer-modified of mark’s buffer unaffected.

Function: delete-region region

This deletes region. This is faster than delete-and-save-region (below) because no lines are copied. If region is empty and contained in some buffer’s buffer-region, then Hemlock leaves buffer-modified of the buffer unaffected.

Function: delete-and-save-region region

This deletes region and returns a region containing the original region’s text. If region is empty and contained in some buffer’s buffer-region, then Hemlock leaves buffer-modified of the buffer unaffected. In this case, this returns a distinct empty region.

Function: filter-region function region

Destructively modifies region by replacing the text of each line with the result of the application of function to a string containing that text. Function must obey the following restrictions:

  1. The argument may not be destructively modified.
  2. The return value may not contain newline characters.
  3. The return value may not be destructively modified after it is returned from function.

The strings are passed in order, and are always simple strings.

Using this function, a region could be uppercased by doing:

(filter-region #'string-upcase region)

Next: Text Predicates, Previous: Altering and Searching Text, Up: Altering and Searching Text   [Contents][Index]