emacs快速跳回上一个地方

Last Updated:

2022-08-12

emacs文档-MarkCommands

跳回上一个地方

C-SPC C-SPC 快速设置一个mark

然后C-x C-SPC,运行 pop-global-mark命令,返回到最近那一次的mark地方

跳到下一个地方

  (defun unpop-to-mark-command ()
    "Unpop off mark ring. Does nothing if mark ring is empty."
    (interactive)
    (when mark-ring
      (let ((pos (marker-position (car (last mark-ring)))))
        (if (not (= (point) pos))
            (goto-char pos)
          (setq mark-ring (cons (copy-marker (mark-marker)) mark-ring))
          (set-marker (mark-marker) pos)
          (setq mark-ring (nbutlast mark-ring))
          (goto-char (marker-position (car (last mark-ring))))))))

然后使用这个unpop-to-mark-command跳到下一个