A mark indicates a specific position within the text represented by a line and a character position within that line. Although a mark is sometimes loosely referred to as pointing to some character, it in fact points between characters. If the charpos is zero, the previous character is the newline character separating the previous line from the mark's line. If the charpos is equal to the number of characters in the line, the next character is the newline character separating the current line from the next. If the mark's line has no previous line, a mark with charpos of zero has no previous character; if the mark's line has no next line, a mark with charpos equal to the length of the line has no next character. [annotate]
This section discusses the very basic operations involving marks, but a lot of Hemlock programming is built on altering some text at a mark. For more extended uses of marks see chapter 4. [annotate]
A mark may have one of two lifetimes: temporary or permanent. Permanent marks remain valid after arbitrary operations on the text; temporary marks do not. Temporary marks are used because less bookkeeping overhead is involved in their creation and use. If a temporary mark is used after the text it points to has been modified results will be unpredictable. Permanent marks continue to point between the same two characters regardless of insertions and deletions made before or after them. [annotate]
There are two different kinds of permanent marks which differ only in their behavior when text is inserted at the position of the mark; text is inserted to the left of a left-inserting mark and to the right of right-inserting mark. [annotate]
This function returns t if mark is a mark object, otherwise nil. [annotate] |
This function returns the line to which mark points. [annotate] |
This function returns the character position of the character after mark. If mark's line has no next line, this returns the length of the line as usual; however, there is actually is no character after the mark. [annotate] |
This function returns one of :right-inserting, :left-inserting or :temporary depending on the mark's kind. A corresponding setf form changes the mark's kind. [annotate] |
This function returns the character immediately before (after) the position of the mark, or nil if there is no previous (next) character. These characters may be set with setf when they exist; the setf methods for these forms signal errors when there is no previous or next character. [annotate] |
This function returns a mark object that points to the charpos'th character of the line. Kind is the kind of mark to create, one of :temporary, :left-inserting, or :right-inserting. The default is :temporary. [annotate] |
This function returns a new mark pointing to the same position and of the same kind, or of kind kind if it is supplied. [annotate] |
This function deletes mark. Delete any permanent marks when you are finished using it. [annotate] |
This macro binds to each variable mark a mark of kind kind, which defaults to :temporary, pointing to the same position as the mark pos. On exit from the scope the mark is deleted. The value of the last form is the value returned. [annotate] |
These functions destructively modify marks to point to new positions. Other sections of this document describe mark moving routines specific to higher level text forms than characters and lines, such as words, sentences, paragraphs, Lisp forms, etc. [annotate]
This function changes the mark to point to the given character position on the line line. Line defaults to mark's line. [annotate] |
This function moves mark to the same position as the mark new-position and returns it. [annotate] |
This function changes mark to point to the beginning or the end of line and returns it. Line defaults to mark's line. [annotate] |
These functions change mark to point to the beginning or end of buffer, which defaults to the buffer mark currently points into. If buffer is unsupplied, then it is an error for mark to be disassociated from any buffer. [annotate] |
These functions change mark to point one character before or after the current position. If there is no character before/after the current position, then they return nil and leave mark unmodified. [annotate] |
This function changes mark to point n characters after (n before if n is negative) the current position. If there are less than n characters after (before) the mark, then this returns nil and mark is unmodified. [annotate] |
This function changes mark to point n lines after (n before if n is negative) the current position. The character position of the resulting mark is min (line-length resulting-line (mark-charpos mark)) if charpos is unspecified, or min (line-length resulting-line charpos) if it is. As with character-offset, if there are not n lines then nil is returned and mark is not modified. [annotate] |