デフォルトでは、Emacs はこれらの動きをどこにも記録しません。そのため、必要なことを行うには、バッファー位置を記録する必要があります。何かのようなもの
(defvar my-positions-history nil)
(make-variable-buffer-local 'my-positions-history)
(add-hook 'post-command-hook 'my-record-positions)
(defun my-record-positions ()
(unless (and my-positions-history
(equal (point) (marker-position (car my-positions-history))))
(push (point-marker) my-positions-history)))
これにより多数のマーカーが作成され、Emacs が大幅に遅くなる可能性があることに注意してください。(point)
代わりに を使用すると(point-marker)
この問題は解決しますが、これらの位置はバッファーへの変更を追跡しないため、このモーションを実行した後にバッファーが変更された場合、元の場所に戻らない可能性があります。
次に、次のようなコマンドを追加できます
(defun my-undo-movement ()
(interactive)
(while (and my-positions-history
(equal (point) (marker-position (car my-positions-history))))
(pop my-positions-history))
(when my-positions-history
(goto-char (pop my-positions-history))))