all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#31557: 27.0.50; SES hangs on save when 'delete-trailing-whitespace' is in 'before-save-hook'
@ 2018-05-22 17:53 Filipp Gunbin
  2018-06-03 15:44 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Filipp Gunbin @ 2018-05-22 17:53 UTC (permalink / raw
  To: 31557


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)



In GNU Emacs 27.0.50 (build 10, x86_64-apple-darwin17.5.0)
 of 2018-05-14 built on fgunbin.playteam.ru
Repository revision: 15fa8de1ae3228413fde95e583008d9b9f19e7c7
System Description:  Mac OS X 10.13.4

Configured using:
 'configure CC=/usr/bin/gcc --without-all --without-ns --with-dbus
 --with-file-notification=no --with-gnutls --with-modules --with-threads
 --with-xml2 --with-zlib --without-x'

Configured features:
GNUTLS LIBXML2 ZLIB MODULES THREADS





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#31557: 27.0.50; SES hangs on save when 'delete-trailing-whitespace' is in 'before-save-hook'
  2018-05-22 17:53 bug#31557: 27.0.50; SES hangs on save when 'delete-trailing-whitespace' is in 'before-save-hook' Filipp Gunbin
@ 2018-06-03 15:44 ` Eli Zaretskii
  2018-06-03 16:05   ` Noam Postavsky
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2018-06-03 15:44 UTC (permalink / raw
  To: Filipp Gunbin, Noam Postavsky; +Cc: 31557

> 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.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#31557: 27.0.50; SES hangs on save when 'delete-trailing-whitespace' is in 'before-save-hook'
  2018-06-03 15:44 ` Eli Zaretskii
@ 2018-06-03 16:05   ` Noam Postavsky
  2018-06-04 14:26     ` Filipp Gunbin
  0 siblings, 1 reply; 5+ messages in thread
From: Noam Postavsky @ 2018-06-03 16:05 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: Filipp Gunbin, 31557

Eli Zaretskii <eliz@gnu.org> writes:

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

Yes, agreed.

> 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)))))

Looks good to me.






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#31557: 27.0.50; SES hangs on save when 'delete-trailing-whitespace' is in 'before-save-hook'
  2018-06-03 16:05   ` Noam Postavsky
@ 2018-06-04 14:26     ` Filipp Gunbin
  2018-06-04 16:34       ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Filipp Gunbin @ 2018-06-04 14:26 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: 31557

On 03/06/2018 12:05 -0400, Noam Postavsky wrote:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>> Does the patch below look right?
>> ...
>
> Looks good to me.

And also to me.  Thanks!





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#31557: 27.0.50; SES hangs on save when 'delete-trailing-whitespace' is in 'before-save-hook'
  2018-06-04 14:26     ` Filipp Gunbin
@ 2018-06-04 16:34       ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2018-06-04 16:34 UTC (permalink / raw
  To: Filipp Gunbin; +Cc: 31557-done

> From: Filipp Gunbin <fgunbin@fastmail.fm>
> Cc: 31557@debbugs.gnu.org
> Date: Mon, 04 Jun 2018 17:26:58 +0300
> 
> On 03/06/2018 12:05 -0400, Noam Postavsky wrote:
> 
> > Eli Zaretskii <eliz@gnu.org> writes:
> >
> >> Does the patch below look right?
> >> ...
> >
> > Looks good to me.
> 
> And also to me.  Thanks!

Thanks for testing.  I installed this on the emacs-26 branch, and I'm
closing the bug.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-06-04 16:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-22 17:53 bug#31557: 27.0.50; SES hangs on save when 'delete-trailing-whitespace' is in 'before-save-hook' Filipp Gunbin
2018-06-03 15:44 ` Eli Zaretskii
2018-06-03 16:05   ` Noam Postavsky
2018-06-04 14:26     ` Filipp Gunbin
2018-06-04 16:34       ` Eli Zaretskii

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.