Use Emacs Lisp xref backend in Lisp Help buffers
* lisp/help-fns.el (help-fns--setup-xref-backend): New function (bug#69462). (describe-function, describe-variable): Use it here. * lisp/emacs-lisp/cl-extra.el (cl-describe-type): And here. * lisp/progmodes/elisp-mode.el (xref-backend-definitions): Only infer namespace in emacs-lisp-mode (use 'any' otherwise).
This commit is contained in:
@@ -733,6 +733,8 @@ PROPLIST is a list of the sort returned by `symbol-plist'.
|
||||
Call `cl--find-class' to get TYPE's propname `cl--class'"
|
||||
(cl--find-class type))
|
||||
|
||||
(declare-function help-fns--setup-xref-backend "help-fns" ())
|
||||
|
||||
;;;###autoload
|
||||
(defun cl-describe-type (type &optional _buf _frame)
|
||||
"Display the documentation for type TYPE (a symbol)."
|
||||
@@ -753,6 +755,7 @@ Call `cl--find-class' to get TYPE's propname `cl--class'"
|
||||
;; cl-deftype).
|
||||
(user-error "Unknown type %S" type))))
|
||||
(with-current-buffer standard-output
|
||||
(help-fns--setup-xref-backend)
|
||||
;; Return the text we displayed.
|
||||
(buffer-string)))))
|
||||
|
||||
|
||||
@@ -262,6 +262,11 @@ interactive command."
|
||||
fn))
|
||||
(list fn)))
|
||||
|
||||
(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 semantic-symref-filepattern-alist '((help-mode "*.el"))))
|
||||
|
||||
;;;###autoload
|
||||
(defun describe-function (function)
|
||||
"Display the full documentation of FUNCTION (a symbol).
|
||||
@@ -295,6 +300,8 @@ handling of autoloaded functions."
|
||||
(princ " is ")
|
||||
(describe-function-1 function)
|
||||
(with-current-buffer standard-output
|
||||
(help-fns--setup-xref-backend)
|
||||
|
||||
;; Return the text we displayed.
|
||||
(buffer-string))))))
|
||||
|
||||
@@ -1510,6 +1517,7 @@ it is displayed along with the global value."
|
||||
(delete-char 1)))))
|
||||
|
||||
(with-current-buffer standard-output
|
||||
(help-fns--setup-xref-backend)
|
||||
;; Return the text we displayed.
|
||||
(buffer-string))))))))
|
||||
|
||||
|
||||
@@ -1049,7 +1049,9 @@ namespace but with lower confidence."
|
||||
(let ((sym (intern-soft identifier)))
|
||||
(when sym
|
||||
(let* ((pos (get-text-property 0 'pos identifier))
|
||||
(namespace (if pos
|
||||
(namespace (if (and pos
|
||||
;; Reusing it in Help Mode.
|
||||
(derived-mode-p 'emacs-lisp-mode))
|
||||
(elisp--xref-infer-namespace pos)
|
||||
'any))
|
||||
(defs (elisp--xref-find-definitions sym)))
|
||||
|
||||
Reference in New Issue
Block a user