unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Bruno Félix Rezende Ribeiro" <oitofelix@gnu.org>
To: 37548@debbugs.gnu.org
Subject: bug#37548: Implement sanitation of single-file package long description
Date: Sun, 29 Sep 2019 02:42:54 -0300	[thread overview]
Message-ID: <87eezzwtcx.fsf@oitofelix.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 909 bytes --]

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.



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: package-x-single-file-package-long-description-sanitization.patch --]
[-- Type: text/x-diff, Size: 1609 bytes --]

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))

[-- Attachment #3: Type: text/plain, Size: 318 bytes --]



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@gnu.org
 8   8  F     irc://chat.freenode.org/oitofelix
 88888  F     xmpp://oitofelix@riseup.net


             reply	other threads:[~2019-09-29  5:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-29  5:42 Bruno Félix Rezende Ribeiro [this message]
2019-09-30 17:27 ` bug#37548: Implement sanitation of single-file package long description Stefan Kangas
2019-09-30 17:39   ` Stefan Kangas
2019-10-08  8:36     ` Bruno Félix Rezende Ribeiro
2019-10-08  8:40       ` Eli Zaretskii
2019-11-11 19:02       ` Stefan Kangas
2019-11-14 11:28         ` Eli Zaretskii
2020-01-23 20:56         ` Stefan Kangas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eezzwtcx.fsf@oitofelix.com \
    --to=oitofelix@gnu.org \
    --cc=37548@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).