unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#56696: [PATCH] 29.0.50; compile.el doesn't always clean up after itself
@ 2022-07-22  8:26 João Távora
  2022-07-23  5:57 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: João Távora @ 2022-07-22  8:26 UTC (permalink / raw)
  To: 56696

[-- Attachment #1: Type: text/plain, Size: 453 bytes --]

Hello maintainers,

compile.el, which runs user code, doesn't use `unwind-protect` in its
process sentinel.  I really think it should.

I noticed this while playing around with the excellent rmsbolt.el of Jay
Kamat, which makes use of compilation-finish-functions.  If ones of
these functions errors, the user is stuck with a "[Compiling]" in her
modeline, even if compilation has long finished.

Let me know if there are any objections to this patch:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Clean-up-more-robustly-in-compile.el.patch --]
[-- Type: text/x-patch, Size: 2358 bytes --]

From de8025f19a7fe0cc37beeed61f4c1269de3519af Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= <joaotavora@gmail.com>
Date: Fri, 22 Jul 2022 09:23:02 +0100
Subject: [PATCH] Clean up more robustly in compile.el

* lisp/progmodes/compile.el (compilation-sentinel): Use
unwind-protect.
---
 lisp/progmodes/compile.el | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index c71a50d4fd..a665fccc73 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -2464,22 +2464,23 @@ compilation-handle-exit
 (defun compilation-sentinel (proc msg)
   "Sentinel for compilation buffers."
   (if (memq (process-status proc) '(exit signal))
-      (let ((buffer (process-buffer proc)))
-	(if (null (buffer-name buffer))
-	    ;; buffer killed
-	    (set-process-buffer proc nil)
-	  (with-current-buffer buffer
-	    ;; Write something in the compilation buffer
-	    ;; and hack its mode line.
-	    (compilation-handle-exit (process-status proc)
-				     (process-exit-status proc)
-				     msg)
-	    ;; Since the buffer and mode line will show that the
-	    ;; process is dead, we can delete it now.  Otherwise it
-	    ;; will stay around until M-x list-processes.
-	    (delete-process proc)))
+      (unwind-protect
+          (let ((buffer (process-buffer proc)))
+            (if (null (buffer-name buffer))
+                ;; buffer killed
+                (set-process-buffer proc nil)
+              (with-current-buffer buffer
+                ;; Write something in the compilation buffer
+                ;; and hack its mode line.
+                (compilation-handle-exit (process-status proc)
+                                         (process-exit-status proc)
+                                         msg))))
         (setq compilation-in-progress (delq proc compilation-in-progress))
-        (compilation--update-in-progress-mode-line))))
+        (compilation--update-in-progress-mode-line)
+        ;; Since the buffer and mode line will show that the
+        ;; process is dead, we can delete it now.  Otherwise it
+        ;; will stay around until M-x list-processes.
+        (delete-process proc))))
 
 (defun compilation-filter (proc string)
   "Process filter for compilation buffers.
-- 
2.37.0


[-- Attachment #3: Type: text/plain, Size: 9 bytes --]


João

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

* bug#56696: [PATCH] 29.0.50; compile.el doesn't always clean up after itself
  2022-07-22  8:26 bug#56696: [PATCH] 29.0.50; compile.el doesn't always clean up after itself João Távora
@ 2022-07-23  5:57 ` Lars Ingebrigtsen
  2022-07-23  9:25   ` João Távora
  0 siblings, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-07-23  5:57 UTC (permalink / raw)
  To: João Távora; +Cc: 56696

João Távora <joaotavora@gmail.com> writes:

> Let me know if there are any objections to this patch:

Looks good to me.







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

* bug#56696: [PATCH] 29.0.50; compile.el doesn't always clean up after itself
  2022-07-23  5:57 ` Lars Ingebrigtsen
@ 2022-07-23  9:25   ` João Távora
  2022-07-25 13:20     ` João Távora
  0 siblings, 1 reply; 4+ messages in thread
From: João Távora @ 2022-07-23  9:25 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 56696

Lars Ingebrigtsen <larsi@gnus.org> writes:

> João Távora <joaotavora@gmail.com> writes:
>
>> Let me know if there are any objections to this patch:
>
> Looks good to me.

It seems it helps, but doesn't quite fix the problem I'm experiencing,
so I'll play around with it some more and see if I can improve it.

João





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

* bug#56696: [PATCH] 29.0.50; compile.el doesn't always clean up after itself
  2022-07-23  9:25   ` João Távora
@ 2022-07-25 13:20     ` João Távora
  0 siblings, 0 replies; 4+ messages in thread
From: João Távora @ 2022-07-25 13:20 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 56696, 56696-done

João Távora <joaotavora@gmail.com> writes:

> Lars Ingebrigtsen <larsi@gnus.org> writes:
>
>> João Távora <joaotavora@gmail.com> writes:
>>
>>> Let me know if there are any objections to this patch:
>>
>> Looks good to me.
>
> It seems it helps, but doesn't quite fix the problem I'm experiencing,
> so I'll play around with it some more and see if I can improve it.

Nevermind, the patch is fine, the persistent problem I was still seeing
was due to some mischief by the client of compile.el.

Pushed.  Commit ffe12ff250

Thanks,
João





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

end of thread, other threads:[~2022-07-25 13:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-22  8:26 bug#56696: [PATCH] 29.0.50; compile.el doesn't always clean up after itself João Távora
2022-07-23  5:57 ` Lars Ingebrigtsen
2022-07-23  9:25   ` João Távora
2022-07-25 13:20     ` João Távora

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).