summaryrefslogtreecommitdiff
path: root/lisp/sort.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/sort.el')
-rw-r--r--lisp/sort.el7
1 files changed, 4 insertions, 3 deletions
diff --git a/lisp/sort.el b/lisp/sort.el
index 4d7311f1e51..7f8acfc9b83 100644
--- a/lisp/sort.el
+++ b/lisp/sort.el
@@ -1,4 +1,4 @@
-;;; sort.el --- commands to sort text in an Emacs buffer
+;;; sort.el --- commands to sort text in an Emacs buffer -*- lexical-binding: t -*-
;; Copyright (C) 1986-1987, 1994-1995, 2001-2016 Free Software
;; Foundation, Inc.
@@ -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))