From unknown Wed Jun 18 23:09:04 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#21785 <21785@debbugs.gnu.org> To: bug#21785 <21785@debbugs.gnu.org> Subject: Status: 25.0.50; sort-fields fails if region ends in a newline and sort-paragraph fails if it doesn't Reply-To: bug#21785 <21785@debbugs.gnu.org> Date: Thu, 19 Jun 2025 06:09:04 +0000 retitle 21785 25.0.50; sort-fields fails if region ends in a newline and so= rt-paragraph fails if it doesn't reassign 21785 emacs submitter 21785 bruce.connor.am@gmail.com severity 21785 minor tag 21785 fixed patch thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 29 08:38:33 2015 Received: (at submit) by debbugs.gnu.org; 29 Oct 2015 12:38:33 +0000 Received: from localhost ([127.0.0.1]:43391 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZrmTQ-00064C-V4 for submit@debbugs.gnu.org; Thu, 29 Oct 2015 08:38:33 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45531) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZrmTO-000644-JZ for submit@debbugs.gnu.org; Thu, 29 Oct 2015 08:38:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrmTN-0004KI-4M for submit@debbugs.gnu.org; Thu, 29 Oct 2015 08:38:30 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_20,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:55986) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrmTN-0004KD-1A for submit@debbugs.gnu.org; Thu, 29 Oct 2015 08:38:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55523) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrmTM-0002sf-5B for bug-gnu-emacs@gnu.org; Thu, 29 Oct 2015 08:38:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrmTL-0004Jh-CD for bug-gnu-emacs@gnu.org; Thu, 29 Oct 2015 08:38:28 -0400 Received: from mail-lf0-x231.google.com ([2a00:1450:4010:c07::231]:35489) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrmTL-0004JW-54 for bug-gnu-emacs@gnu.org; Thu, 29 Oct 2015 08:38:27 -0400 Received: by lfbn126 with SMTP id n126so17839194lfb.2 for ; Thu, 29 Oct 2015 05:38:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:sender:date:message-id:subject:from:to :content-type; bh=/CQzVL2QX6rLwGcZWbKbuoFprbxe+BCsfkeSqoYgIBE=; b=wnusk+lblW+XJ+mj+ZAC0N6fCK56//Pc4Z1IXWrsInNvRarnNB/HLHOgdYLp2Kyvs/ S1LiBevY2cvy244bIFVn9KvmcZZhQOE2keKnRL2jsQ0mOyqUAZC5iL4xX8ssVu1ryKEw jNdBvCNOKvhb94BY7ncOoVZI2Z/4vQMces2yoMp790PsPNSL+RENS2EKWL+TNX0wkQsZ vnUpV/9f9lv4FMOguhkCD1BQELDgUfW3N4TsA4AzyKZzVBVtkSAYB4lFYfFBLEyByVbx A3mOY7kYsV9jBNA9c6X0uUTCb6U/R5aXqEVIx/17QSE9vs/NqXOWu5GM5EzTf5/yt2Cg O9Mw== MIME-Version: 1.0 X-Received: by 10.25.85.193 with SMTP id j184mr552881lfb.2.1446122306317; Thu, 29 Oct 2015 05:38:26 -0700 (PDT) Received: by 10.112.91.106 with HTTP; Thu, 29 Oct 2015 05:38:26 -0700 (PDT) Date: Thu, 29 Oct 2015 12:38:26 +0000 X-Google-Sender-Auth: Chjy_yEPSzVjoXX3FAHLwkiWIUU Message-ID: Subject: 25.0.50; sort-fields fails if region ends in a newline and sort-paragraph fails if it doesn't From: Artur Malabarba To: bug-gnu-emacs@gnu.org Content-Type: text/plain; charset=UTF-8 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: bruce.connor.am@gmail.com 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: -4.0 (----) I noticed this while writing tests for sort.el With the following buffer contents (the text between the dashes, including a final newline), issue `C-x h M-x sort-numeric-fields'. You'll get the error that the last line doesn't have enough fields. I think that error should not be thrown because of a final newline. --------------------- 1 hi 2 bye ---------------------- Meanwhile take the following buffer contents, -------------------- paragraph 2 paragraph 1 -------------------- If you issue `sort-paragraphs' on the whole buffer, you'll get this: -------------------- paragraph 1 paragraph 2 ------------------- In my opinion both behavior are bugs. But surely one of them is, as the functions should be somewhat consistent on demanding final newlines. From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 01 14:38:39 2019 Received: (at 21785) by debbugs.gnu.org; 1 Aug 2019 18:38:39 +0000 Received: from localhost ([127.0.0.1]:55195 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1htFyI-0000x1-TE for submit@debbugs.gnu.org; Thu, 01 Aug 2019 14:38:39 -0400 Received: from quimby.gnus.org ([80.91.231.51]:44034) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1htFyG-0000wr-W9 for 21785@debbugs.gnu.org; Thu, 01 Aug 2019 14:38:37 -0400 Received: from 77.18.62.220.tmi.telenormobil.no ([77.18.62.220] helo=sandy) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1htFyC-0002ps-53; Thu, 01 Aug 2019 20:38:34 +0200 From: Lars Ingebrigtsen To: Artur Malabarba Subject: Re: bug#21785: 25.0.50; sort-fields fails if region ends in a newline and sort-paragraph fails if it doesn't References: Date: Thu, 01 Aug 2019 20:38:31 +0200 In-Reply-To: (Artur Malabarba's message of "Thu, 29 Oct 2015 12:38:26 +0000") Message-ID: <87zhkshgt4.fsf@mouse.gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.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: (I'm going through old bug reports that have unfortunately not gotten any responses.) Artur Malabarba writes: > I noticed this while writing tests for sort.el > > With the following buffer contents (the text between the dashes, > including a final newline), issue `C-x h M-x sort-numeric-fields'. > You'll get [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP 0.0 TVD_RCVD_IP Message was received from an IP address -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 21785 Cc: 21785@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: -1.0 (-) (I'm going through old bug reports that have unfortunately not gotten any responses.) Artur Malabarba writes: > I noticed this while writing tests for sort.el > > With the following buffer contents (the text between the dashes, > including a final newline), issue `C-x h M-x sort-numeric-fields'. > You'll get the error that the last line doesn't have enough fields. I > think that error should not be thrown because of a final newline. > > --------------------- > 1 hi > 2 bye > > ---------------------- > > Meanwhile take the following buffer contents, > -------------------- > paragraph 2 > > paragraph 1 > -------------------- > > If you issue `sort-paragraphs' on the whole buffer, you'll get this: > -------------------- > paragraph 1 > paragraph 2 > > ------------------- > > In my opinion both behavior are bugs. But surely one of them is, as > the functions should be somewhat consistent on demanding final > newlines. I don't really think this first is a bug. You've asked Emacs to sort numeric fields, and one of the lines in question doesn't have a numeric field, so bugging out seems like what's required. The second does seem like a bug. If the final paragraph doesn't end in a newline, it's squashed into the following paragraph after sorting. The following patch fixes the problem (by adding a newline in these cases). Does this seems like the correct approach for everybody? diff --git a/lisp/sort.el b/lisp/sort.el index 6ea1c44060..6ceda8e448 100644 --- a/lisp/sort.el +++ b/lisp/sort.el @@ -225,11 +225,17 @@ sort-paragraphs (narrow-to-region beg end) (goto-char (point-min)) (sort-subr reverse - (function - (lambda () - (while (and (not (eobp)) (looking-at paragraph-separate)) - (forward-line 1)))) - 'forward-paragraph)))) + (lambda () + (while (and (not (eobp)) (looking-at paragraph-separate)) + (forward-line 1))) + (lambda () + (forward-paragraph) + ;; If the buffer doesn't end with a newline, add a + ;; newline to avoid having paragraphs being + ;; concatenated after sorting. + (when (and (eobp) + (not (bolp))) + (insert "\n"))))))) ;;;###autoload (defun sort-pages (reverse beg end) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 01 14:38:43 2019 Received: (at control) by debbugs.gnu.org; 1 Aug 2019 18:38:43 +0000 Received: from localhost ([127.0.0.1]:55198 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1htFyN-0000xK-6C for submit@debbugs.gnu.org; Thu, 01 Aug 2019 14:38:43 -0400 Received: from quimby.gnus.org ([80.91.231.51]:44048) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1htFyL-0000xA-FO for control@debbugs.gnu.org; Thu, 01 Aug 2019 14:38:41 -0400 Received: from 77.18.62.220.tmi.telenormobil.no ([77.18.62.220] helo=sandy) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1htFyI-0002pz-Qz for control@debbugs.gnu.org; Thu, 01 Aug 2019 20:38:40 +0200 Date: Thu, 01 Aug 2019 20:38:38 +0200 Message-Id: <87y30chgsx.fsf@mouse.gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #21785 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: tags 21785 + patch 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 0.0 TVD_RCVD_IP Message was received from an IP address -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) 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: -1.0 (-) tags 21785 + patch quit From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 22 21:44:13 2019 Received: (at 21785) by debbugs.gnu.org; 23 Aug 2019 01:44:13 +0000 Received: from localhost ([127.0.0.1]:38659 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i0ycf-0004IO-9C for submit@debbugs.gnu.org; Thu, 22 Aug 2019 21:44:13 -0400 Received: from quimby.gnus.org ([80.91.231.51]:37746) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i0ycd-0004ID-8p for 21785@debbugs.gnu.org; Thu, 22 Aug 2019 21:44:11 -0400 Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=sandy) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i0ycY-0002Ur-NA; Fri, 23 Aug 2019 03:44:10 +0200 From: Lars Ingebrigtsen To: Artur Malabarba Subject: Re: bug#21785: 25.0.50; sort-fields fails if region ends in a newline and sort-paragraph fails if it doesn't References: <87zhkshgt4.fsf@mouse.gnus.org> Date: Fri, 23 Aug 2019 03:44:06 +0200 In-Reply-To: <87zhkshgt4.fsf@mouse.gnus.org> (Lars Ingebrigtsen's message of "Thu, 01 Aug 2019 20:38:31 +0200") Message-ID: <87o90gd5ax.fsf@mouse.gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.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: Lars Ingebrigtsen writes: > The second does seem like a bug. If the final paragraph doesn't end in > a newline, it's squashed into the following paragraph after sorting. > > The following patch fixes the problem (by adding a n [...] Content analysis details: (-2.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 NO_DNS_FOR_FROM DNS: Envelope sender has no MX or A DNS records -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP 0.9 DKIM_ADSP_NXDOMAIN No valid author signature and domain not in DNS -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.4 (/) X-Debbugs-Envelope-To: 21785 Cc: 21785@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: -0.6 (/) Lars Ingebrigtsen writes: > The second does seem like a bug. If the final paragraph doesn't end in > a newline, it's squashed into the following paragraph after sorting. > > The following patch fixes the problem (by adding a newline in these > cases). Does this seems like the correct approach for everybody? There were no comments, so I've applied the patch. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 22 21:44:18 2019 Received: (at control) by debbugs.gnu.org; 23 Aug 2019 01:44:18 +0000 Received: from localhost ([127.0.0.1]:38662 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i0yck-0004Ik-LS for submit@debbugs.gnu.org; Thu, 22 Aug 2019 21:44:18 -0400 Received: from quimby.gnus.org ([80.91.231.51]:37760) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i0yci-0004Ic-Ut for control@debbugs.gnu.org; Thu, 22 Aug 2019 21:44:17 -0400 Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=sandy) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i0ycg-0002Uy-6K for control@debbugs.gnu.org; Fri, 23 Aug 2019 03:44:16 +0200 Date: Fri, 23 Aug 2019 03:44:13 +0200 Message-Id: <87mug0d5aq.fsf@mouse.gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #21785 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: tags 21785 fixed close 21785 27.1 quit Content analysis details: (-2.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 NO_DNS_FOR_FROM DNS: Envelope sender has no MX or A DNS records -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP 0.9 DKIM_ADSP_NXDOMAIN No valid author signature and domain not in DNS -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.4 (/) 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: -0.6 (/) tags 21785 fixed close 21785 27.1 quit From unknown Wed Jun 18 23:09:04 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 20 Sep 2019 11:24:10 +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