]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix xref interaction with which-func (bug#59575)
authorJuanma Barranquero <lekktu@gmail.com>
Sun, 27 Nov 2022 13:57:14 +0000 (14:57 +0100)
committerJuanma Barranquero <lekktu@gmail.com>
Sun, 27 Nov 2022 13:58:45 +0000 (14:58 +0100)
* 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'.

lisp/progmodes/xref.el

index 9b8d37a28e558dfd323b53ea252631528c827b73..f3ba60fc0547ff3e14ea6de6f64d939f719ce07c 100644 (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)))