all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: "Adrián Medraño Calvo" <adrian@medranocalvo.com>
Cc: 23863@debbugs.gnu.org
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	[thread overview]
Message-ID: <87inwsbc30.fsf@gmx.net> (raw)
In-Reply-To: <5772D374.9080406@fastmail.fm> ("Adrián Medraño Calvo"'s message of "Tue, 28 Jun 2016 21:43:48 +0200")

On Tue, 28 Jun 2016 21:43:48 +0200 Adrián Medraño Calvo <adrian@medranocalvo.com> 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 (<= (point) beg) (bobp))))
 	(setq line (buffer-substring-no-properties
 		    (line-beginning-position) (line-end-position)))
         (if (and keep-blanks (string= "" line))





  reply	other threads:[~2016-06-29  9:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-28 19:43 bug#23863: 25.0.94; `delete-duplicate-lines' ignores first line in when REVERSE is non-nil Adrián Medraño Calvo
2016-06-29  9:04 ` Stephen Berman [this message]
2016-07-13 15:29   ` Adrián Medraño Calvo
2016-07-14  8:13     ` Stephen Berman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87inwsbc30.fsf@gmx.net \
    --to=stephen.berman@gmx.net \
    --cc=23863@debbugs.gnu.org \
    --cc=adrian@medranocalvo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.