Previous: , Up: Regions   [Contents][Index]


2.3.1 Region Functions

Function: region start end

This function returns a region constructed from the marks start and end. It is an error for the marks to point to non-contiguous lines or for start to come after end.

Function: regionp region

This function returns t if region is a region object, otherwise nil.

Function: make-empty-region

This function returns a region with start and end marks pointing to the start of one empty line. The start mark is a :right-inserting mark, and the end is a :left-inserting mark.

Function: copy-region region

This function returns a region containing a copy of the text in the specified region. The resulting region is completely disjoint from region with respect to data references — marks, lines, text, etc.

Function: region-to-string region
Function: string-to-region string

These functions coerce regions to Lisp strings and vice versa. Within the string, lines are delimited by newline characters.

Function: line-to-region line

This function returns a region containing all the characters on line. The first mark is :right-inserting and the last is :left-inserting.

Function: region-start region
Function: region-end region

This function returns the start or end mark of region.

Function: region-bounds region

This function returns as multiple-values the starting and ending marks of region.

Function: set-region-bounds region start end

This function sets the start and end of region to start and end. It is an error for start to be after or in a different buffer from end.

Function: count-lines region

This function returns the number of lines in the region, first and last lines inclusive. A newline is associated with the line it follows, thus a region containing some number of non-newline characters followed by one newline is one line, but if a newline were added at the beginning, it would be two lines.

Function: count-characters region

This function returns the number of characters in a given region. This counts line breaks as one character.

Hemlock Variable: Region Query Size (initial value 30)
Function: check-region-query-size region

check-region-query-size counts the lines in region, and if their number exceeds the Region Query Size threshold, it prompts the user for confirmation. This should be used in commands that perform destructive operations and are not undoable. If the user responds negatively, then this signals an editor-error, aborting whatever command was in progress.


Previous: Regions, Up: Regions   [Contents][Index]