bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#31557: 27.0.50; SES hangs on save when 'delete-trailing-whitespace'


From: Eli Zaretskii
Subject: bug#31557: 27.0.50; SES hangs on save when 'delete-trailing-whitespace' is in 'before-save-hook'
Date: Sun, 03 Jun 2018 18:44:01 +0300

> From: Filipp Gunbin <fgunbin@fastmail.fm>
> Date: Tue, 22 May 2018 20:53:55 +0300
> 
> 
> emacs -Q
> M-: (add-hook 'before-save-hook #'delete-trailing-whitespace)
> C-x C-f ~/tmp/1.ses (file does not exist)
> C-x C-s
> 
> At this point emacs hangs, echo area shows "Saving file .../1.ses".  
> 
> With `toggle-error-on-quit', I see the following backtrace:
> 
>   re-search-forward("\\s-$" nil t)
>   delete-trailing-whitespace()
>   run-hooks(before-save-hook)
>   basic-save-buffer(t)
>   save-buffer(1)
>   funcall-interactively(save-buffer 1)
>   call-interactively(save-buffer nil nil)
>   command-execute(save-buffer)

If my reading of the code is correct, it should infloop for every use
case where region-modifiable-p returns nil.

Does the patch below look right?

--- lisp/simple.el~0    2018-03-14 06:40:04.000000000 +0200
+++ lisp/simple.el      2018-06-03 17:51:37.213490900 +0300
@@ -667,8 +667,9 @@
           (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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]