From 1f02cbea8b489ed7676110431aa36ad5abc47d9b Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Wed, 28 Oct 2015 09:55:25 +0100 Subject: Fix bug#21766 and add test * lisp/simple.el (delete-trailing-whitespace): Save match data when calling `skip-syntax-backward'. * test/automated/simple-test.el (simple-delete-trailing-whitespace): New test. --- lisp/simple.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lisp/simple.el') diff --git a/lisp/simple.el b/lisp/simple.el index 338a0600829..f6c580ffcd6 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -609,7 +609,8 @@ buffer if the variable `delete-trailing-lines' is non-nil." (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))) -- cgit v1.2.1