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:
parent
0170e6d0e8
commit
241574375d
2 changed files with 28 additions and 15 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -362,19 +362,13 @@ not `finder-known-keywords'."
|
|||
(let ((package-list-unversioned t))
|
||||
(package-show-package-list packages))))
|
||||
|
||||
(define-button-type 'finder-xref 'action #'finder-goto-xref)
|
||||
|
||||
(defun 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))))
|
||||
|
||||
;;;###autoload
|
||||
(defun finder-commentary (file)
|
||||
"Display FILE's commentary section.
|
||||
FILE should be in a form suitable for passing to `locate-library'."
|
||||
;; FIXME: Merge this function into `describe-package', which is
|
||||
;; strictly better as it has links to URL's and is in a proper help
|
||||
;; buffer with navigation forward and backward, etc.
|
||||
(interactive
|
||||
(list
|
||||
(completing-read "Library name: "
|
||||
|
|
@ -391,12 +385,7 @@ FILE should be in a form suitable for passing to `locate-library'."
|
|||
(erase-buffer)
|
||||
(insert str)
|
||||
(goto-char (point-min))
|
||||
(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 'finder-xref)))
|
||||
(package--describe-add-library-links)
|
||||
(goto-char (point-min))
|
||||
(setq buffer-read-only t)
|
||||
(set-buffer-modified-p nil)
|
||||
|
|
@ -469,6 +458,9 @@ Quit the window and kill all Finder-related buffers."
|
|||
;; continue standard unloading
|
||||
nil)
|
||||
|
||||
(define-obsolete-function-alias 'finder-goto-xref
|
||||
#'package--finder-goto-xref "29.1")
|
||||
|
||||
|
||||
(provide 'finder)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue