Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to jump to mark in Emacs

Tags:

emacs

elisp

What variable or function I need to use to jump to the place of the marker set by set-mark-command C-SPC using goto-char?

(defun jump-to-mark ()
  (interactive)
  (goto-char <WHAT PUT HERE>))
like image 864
jcubic Avatar asked Mar 07 '13 10:03

jcubic


2 Answers

The exchange-point-and-mark command (bound to C-xC-x) jumps to the mark, and puts the current position (i.e. just before the jump) on top of the mark ring.

A side effect is that the region is activated. You can pass a prefix argument (i.e. press C-uC-xC-x) to avoid this.


As mentioned in other answers, another way to navigate in the mark ring consists in using C-uC-SPC, which jumps to the mark and removes it from the mark ring. Repeating the command thus makes you navigate through all successive mark positions in reverse-chronological order. However, mark positions visited that way are lost.

A sibling of C-uC-SPC is C-xC-SPC, which is very similar but acts on the global mark ring, which stores successive marks in all buffers.

like image 104
François Févotte Avatar answered Nov 02 '22 23:11

François Févotte


I just found that it's mark-marker so my function to jump should be:

(defun jump-to-mark ()
  (interactive)
  (goto-char (mark-marker)))
like image 22
jcubic Avatar answered Nov 03 '22 01:11

jcubic