Next: , Previous: , Up: Concepts   [Index]


1.5.3.4 Point and Mark

Point is your current cursor position in a buffer. Each buffer tracks its own point separately, so each buffer has a different position for point. The “current buffer” is that buffer which currently “has the point.” This is the buffer that you can write and move around in. Only one buffer can ever be the “current buffer” at any one time.

The point is one part of a duo called point and mark. The point and mark represent the boundaries of a region, which is a contiguous block of text. Emacs can show you the region. This is called transient mark mode.

The mark saves a location for the user’s convenience. Most editing commands should not alter the mark.

To remember a location for internal use in the Lisp program, store it in a Lisp variable. Example:

(let ((beg (point))) (forward-line 1) (delete-region beg (point))).
set-mark POS

Set this buffer’s MARK to POS. The user will see that the MARK has moved, and the previous MARK position will be lost. Normally, when a new mark is set, the old one should go on the stack. This is why most applications should use ‘push-mark’, not ‘set-mark’.

push-mark &optional LOCATION NOMSG ACTIVATE

Set mark at LOCATION (point, by default) and push old mark on mark ring. Display ‘Mark set’ unless the optional second arg NOMSG is non-nil. In Transient Mark mode, activate mark if optional third arg ACTIVATE non-nil.

  1. Global Mark Ring

    In addition to the ordinary mark ring that belongs to each buffer, Emacs has a single global mark ring.

    Each time you set a mark, this is recorded in the global mark ring in addition to the current buffer’s own mark ring, if you have switched buffers since the previous mark setting. Hence, the global mark ring records a sequence of buffers that you have been in, and, for each buffer, a place where you set the mark.

    C-x C-SPC’ – pop-global-mark

    Jumps to the buffer and position of the latest entry in the global ring. It also rotates the ring, so that successive uses of C-x C-SPC take you to earlier buffers and mark positions.

    Function: pop-global-mark

    Pop off global mark ring and jump to the top location.

    Variable: global-mark-ring-max

    Maximum size of global mark ring. Default value is 16. Start discarding off end if gets this big.


Next: Killing Yanking and CUA, Previous: Modeline Echo Area Minibuffer, Up: Concepts   [Index]