Fix xref interaction with which-func (bug#59575)

* lisp/progmodes/xref.el (xref--add-log-current-defun):
New function.
(xref--xref-buffer-mode): Assign it buffer-locally to
`add-log-current-defun-function'.
This commit is contained in:
Juanma Barranquero 2022-11-27 14:57:14 +01:00
parent a5259b48a4
commit 31cfd6d311

View file

@ -985,6 +985,8 @@ ITEMS is an xref item which " ; FIXME: Expand documentation.
#'xref--imenu-prev-index-position)
(setq imenu-extract-index-name-function
#'xref--imenu-extract-index-name)
(setq-local add-log-current-defun-function
#'xref--add-log-current-defun)
(setq-local outline-minor-mode-cycle t
outline-minor-mode-use-buttons t
outline-search-function
@ -1019,6 +1021,15 @@ beginning of the line."
(buffer-substring-no-properties (line-beginning-position)
(line-end-position)))
(defun xref--add-log-current-defun ()
"Return the string used to group a set of locations.
This function is used as a value for `add-log-current-defun-function'."
(xref--group-name-for-display
(if-let (item (xref--item-at-point))
(xref-location-group (xref-match-item-location item))
(xref--imenu-extract-index-name))
(xref--project-root (project-current))))
(defun xref--next-error-function (n reset?)
(when reset?
(goto-char (point-min)))