Commit 963a9ffd authored by Bruno Félix Rezende Ribeiro's avatar Bruno Félix Rezende Ribeiro Committed by Stefan Kangas

Globally sanitize single-file package long descriptions (Bug#37548)

Consistent with multi-file package descriptions which don’t have
commentary sections nor double semicolon prefixes.
* lisp/emacs-lisp/lisp-mnt.el (lm-commentary): Remove commentary
header, double semicolon prefixes of each line, trailing new-lines and
trailing white-space from commentary.
* lisp/emacs-lisp/package.el (package--get-description)
* lisp/finder.el (finder-commentary):
* lisp/info.el (Info-finder-find-node): Remove ad-hoc sanitation.
parent cd2d812e
Pipeline #4670 failed with stage
in 53 minutes and 38 seconds
......@@ -485,7 +485,18 @@ absent, return nil."
(lm-with-file file
(let ((start (lm-commentary-start)))
(when start
(buffer-substring-no-properties start (lm-commentary-end))))))
(replace-regexp-in-string ; Get rid of...
"[[:blank:]]*$" "" ; trailing white-space
(format "%s\\|%s\\|%s"
;; commentary header
(concat "^;;;[[:blank:]]*\\("
"^;;[[:blank:]]*" ; double semicolon prefix
"[[:blank:]\n]*\\'") ; trailing new-lines
"" (buffer-substring-no-properties
start (lm-commentary-end))))))))
(defun lm-homepage (&optional file)
"Return the homepage in file FILE, or current buffer if FILE is nil."
......@@ -2376,18 +2376,9 @@ The description is read from the installed package files."
;; Look for Commentary header.
(let ((mainsrcfile (expand-file-name (format "%s.el" (package-desc-name desc))
(when (file-readable-p mainsrcfile)
(insert (or (lm-commentary mainsrcfile) ""))
(goto-char (point-min))
(when (re-search-forward "^;;; Commentary:\n" nil t)
(replace-match ""))
(while (re-search-forward "^\\(;+ ?\\)" nil t)
(replace-match ""))
(lm-commentary (expand-file-name
(format "%s.el" (package-desc-name desc)) srcdir))
(defun describe-package-1 (pkg)
"Insert the package description for PKG.
......@@ -2582,16 +2573,10 @@ Helper function for `describe-package'."
(if built-in
;; For built-in packages, get the description from the
;; Commentary header.
(let ((fn (locate-file (format "%s.el" name) load-path
(opoint (point)))
(insert (or (lm-commentary fn) ""))
(goto-char opoint)
(when (re-search-forward "^;;; Commentary:\n" nil t)
(replace-match ""))
(while (re-search-forward "^\\(;+ ?\\)" nil t)
(replace-match ""))))
(insert (or (lm-commentary (locate-file (format "%s.el" name)
(if (package-installed-p desc)
;; For installed packages, get the description from the
......@@ -394,13 +394,6 @@ FILE should be in a form suitable for passing to `locate-library'."
(insert str)
(goto-char (point-min))
(goto-char (point-max))
(goto-char (point-min))
(while (re-search-forward "^;+ ?" nil t)
(replace-match "" nil nil))
(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)
......@@ -3780,20 +3780,8 @@ Build a menu of the possible matches."
;; there is no "nxml.el" (it's nxml-mode.el).
;; But package.el makes the same assumption.
;; I think nxml is the only exception - maybe it should be just be renamed.
(let ((str (ignore-errors (lm-commentary (find-library-name nodename)))))
(if (null str)
(insert "Can’t find package description.\n\n")
(insert str)
(goto-char (point-min))
(goto-char (point-max))
(goto-char (point-min))
(while (re-search-forward "^;+ ?" nil t)
(replace-match "" nil nil))
(insert (or (ignore-errors (lm-commentary (find-library-name nodename)))
(insert "Can’t find package description.\n\n"))))))
(defun info-finder (&optional keywords)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment