Skip to content

Commit

Permalink
Merge pull request #59 from dkellner/kill-on-recompile
Browse files Browse the repository at this point in the history
Kill process if it's still running before starting a new one
  • Loading branch information
psibi authored Sep 24, 2024
2 parents 9bf1fc6 + 27be6e0 commit 9a06e61
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Changelog.org
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
* Unreleased

- Kill process if it's still running before starting a new one in the same
buffer.

* 0.14

- Respect buffer-local environments, for compatibility with ~envrc.el~
Expand Down
15 changes: 15 additions & 0 deletions justl.el
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,21 @@ ARGS is a plist that affects how the process is run.
(defun justl-recompile ()
"Execute the same just target again."
(interactive)
;; This is copied and adapted from `compilation-start'.
(let ((comp-proc (get-buffer-process (current-buffer))))
(if comp-proc
(if (or (not (eq (process-status comp-proc) 'run))
(eq (process-query-on-exit-flag comp-proc) nil)
(yes-or-no-p "The last target is still running; kill it? "))
(condition-case ()
(progn
(interrupt-process comp-proc)
(sit-for 1)
(delete-process comp-proc))
(error nil))
(error "Cannot have two processes in `%s' at once"
(buffer-name)))))

(justl--make-process justl--compile-command (list :buffer (buffer-name)
:process "just"
:directory (if justl-justfile
Expand Down

0 comments on commit 9a06e61

Please sign in to comment.