From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.bugs Subject: bug#23863: 25.0.94; `delete-duplicate-lines' ignores first line in when REVERSE is non-nil Date: Wed, 29 Jun 2016 11:04:19 +0200 Message-ID: <87inwsbc30.fsf@gmx.net> References: <5772D374.9080406@fastmail.fm> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1467191132 21918 80.91.229.3 (29 Jun 2016 09:05:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 29 Jun 2016 09:05:32 +0000 (UTC) Cc: 23863@debbugs.gnu.org To: =?UTF-8?Q?Adri=C3=A1n_?= =?UTF-8?Q?Medra=C3=B1o?= Calvo Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jun 29 11:05:20 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bIBQr-0002pU-L8 for geb-bug-gnu-emacs@m.gmane.org; Wed, 29 Jun 2016 11:05:17 +0200 Original-Received: from localhost ([::1]:42240 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIBQq-000112-21 for geb-bug-gnu-emacs@m.gmane.org; Wed, 29 Jun 2016 05:05:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIBQh-0000wI-2x for bug-gnu-emacs@gnu.org; Wed, 29 Jun 2016 05:05:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bIBQc-0003hd-Pw for bug-gnu-emacs@gnu.org; Wed, 29 Jun 2016 05:05:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47306) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIBQc-0003hZ-MO for bug-gnu-emacs@gnu.org; Wed, 29 Jun 2016 05:05:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bIBQc-0003TE-H0 for bug-gnu-emacs@gnu.org; Wed, 29 Jun 2016 05:05:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stephen Berman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 29 Jun 2016 09:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23863 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23863-submit@debbugs.gnu.org id=B23863.146719107413290 (code B ref 23863); Wed, 29 Jun 2016 09:05:02 +0000 Original-Received: (at 23863) by debbugs.gnu.org; 29 Jun 2016 09:04:34 +0000 Original-Received: from localhost ([127.0.0.1]:59643 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bIBQ9-0003SI-QA for submit@debbugs.gnu.org; Wed, 29 Jun 2016 05:04:34 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:54375) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bIBQ7-0003S5-9n for 23863@debbugs.gnu.org; Wed, 29 Jun 2016 05:04:31 -0400 Original-Received: from rosalinde ([89.245.78.200]) by mail.gmx.com (mrgmx002) with ESMTPSA (Nemesis) id 0LeMij-1bh6iG01BF-00qF9v; Wed, 29 Jun 2016 11:04:21 +0200 In-Reply-To: <5772D374.9080406@fastmail.fm> ("=?UTF-8?Q?Adri=C3=A1n_?= =?UTF-8?Q?Medra=C3=B1o?= Calvo"'s message of "Tue, 28 Jun 2016 21:43:48 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) X-Prov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Vx9SpSaNjQUT5vAAivBW8DgM6ITQHx7ZZOwcdS 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: 208.118.235.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:120195 Archived-At: On Tue, 28 Jun 2016 21:43:48 +0200 Adri=C3=A1n Medra=C3=B1o Calvo wrote: > When running `delete-duplicate-lines' in reverse mode (i.e., REVERSE is > non-nil) the topmost line is not deleted. Please, see recipe: > > 1. Place the following lines in a buffer: > > This is line A. > This is line B. > This is line A. > This is line C. > This is line A. > > 2. Select all the lines > 3. Invoke "C-u M-x delete-duplicate-lines". > 4. Result is: > > This is line A. > This is line B. > This is line C. > This is line A. > > The top line "This is line A." should have been deleted. The patch below fixes this. This bug has existed since the command was introduced in Emacs 24, i.e., it's not a regression in Emacs 25, so if the patch is acceptable, should it be pushed to master? Steve Berman diff --git a/lisp/sort.el b/lisp/sort.el index 4d7311f..8bc7138 100644 --- a/lisp/sort.el +++ b/lisp/sort.el @@ -596,7 +596,7 @@ delete-duplicate-lines (equal current-prefix-arg '(64)) t))) (let ((lines (unless adjacent (make-hash-table :test 'equal))) - line prev-line + line prev-line first-line (count 0) (beg (copy-marker beg)) (end (copy-marker end))) @@ -604,8 +604,9 @@ delete-duplicate-lines (goto-char (if reverse end beg)) (if (and reverse (bolp)) (forward-char -1)) (while (if reverse - (and (> (point) beg) (not (bobp))) + (not first-line) (and (< (point) end) (not (eobp)))) + (setq first-line (and reverse (or (<=3D (point) beg) (bobp)))) (setq line (buffer-substring-no-properties (line-beginning-position) (line-end-position))) (if (and keep-blanks (string=3D "" line))