When I have an xref buffer, if I click mouse-1 on a reference when the window containing the xref buffer is inactive, I get a "Choose a reference to visit" error and the point doesn't move. If I switch to the *xref* window first, it works as expected. This appears to be because [mouse-1] and [mouse-2] are bound to xref-goto-ref, which calls (xref--item-at-point) to find the current item; however, at least in my (fairly complex) environment, the point isn't first moved to where the mouse was clicked and xref can't find any item at the point where it was previously. There's another function xref-select-and-show-ref that explicitly sets the point from the mouse event before attempting to follow the xref, and it works fine. I'm not that familiar with mouse event handling in emacs but I hacked up this function (largely copied from xref-goto-xref) which seems to work as expected when I bind it to [mouse-1] in xref--button-map: (defun my:xref-goto-xref-mouse (event &optional quit) (interactive "eP") (let ((xref-buffer) (xref (save-excursion (set-mouse-point event) (setq xref-buffer (current-buffer)) (xref-current-item (xref--item-at-point))))) (if (not xref) (user-error "Choose a reference to visit") (progn (xref--set-arrow) (xref--show-location (xref-item-location xref) (if quit 'quit t)) (next-error-found-buffer xref-buffer))))) (bind-key [mouse-1] #'my:xref-goto-xref-mouse xref--button-map) In GNU Emacs 29.1 (build 2, x86_64-apple-darwin22.6.0, NS appkit-2299.70 Version 13.5 (Build 22G74)) of 2023-08-14 built on C02DR5M6MD6T Windowing system distributor 'Apple', version 10.3.2299 System Description: macOS 13.5.1 Configured using: 'configure --disable-dependency-tracking --disable-silent-rules --enable-locallisppath=/usr/local/share/emacs/site-lisp --infodir=/usr/local/Cellar/emacs-plus@29/29.1/share/info/emacs --prefix=/usr/local/Cellar/emacs-plus@29/29.1 --with-xml2 --with-gnutls --with-native-compilation --without-compress-install --without-dbus --without-imagemagick --with-modules --with-rsvg --with-ns --disable-ns-self-contained 'CFLAGS=-Os -w -pipe -march=nehalem -mmacosx-version-min=13 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -DFD_SETSIZE=10000 -DDARWIN_UNLIMITED_SELECT' 'CPPFLAGS=-I/usr/local/opt/zlib/include -I/usr/local/opt/jpeg/include -I/usr/local/opt/icu4c/include -F/usr/local/Frameworks -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk' 'LDFLAGS=-L/usr/local/opt/zlib/lib -L/usr/local/opt/jpeg/lib -L/usr/local/opt/icu4c/lib -L/usr/local/lib -F/usr/local/Frameworks -Wl,-headerpad_max_install_names -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -L/usr/local/opt/libgccjit/lib'' Configured features: ACL GIF GLIB GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP NOTIFY KQUEUE NS PDUMPER PNG RSVG SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM ZLIB Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: ELisp/l Minor modes in effect: recentf-mode: t dap-tooltip-mode: t dap-ui-many-windows-mode: t dap-ui-controls-mode: t dap-ui-mode: t ivy-mode: t flycheck-color-mode-line-mode: t global-edit-server-edit-mode: t yas-global-mode: t yas-minor-mode: t global-display-line-numbers-mode: t display-line-numbers-mode: t pixel-scroll-precision-mode: t savehist-mode: t global-flycheck-mode: t flycheck-mode: t dap-auto-configure-mode: t dap-mode: t lsp-treemacs-sync-mode: t rainbow-delimiters-mode: t projectile-mode: t global-atomic-chrome-edit-mode: t treemacs-filewatch-mode: t treemacs-follow-mode: t treemacs-git-mode: t treemacs-fringe-indicator-mode: t windmove-mode: t global-company-mode: t company-mode: t global-git-commit-mode: t magit-auto-revert-mode: t auto-revert-mode: t shell-dirtrack-mode: t server-mode: t TeX-PDF-mode: t global-treesit-auto-mode: t global-evil-surround-mode: t evil-surround-mode: t evil-cleverparens-mode: t paredit-mode: t global-evil-collection-unimpaired-mode: t evil-collection-unimpaired-mode: t evil-leader-mode: t evil-mode: t evil-local-mode: t global-undo-tree-mode: t undo-tree-mode: t override-global-mode: t editorconfig-mode: t straight-use-package-mode: t straight-package-neutering-mode: t tooltip-mode: t global-eldoc-mode: t eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t line-number-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: /Users/evan.moses@okta.com/.emacs.d/straight/build/help-fns+/help-fns+ hides ~/.emacs.d/elisp/help-fns+ /Users/evan.moses@okta.com/.emacs.d/straight/build/protobuf-mode/protobuf-mode hides /usr/local/share/emacs/site-lisp/protobuf/protobuf-mode /Users/evan.moses@okta.com/.emacs.d/straight/build/transient/transient hides /usr/local/Cellar/emacs-plus@29/29.1/share/emacs/29.1/lisp/transient /Users/evan.moses@okta.com/.emacs.d/straight/build/use-package/use-package-jump hides /usr/local/Cellar/emacs-plus@29/29.1/share/emacs/29.1/lisp/use-package/use-package-jump /Users/evan.moses@okta.com/.emacs.d/straight/build/use-package/use-package-diminish hides /usr/local/Cellar/emacs-plus@29/29.1/share/emacs/29.1/lisp/use-package/use-package-diminish /Users/evan.moses@okta.com/.emacs.d/straight/build/use-package/use-package hides /usr/local/Cellar/emacs-plus@29/29.1/share/emacs/29.1/lisp/use-package/use-package /Users/evan.moses@okta.com/.emacs.d/straight/build/use-package/use-package-delight hides /usr/local/Cellar/emacs-plus@29/29.1/share/emacs/29.1/lisp/use-package/use-package-delight /Users/evan.moses@okta.com/.emacs.d/straight/build/use-package/use-package-lint hides /usr/local/Cellar/emacs-plus@29/29.1/share/emacs/29.1/lisp/use-package/use-package-lint /Users/evan.moses@okta.com/.emacs.d/straight/build/bind-key/bind-key hides /usr/local/Cellar/emacs-plus@29/29.1/share/emacs/29.1/lisp/use-package/bind-key /Users/evan.moses@okta.com/.emacs.d/straight/build/use-package/use-package-core hides /usr/local/Cellar/emacs-plus@29/29.1/share/emacs/29.1/lisp/use-package/use-package-core /Users/evan.moses@okta.com/.emacs.d/straight/build/use-package/use-package-ensure hides /usr/local/Cellar/emacs-plus@29/29.1/share/emacs/29.1/lisp/use-package/use-package-ensure /Users/evan.moses@okta.com/.emacs.d/straight/build/use-package/use-package-bind-key hides /usr/local/Cellar/emacs-plus@29/29.1/share/emacs/29.1/lisp/use-package/use-package-bind-key /Users/evan.moses@okta.com/.emacs.d/straight/build/less-css-mode/less-css-mode hides /usr/local/Cellar/emacs-plus@29/29.1/share/emacs/29.1/lisp/textmodes/less-css-mode /Users/evan.moses@okta.com/.emacs.d/straight/build/cperl-mode/cperl-mode hides /usr/local/Cellar/emacs-plus@29/29.1/share/emacs/29.1/lisp/progmodes/cperl-mode /Users/evan.moses@okta.com/.emacs.d/straight/build/map/map hides /usr/local/Cellar/emacs-plus@29/29.1/share/emacs/29.1/lisp/emacs-lisp/map /Users/evan.moses@okta.com/.emacs.d/straight/build/let-alist/let-alist hides /usr/local/Cellar/emacs-plus@29/29.1/share/emacs/29.1/lisp/emacs-lisp/let-alist /Users/evan.moses@okta.com/.emacs.d/straight/build/eldoc/eldoc hides /usr/local/Cellar/emacs-plus@29/29.1/share/emacs/29.1/lisp/emacs-lisp/eldoc Features: (shadow sort mail-extr emacsbug cl-print edebug debug backtrace shortdoc prettier-js add-node-modules-path typescript-ts-mode org-capture vc-hg vc-bzr vc-src vc-sccs vc-cvs vc-rcs log-view magit-extras emacsql-sqlite-builtin sqlite recentf treemacs-bookmarks treemacs-tags magit-bookmark bookmark counsel counsel-jq swiper tabify ace-window avy misearch multi-isearch lsp-diagnostics lsp-headerline lsp-icons lsp-modeline dap-mouse dap-ui gdb-mi bui bui-list bui-info bui-entry bui-core bui-history bui-button bui-utils lsp-lens vc-git lsp-ui lsp-ui-flycheck lsp-ui-doc evil-collection-lsp-ui-imenu lsp-ui-imenu lsp-ui-peek lsp-ui-sideline lsp-ui-util lsp-zig lsp-tilt lsp-steep lsp-svelte lsp-sqls lsp-ruby-syntax-tree lsp-ruby-lsp lsp-yaml lsp-xml lsp-vimscript lsp-vhdl lsp-volar lsp-vetur lsp-html lsp-verilog lsp-vala lsp-v lsp-typeprof lsp-ttcn3 lsp-toml lsp-terraform lsp-tex lsp-sorbet lsp-solargraph lsp-semgrep lsp-rust lsp-rf lsp-ruff-lsp lsp-remark lsp-racket lsp-r lsp-purescript lsp-python-ms lsp-pylsp lsp-pyls lsp-pwsh lsp-php lsp-pls lsp-perlnavigator lsp-perl lsp-openscad lsp-ocaml lsp-magik lsp-nix lsp-nim lsp-nginx lsp-mint lsp-marksman lsp-markdown lsp-lua lsp-kotlin lsp-json lsp-javascript lsp-idris lsp-haxe lsp-groovy lsp-hack lsp-graphql lsp-glsl lsp-gleam lsp-go lsp-completion lsp-gdscript lsp-fsharp lsp-fortran lsp-eslint lsp-erlang lsp-emmet lsp-elixir lsp-elm lsp-dockerfile lsp-dhall lsp-d lsp-css lsp-csharp lsp-crystal lsp-credo lsp-cmake lsp-clojure lsp-semantic-tokens lsp-clangd lsp-beancount lsp-bash lsp-astro lsp-awk lsp-ansible lsp-angular lsp-ada lsp-actionscript go-ts-mode ivy-hydra evil-collection-ivy ivy delsel ivy-faces ivy-overlay colir flycheck-color-mode-line face-remap company-oddmuse company-keywords company-etags company-gtags company-dabbrev-code company-dabbrev company-files company-clang company-capf company-cmake company-semantic company-template company-bbdb edit-server edit-server-autoloads treemacs-projectile treemacs-projectile-autoloads yasnippet-snippets yasnippet yasnippet-snippets-autoloads yasnippet-autoloads terminal-here-autoloads zoom-frm-autoloads frame-cmds-autoloads frame-fns-autoloads help-fns+ help-fns radix-tree help-fns+-autoloads ace-jump-mode cl ace-jump-mode-autoloads flycheck-color-mode-line-autoloads smart-mode-line-light-powerline-theme smart-mode-line rich-minority smart-mode-line-powerline-theme smart-mode-line-powerline-theme-autoloads smart-mode-line-autoloads rich-minority-autoloads powerline powerline-separators powerline-themes powerline-autoloads go-impl exec-path-from-shell exec-path-from-shell-autoloads find-file-in-repository find-file-in-repository-autoloads ripgrep ripgrep-autoloads evil-collection-ag ag vc-svn find-dired ag-autoloads ivy-hydra-autoloads hydra counsel-autoloads display-line-numbers pixel-scroll cua-base savehist ispell gotest go-impl-autoloads flycheck-golangci-lint evil-collection-flycheck flycheck flycheck-golangci-lint-autoloads gotest-autoloads go-dlv go-mode find-file gud go-dlv-autoloads go-mode-autoloads present-minor-mode pyvenv pyvenv-autoloads lsp-python-ms-autoloads python-pytest-autoloads lsp-ivy-autoloads lsp-ui-autoloads dap-java dap-mode dap-tasks dap-launch lsp-docker posframe dap-overlays lsp-java lsp-treemacs lsp-treemacs-generic lsp-treemacs-themes treemacs-treelib lsp-java-autoloads dap-mode-autoloads lsp-docker-autoloads lsp-treemacs-autoloads bui-autoloads ccls ccls-member-hierarchy ccls-inheritance-hierarchy ccls-call-hierarchy ccls-tree ccls-code-lens ccls-semantic-highlight ccls-common lsp-mode lsp-protocol tree-widget network-stream lv f f-shortdoc ewoc ccls-autoloads lsp-mode-autoloads eldoc-autoloads racket-mode-autoloads cider-autoloads sesman-autoloads parseedn-autoloads map-autoloads parseclj-autoloads clojure-mode-autoloads rainbow-delimiters rainbow-delimiters-autoloads evil-paredit evil-paredit-autoloads chatgpt-shell shell-maker view goto-addr ielm evil-collection-eshell em-prompt eshell esh-mode esh-cmd esh-ext esh-opt esh-proc esh-io esh-arg esh-module esh-groups esh-util chatgpt-shell-autoloads shell-maker-autoloads mocha-autoloads prettier-js-autoloads less-css-mode-autoloads counsel-jq-autoloads swiper-autoloads ivy-autoloads json-mode-autoloads json-snatcher-autoloads typescript-mode-autoloads web-mode-autoloads xref-js2 vc vc-dispatcher xref-js2-autoloads rjsx-mode-autoloads add-node-modules-path-autoloads jest jest-traversal projectile lisp-mnt grep ibuf-ext ibuffer ibuffer-loaddefs evil-collection-js2-mode js2-mode etags fileloop evil-collection-xref xref project jest-autoloads js2-mode-autoloads projectile-autoloads sqlformat-autoloads atomic-chrome websocket bindat atomic-chrome-autoloads websocket-autoloads nix-mode ffap nix-repl nix-shell nix-store nix-log nix-instantiate nix-shebang nix-format nix nix-mode-autoloads rego-mode-autoloads kubernetes-evil kubernetes kubernetes-overview kubernetes-services kubernetes-secrets kubernetes-persistentvolumeclaims kubernetes-namespaces kubernetes-jobs kubernetes-pod-line kubernetes-ingress kubernetes-errors kubernetes-nodes kubernetes-statefulsets kubernetes-deployments kubernetes-configmaps kubernetes-logs kubernetes-labels kubernetes-commands mode-local kubernetes-popups kubernetes-el-tramp tramp tramp-loaddefs trampver tramp-integration files-x tramp-compat magit-popup kubernetes-pods kubernetes-loading-container kubernetes-contexts kubernetes-yaml kubernetes-utils evil-collection-term term disp-table ehelp kubernetes-modes kubernetes-kubectl kubernetes-state kubernetes-process request kubernetes-core kubernetes-vars kubernetes-ast kubernetes-autoloads request-autoloads magit-popup-autoloads elixir-mode elixir-format elixir-smie elixir-mode-autoloads terraform-mode-autoloads hcl-mode-autoloads vterm-autoloads powershell-autoloads treemacs-evil treemacs treemacs-header-line treemacs-compatibility treemacs-mode treemacs-interface treemacs-persistence treemacs-filewatch-mode treemacs-follow-mode treemacs-rendering treemacs-annotations treemacs-async treemacs-workspaces treemacs-dom treemacs-visuals treemacs-fringe-indicator pulse treemacs-faces treemacs-icons treemacs-scope treemacs-themes treemacs-core-utils pfuture inline hl-line ht treemacs-logging treemacs-customization treemacs-macros s protobuf-mode-autoloads cram-test-mode-autoloads restclient-jq restclient-jq-autoloads jq-mode jq-mode-autoloads scad-mode-autoloads flycheck-yamllint-autoloads flycheck-autoloads pkg-info-autoloads epl-autoloads yaml-mode-autoloads dockerfile-mode-autoloads evil-collection-compile compile plantuml-mode-autoloads groovy-mode-autoloads graphql-mode-autoloads elm-mode-autoloads reformatter-autoloads f-autoloads win-switch windmove win-switch-autoloads arduino-mode-autoloads ede/auto lua-mode-autoloads eldoc-overlay eldoc-overlay-autoloads quick-peek-autoloads inline-docs-autoloads evil-collection-company company company-autoloads forge-list forge-commands forge-semi forge-bitbucket buck forge-gogs gogs forge-gitea gtea forge-gitlab glab forge-github ghub-graphql treepy gsexp ghub url-http url-gw nsm url-auth let-alist gnutls forge-notify forge-revnote forge-pullreq forge-issue forge-topic yaml parse-time iso8601 bug-reference forge-post forge-repo forge forge-core forge-db closql emacsql-sqlite-common emacsql emacsql-compiler eieio-base forge-autoloads yaml-autoloads ghub-autoloads treepy-autoloads let-alist-autoloads closql-autoloads emacsql-autoloads magit-delta xterm-color magit-submodule magit-blame magit-stash magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit magit-sequence magit-notes magit-worktree magit-tag magit-merge magit-branch magit-reset magit-files magit-refs magit-status magit evil-collection-package-menu package url-handlers magit-repos magit-apply magit-wip magit-log which-func magit-diff smerge-mode evil-collection-diff-mode diff-mode git-commit log-edit message sendmail yank-media rfc822 mml mml-sec epa derived epg rfc6068 epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev gmm-utils mailheader pcvs-util add-log magit-core magit-autorevert autorevert filenotify magit-margin magit-transient magit-process with-editor shell server magit-mode transient magit-git magit-base magit-section cursor-sensor compat magit-delta-autoloads xterm-color-autoloads magit-autoloads magit-section-autoloads git-commit-autoloads with-editor-autoloads transient-autoloads compat-autoloads haml-mode js c-ts-common cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs markdown-mode css-mode sgml-mode facemenu imenu eww url-queue shr pixel-fill kinsoku url-file svg xml dom puny mm-url gnus nnheader gnus-util text-property-search mail-utils range mm-util mail-prsvr evil-collection-ruby-mode ruby-mode smie haml-mode-autoloads haskell-mode-autoloads markdown-mode-autoloads flymd browse-url flymd-autoloads generic-x php-mode-autoloads cperl-mode-autoloads google-c-style google-c-style-autoloads tex crm texmathp auctex-autoloads tex-site treesit-auto treesit treesit-auto-autoloads org-mouse sanityinc-tomorrow-night-theme color-theme-sanityinc-tomorrow color color-theme-sanityinc-tomorrow-autoloads evil-numbers evil-numbers-autoloads treemacs-evil-autoloads treemacs-autoloads cfrs-autoloads posframe-autoloads ht-autoloads hydra-autoloads lv-autoloads pfuture-autoloads ace-window-autoloads avy-autoloads s-autoloads evil-surround evil-surround-autoloads evil-iedit-state-autoloads iedit iedit-lib iedit-autoloads evil-cleverparens evil-cleverparens-text-objects evil-cleverparens-util smartparens loadhist paredit dash evil-cleverparens-autoloads smartparens-autoloads dash-autoloads paredit-autoloads evil-collection-unimpaired evil-collection-restclient evil-collection-replace evil-collection-info evil-collection-elisp-mode evil-collection annalist evil-collection-autoloads annalist-autoloads evil-org-autoloads evil-leader evil-leader-autoloads evil evil-integration evil-maps evil-commands reveal evil-jumps evil-command-window evil-search evil-ex evil-types evil-macros evil-repeat evil-states evil-core evil-common rect evil-digraphs evil-vars evil-autoloads goto-chg-autoloads git-link thingatpt git-link-autoloads undo-tree diff queue undo-tree-autoloads queue-autoloads ox-reveal ox-reveal-autoloads use-package-ensure ob-restclient restclient url url-proxy url-privacy url-expand url-methods url-history url-cookie generate-lisp-file url-domsuf url-util url-parse auth-source eieio eieio-core password-cache json map url-vars mailcap ob-restclient-autoloads restclient-autoloads ox-slack ox-slack-autoloads ox-gfm ox-odt rng-loc rng-uri rng-parse rng-match rng-dt rng-util rng-pttrn nxml-parse nxml-ns nxml-enc xmltok nxml-util ox-md ox-latex ox-icalendar org-agenda ox-html table ox-ascii ox-publish ox org-element org-persist xdg org-id org-refile org ob ob-tangle ob-ref ob-lob ob-table org-macro org-src ob-comint org-pcomplete pcomplete comint ansi-osc ansi-color org-list org-footnote org-faces org-entities time-date noutline outline ob-emacs-lisp org-table org-keys org-loaddefs find-func cal-menu calendar cal-loaddefs ring avl-tree generator ol oc ob-exp ob-core org-cycle org-fold org-fold-core org-compat ob-eval org-version org-macs format-spec ox-gfm-autoloads htmlize htmlize-autoloads use-package-bind-key edmacro kmacro bind-key easy-mmode ediff ediff-merg ediff-mult ediff-wind ediff-diff ediff-help ediff-init ediff-util spinner spinner-autoloads editorconfig editorconfig-core editorconfig-core-handle editorconfig-fnmatch pcase editorconfig-autoloads ido-completing-read+ memoize cus-edit pp cus-load wid-edit minibuf-eldef ido-completing-read+-autoloads comp comp-cstr warnings icons rx memoize-autoloads flx-ido flx ido flx-ido-autoloads flx-autoloads finder-inf dired-details+ byte-opt advice dired dired-loaddefs dired-details dired-details+-autoloads dired-details-autoloads use-package-core use-package-autoloads info bind-key-autoloads straight-autoloads cl-seq cl-extra help-mode straight subr-x cl-macs gv cl-loaddefs cl-lib bytecomp byte-compile rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/ns-win ns-win ucs-normalize mule-util term/common-win tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic indonesian philippine 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 composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads kqueue cocoa ns lcms2 multi-tty make-network-process native-compile emacs) Memory information: ((conses 16 4413001 235204) (symbols 48 1069773 55) (strings 32 1349526 10723) (string-bytes 1 28696588) (vectors 16 355207) (vector-slots 8 9933206 2743271) (floats 8 897 2859) (intervals 56 60445 41752) (buffers 984 103))