; elisp-scope.el: Support hooking into `describe-symbol-backends'.

* lisp/emacs-lisp/elisp-scope.el
(elisp-scope-add-symbol-roles-to-describe-symbol): New
autoloaded function intended for user configs, hooks
`elisp-scope-describe-symbol-role' into `describe-symbol'.
This commit is contained in:
Eshel Yaron 2025-10-03 19:40:42 +02:00
parent efa5b73044
commit f269531255
No known key found for this signature in database
GPG key ID: EF3EE9CA35D78618

View file

@ -81,10 +81,18 @@ NAME inherits properties that do not appear in PROPS from its PARENTS."
obarray #'elisp-scope-symbol-role-p 'confirm
nil 'elisp-scope-read-symbol-role-history default))
(defvar describe-symbol-backends)
(defvar help-mode--current-data)
;;;###autoload
(defun elisp-scope-describe-symbol-role (role)
(defun elisp-scope-add-symbol-roles-to-describe-symbol ()
(require 'help-mode)
(setf
(alist-get "symbol-role" describe-symbol-backends nil nil #'equal)
`(,#'elisp-scope-symbol-role-p ,#'elisp-scope-describe-symbol-role)))
;;;###autoload
(defun elisp-scope-describe-symbol-role (role &rest _)
(interactive (list (elisp-scope-read-symbol-role
"Describe symbol role"
(when-let* ((def (symbol-at-point))
@ -116,7 +124,9 @@ NAME inherits properties that do not appear in PROPS from its PARENTS."
parents ", ")))
(setq help-mode--current-data
(list :symbol role :type 'define-symbol-role
:file (find-lisp-object-file-name role 'define-symbol-role)))))))
:file (find-lisp-object-file-name role 'define-symbol-role)))
;; Return the text we displayed for `describe-symbol-backends'.
(buffer-string)))))
(elisp-scope-define-symbol-role symbol-role ()
:doc "Symbol role names."