From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Bruno =?UTF-8?Q?F=C3=A9lix?= Rezende Ribeiro Newsgroups: gmane.emacs.bugs Subject: bug#37548: Implement sanitation of single-file package long description Date: Tue, 08 Oct 2019 05:36:40 -0300 Message-ID: <87d0f7tyzr.fsf@oitofelix.com> References: <87eezzwtcx.fsf@oitofelix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="77812"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cc: Bruno =?UTF-8?Q?F=C3=A9lix?= Rezende Ribeiro , 37548@debbugs.gnu.org To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Oct 08 10:37:15 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iHkzb-000K7F-HI for geb-bug-gnu-emacs@m.gmane.org; Tue, 08 Oct 2019 10:37:15 +0200 Original-Received: from localhost ([::1]:52104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHkzZ-0000R5-PX for geb-bug-gnu-emacs@m.gmane.org; Tue, 08 Oct 2019 04:37:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56442) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHkzS-0000Qw-4h for bug-gnu-emacs@gnu.org; Tue, 08 Oct 2019 04:37:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iHkzQ-0000tU-7c for bug-gnu-emacs@gnu.org; Tue, 08 Oct 2019 04:37:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40623) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iHkzQ-0000t6-3n for bug-gnu-emacs@gnu.org; Tue, 08 Oct 2019 04:37:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iHkzN-0001Ph-Rs for bug-gnu-emacs@gnu.org; Tue, 08 Oct 2019 04:37:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Bruno =?UTF-8?Q?F=C3=A9lix?= Rezende Ribeiro Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 08 Oct 2019 08:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37548 X-GNU-PR-Package: emacs Original-Received: via spool by 37548-submit@debbugs.gnu.org id=B37548.15705238205426 (code B ref 37548); Tue, 08 Oct 2019 08:37:01 +0000 Original-Received: (at 37548) by debbugs.gnu.org; 8 Oct 2019 08:37:00 +0000 Original-Received: from localhost ([127.0.0.1]:49444 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iHkzG-0001PM-CQ for submit@debbugs.gnu.org; Tue, 08 Oct 2019 04:37:00 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:47356) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iHkzD-0001P8-8d for 37548@debbugs.gnu.org; Tue, 08 Oct 2019 04:36:53 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:37892) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iHkz7-0000Tj-T5; Tue, 08 Oct 2019 04:36:46 -0400 Original-Received: from [189.15.97.184] (port=49772 helo=felix-laptop) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_S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aBhTfiz1QDL9tAMaN70C8L8ei/Q32rYlN6hgdj0DS+u5+J4AqFYAAAAAElFTkSuQmCC In-Reply-To: (Stefan Kangas's message of "Mon, 30 Sep 2019 19:39:26 +0200") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:168607 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > Stefan Kangas writes: > > I noticed something else: There is actually already code duplication > in package.el -- there is code to strip the commentary section in both > package--get-description and describe-package-1. > > Perhaps it would make sense to look this all over and see how we can do b= etter? I decided to tackle the problem=E2=80=99s root. After figuring out that ev= ery function depending on =E2=80=98lm-commentary=E2=80=99 implemented their own= ad-hoc sanitation for the same effect, I changed =E2=80=98lm-commentary=E2=80=99 t= o return a sanitized string and removed the code/functionality duplication from all callers. > I also have two general questions, which are applicable to both your > recent patches: > > 1. It looks likely that this together with your other patch and your > previous contributions will together amount to more than 15 lines of > code. That means that you would have to sign Copyright Assignment > papers for GNU Emacs. I see you're emailing from gnu.org, so I assume > there are no surprises for you here; I guess Eli can help you sort > that out if it's not already. I=E2=80=99ve assigned my copyright for work on Emacs to the FSF already. > 2. Could you please provide a commit message formatted as a changelog > entry? Details on this are in the CONTRIBUTE file in the repository. Please, find it in the patch attached. --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-Globally-sanitize-single-file-package-long-descripti.patch Content-Transfer-Encoding: quoted-printable >From d3e3983fc6cb74900bfa99f0bfcf2497ab396d67 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Bruno=3D20F=3DC3=3DA9lix=3D20Rezende=3D20Ribeiro?=3D Date: Tue, 8 Oct 2019 04:32:18 -0300 Subject: [PATCH] Globally sanitize single-file package long descriptions (Bug#37548) MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit Consistent with multi-file package descriptions which don=E2=80=99t 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) (describe-package-1): * lisp/finder.el (finder-commentary): * lisp/info.el (Info-finder-find-node): remove ad-hoc sanitation. --- lisp/emacs-lisp/lisp-mnt.el | 14 +++++++++++++- lisp/emacs-lisp/package.el | 30 ++++++++---------------------- lisp/finder.el | 8 +------- lisp/info.el | 16 ++-------------- 4 files changed, 24 insertions(+), 44 deletions(-) diff --git a/lisp/emacs-lisp/lisp-mnt.el b/lisp/emacs-lisp/lisp-mnt.el index 91c7615..dda7895 100644 --- a/lisp/emacs-lisp/lisp-mnt.el +++ b/lisp/emacs-lisp/lisp-mnt.el @@ -4,6 +4,7 @@ ;; Inc. =20 ;; Author: Eric S. Raymond +;; Bruno F=C3=A9lix Rezende Ribeiro ;; Maintainer: emacs-devel@gnu.org ;; Created: 14 Jul 1992 ;; Keywords: docs @@ -485,7 +486,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 + (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 + "" (buffer-substring-no-properties + start (lm-commentary-end)))))))) =20 (defun lm-homepage (&optional file) "Return the homepage in file FILE, or current buffer if FILE is nil." diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index ab1fb8b..f65559d 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -4,6 +4,7 @@ =20 ;; Author: Tom Tromey ;; Daniel Hackney +;; Bruno F=C3=A9lix Rezende Ribeiro ;; Created: 10 Mar 2007 ;; Version: 1.1.0 ;; Keywords: tools @@ -2349,18 +2350,9 @@ The description is read from the installed package f= iles." result =20 ;; Look for Commentary header. - (let ((mainsrcfile (expand-file-name (format "%s.el" (package-desc-na= me desc)) - srcdir))) - (when (file-readable-p mainsrcfile) - (with-temp-buffer - (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 "")) - (buffer-string)))) - ))) + (or (lm-commentary (expand-file-name + (format "%s.el" (package-desc-name desc)) srcdir)) + "")))) =20 (defun describe-package-1 (pkg) "Insert the package description for PKG. @@ -2555,16 +2547,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 - load-file-rep-suffixes)) - (opoint (point))) - (insert (or (lm-commentary fn) "")) - (save-excursion - (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) + load-path + load-file-rep-suffixes)) + "")) =20 (if (package-installed-p desc) ;; For installed packages, get the description from the diff --git a/lisp/finder.el b/lisp/finder.el index 89706cf..02d25ec 100644 --- a/lisp/finder.el +++ b/lisp/finder.el @@ -4,6 +4,7 @@ ;; Inc. =20 ;; Author: Eric S. Raymond +;; Bruno F=C3=A9lix Rezende Ribeiro ;; Created: 16 Jun 1992 ;; Version: 1.0 ;; Keywords: help @@ -394,13 +395,6 @@ FILE should be in a form suitable for passing to `loca= te-library'." (erase-buffer) (insert str) (goto-char (point-min)) - (delete-blank-lines) - (goto-char (point-max)) - (delete-blank-lines) - (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) diff --git a/lisp/info.el b/lisp/info.el index 02f3ea5..4262219 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -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 ren= amed. - (let ((str (ignore-errors (lm-commentary (find-library-name nodename))= ))) - (if (null str) - (insert "Can=E2=80=99t find package description.\n\n") - (insert - (with-temp-buffer - (insert str) - (goto-char (point-min)) - (delete-blank-lines) - (goto-char (point-max)) - (delete-blank-lines) - (goto-char (point-min)) - (while (re-search-forward "^;+ ?" nil t) - (replace-match "" nil nil)) - (buffer-string)))))))) + (insert (or (ignore-errors (lm-commentary (find-library-name nodename)= )) + (insert "Can=E2=80=99t find package description.\n\n")))))) =20 ;;;###autoload (defun info-finder (&optional keywords) --=20 2.7.4 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable --=20 Bruno F=C3=A9lix Rezende Ribeiro (oitofelix) [0x28D618AF] --=-=-=--