Add links to commentary reached with finder-list-keywords

* lisp/finder.el (finder-goto-xref): Move from here...
* lisp/emacs-lisp/package.el (package--finder-goto-xref): ...to
here.  Make the old name into an obsolete function alias.
(package--finder-xref): New button type.
(package--describe-add-library-links): Factor out new function...
* lisp/finder.el (finder-commentary): ...from here.
(describe-package-1): Call above new function.  This fixes an
issue where commentaries reached via 'finder-list-keywords' did
not have links.  (Bug#10814)
This commit is contained in:
Stefan Kangas 2021-10-23 05:25:37 +02:00
parent 0170e6d0e8
commit 241574375d
2 changed files with 28 additions and 15 deletions

View file

@ -2488,6 +2488,15 @@ The description is read from the installed package files."
(format "%s.el" (package-desc-name desc)) srcdir))
"")))
(defun package--describe-add-library-links ()
"Add links to library names in package description."
(while (re-search-forward "\\<\\([-[:alnum:]]+\\.el\\)\\>" nil t)
(if (locate-library (match-string 1))
(make-text-button (match-beginning 1) (match-end 1)
'xref (match-string-no-properties 1)
'help-echo "Read this file's commentary"
:type 'package--finder-xref))))
(defun describe-package-1 (pkg)
"Insert the package description for PKG.
Helper function for `describe-package'."
@ -2714,6 +2723,9 @@ Helper function for `describe-package'."
t)
(insert (or readme-string
"This package does not provide a description.")))))
;; Make library descriptions into links.
(goto-char start-of-description)
(package--describe-add-library-links)
;; Make URLs in the description into links.
(goto-char start-of-description)
(browse-url-add-buttons))))
@ -2759,6 +2771,15 @@ function is a convenience wrapper used by `describe-package-1'."
(apply #'insert-text-button button-text 'face button-face 'follow-link t
properties)))
(defun package--finder-goto-xref (button)
"Jump to a Lisp file for the BUTTON at point."
(let* ((file (button-get button 'xref))
(lib (locate-library file)))
(if lib (finder-commentary lib)
(message "Unable to locate `%s'" file))))
(define-button-type 'package--finder-xref 'action #'package--finder-goto-xref)
(defun package--print-email-button (recipient)
"Insert a button whose action will send an email to RECIPIENT.
NAME should have the form (FULLNAME . EMAIL) where FULLNAME is