From: Dmitry Gutov Date: Thu, 3 Oct 2024 01:17:35 +0000 (+0300) Subject: Make xref-find-references work in Help buffers outside of projects X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=267a27f540a7165611b53148097bae661f9452a2;p=emacs.git Make xref-find-references work in Help buffers outside of projects * 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) --- diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 32a55e15e63..44d9c7c028d 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -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