Next: , Previous: , Up: Markers   [Contents][Index]


42.5 Changing Marker Positions

This section describes how to change the position of an existing marker. When you do this, be sure you know whether the marker is used outside of your program, and, if so, what effects will result from moving it—otherwise, confusing things may happen in other parts of SXEmacs.

Function: set-marker marker position &optional buffer

This function moves marker to position in buffer. If buffer is not provided, it defaults to the current buffer.

position can be a marker, an integer or nil. If position is an integer, set-marker moves marker to point before the positionth character in buffer. If position is nil, marker is made to point nowhere. Then it no longer slows down editing in any buffer. If position is less than 1, marker is moved to the beginning of buffer. If position is greater than the size of buffer, marker is moved to the end of buffer.

The value returned is marker.

(setq m (point-marker))
     ⇒ #<marker at 4714 in markers.texi>
(set-marker m 55)
     ⇒ #<marker at 55 in markers.texi>
(setq b (get-buffer "foo"))
     ⇒ #<buffer foo>
(set-marker m 0 b)
     ⇒ #<marker at 1 in foo>
Function: move-marker marker position &optional buffer

This is another name for set-marker.