Function: vc-jj-log-view-restore-position

vc-jj-log-view-restore-position is a natively compiled function defined in vc-jj.el.

Signature

(vc-jj-log-view-restore-position)

Documentation

Restore the position of point prior to reverting.

When this function is added to revert-buffer-restore-functions in a vc-jj-log-view-mode buffer, after reverting the buffer, restore the position of the point to the revision the point was on prior to reverting. If that revision no longer exists, do not move the point.

Source Code

;; Defined in /nix/store/j1ql1qsv99iszr5pqf5fk9yfcl5pq4nv-emacs-packages-deps/share/emacs/site-lisp/elpa/vc-jj-0.5/vc-jj.el
;;;; log-outgoing

;; (defun vc-jj-log-outgoing (buffer remote-location)
;;   ;; TODO
;;   )

;;;; log-incoming

;; (defun vc-jj-log-incoming (buffer remote-location)
;;   ;; TODO
;;   )

;;;; log-search

;;;; log-view-mode

(defun vc-jj-log-view-restore-position ()
  "Restore the position of point prior to reverting.
When this function is added to `revert-buffer-restore-functions' in a
`vc-jj-log-view-mode' buffer, after reverting the buffer, restore the
position of the point to the revision the point was on prior to
reverting.  If that revision no longer exists, do not move the point."
  (when-let* ((rev (log-view-current-tag)))
    (lambda ()
      (when (re-search-forward rev nil t)
        (goto-char (match-beginning 0))
        (beginning-of-line)
        ;; Report to the user that we've restored the point, otherwise
        ;; they might think the buffer was not reverted or that
        ;; something has gone wrong (because that would likely be the
        ;; case with the default behavior, without this function)
        (message "Buffer reverted and point restored to revision %s"
                 (propertize (vc-jj--command-parseable "show" "--no-patch"
                                                       "-r" rev
                                                       "-T" "change_id.shortest()")
                             'face 'log-view-message))))))