From unknown Sun Jun 22 11:43:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#13207: lisp-mnt.el improvements Resent-From: Jonas Bernoulli Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 17 Dec 2012 16:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 13207 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 13207@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.135576169314169 (code B ref -1); Mon, 17 Dec 2012 16:29:02 +0000 Received: (at submit) by debbugs.gnu.org; 17 Dec 2012 16:28:13 +0000 Received: from localhost ([127.0.0.1]:47334 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TkdY4-0003gT-3y for submit@debbugs.gnu.org; Mon, 17 Dec 2012 11:28:13 -0500 Received: from eggs.gnu.org ([208.118.235.92]:41686) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TkdXx-0003gI-La for submit@debbugs.gnu.org; Mon, 17 Dec 2012 11:28:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TkdWf-0000IA-UD for submit@debbugs.gnu.org; Mon, 17 Dec 2012 11:26:49 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-102.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, USER_IN_WHITELIST autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:58280) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkdWf-0000I5-Qc for submit@debbugs.gnu.org; Mon, 17 Dec 2012 11:26:45 -0500 Received: from eggs.gnu.org ([208.118.235.92]:53040) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkdWb-00028R-Uh for bug-gnu-emacs@gnu.org; Mon, 17 Dec 2012 11:26:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TkdWX-0000Fa-V4 for bug-gnu-emacs@gnu.org; Mon, 17 Dec 2012 11:26:41 -0500 Received: from mail-wi0-f179.google.com ([209.85.212.179]:43863) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkdWX-0000FS-Fc for bug-gnu-emacs@gnu.org; Mon, 17 Dec 2012 11:26:37 -0500 Received: by mail-wi0-f179.google.com with SMTP id o1so2043982wic.12 for ; Mon, 17 Dec 2012 08:26:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:user-agent:date:message-id:mime-version :content-type; bh=MDYyqpNxZPHNglj0ViDEIT5YFSXg3UCCARuA/GhgCac=; b=YiFKTQs2fiAy/vCdALiIjMPZVytGb6UgpTgJfcPJzdAzmwWO+m6/ovu8oSDx4gTSqo IE6xbqIafqNJGbvn+OVJJ8F3MGY8JMzvCrBg1HJpOvpI5FKU52XZUpfHBR9aoqSogdlm F3dSRcfEelsxVf8Srw6GfOOnnEQwH/Si99eQC8YbbemVQSGpaYCqy4vRARxV/94QB3TJ jM/DRI/MAYFyseug5vzO5MUaL4sW1vmjQl7VxjL18IV7jEu+SqksrgG/cRSwpv0sYsmt 8pbS9APBfip4bXgpVpkJMCCVDV9h0jE/lg1++vVBKTuM2b7QxMT6jUbKpdOKhS7lGhVU T1sA== Received: by 10.180.107.197 with SMTP id he5mr16833532wib.1.1355761596046; Mon, 17 Dec 2012 08:26:36 -0800 (PST) Received: from lem (178-83-148-79.dynamic.hispeed.ch. [178.83.148.79]) by mx.google.com with ESMTPS id i2sm11797204wiw.3.2012.12.17.08.26.34 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Dec 2012 08:26:34 -0800 (PST) From: Jonas Bernoulli User-agent: mu4e 0.9.9.5-dev4; emacs 24.3.50.1 Date: Mon, 17 Dec 2012 17:26:33 +0100 Message-ID: <878v8wve4m.fsf@bernoul.li> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -3.4 (---) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) --=-=-= Content-Type: text/plain Hello I extract information from the library headers of all packages mirrored on the Emacsmirror. Since many packages don't follow the header conventions lisp-mnt.el in it's current form isn't always suitable. So I have written elx.el which can handle some departure from the standard; it also includes some additions. Now I would like to merge some of the changes back into lisp-mnt.el: 1. Add function lm-homepage (lm-header "\\(?:x-\\)?\\(?:homepage\\|url\\)") These keywords are used quite often, most often without the X- prefix. 2. lm-section-end: the end is now always before the following non-comment text Many people don't add ;;; Code: after the header. As a result lm-commentary was often way of (like eof!) and lm-commentary returned text that isn't part of the commentary but code. 3. lm-header, lm-header-multiline: wrap with save-match-data 4. lm-header-multiline: continuation lines now need to be intended more than the first line. E.g: ;; Keyword: value ;; more value This is necessary because some built-in libraries contain things like: ;; Author: Kenichi HANDA ;; (according to ack.texi) And some third-party libraries contain things like: ;; Keywords: key words ;; This file is not part of Emacs Among the 3500 packages mirrored on the Emacsmirror there are only three where this change results in lines intended as continuation lines not to be recognised anymore. At the same time this change fixes ~50 errors. There now have to be at least two spaces or one tab after the initial semicolons for a line to be considered a continuation line. (1) and (4) should be documented in the info page. Let me know if you want to do that. elx.el contains some more things that could be merged into lisp-mnt.el, but I would first like to know how these changes are received. Jonas --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=lisp-mnt.patch >From c9a79155d00e48a282d7fce1b6d21838c9fa5a90 Mon Sep 17 00:00:00 2001 From: Jonas Bernoulli Date: Mon, 17 Dec 2012 17:03:41 +0100 Subject: [PATCH] lisp/emacs-lisp/lisp-mnt.el: new function lm-homepage (lm-section-end): the end is now always before the following non-comment text (lm-header): save-match-data (lm-header-multiline): save-match-data, continuation lines now need to be intended more than the first line (lm-with-file): widen and goto beginning of buffer before reusing current buffer --- lisp-mnt.el | 75 ++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 31 deletions(-) diff --git a/lisp-mnt.el b/lisp-mnt.el index f9a1c5d..7bbc033 100644 --- a/lisp-mnt.el +++ b/lisp-mnt.el @@ -208,10 +208,10 @@ If the given section does not exist, return nil." The HEADER is the section string marking the beginning of the section. If the given section does not exist, return nil. -The end of the section is defined as the beginning of the next -section of the same level or lower. The function -`lisp-outline-level' is used to compute the level of a section. -If no such section exists, return the end of the buffer." +The section ends before the first non-comment text or the next +section of the same level or lower; whatever comes first. The +function `lisp-outline-level' is used to compute the level of +a section." (require 'outline) ;; for outline-regexp. (let ((start (lm-section-start header))) (when start @@ -229,9 +229,15 @@ If no such section exists, return the end of the buffer." (beginning-of-line) (lisp-outline-level)) level))) - (if next-section-found - (line-beginning-position) - (point-max))))))) + (min (if next-section-found + (progn (beginning-of-line 0) + (unless (looking-at " ") + (beginning-of-line 2)) + (point)) + (point-max)) + (progn (goto-char start) + (while (forward-comment 1)) + (point)))))))) (defsubst lm-code-start () "Return the buffer location of the `Code' start marker." @@ -262,35 +268,32 @@ If no such section exists, return the end of the buffer." (defun lm-header (header) "Return the contents of the header named HEADER." - (goto-char (point-min)) - (let ((case-fold-search t)) - (when (and (re-search-forward (lm-get-header-re header) (lm-code-mark) t) - ;; RCS ident likes format "$identifier: data$" - (looking-at - (if (save-excursion - (skip-chars-backward "^$" (match-beginning 0)) - (= (point) (match-beginning 0))) - "[^\n]+" "[^$\n]+"))) - (match-string-no-properties 0)))) + (save-match-data + (goto-char (point-min)) + (let ((case-fold-search t)) + (when (and (re-search-forward (lm-get-header-re header) (lm-code-mark) t) + ;; RCS ident likes format "$identifier: data$" + (looking-at + (if (save-excursion + (skip-chars-backward "^$" (match-beginning 0)) + (= (point) (match-beginning 0))) + "[^\n]+" "[^$\n]+"))) + (match-string-no-properties 0))))) (defun lm-header-multiline (header) "Return the contents of the header named HEADER, with continuation lines. The returned value is a list of strings, one per line." (save-excursion - (goto-char (point-min)) - (let ((res (lm-header header))) - (when res - (setq res (list res)) - (forward-line 1) - (while (and (or (looking-at (concat lm-header-prefix "[\t ]+")) - (and (not (looking-at - (lm-get-header-re "\\sw\\(\\sw\\|\\s_\\)*"))) - (looking-at lm-header-prefix))) - (goto-char (match-end 0)) - (looking-at ".+")) - (setq res (cons (match-string-no-properties 0) res)) - (forward-line 1))) - (nreverse res)))) + (save-match-data + (goto-char (point-min)) + (let ((res (lm-header header))) + (when res + (setq res (list res)) + (forward-line 1) + (while (looking-at "^;+\\(\t\\|[\t\s]\\{2,\\}\\)\\(.+\\)") + (push (match-string-no-properties 2) res) + (forward-line 1))) + (nreverse res))))) ;; These give us smart access to the header fields and commentary @@ -306,6 +309,8 @@ If FILE is nil, execute BODY in the current buffer." (emacs-lisp-mode) ,@body) (save-excursion + (widen) + (goto-char (point-min)) ;; Switching major modes is too drastic, so just switch ;; temporarily to the Emacs Lisp mode syntax table. (with-syntax-table emacs-lisp-mode-syntax-table @@ -489,6 +494,14 @@ absent, return nil." (when start (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." + (let ((page (lm-with-file file + (lm-header "\\(?:x-\\)?\\(?:homepage\\|url\\)")))) + (if (and page (string-match "^<.+>$" page)) + (substring page 1 -1) + page))) + ;;; Verification and synopses (defun lm-insert-at-column (col &rest strings) -- 1.8.0.1 --=-=-=-- From unknown Sun Jun 22 11:43:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#13207: lisp-mnt.el improvements Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 17 Dec 2012 18:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13207 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Jonas Bernoulli Cc: 13207@debbugs.gnu.org Received: via spool by 13207-submit@debbugs.gnu.org id=B13207.135576721526032 (code B ref 13207); Mon, 17 Dec 2012 18:01:02 +0000 Received: (at 13207) by debbugs.gnu.org; 17 Dec 2012 18:00:15 +0000 Received: from localhost ([127.0.0.1]:47477 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tkez5-0006ll-2x for submit@debbugs.gnu.org; Mon, 17 Dec 2012 13:00:15 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:46881) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tkeyz-0006lD-Dr for 13207@debbugs.gnu.org; Mon, 17 Dec 2012 13:00:10 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAG6Zu09FxLDj/2dsb2JhbABEtBGBCIIVAQEEAVYjBQsLNBIUGA0kE4gJBboJkEQDiEKacYFYgwc X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="210096026" Received: from 69-196-176-227.dsl.teksavvy.com (HELO pastel.home) ([69.196.176.227]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 17 Dec 2012 12:58:48 -0500 Received: by pastel.home (Postfix, from userid 20848) id 7800C5912C; Mon, 17 Dec 2012 12:58:48 -0500 (EST) From: Stefan Monnier Message-ID: References: <878v8wve4m.fsf@bernoul.li> Date: Mon, 17 Dec 2012 12:58:48 -0500 In-Reply-To: <878v8wve4m.fsf@bernoul.li> (Jonas Bernoulli's message of "Mon, 17 Dec 2012 17:26:33 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -0.0 (/) > 1. Add function lm-homepage > (lm-header "\\(?:x-\\)?\\(?:homepage\\|url\\)") > These keywords are used quite often, most often without the X- prefix. Sounds OK. > 2. lm-section-end: the end is now always before the following > non-comment text > Many people don't add ;;; Code: after the header. As a result > lm-commentary was often way of (like eof!) and lm-commentary returned > text that isn't part of the commentary but code. Good. > 3. lm-header, lm-header-multiline: wrap with save-match-data This one doesn't sound right. The callers should be fixed instead. > 4. lm-header-multiline: continuation lines now need to be intended more > than the first line. E.g: > ;; Keyword: value > ;; more value > This is necessary because some built-in libraries contain things > like: > ;; Author: Kenichi HANDA > ;; (according to ack.texi) > And some third-party libraries contain things like: > ;; Keywords: key words > ;; This file is not part of Emacs > Among the 3500 packages mirrored on the Emacsmirror there are only > three where this change results in lines intended as continuation > lines not to be recognised anymore. At the same time this change > fixes ~50 errors. An important measure is how much breakage/improvement does it introduce when applied to files that are expected to do thing right (e.g. files in emacs/lisp and in elpa/packages). I'm OK with making lisp-mnt.el more forgiving, but it should not come at the cost of those packages that do things right. Stefan From unknown Sun Jun 22 11:43:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#13207: lisp-mnt.el improvements Resent-From: Jonas Bernoulli Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 17 Dec 2012 22:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13207 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: "Stefan Monnier" Cc: 13207@debbugs.gnu.org Received: via spool by 13207-submit@debbugs.gnu.org id=B13207.135578159924988 (code B ref 13207); Mon, 17 Dec 2012 22:00:02 +0000 Received: (at 13207) by debbugs.gnu.org; 17 Dec 2012 21:59:59 +0000 Received: from localhost ([127.0.0.1]:47673 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tkij3-0006Us-PI for submit@debbugs.gnu.org; Mon, 17 Dec 2012 16:59:59 -0500 Received: from mail-wi0-f170.google.com ([209.85.212.170]:50964) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tkiiw-0006Ud-5A for 13207@debbugs.gnu.org; Mon, 17 Dec 2012 16:59:52 -0500 Received: by mail-wi0-f170.google.com with SMTP id hq7so2462375wib.3 for <13207@debbugs.gnu.org>; Mon, 17 Dec 2012 13:58:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:references:user-agent:in-reply-to:date :message-id:mime-version:content-type; bh=Sdb8tT9CVWcXVqg+OD1MgrM1rT357fgR51veC7xnwcQ=; b=GaDJgP2rw3RvLTkIXHRWNUOzTVosiWzD71cptbwJ9iEuwN6c606Wag1+YON2kjI9kl fJ/204aQVdybWKZasLQ2M+9ak6rUYuWHZP8Ij/qc7nc/KKMOnKejyHjWte72gWPqw+WQ leAm89qO6GA/t9G4qDE8SOWX5drniHS8kziDVzk0qk8yIPq7LOgHEU92tbWCcXAQVZbC S0s77BuPCI/2uGE17MBzkK+cKt2mM8l3+7cea7i5zLkI/SKY8/qT0+wh08LZmK5jo/Uz c0iotTbaITFxgkpV9c4+m3bfQj89CrQqM+IKIHmswKwONUI3oBMMb91RDbxCsk53YB+C Ahgg== Received: by 10.194.76.165 with SMTP id l5mr19945224wjw.14.1355781508479; Mon, 17 Dec 2012 13:58:28 -0800 (PST) Received: from lem (178-83-148-79.dynamic.hispeed.ch. [178.83.148.79]) by mx.google.com with ESMTPS id t17sm14603087wiv.6.2012.12.17.13.58.27 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Dec 2012 13:58:27 -0800 (PST) From: Jonas Bernoulli References: <878v8wve4m.fsf@bernoul.li>, User-agent: mu4e 0.9.9.5-dev4; emacs 24.3.50.1 In-reply-to: Date: Mon, 17 Dec 2012 22:58:26 +0100 Message-ID: <8738z42vel.fsf@bernoul.li> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.1 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -0.7 (/) >> 3. lm-header, lm-header-multiline: wrap with save-match-data > > This one doesn't sound right. The callers should be fixed instead. Okay. On second though: it wouldn't be very useful to use the match data set by these functions. Why not save the match-data here once so that no caller has to ever worry about it? Is there a general policy that this kinda thing shouldn't be done? >> 4. lm-header-multiline: continuation lines now need to be intended more >> than the first line. E.g: >> ;; Keyword: value >> ;; more value >> This is necessary because some built-in libraries contain things >> like: >> ;; Author: Kenichi HANDA >> ;; (according to ack.texi) >> And some third-party libraries contain things like: >> ;; Keywords: key words >> ;; This file is not part of Emacs >> Among the 3500 packages mirrored on the Emacsmirror there are only >> three where this change results in lines intended as continuation >> lines not to be recognised anymore. At the same time this change >> fixes ~50 errors. > > An important measure is how much breakage/improvement does it introduce > when applied to files that are expected to do thing right (e.g. files in > emacs/lisp and in elpa/packages). I'm OK with making lisp-mnt.el more > forgiving, but it should not come at the cost of those packages that do > things right. The 3500 packages from which I extracted metadata include all built-in and fsf-elpa packages (though I did not process every library, just the "main library" of each package). The three packages affected in a negative way didn't do things right, and they aren't fsf packages. This should be possible ;; Author: Kenichi HANDA ;; (according to ack.texi) and this can be sacrificed ;; Author: Kenichi HANDA ;; Jonas Bernoulli -- Jonas From unknown Sun Jun 22 11:43:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#13207: lisp-mnt.el improvements Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 18 Dec 2012 01:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13207 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Jonas Bernoulli Cc: 13207@debbugs.gnu.org Received: via spool by 13207-submit@debbugs.gnu.org id=B13207.135579424114326 (code B ref 13207); Tue, 18 Dec 2012 01:31:02 +0000 Received: (at 13207) by debbugs.gnu.org; 18 Dec 2012 01:30:41 +0000 Received: from localhost ([127.0.0.1]:47835 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tkm13-0003j1-DY for submit@debbugs.gnu.org; Mon, 17 Dec 2012 20:30:41 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:23093) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tkm11-0003iu-Mg for 13207@debbugs.gnu.org; Mon, 17 Dec 2012 20:30:40 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAG6Zu09FxLDj/2dsb2JhbABEtBGBCIIVAQEEAVYjBQsLNBIUGA0kiBwFugmQRAOIQppxgViDBw X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="210134911" Received: from 69-196-176-227.dsl.teksavvy.com (HELO pastel.home) ([69.196.176.227]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 17 Dec 2012 20:29:21 -0500 Received: by pastel.home (Postfix, from userid 20848) id 34ADA58FA3; Mon, 17 Dec 2012 20:29:22 -0500 (EST) From: Stefan Monnier Message-ID: References: <878v8wve4m.fsf@bernoul.li> <8738z42vel.fsf@bernoul.li> Date: Mon, 17 Dec 2012 20:29:22 -0500 In-Reply-To: <8738z42vel.fsf@bernoul.li> (Jonas Bernoulli's message of "Mon, 17 Dec 2012 22:58:26 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 0.8 (/) > Okay. On second though: it wouldn't be very useful to use the match > data set by these functions. Why not save the match-data here once so > that no caller has to ever worry about it? Is there a general policy > that this kinda thing shouldn't be done? Yes, the general policy is: all functions should be presumed to trash the match-data, except for a very few exceptions. > The 3500 packages from which I extracted metadata include all built-in > and fsf-elpa packages (though I did not process every library, just the > "main library" of each package). The three packages affected in a > negative way didn't do things right, and they aren't fsf packages. OK, thanks for checking. It sounds good then. Can you send a "final" patch? Stefan From unknown Sun Jun 22 11:43:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#13207: lisp-mnt.el improvements Resent-From: Jonas Bernoulli Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 19 Dec 2012 15:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13207 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: "Stefan Monnier" Cc: 13207@debbugs.gnu.org Received: via spool by 13207-submit@debbugs.gnu.org id=B13207.135593152926562 (code B ref 13207); Wed, 19 Dec 2012 15:39:02 +0000 Received: (at 13207) by debbugs.gnu.org; 19 Dec 2012 15:38:49 +0000 Received: from localhost ([127.0.0.1]:50955 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TlLjN-0006uM-0m for submit@debbugs.gnu.org; Wed, 19 Dec 2012 10:38:49 -0500 Received: from mail-ea0-f181.google.com ([209.85.215.181]:51438) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TlLjJ-0006uE-Pg for 13207@debbugs.gnu.org; Wed, 19 Dec 2012 10:38:47 -0500 Received: by mail-ea0-f181.google.com with SMTP id k14so891479eaa.40 for <13207@debbugs.gnu.org>; Wed, 19 Dec 2012 07:38:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:references:user-agent :in-reply-to:date:message-id:mime-version:content-type; bh=Z6kz5uNDSxptF231J4F6pykdDIYEsd/tS3CKBhdtnA8=; b=X2i06S39TpY69rTXqnrIcwLpCCel5ugnsCA4wwBgOJmyXQeTE6dB2HyunwGiUXYrUP nYFT8JBk1ha/5OfjNUPOkiKm+MO0Keew/DkEnzSP76r+0n/L7wldJKPqeElVjXlgpAcb D9Xb7J8RojwA5hYPoF94DPreVC0y8M5uHjfLxJwTfX6TYoOQJ7bFu/MoqY+adCv4Mb8F Z+vrWau+5cvRGhTXlyc6iGlX4968GzKJUejW6ScDZGDa3YzVHdK3QRSdZVkbOXIpJO/h D9zsFYcracM/RwFzzqPc8Yh6naQv9kQg3bmXlZc9cOrL6enn3ChUrQ2RnB1CnPA3fO3J 9q0Q== X-Received: by 10.14.205.198 with SMTP id j46mr15128307eeo.27.1355931521115; Wed, 19 Dec 2012 07:38:41 -0800 (PST) Received: from lem (178-83-148-79.dynamic.hispeed.ch. [178.83.148.79]) by mx.google.com with ESMTPS id b2sm9828175eep.9.2012.12.19.07.38.39 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 19 Dec 2012 07:38:40 -0800 (PST) From: Jonas Bernoulli References: <878v8wve4m.fsf@bernoul.li>, , <8738z42vel.fsf@bernoul.li>, User-agent: mu4e 0.9.9.5-dev4; emacs 24.3.50.1 In-reply-to: Date: Wed, 19 Dec 2012 16:38:38 +0100 Message-ID: <878v8u6oht.fsf@bernoul.li> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.6 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) --=-=-= Content-Type: text/plain >> The 3500 packages from which I extracted metadata include all built-in >> and fsf-elpa packages (though I did not process every library, just the >> "main library" of each package). The three packages affected in a >> negative way didn't do things right, and they aren't fsf packages. > > OK, thanks for checking. It sounds good then. Can you send a "final" patch? I have also updated the info page. Jonas --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=lisp-mnt.patch >From 001bdfead8d2fa19ef2b7b339ed01f8cf909257d Mon Sep 17 00:00:00 2001 From: Jonas Bernoulli Date: Wed, 19 Dec 2012 16:32:08 +0100 Subject: [PATCH] * lisp/emacs-lisp/lisp-mnt.el: new function lm-homepage (lm-section-end): the end is now always before the following non-comment text (lm-header-multiline): continuation lines now need to be intended more than the first line (lm-with-file): widen and goto beginning of buffer before reusing current buffer * doc/lispref/tips.texi: new header keyword Homepage, continuation lines can use two or more spaces instead of a tab after the semicolons --- doc/lispref/tips.texi | 7 +++++-- lisp/emacs-lisp/lisp-mnt.el | 39 +++++++++++++++++++++++++-------------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/doc/lispref/tips.texi b/doc/lispref/tips.texi index d54d91b..854ce8f 100644 --- a/doc/lispref/tips.texi +++ b/doc/lispref/tips.texi @@ -942,6 +942,7 @@ explains these conventions, starting with an example: ;; Created: 14 Jul 2010 @group ;; Keywords: languages +;; Homepage: http://example.com/foo ;; This file is not part of GNU Emacs. @@ -980,8 +981,7 @@ the conventional possibilities for @var{header-name}: @item Author This line states the name and email address of at least the principal author of the library. If there are multiple authors, list them on -continuation lines led by @code{;;} and whitespace (this is easier -for tools to parse than having more than one author on one line). +continuation lines led by @code{;;} and a tab or at least two spaces. We recommend including a contact email address, of the form @samp{<@dots{}>}. For example: @@ -1028,6 +1028,9 @@ The name of this field is unfortunate, since people often assume it is the place to write arbitrary keywords that describe their package, rather than just the relevant Finder keywords. +@item Homepage +This line states the homepage of the library. + @item Package-Version If @samp{Version} is not suitable for use by the package manager, then a package can define @samp{Package-Version}; it will be used instead. diff --git a/lisp/emacs-lisp/lisp-mnt.el b/lisp/emacs-lisp/lisp-mnt.el index f9a1c5d..4d210c2 100644 --- a/lisp/emacs-lisp/lisp-mnt.el +++ b/lisp/emacs-lisp/lisp-mnt.el @@ -208,10 +208,10 @@ If the given section does not exist, return nil." The HEADER is the section string marking the beginning of the section. If the given section does not exist, return nil. -The end of the section is defined as the beginning of the next -section of the same level or lower. The function -`lisp-outline-level' is used to compute the level of a section. -If no such section exists, return the end of the buffer." +The section ends before the first non-comment text or the next +section of the same level or lower; whatever comes first. The +function `lisp-outline-level' is used to compute the level of +a section." (require 'outline) ;; for outline-regexp. (let ((start (lm-section-start header))) (when start @@ -229,9 +229,15 @@ If no such section exists, return the end of the buffer." (beginning-of-line) (lisp-outline-level)) level))) - (if next-section-found - (line-beginning-position) - (point-max))))))) + (min (if next-section-found + (progn (beginning-of-line 0) + (unless (looking-at " ") + (beginning-of-line 2)) + (point)) + (point-max)) + (progn (goto-char start) + (while (forward-comment 1)) + (point)))))))) (defsubst lm-code-start () "Return the buffer location of the `Code' start marker." @@ -282,13 +288,8 @@ The returned value is a list of strings, one per line." (when res (setq res (list res)) (forward-line 1) - (while (and (or (looking-at (concat lm-header-prefix "[\t ]+")) - (and (not (looking-at - (lm-get-header-re "\\sw\\(\\sw\\|\\s_\\)*"))) - (looking-at lm-header-prefix))) - (goto-char (match-end 0)) - (looking-at ".+")) - (setq res (cons (match-string-no-properties 0) res)) + (while (looking-at "^;+\\(\t\\|[\t\s]\\{2,\\}\\)\\(.+\\)") + (push (match-string-no-properties 2) res) (forward-line 1))) (nreverse res)))) @@ -306,6 +307,8 @@ If FILE is nil, execute BODY in the current buffer." (emacs-lisp-mode) ,@body) (save-excursion + (widen) + (goto-char (point-min)) ;; Switching major modes is too drastic, so just switch ;; temporarily to the Emacs Lisp mode syntax table. (with-syntax-table emacs-lisp-mode-syntax-table @@ -489,6 +492,14 @@ absent, return nil." (when start (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." + (let ((page (lm-with-file file + (lm-header "\\(?:x-\\)?\\(?:homepage\\|url\\)")))) + (if (and page (string-match "^<.+>$" page)) + (substring page 1 -1) + page))) + ;;; Verification and synopses (defun lm-insert-at-column (col &rest strings) -- 1.8.0.1 --=-=-=-- From unknown Sun Jun 22 11:43:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#13207: lisp-mnt.el improvements Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 19 Dec 2012 19:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13207 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Jonas Bernoulli Cc: 13207@debbugs.gnu.org Received: via spool by 13207-submit@debbugs.gnu.org id=B13207.135594673020623 (code B ref 13207); Wed, 19 Dec 2012 19:53:01 +0000 Received: (at 13207) by debbugs.gnu.org; 19 Dec 2012 19:52:10 +0000 Received: from localhost ([127.0.0.1]:51223 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TlPgY-0005MZ-Jl for submit@debbugs.gnu.org; Wed, 19 Dec 2012 14:52:10 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:40548) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TlPgV-0005MR-K7 for 13207@debbugs.gnu.org; Wed, 19 Dec 2012 14:52:07 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAG6Zu09FxLDj/2dsb2JhbABEtBGBCIIVAQEEAVYjBQsLNBIUGA0kiBwFugmQRAOIQppxgViDBw X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="210372107" Received: from 69-196-176-227.dsl.teksavvy.com (HELO pastel.home) ([69.196.176.227]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 19 Dec 2012 14:52:03 -0500 Received: by pastel.home (Postfix, from userid 20848) id B4E8C4E0D7; Wed, 19 Dec 2012 14:52:02 -0500 (EST) From: Stefan Monnier Message-ID: References: <878v8wve4m.fsf@bernoul.li> <8738z42vel.fsf@bernoul.li> <878v8u6oht.fsf@bernoul.li> Date: Wed, 19 Dec 2012 14:52:02 -0500 In-Reply-To: <878v8u6oht.fsf@bernoul.li> (Jonas Bernoulli's message of "Wed, 19 Dec 2012 16:38:38 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -0.5 (/) > I have also updated the info page. Thanks, installed, Stefan From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 22 22:48:53 2013 Received: (at control) by debbugs.gnu.org; 23 Nov 2013 03:48:53 +0000 Received: from localhost ([127.0.0.1]:39191 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vk4DE-00035W-NP for submit@debbugs.gnu.org; Fri, 22 Nov 2013 22:48:52 -0500 Received: from fencepost.gnu.org ([208.118.235.10]:40790 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vk4DB-00035N-Pa for control@debbugs.gnu.org; Fri, 22 Nov 2013 22:48:50 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1Vk4DB-0005sM-9b for control@debbugs.gnu.org; Fri, 22 Nov 2013 22:48:49 -0500 Date: Fri, 22 Nov 2013 22:48:49 -0500 Message-Id: Subject: control message for bug 13207 To: X-Mailer: mail (GNU Mailutils 2.1) From: Glenn Morris X-Spam-Score: -5.5 (-----) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.5 (-----) close 13207 24.4