I've tried to modify point-undo
. It seems to work. However I included the first jump on the current line. That's intended behaviour.
(defvar point-undo-ring-length 20)
(defvar point-undo-ring (make-ring point-undo-ring-length))
(make-variable-buffer-local 'point-undo-ring)
(defvar point-redo-ring (make-ring point-undo-ring-length))
(make-variable-buffer-local 'point-redo-ring)
(defun point-undo-pre-command-hook ()
"Save positions before command."
(unless (or (eq this-command 'point-undo)
(eq this-command 'point-redo))
(let ((line (line-number-at-pos)))
(when (eq line (cdr (nth 0 (ring-elements point-undo-ring))))
(ring-remove point-undo-ring 0))
(ring-insert point-undo-ring (cons (point) line))
(setq point-redo-ring (make-ring point-undo-ring-length)))))
(add-hook 'pre-command-hook 'point-undo-pre-command-hook)
(defun point-undo-doit (ring1 ring2)
"ring1, ring2 = {point-undo-ring, point-redo-ring}"
(condition-case nil
(progn
(goto-char (car (nth 0 (ring-elements ring1))))
(ring-insert ring2 (ring-remove ring1 0)))
(error nil)))
(defun point-undo ()
"Undo position."
(interactive)
(point-undo-doit point-undo-ring point-redo-ring))
(defun point-redo ()
"Redo position."
(interactive)
(when (or (eq last-command 'point-undo)
(eq last-command 'point-redo))
(point-undo-doit point-redo-ring point-undo-ring)))
(define-key global-map [f9] 'point-undo)
(define-key global-map [f10] 'point-redo)
avy
it allows you to quickly jump to any lines in the visible text withavy-goto-lines
command.scroll-up
and so on. Since multiplenext-line
commands also cause ascroll-up
those line-commands are also covered in some sense.pointhistory
. And the way it jumps is somewhat enigmatic, as to the positions that go into the ring. Maybe the code ofpointhistory
could be modified to also include line-based jumps?ace-jump-mode
is a nice alternative toavy
. Demoed here.