Previous Section | Next Section | Table of Contents | Glossary | Index |
A note on marks and text alteration: :temporary marks are invalid after any change has been made to the buffer 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.
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.
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.
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:
The argument may not be destructively modified.
The return value may not contain newline characters.
The return value may not be destructively modified after it is returned from function.
The strings are passed in order.
Using this function, a region could be uppercased by doing:
(filter-region #'string-upcase region)
Returns t if line contains only characters with a Whitespace attribute of 1. See the Character Attributes chapter for discussion of character attributes.
These predicates test the relative ordering of two marks in a piece of text, that is a mark is mark> another if it points to a position after it. An error is signalled if the marks do not point into the same buffer, except that for such marks mark= is always false and mark/= is always true.
There is a global ring of regions deleted from buffers. Some commands save affected regions on the kill ring before performing modifications. You should consider making the command undoable, but this is a simple way of achieving a less satisfactory means for the user to recover.
This kills region saving it in the kill ring. Current-type is either :kill-forward or :kill-backward. When the last-command-type is one of these, this adds region to the beginning or end, respectively, of the top of the kill ring. The result of calling this is undoable using the command Undo (see the Hemlock User's Manual). This sets last-command-type to current-type, and it interacts with kill-characters.
kill-characters kills count characters after mark if count is positive, otherwise before mark if count is negative. When count is greater than or equal to Character Deletion Threshold, the killed characters are saved on the kill ring. This may be called multiple times contiguously (that is, without last-command-type being set) to accumulate an effective count for purposes of comparison with the threshold.
This sets last-command-type, and it interacts with kill-region. When this adds a new region to the kill ring, it sets last-command-type to :kill-forward (if count is positive) or :kill-backward (if count is negative). When last-command-type is :kill-forward or :kill-backward, this adds the killed characters to the beginning (if count is negative) or the end (if count is positive) of the top of the kill ring, and it sets last-command-type as if it added a new region to the kill ring. When the kill ring is unaffected, this sets last-command-type to :char-kill-forward or :char-kill-backward depending on whether count is positive or negative, respectively.
This returns mark if it deletes characters. If there are not count characters in the appropriate direction, this returns nil.
Every buffer has a mark stack and a mark known as the point where most text altering nominally occurs. Between the top of the mark stack, the current-mark, and the current-buffer's point, the current-point, is what is known as the current-region . Certain commands signal errors when the user tries to operate on the current-region without its having been activated. If the user turns off this feature, then the current-region is effectively always active.
When writing a command that marks a region of text, the programmer should make sure to activate the region. This typically occurs naturally from the primitives that you use to mark regions, but sometimes you must explicitly activate the region. These commands should be written this way, so they do not require the user to separately mark an area and then activate it. Commands that modify regions do not have to worry about deactivating the region since modifying a buffer automatically deactivates the region. Commands that insert text often activate the region ephemerally; that is, the region is active for the immediately following command, allowing the user wants to delete the region inserted, fill it, or whatever.
Once a marking command makes the region active, it remains active until:
a command uses the region,
a command modifies the buffer,
a command changes the current window or buffer,
a command signals an editor-error,
or the user types C-g.
This is a list of command types, and its initial value is the list of :ephemerally-active and :unkill. When the previous command's type is one of these, the current-region is active for the currently executing command only, regardless of whether it does something to deactivate the region. However, the current command may activate the region for future commands. :ephemerally-active is a default command type that may be used to ephemerally activate the region, and:unkill is the type used by two commands, Un-kill and Rotate Kill Ring (what users typically think of as C-y and M-y).
This returns a region formed with current-mark and current-point, optionally signaling an editor-error if the current region is not active. Error-if-not-active defaults to t. Each call returns a distinct region object. Depending on deactivate-region (defaults to t), fetching the current region deactivates it. Hemlock primitives are free to modify text regardless of whether the region is active, so a command that checks for this can deactivate the region whenever it is convenient.
Before using any of these functions to do a character search, look at character attributes. They provide a facility similar to the syntax table in real Emacs. Syntax tables are a powerful, general, and efficient mechanism for assigning meanings to characters in various modes.
Returns a search-pattern object which can be given to the find-pattern and replace-pattern functions. A search-pattern is a specification of a particular sort of search to do. direction is either :forward or :backward, indicating the direction to search in. kind specifies the kind of search pattern to make, and pattern is a thing which specifies what to search for. The interpretation of pattern depends on the kind of pattern being made. Currently defined kinds of search pattern are:
:string-insensitive--- Does a case-insensitive string search for pattern
:string-sensitive--- Does a case-sensitive string search for pattern.
:character--- Finds an occurrence of the character pattern. This is case sensitive.
:not-character--- Find a character which is not the character pattern.
:test--- Finds a character which satisfies the function pattern. This function may not be applied an any particular fashion, so it should depend only on what its argument is, and should have no side-effects.
:test-not--- Similar to :test, except it finds a character that fails the test.
:any--- Finds a character that is in the string pattern.
:not-any--- Finds a character that is not in the string pattern.
result-search-pattern, if supplied, is a search-pattern to destructively modify to produce the new pattern. Where reasonable this should be supplied, since some kinds of search patterns may involve large data structures.
get-search-pattern interfaces to a default search string and pattern that search and replacing commands can use. These commands then share a default when prompting for what to search or replace, and save on consing a search pattern each time they execute. This uses Default Search Kind (see the Hemlock User's Manual) when updating the pattern object.
Previous Section | Next Section | Table of Contents | Glossary | Index |