GNU bug report logs - #37548
Implement sanitation of single-file package long description

Previous Next

Package: emacs;

Reported by: Bruno Félix Rezende Ribeiro <oitofelix <at> gnu.org>

Date: Sun, 29 Sep 2019 05:43:02 UTC

Severity: normal

Tags: patch

Fixed in version 28.1

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Bruno Félix Rezende Ribeiro <oitofelix <at> gnu.org>
To: 37548 <at> debbugs.gnu.org
Subject: bug#37548: Implement sanitation of single-file package long description
Date: Sun, 29 Sep 2019 02:42:54 -0300
[Message part 1 (text/plain, inline)]
Hello Emacs developers,

The inlined patch implements sanitation of single-file package’s long
description which is derived from the package’s commentary header
section.  It removes the commentary header, the double semicolon prefix
of each line, trailing new-lines and trailing white-space.  I think this
is the usual practice for packages in GNU ELPA and MELPA repositories.
Furthermore it’s aligned with the intended behavior for multi-file
packages which is to read the long description from a README file[1] ---
which presumably does not have commentary sections nor double semicolon
prefixes.


Please, let me know of any changes required.
Thanks!


PS: For some reason I was not able to use a single regexp within a
single invocation of ‘replace-regexp-in-string’, as would be natural.
It simply didn’t work as expected.  It’s working fine now with nested
calls.


[package-x-single-file-package-long-description-sanitization.patch (text/x-diff, inline)]
diff --git a/lisp/emacs-lisp/package-x.el b/lisp/emacs-lisp/package-x.el
index 2815be3..7fe6f6d 100644
--- a/lisp/emacs-lisp/package-x.el
+++ b/lisp/emacs-lisp/package-x.el
@@ -159,6 +159,7 @@ DESCRIPTION is the text of the news item."
 
 (declare-function lm-commentary "lisp-mnt" (&optional file))
 (defvar tar-data-buffer)
+(defvar lm-commentary-header)
 
 (defun package-upload-buffer-internal (pkg-desc extension &optional archive-url)
   "Upload a package whose contents are in the current buffer.
@@ -204,7 +205,17 @@ if it exists."
 	       (split-version (package-desc-version pkg-desc))
 	       (commentary
                 (pcase file-type
-                  ('single (lm-commentary))
+                  ('single (replace-regexp-in-string ; Get rid of...
+                            "[[:blank:]]*$" "" ; trailing white-space
+                            (replace-regexp-in-string
+                             (format "%s\\|%s\\|%s"
+                                     ;; commentary header
+                                     (concat "^;;;[[:blank:]]*\\("
+                                             lm-commentary-header
+                                             "\\):[[:blank:]\n]*")
+                                     "^;;[[:blank:]]*" ; double semicolon prefix
+                                     "[[:blank:]\n]*\\'") ; trailing new-lines
+                             "" (lm-commentary))))
                   ('tar nil))) ;; FIXME: Get it from the README file.
                (extras (package-desc-extras pkg-desc))
 	       (pkg-version (package-version-join split-version))
[Message part 3 (text/plain, inline)]

Footnotes: 
[1]  I’ve implemented that in bug#37546.

-- 
 88888  FFFFF Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF]
 8   8  F     http://oitofelix.freeshell.org/
 88888  FFFF  mailto:oitofelix <at> gnu.org
 8   8  F     irc://chat.freenode.org/oitofelix
 88888  F     xmpp://oitofelix <at> riseup.net


This bug report was last modified 5 years and 114 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.