From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 28 03:19:35 2022 Received: (at submit) by debbugs.gnu.org; 28 Jan 2022 08:19:35 +0000 Received: from localhost ([127.0.0.1]:57247 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nDMTY-0003fm-Q5 for submit@debbugs.gnu.org; Fri, 28 Jan 2022 03:19:35 -0500 Received: from lists.gnu.org ([209.51.188.17]:46982) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nDMTW-0003fe-KJ for submit@debbugs.gnu.org; Fri, 28 Jan 2022 03:19:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDMTH-0004Tw-I3 for bug-gnu-emacs@gnu.org; Fri, 28 Jan 2022 03:19:04 -0500 Received: from orphu.arstecnica.it ([178.63.97.204]:33940) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDMTF-00054y-13 for bug-gnu-emacs@gnu.org; Fri, 28 Jan 2022 03:19:02 -0500 From: Lele Gaifax DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=metapensiero.it; s=mail; t=1643357928; bh=UrJXBP76uKu6UKl9svSx7Ud4NxpqAsZhkKLRryLPaK0=; h=From:To:Subject:Date; b=CEaGS1BFU8SLiLVfN7bjfUOtQ5ZbnQVjTP/ubAex1GtQaRSrhryVhlz3CygDaVTuH T5Tefhv8/Z2RHda2o0EmaCxgkG2rnerzHLniJ3RpbgIZ3aoZjiQDaxXVBlA2HRWTuR GWpSQUCXtZwkk+xbRbS5SQevONixyWdV04A9jKM8= To: bug-gnu-emacs@gnu.org Subject: copyright-fix-years generates incorrect years ranges Date: Fri, 28 Jan 2022 09:18:47 +0100 Message-ID: <871r0s8e8o.fsf@metapensiero.it> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=178.63.97.204; envelope-from=lele@metapensiero.it; helo=orphu.arstecnica.it X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 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: -0.1 (/) --=-=-= Content-Type: text/plain Hi, I'm attaching a patch that describes and hopefully cures the problem I found in copyright-fix-years. All the best, ciao, lele. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Fix-copyright-fix-years-use-a-dash-to-separate-years.patch >From 6b924868878d17974f0d289c6f9b6318bfc455ec Mon Sep 17 00:00:00 2001 From: Lele Gaifax Date: Fri, 28 Jan 2022 08:41:51 +0100 Subject: [PATCH] Fix copyright-fix-years, use a dash to separate years in a range Commit 7a46fa9c751f7c3147cd9b27fe84c1ce25419d3b, allowing en-dash as years separator, changed the way the years range is composed taking the separator from the `sep' variable instead of always using an hardwired hyphen. Since the code explicitly avoid to touch (that is, extend) existing ranges, that `sep' variable is almost always a space, or whatever character precedes the last parsed year, thus generating a range like "2020 2022" instead of "2020-2022". * lisp/emacs-lisp/copyright.el (copyright-fix-years): Always use an dash to separate years in a range. * test/lisp/emacs-lisp/copyright-tests.el (with-copyright-fix-years-test): (copyright-fix-years-tests--data): (text-copyright-fix-years): New test cases. --- lisp/emacs-lisp/copyright.el | 2 +- test/lisp/emacs-lisp/copyright-tests.el | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lisp/emacs-lisp/copyright.el b/lisp/emacs-lisp/copyright.el index 6b60097782..e5087672ae 100644 --- a/lisp/emacs-lisp/copyright.el +++ b/lisp/emacs-lisp/copyright.el @@ -313,7 +313,7 @@ copyright-fix-years (> prev-year first-year)) (goto-char range-end) (delete-region range-start range-end) - (insert (format "%c%d" sep prev-year)) + (insert (format "-%d" prev-year)) (goto-char p)) (setq first-year year range-start (point))))) diff --git a/test/lisp/emacs-lisp/copyright-tests.el b/test/lisp/emacs-lisp/copyright-tests.el index abb0913a0d..b00d697aa6 100644 --- a/test/lisp/emacs-lisp/copyright-tests.el +++ b/test/lisp/emacs-lisp/copyright-tests.el @@ -72,5 +72,25 @@ copyright-tests--data (buffer-string)) "Copyright 2021 FSF\nCopyright 2021, 2022 FSF\n"))) +(defmacro with-copyright-fix-years-test (orig result) + `(let ((copyright-year-ranges t)) + (with-temp-buffer + (insert ,orig) + (copyright-fix-years) + (should (equal (buffer-string) ,result))))) + +(defvar copyright-fix-years-tests--data + '((";; Copyright (C) 2008, 2010, 2012" + . ";; Copyright (C) 2008, 2010, 2012") + (";; Copyright (C) 2008, 2009, 2010, 2013, 2014, 2015, 2016, 2018" + . ";; Copyright (C) 2008-2010, 2013-2016, 2018") + (";; Copyright (C) 2008-2010, 2011, 2015, 2016, 2017" + . ";; Copyright (C) 2008-2010, 2011, 2015-2017"))) + +(ert-deftest text-copyright-fix-years () + "Test basics of \\[copyright-fix-years]." + (dolist (test copyright-fix-years-tests--data) + (with-copyright-fix-years-test (car test) (cdr test)))) + (provide 'copyright-tests) ;;; copyright-tests.el ends here -- 2.34.1 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable --=20 nickname: Lele Gaifax | Quando vivr=C3=B2 di quello che ho pensato ieri real: Emanuele Gaifas | comincer=C3=B2 ad aver paura di chi mi copia. lele@metapensiero.it | -- Fortunato Depero, 1929. --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 28 09:24:03 2022 Received: (at 53597) by debbugs.gnu.org; 28 Jan 2022 14:24:03 +0000 Received: from localhost ([127.0.0.1]:57918 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nDSAV-0004NN-5Z for submit@debbugs.gnu.org; Fri, 28 Jan 2022 09:24:03 -0500 Received: from quimby.gnus.org ([95.216.78.240]:42356) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nDSAQ-0004Mm-Iw for 53597@debbugs.gnu.org; Fri, 28 Jan 2022 09:24:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=qvmuIq9kqvMvW6+kVPNruaaJVibZXm3lk6xqC0AlBqM=; b=KzYZg8etnm7FF8GYJnzWzmTvJB 0u1cuBIQV1PtSqPuhN5mSPCdkiEfJmu3IbEi1OaIKVbm4HoirH9JYmCPKARYCFX5Wo/UkphGNsAIH T1NtLl6Tqx3xh2HzTzR8IkDoOYQGmQ89ANBKsps1Sg2NClg9+ctkR2GGE9htdZUJN47c=; Received: from [84.212.220.105] (helo=giant) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nDSAH-0003ET-Fn; Fri, 28 Jan 2022 15:23:52 +0100 From: Lars Ingebrigtsen To: Lele Gaifax Subject: Re: bug#53597: copyright-fix-years generates incorrect years ranges References: <871r0s8e8o.fsf@metapensiero.it> X-Now-Playing: It's Immaterial's _Life's Hard And Then You Die_: "Driving Away From Home (Jim's Tune)" Date: Fri, 28 Jan 2022 15:23:48 +0100 In-Reply-To: <871r0s8e8o.fsf@metapensiero.it> (Lele Gaifax's message of "Fri, 28 Jan 2022 09:18:47 +0100") Message-ID: <87h79ogcqz.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Lele Gaifax writes: > I'm attaching a patch that describes and hopefully cures the problem I found > in copyright-fix-years. Thanks; pushed to Emacs 29. Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 53597 Cc: 53597@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 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: -3.3 (---) Lele Gaifax writes: > I'm attaching a patch that describes and hopefully cures the problem I found > in copyright-fix-years. Thanks; pushed to Emacs 29. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 28 09:24:06 2022 Received: (at control) by debbugs.gnu.org; 28 Jan 2022 14:24:06 +0000 Received: from localhost ([127.0.0.1]:57921 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nDSAY-0004Nc-BX for submit@debbugs.gnu.org; Fri, 28 Jan 2022 09:24:06 -0500 Received: from quimby.gnus.org ([95.216.78.240]:42370) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nDSAX-0004Mx-0Q for control@debbugs.gnu.org; Fri, 28 Jan 2022 09:24:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=cl3T9bqCkMgVshuqwC7kv2b/qWIihZaAK7rlGoIU474=; b=bTgqExe6p5DJ97ZEdIuuMW1vd+ WpFJGE5RSNN4YTzrkYsEJASPg37l0dpjyFVaCIU3NOhfwdPaXzFBNPgXdR6XA8Wyliye+v8f0wFZZ KhMvCFKlXvKkEoDqAgjG8EkRG95sdTTvj+uYuecDoJ1CnbcXGS2NmpFkxDztUQtnRn90=; Received: from [84.212.220.105] (helo=giant) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nDSAO-0003Eb-UF for control@debbugs.gnu.org; Fri, 28 Jan 2022 15:23:59 +0100 Date: Fri, 28 Jan 2022 15:23:54 +0100 Message-Id: <87fsp8gcqt.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #53597 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: close 53597 29.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 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: -3.3 (---) close 53597 29.1 quit From unknown Fri Aug 15 03:56:45 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 26 Feb 2022 12:24:08 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator