]> git.eshelyaron.com Git - emacs.git/commitdiff
Prevent infloop in 'delete-trailing-whitespace'
authorEli Zaretskii <eliz@gnu.org>
Mon, 4 Jun 2018 16:33:07 +0000 (19:33 +0300)
committerEli Zaretskii <eliz@gnu.org>
Mon, 4 Jun 2018 16:33:07 +0000 (19:33 +0300)
* lisp/simple.el (delete-trailing-whitespace): Avoid inflooping
when some region of trailing whitespace is unmodifiable.
(Bug#31557)

lisp/simple.el

index 9483170a0b6d6df693692fda11c43abf83b7459d..bcf2b0677049f5769a2a435dccf7fc043e584409 100644 (file)
@@ -639,8 +639,9 @@ buffer if the variable `delete-trailing-lines' is non-nil."
           (while (re-search-forward "\\s-$" end-marker t)
             (skip-syntax-backward "-" (line-beginning-position))
             (let ((b (point)) (e (match-end 0)))
-              (when (region-modifiable-p b e)
-                (delete-region b e)))))
+              (if (region-modifiable-p b e)
+                  (delete-region b e)
+                (goto-char e)))))
         (if end
             (set-marker end-marker nil)
           ;; Delete trailing empty lines.