]> code.delx.au - gnu-emacs/commitdiff
Fix delete-duplicate-lines
authorStephen Berman <stephen.berman@gmx.net>
Thu, 14 Jul 2016 07:55:28 +0000 (09:55 +0200)
committerStephen Berman <stephen.berman@gmx.net>
Thu, 14 Jul 2016 07:55:28 +0000 (09:55 +0200)
* lisp/sort.el (delete-duplicate-lines): Delete duplicate
first line when operating backward (bug#23863).

lisp/sort.el

index 4d7311f1e510a0e4e17c86c099c2a4a93a4024a6..8bc71388ad5642c020e862dd2903c9b434521961 100644 (file)
@@ -596,7 +596,7 @@ is non-nil, it also prints a message describing the number of deletions."
           (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 @@ is non-nil, it also prints a message describing the number of deletions."
       (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))