]> git.eshelyaron.com Git - emacs.git/commitdiff
Clean up more robustly in compile.el
authorJoão Távora <joaotavora@gmail.com>
Fri, 22 Jul 2022 08:23:02 +0000 (09:23 +0100)
committerJoão Távora <joaotavora@gmail.com>
Mon, 25 Jul 2022 13:19:02 +0000 (14:19 +0100)
* lisp/progmodes/compile.el (compilation-sentinel): Use
unwind-protect.

lisp/progmodes/compile.el

index c71a50d4fde5ac6a575cedbb59c7995686e8e05c..a665fccc733c94bdcf89934c0064dca7ae7ea6aa 100644 (file)
@@ -2464,22 +2464,23 @@ commands of Compilation major mode are available.  See
 (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.