]> git.eshelyaron.com Git - emacs.git/commitdiff
Make xref-find-references work in Help buffers outside of projects
authorDmitry Gutov <dmitry@gutov.dev>
Thu, 3 Oct 2024 01:17:35 +0000 (04:17 +0300)
committerEshel Yaron <me@eshelyaron.com>
Thu, 3 Oct 2024 06:49:00 +0000 (08:49 +0200)
* lisp/help-fns.el (xref-backend-references):
New context-dependent override.  Don't call project-current and
use elisp-load-path-roots directly (bug#69462).
(help-fns--setup-xref-backend): No need to set
project-vc-external-roots-function then.

(cherry picked from commit ad529831018555b4c693844bc3b18766eb78465a)

lisp/help-fns.el

index 32a55e15e630dca84a576a855c4ea1c74bafa3ae..44d9c7c028d22807632e1068af5a30b3cc3eba83 100644 (file)
@@ -255,9 +255,21 @@ interactive command."
                   fn))
     (list fn)))
 
+(declare-function project-combine-directories "project" (&rest lists))
+
+(cl-defmethod xref-backend-references ((_backend (eql 'elisp)) identifier
+                                       &context (major-mode help-mode))
+  (mapcan
+   (lambda (dir)
+     (message "Searching %s..." dir)
+     (redisplay)
+     (prog1
+         (xref-references-in-directory identifier dir)
+       (message "Searching %s... done" dir)))
+   (project-combine-directories (elisp-load-path-roots))))
+
 (defun help-fns--setup-xref-backend ()
   (add-hook 'xref-backend-functions #'elisp--xref-backend nil t)
-  (setq-local project-vc-external-roots-function #'elisp-load-path-roots)
   (setq-local grep-filepattern-alist '((help-mode "*.el"))))
 
 ;;;###autoload