Emacs: Cycle Marks (Cycle local mark ring) 📜

By Xah Lee. Date: . Last updated: .

put this in your Emacs Init File:

(defun xah-pop-local-mark-ring ()
  "Move cursor to last mark position of current buffer.
Repeat call cycles all positions in `mark-ring'.

After this command is called, press `xah-repeat-key' to repeat it.

URL `http://xahlee.info/emacs/emacs/emacs_cycle_local_mark_ring.html'
Created: 2016-04-04
Version: 2025-07-28"
  (interactive)
  (set-mark-command t)
  (set-transient-map
   (let ((xkmap (make-sparse-keymap)))
     (define-key xkmap (kbd (if (boundp 'xah-repeat-key) xah-repeat-key "RET")) real-this-command)
     xkmap)))

give the command a easy key.

(global-set-key (kbd "C-0") 'xah-pop-local-mark-ring)
(global-set-key (kbd "C-9") 'pop-global-mark)

〔see Emacs Keys: Define Key〕

Emacs Mark Ring