From 108ce84432d597f92637ea74bd0a094224d157de Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Wed, 28 Feb 2018 04:03:16 +0200 Subject: [PATCH] xref--next-error-function: Move xref's window point * lisp/progmodes/xref.el (xref--next-error-function): Move xref's window point if it's visible. When we don't do that, navigation can start looping after a while. --- lisp/progmodes/xref.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 1c1fc597c50..5a9a7a925a9 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -693,6 +693,10 @@ references displayed in the current *xref* buffer." (dotimes (_ n) (setq xref (xref--search-property 'xref-item backward))) (cond (xref + ;; Save the current position (when the buffer is visible, + ;; it gets reset to that window's point from time to time). + (let ((win (get-buffer-window (current-buffer)))) + (and win (set-window-point win (point)))) (xref--show-location (xref-item-location xref) t)) (t (error "No %s xref" (if backward "previous" "next")))))) -- 2.39.5