diff options
| author | Lars Ingebrigtsen | 2019-07-28 16:01:45 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-07-28 16:01:45 +0200 |
| commit | efc6301068b53ab319aa6a8a1b5607273e4d5b17 (patch) | |
| tree | f57e806695781a35760da5a1ab0c56c677fa07ff | |
| parent | a32e1feb438e793a8378671c7124d226b58f65f0 (diff) | |
| download | emacs-efc6301068b53ab319aa6a8a1b5607273e4d5b17.tar.gz emacs-efc6301068b53ab319aa6a8a1b5607273e4d5b17.zip | |
Make URLs in package descriptions into links
* lisp/emacs-lisp/package.el (describe-package-1): Make the URLs
in package descriptions into links (bug#23480).
| -rw-r--r-- | lisp/emacs-lisp/package.el | 78 |
1 files changed, 41 insertions, 37 deletions
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 15f0f93cf5b..e7e0bd11247 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el | |||
| @@ -151,6 +151,7 @@ | |||
| 151 | (require 'tabulated-list) | 151 | (require 'tabulated-list) |
| 152 | (require 'macroexp) | 152 | (require 'macroexp) |
| 153 | (require 'url-handlers) | 153 | (require 'url-handlers) |
| 154 | (require 'browse-url) | ||
| 154 | 155 | ||
| 155 | (defgroup package nil | 156 | (defgroup package nil |
| 156 | "Manager for Emacs Lisp packages." | 157 | "Manager for Emacs Lisp packages." |
| @@ -2504,44 +2505,47 @@ The description is read from the installed package files." | |||
| 2504 | 2505 | ||
| 2505 | (insert "\n") | 2506 | (insert "\n") |
| 2506 | 2507 | ||
| 2507 | (if built-in | 2508 | (let ((start-of-description (point))) |
| 2508 | ;; For built-in packages, get the description from the | 2509 | (if built-in |
| 2509 | ;; Commentary header. | 2510 | ;; For built-in packages, get the description from the |
| 2510 | (let ((fn (locate-file (format "%s.el" name) load-path | 2511 | ;; Commentary header. |
| 2511 | load-file-rep-suffixes)) | 2512 | (let ((fn (locate-file (format "%s.el" name) load-path |
| 2512 | (opoint (point))) | 2513 | load-file-rep-suffixes)) |
| 2513 | (insert (or (lm-commentary fn) "")) | 2514 | (opoint (point))) |
| 2514 | (save-excursion | 2515 | (insert (or (lm-commentary fn) "")) |
| 2515 | (goto-char opoint) | ||
| 2516 | (when (re-search-forward "^;;; Commentary:\n" nil t) | ||
| 2517 | (replace-match "")) | ||
| 2518 | (while (re-search-forward "^\\(;+ ?\\)" nil t) | ||
| 2519 | (replace-match "")))) | ||
| 2520 | |||
| 2521 | (if (package-installed-p desc) | ||
| 2522 | ;; For installed packages, get the description from the | ||
| 2523 | ;; installed files. | ||
| 2524 | (insert (package--get-description desc)) | ||
| 2525 | |||
| 2526 | ;; For non-built-in, non-installed packages, get description from | ||
| 2527 | ;; the archive. | ||
| 2528 | (let* ((basename (format "%s-readme.txt" name)) | ||
| 2529 | readme-string) | ||
| 2530 | |||
| 2531 | (package--with-response-buffer (package-archive-base desc) | ||
| 2532 | :file basename :noerror t | ||
| 2533 | (save-excursion | 2516 | (save-excursion |
| 2534 | (goto-char (point-max)) | 2517 | (goto-char opoint) |
| 2535 | (unless (bolp) | 2518 | (when (re-search-forward "^;;; Commentary:\n" nil t) |
| 2536 | (insert ?\n))) | 2519 | (replace-match "")) |
| 2537 | (cl-assert (not enable-multibyte-characters)) | 2520 | (while (re-search-forward "^\\(;+ ?\\)" nil t) |
| 2538 | (setq readme-string | 2521 | (replace-match "")))) |
| 2539 | ;; The readme.txt files are defined to contain utf-8 text. | 2522 | |
| 2540 | (decode-coding-region (point-min) (point-max) 'utf-8 t)) | 2523 | (if (package-installed-p desc) |
| 2541 | t) | 2524 | ;; For installed packages, get the description from the |
| 2542 | (insert (or readme-string | 2525 | ;; installed files. |
| 2543 | "This package does not provide a description."))) | 2526 | (insert (package--get-description desc)) |
| 2544 | )))) | 2527 | |
| 2528 | ;; For non-built-in, non-installed packages, get description from | ||
| 2529 | ;; the archive. | ||
| 2530 | (let* ((basename (format "%s-readme.txt" name)) | ||
| 2531 | readme-string) | ||
| 2532 | |||
| 2533 | (package--with-response-buffer (package-archive-base desc) | ||
| 2534 | :file basename :noerror t | ||
| 2535 | (save-excursion | ||
| 2536 | (goto-char (point-max)) | ||
| 2537 | (unless (bolp) | ||
| 2538 | (insert ?\n))) | ||
| 2539 | (cl-assert (not enable-multibyte-characters)) | ||
| 2540 | (setq readme-string | ||
| 2541 | ;; The readme.txt files are defined to contain utf-8 text. | ||
| 2542 | (decode-coding-region (point-min) (point-max) 'utf-8 t)) | ||
| 2543 | t) | ||
| 2544 | (insert (or readme-string | ||
| 2545 | "This package does not provide a description."))))) | ||
| 2546 | ;; Make URLs in the description into links. | ||
| 2547 | (goto-char start-of-description) | ||
| 2548 | (browse-url-add-buttons)))) | ||
| 2545 | 2549 | ||
| 2546 | (defun package-install-button-action (button) | 2550 | (defun package-install-button-action (button) |
| 2547 | (let ((pkg-desc (button-get button 'package-desc))) | 2551 | (let ((pkg-desc (button-get button 'package-desc))) |