[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/gnus-cloud c5ea255 14/15: Merge branch 'master' of
From: |
Teodor Zlatanov |
Subject: |
[Emacs-diffs] scratch/gnus-cloud c5ea255 14/15: Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs |
Date: |
Tue, 5 Jul 2016 02:22:48 +0000 (UTC) |
branch: scratch/gnus-cloud
commit c5ea255607b6987bc9a0265dcf0d3d29c4ebc4b2
Merge: 41628a7 dcefd2b
Author: Ted Zlatanov <address@hidden>
Commit: Ted Zlatanov <address@hidden>
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
---
etc/NEWS | 6 ++++++
lisp/simple.el | 33 ++++++++++++++++-----------------
test/lisp/simple-tests.el | 18 ++++++++++++++++--
3 files changed, 38 insertions(+), 19 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 2f2ae65..bc8b097 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -187,6 +187,12 @@ questions, with a handy way to display help texts.
'undo', undo the last replacement; bound to 'u'.
'undo-all', undo all replacements; bound to 'U'.
+** 'delete-trailing-whitespace' deletes whitespace after form feed.
+In modes where form feed was treated as a whitespace character,
+'delete-trailing-whitespace' would keep lines containing it unchanged.
+It now deletes whitespace after the last form feed thus behaving the
+same as in modes where the character is not whitespace.
+
* Changes in Specialized Modes and Packages in Emacs 25.2
diff --git a/lisp/simple.el b/lisp/simple.el
index 0da7097..ba026af 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -602,24 +602,23 @@ buffer if the variable `delete-trailing-lines' is
non-nil."
(list nil nil))))
(save-match-data
(save-excursion
- (let ((end-marker (copy-marker (or end (point-max))))
- (start (or start (point-min))))
- (goto-char start)
- (while (re-search-forward "\\s-$" end-marker t)
- (skip-syntax-backward "-" (line-beginning-position))
+ (let ((end-marker (and end (copy-marker end))))
+ (goto-char (or start (point-min)))
+ (with-syntax-table (make-syntax-table (syntax-table))
;; Don't delete formfeeds, even if they are considered whitespace.
- (if (looking-at-p ".*\f")
- (goto-char (match-end 0)))
- (delete-region (point) (match-end 0)))
- ;; Delete trailing empty lines.
- (goto-char end-marker)
- (when (and (not end)
- delete-trailing-lines
- ;; Really the end of buffer.
- (= (point-max) (1+ (buffer-size)))
- (<= (skip-chars-backward "\n") -2))
- (delete-region (1+ (point)) end-marker))
- (set-marker end-marker nil))))
+ (modify-syntax-entry ?\f "_")
+ ;; Treating \n as non-whitespace makes things easier.
+ (modify-syntax-entry ?\n "_")
+ (while (re-search-forward "\\s-+$" end-marker t)
+ (delete-region (match-beginning 0) (match-end 0))))
+ (if end
+ (set-marker end-marker nil)
+ ;; Delete trailing empty lines.
+ (and delete-trailing-lines
+ ;; Really the end of buffer.
+ (= (goto-char (point-max)) (1+ (buffer-size)))
+ (<= (skip-chars-backward "\n") -2)
+ (delete-region (1+ (point)) (point-max)))))))
;; Return nil for the benefit of `write-file-functions'.
nil)
diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el
index 40cd1d2..97b6c49 100644
--- a/test/lisp/simple-tests.el
+++ b/test/lisp/simple-tests.el
@@ -204,7 +204,7 @@
;;; `delete-trailing-whitespace'
-(ert-deftest simple-delete-trailing-whitespace ()
+(ert-deftest simple-delete-trailing-whitespace--bug-21766 ()
"Test bug#21766: delete-whitespace sometimes deletes non-whitespace."
(defvar python-indent-guess-indent-offset) ; to avoid a warning
(let ((python (featurep 'python))
@@ -219,11 +219,25 @@
"\n"
"\n"))
(delete-trailing-whitespace)
- (should (equal (count-lines (point-min) (point-max)) 3)))
+ (should (string-equal (buffer-string)
+ (concat "query = \"\"\"WITH filtered AS\n"
+ "WHERE\n"
+ "\"\"\".format(fv_)\n"))))
;; Let's clean up if running interactive
(unless (or noninteractive python)
(unload-feature 'python)))))
+(ert-deftest simple-delete-trailing-whitespace--formfeeds ()
+ "Test formfeeds are not deleted but whitespace past them is."
+ (with-temp-buffer
+ (with-syntax-table (make-syntax-table)
+ (modify-syntax-entry ?\f " ") ; Make sure \f is whitespace
+ (insert " \f \n \f \f \n\nlast\n")
+ (delete-trailing-whitespace)
+ (should (string-equal (buffer-string) " \f\n \f \f\n\nlast\n"))
+ (should (equal ?\s (char-syntax ?\f)))
+ (should (equal ?\s (char-syntax ?\n))))))
+
;;; auto-boundary tests
(ert-deftest undo-auto-boundary-timer ()
- [Emacs-diffs] scratch/gnus-cloud updated (1a30c81 -> 1eefc9c), Teodor Zlatanov, 2016/07/04
- [Emacs-diffs] scratch/gnus-cloud c47ffc1 02/15: Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs, Teodor Zlatanov, 2016/07/04
- [Emacs-diffs] scratch/gnus-cloud 8fa2a11 06/15: Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs, Teodor Zlatanov, 2016/07/04
- [Emacs-diffs] scratch/gnus-cloud 6141547 03/15: Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs, Teodor Zlatanov, 2016/07/04
- [Emacs-diffs] scratch/gnus-cloud 1eefc9c 15/15: Protect from null gnus-cloud-sequence, again, Teodor Zlatanov, 2016/07/04
- [Emacs-diffs] scratch/gnus-cloud 08ca49d 07/15: Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs, Teodor Zlatanov, 2016/07/04
- [Emacs-diffs] scratch/gnus-cloud c5ea255 14/15: Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs,
Teodor Zlatanov <=
- [Emacs-diffs] scratch/gnus-cloud 7404048 05/15: Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs, Teodor Zlatanov, 2016/07/04
- [Emacs-diffs] scratch/gnus-cloud 526cbfe 11/15: Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs, Teodor Zlatanov, 2016/07/04
- [Emacs-diffs] scratch/gnus-cloud 477b396 09/15: Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs, Teodor Zlatanov, 2016/07/04
- [Emacs-diffs] scratch/gnus-cloud c69220c 04/15: Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs, Teodor Zlatanov, 2016/07/04
- [Emacs-diffs] scratch/gnus-cloud 5950ff5 12/15: Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs, Teodor Zlatanov, 2016/07/04
- [Emacs-diffs] scratch/gnus-cloud 2f7e8fa 01/15: Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs, Teodor Zlatanov, 2016/07/04
- [Emacs-diffs] scratch/gnus-cloud 41628a7 13/15: Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs, Teodor Zlatanov, 2016/07/04
- [Emacs-diffs] scratch/gnus-cloud 6471fba 10/15: Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs, Teodor Zlatanov, 2016/07/04
- [Emacs-diffs] scratch/gnus-cloud 71a9236 08/15: Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs, Teodor Zlatanov, 2016/07/04