From: Juanma Barranquero <lekktu@gmail.com>
To: Andreas Schwab <schwab@suse.de>
Cc: 21766@debbugs.gnu.org, Markus Triska <triska@metalevel.at>,
Emacs developers <emacs-devel@gnu.org>
Subject: Re: bug#21766: 25.0.50; delete-trailing-whitespace sometimes deletes non-whitespace
Date: Tue, 27 Oct 2015 17:03:20 +0100 [thread overview]
Message-ID: <CAAeL0SQ76tmxLV112FkGrAKmZxBcdxP_D783reO3r_WdsYy9zA@mail.gmail.com> (raw)
In-Reply-To: <CAAeL0SRYta+ZF2BWq7mYWb8-0-fpUNS5a1QOr5Dig_P3Z6MP+g@mail.gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 177 bytes --]
This will be my first ERT test, so, does the following (attached, because
Gmail) patch look acceptable?
And, it is possible to commit a file with trailing whitespace?
[-- Attachment #1.2: Type: text/html, Size: 234 bytes --]
[-- Attachment #2: bug-21766.patch --]
[-- Type: application/octet-stream, Size: 2277 bytes --]
diff --git c/lisp/simple.el i/lisp/simple.el
index 338a060..f6c580f 100644
--- c/lisp/simple.el
+++ i/lisp/simple.el
@@ -609,7 +609,8 @@ delete-trailing-whitespace
(start (or start (point-min))))
(goto-char start)
(while (re-search-forward "\\s-$" end-marker t)
- (skip-syntax-backward "-" (line-beginning-position))
+ (save-match-data
+ (skip-syntax-backward "-" (line-beginning-position)))
;; Don't delete formfeeds, even if they are considered whitespace.
(if (looking-at-p ".*\f")
(goto-char (match-end 0)))
diff --git c/test/automated/data/simple/bug-21766.py i/test/automated/data/simple/bug-21766.py
new file mode 100644
index 0000000..118719a
--- /dev/null
+++ i/test/automated/data/simple/bug-21766.py
@@ -0,0 +1,4 @@
+query = """WITH filtered AS
+WHERE
+""".format(fv_)
+
diff --git c/test/automated/simple-test.el i/test/automated/simple-test.el
index 8da575d..62fe17c 100644
--- c/test/automated/simple-test.el
+++ i/test/automated/simple-test.el
@@ -21,6 +21,10 @@
(require 'ert)
+(defvar simple-tests-data-directory
+ (expand-file-name "data/simple" (getenv "EMACS_TEST_DIRECTORY"))
+ "Directory containing simple.el test data.")
+
(defmacro simple-test--dummy-buffer (&rest body)
(declare (indent 0)
(debug t))
@@ -180,5 +184,23 @@ simple-test--dummy-buffer
(should (= x 2)))
(remove-hook 'post-self-insert-hook inc))))
+\f
+;;; `delete-trailing-whitespace'
+(ert-deftest simple-delete-trailing-whitespace ()
+ (defvar python-indent-guess-indent-offset) ; to avoid a warning
+ (let ((python (featurep 'python))
+ (python-indent-guess-indent-offset nil)
+ (delete-trailing-lines t))
+ (unwind-protect
+ (with-temp-buffer
+ (python-mode)
+ (insert-file-contents (expand-file-name "bug-21766.py"
+ simple-tests-data-directory))
+ (delete-trailing-whitespace)
+ (should (equal (count-lines (point-min) (point-max)) 3)))
+ ;; Let's clean up if running interactive
+ (unless (or noninteractive python)
+ (unload-feature 'python)))))
+
(provide 'simple-test)
;;; simple-test.el ends here
next prev parent reply other threads:[~2015-10-27 16:03 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-26 23:07 bug#21766: 25.0.50; delete-trailing-whitespace sometimes deletes non-whitespace Markus Triska
2015-10-27 0:15 ` Juanma Barranquero
2015-10-27 7:07 ` Andreas Röhler
2015-10-27 7:53 ` Juanma Barranquero
2015-10-27 8:05 ` martin rudalics
2015-10-27 8:12 ` Juanma Barranquero
2015-10-27 8:25 ` martin rudalics
2015-10-27 8:32 ` Juanma Barranquero
2015-10-27 9:01 ` Andreas Schwab
2015-10-27 9:16 ` Juanma Barranquero
2015-10-27 9:24 ` martin rudalics
2015-10-27 9:46 ` Andreas Schwab
2015-10-27 10:21 ` Juanma Barranquero
2015-10-27 16:03 ` Juanma Barranquero [this message]
2015-10-28 1:51 ` Stephen Leake
2015-10-28 9:08 ` Juanma Barranquero
2015-10-28 17:38 ` Juanma Barranquero
2015-10-28 9:08 ` Juanma Barranquero
2015-10-28 1:51 ` Stephen Leake
2015-10-27 16:03 ` Juanma Barranquero
2015-10-28 19:19 ` Stefan Monnier
2015-10-29 6:30 ` Andreas Röhler
2015-10-29 9:41 ` Juanma Barranquero
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=CAAeL0SQ76tmxLV112FkGrAKmZxBcdxP_D783reO3r_WdsYy9zA@mail.gmail.com \
--to=lekktu@gmail.com \
--cc=21766@debbugs.gnu.org \
--cc=emacs-devel@gnu.org \
--cc=schwab@suse.de \
--cc=triska@metalevel.at \
/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.