Rename xref--mouse-2 and adjust documentation

* doc/emacs/maintaining.texi (Xref Commands): `mouse-1' is bound
to `xref-goto-xref', not `mouse-2' (bug#35376).
(Xref Commands): Mention what `mouse-2' does.

* lisp/progmodes/xref.el (xref--button-map): Adjust.
(xref-select-and-goto-xref): Rename from xref--mouse-2 (bug#35376).
This commit is contained in:
Lars Ingebrigtsen 2021-08-31 04:50:18 +02:00
parent bd17fe1d9e
commit 03dcceeeee
2 changed files with 12 additions and 4 deletions

View file

@ -2218,10 +2218,15 @@ the special XREF mode:
@table @kbd
@item @key{RET}
@itemx mouse-2
@itemx mouse-1
Display the reference on the current line (@code{xref-goto-xref}).
With prefix argument, also bury the @file{*xref*} buffer.
@item mouse-2
The same as @code{mouse-1}, but make the window displaying the
@file{*xref*} buffer the selected window
(@code{xref-select-and-goto-xref}).
@item n
@itemx .
@findex xref-next-line

View file

@ -898,17 +898,20 @@ beginning of the line."
(defvar xref--button-map
(let ((map (make-sparse-keymap)))
(define-key map [mouse-1] #'xref-goto-xref)
(define-key map [mouse-2] #'xref--mouse-2)
(define-key map [mouse-2] #'xref-select-and-goto-xref)
map))
(defun xref--mouse-2 (event)
"Move point to the button and show the xref definition."
(defun xref-select-and-goto-xref (event)
"Move point to the button and show the xref definition.
The window showing the xref buffer will be selected."
(interactive "e")
(mouse-set-point event)
(forward-line 0)
(or (get-text-property (point) 'xref-item)
(xref--search-property 'xref-item))
(xref-show-location-at-point))
(define-obsolete-function-alias
'xref--mouse-2 #'xref-select-and-goto-xref "28.1")
(defcustom xref-truncation-width 400
"The column to visually \"truncate\" each Xref buffer line to."