emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/beardbolt b4f31813dc 240/323: Auto stop an existing com


From: ELPA Syncer
Subject: [elpa] externals/beardbolt b4f31813dc 240/323: Auto stop an existing compilation
Date: Thu, 9 Mar 2023 10:58:34 -0500 (EST)

branch: externals/beardbolt
commit b4f31813dc2600880b30f7a949bc0eb14db397f0
Author: Erik Arvstedt <erik.arvstedt@gmail.com>
Commit: Erik Arvstedt <erik.arvstedt@gmail.com>

    Auto stop an existing compilation
    
    This makes rmsbolt work smoothly when the update interval is shorter
    than the compilation duration.
    
    Previously, an interactive query was shown by `compile.el`,
    interrupting the typing flow.
---
 rmsbolt.el | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/rmsbolt.el b/rmsbolt.el
index b20bda0c53..4aa50f9264 100644
--- a/rmsbolt.el
+++ b/rmsbolt.el
@@ -1314,12 +1314,13 @@ Argument ASM-LINES input lines."
     (nreverse result)))
 
 ;;;;; Handlers
-(cl-defun rmsbolt--handle-finish-compile (buffer str &key override-buffer)
+(cl-defun rmsbolt--handle-finish-compile (buffer str &key override-buffer 
stopped)
   "Finish hook for compilations.
 Argument BUFFER compilation buffer.
 Argument STR compilation finish status.
 Argument OVERRIDE-BUFFER asm src buffer to use instead of reading
-   `rmsbolt-output-filename'."
+   `rmsbolt-output-filename'.
+Argument STOPPED The compilation was stopped to start another compilation."
   (when (not (buffer-live-p buffer))
     (error "Dead buffer passed to compilation-finish-function! RMSBolt cannot 
continue."))
   (let ((compilation-fail
@@ -1330,7 +1331,8 @@ Argument OVERRIDE-BUFFER asm src buffer to use instead of 
reading
 
     (with-current-buffer (get-buffer-create rmsbolt-output-buffer)
       ;; Store src buffer value for later linking
-      (cond ((not compilation-fail)
+      (cond (stopped) ; Do nothing
+            ((not compilation-fail)
              (if (and (not override-buffer)
                       (not (file-exists-p (rmsbolt-output-filename src-buffer 
t))))
                  (message "Error reading from output file.")
@@ -1488,6 +1490,7 @@ and return it."
        (rmsbolt-l-elisp-compile-override (rmsbolt--get-lang))
        :src-buffer (current-buffer))))
    (t
+    (rmsbolt--stop-running-compilation)
     (rmsbolt--parse-options)
     (let* ((src-buffer (current-buffer))
            (lang (rmsbolt--get-lang))
@@ -1551,6 +1554,17 @@ and return it."
                   #'rmsbolt--handle-finish-compile nil t)
         (setq rmsbolt-src-buffer src-buffer))))))
 
+(defun rmsbolt--stop-running-compilation ()
+  (when-let* ((compilation-buffer (get-buffer "*rmsbolt-compilation*"))
+              (proc (get-buffer-process compilation-buffer)))
+    (when (eq (process-status proc) 'run)
+      (set-process-sentinel proc nil)
+      (interrupt-process proc)
+      (rmsbolt--handle-finish-compile compilation-buffer nil :stopped t)
+      ;; Wait a short while for the process to exit cleanly
+      (sit-for 0.2)
+      (delete-process proc))))
+
 ;;;; Keymap
 (defvar rmsbolt-mode-map
   (let ((map (make-sparse-keymap)))



reply via email to

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