emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 2415743: Add links to commentary reached with finder-list-keyword


From: Stefan Kangas
Subject: master 2415743: Add links to commentary reached with finder-list-keywords
Date: Fri, 22 Oct 2021 23:30:42 -0400 (EDT)

branch: master
commit 241574375df80a136624ea622d76b426e1437617
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>

    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)
---
 lisp/emacs-lisp/package.el | 21 +++++++++++++++++++++
 lisp/finder.el             | 22 +++++++---------------
 2 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 40318dc..fcbcdc7 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -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
diff --git a/lisp/finder.el b/lisp/finder.el
index c2b9a6d..00f321b 100644
--- a/lisp/finder.el
+++ b/lisp/finder.el
@@ -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)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]