Evaluate: (defun jpk/next-error-hook () (let ((win (get-buffer-window next-error-last-buffer))) (when (window-live-p win) (with-selected-window win ;; breaks with xref (message "window: %s" win))))) (add-hook 'next-error-hook #'jpk/next-error-hook) Run xref-find-references on e.g. add-hook Run next-error or previous-error at least twice. Repeating next-error doesn't find the next match after the 2nd invocation. Running previous-error behaves similarly. I can use a mouse to click on an any match, but next/previous-error will still only move between the clicked match and the next. I can only cycle between two matches. For reference, this is my original hook: (defun jpk/next-error-hook () (let ((win (get-buffer-window next-error-last-buffer)) (buf (buffer-name next-error-last-buffer)) (recenter-redisplay nil)) (when (window-live-p win) (with-selected-window win (recenter))))) The question on Stack Exchange: https://emacs.stackexchange.com/q/36260/651 In GNU Emacs 25.3.1 (x86_64-pc-linux-gnu, X toolkit, Xaw scroll bars) of 2017-09-12 built on shannon Windowing system distributor 'The X.Org Foundation', version 11.0.11905000 Configured using: 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib --localstatedir=/var --with-x-toolkit=lucid --with-xft --without-gconf --without-gsettings --with-modules --with-gameuser=:games '--program-transform-name=s/^ctags$/ctags.emacs/' 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt' CPPFLAGS=-D_FORTIFY_SOURCE=2 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now' Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS NOTIFY ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS LUCID X11 MODULES Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Emacs-Lisp Minor modes in effect: diff-auto-refine-mode: t tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t buffer-read-only: t line-number-mode: t transient-mark-mode: t Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Mark set jpk/next-error-hook (jpk/next-error-hook) Quit [2 times] Mark set Note: file is write protected window: # [11 times] Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message dired format-spec rfc822 mml mml-sec password-cache epg epg-config gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util help-fns mail-prsvr mail-utils pulse semantic/symref/grep grep compile comint ansi-color semantic/symref semantic/util-modes semantic/util semantic semantic/tag semantic/lex semantic/fw mode-local find-func cedet vc-hg vc-git diff-mode easy-mmode vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs vc vc-dispatcher thingatpt xref cl-seq project ring eieio byte-opt bytecomp byte-compile cl-extra help-mode easymenu cconv eieio-core cl-macs gv cl-loaddefs pcase cl-lib time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote dbusbind inotify dynamic-setting font-render-setting x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 121559 6089) (symbols 48 23516 0) (miscs 40 80 140) (strings 32 27164 5634) (string-bytes 1 818145) (vectors 16 17422) (vector-slots 8 491703 4664) (floats 8 264 116) (intervals 56 628 18) (buffers 976 21)) -- Thanks, Jonathan Kotta Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.