Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kill process if it's still running before starting a new one #59

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -64,7 +64,7 @@
;; buffer via `justl-recipe width`. By default it has a value of 20.
;;
;; You can change the shell between `eshell' and `vterm' using the `justl-shell'
;; variable. Using vterm requires the `vterm' package to be installed.

Check warning on line 67 in justl.el

View workflow job for this annotation

GitHub Actions / check (29.3, false)

There should be two spaces after a period

Check warning on line 67 in justl.el

View workflow job for this annotation

GitHub Actions / check (29.2, false)

There should be two spaces after a period

Check warning on line 67 in justl.el

View workflow job for this annotation

GitHub Actions / check (29.1, false)

There should be two spaces after a period

Check warning on line 67 in justl.el

View workflow job for this annotation

GitHub Actions / check (28.2, false)

There should be two spaces after a period
;;

;;; Code:
Expand Down Expand Up @@ -119,7 +119,7 @@

(defcustom justl-shell 'eshell
"Shell to use when running recipes.
Can be either Eshell or vterm. Using vterm requires the vterm package to

Check warning on line 122 in justl.el

View workflow job for this annotation

GitHub Actions / check (29.3, false)

There should be two spaces after a period

Check warning on line 122 in justl.el

View workflow job for this annotation

GitHub Actions / check (29.2, false)

There should be two spaces after a period

Check warning on line 122 in justl.el

View workflow job for this annotation

GitHub Actions / check (29.1, false)

There should be two spaces after a period

Check warning on line 122 in justl.el

View workflow job for this annotation

GitHub Actions / check (28.2, false)

There should be two spaces after a period
be installed."
:type '(choice (const eshell)
(const vterm)))
Expand Down Expand Up @@ -285,6 +285,21 @@
(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 Expand Up @@ -523,10 +538,10 @@
(interactive)
(unless (require 'vterm nil t)
(user-error "Package `vterm' was not found!"))
(let* ((recipe (justl--get-recipe-under-cursor))

Check warning on line 541 in justl.el

View workflow job for this annotation

GitHub Actions / check (28.2, false)

Unused lexical variable ‘vterm-buffer-name’
(vterm-buffer-name (format "justl - vterm - %s" (justl--recipe-name recipe)))

Check warning on line 542 in justl.el

View workflow job for this annotation

GitHub Actions / check (29.3, false)

Unused lexical variable ‘vterm-buffer-name’

Check warning on line 542 in justl.el

View workflow job for this annotation

GitHub Actions / check (29.2, false)

Unused lexical variable ‘vterm-buffer-name’

Check warning on line 542 in justl.el

View workflow job for this annotation

GitHub Actions / check (29.1, false)

Unused lexical variable ‘vterm-buffer-name’
(default-directory (f-dirname justl-justfile)))
(vterm)

Check warning on line 544 in justl.el

View workflow job for this annotation

GitHub Actions / check (29.3, false)

the function ‘vterm’ is not known to be defined.

Check warning on line 544 in justl.el

View workflow job for this annotation

GitHub Actions / check (29.2, false)

the function ‘vterm’ is not known to be defined.

Check warning on line 544 in justl.el

View workflow job for this annotation

GitHub Actions / check (29.1, false)

the function ‘vterm’ is not known to be defined.

Check warning on line 544 in justl.el

View workflow job for this annotation

GitHub Actions / check (28.2, false)

the function ‘vterm’ is not known to be defined.

(let* ((recipe-name (justl--recipe-name recipe))
(recipe-args (justl--recipe-args recipe))
Expand All @@ -535,9 +550,9 @@
(append transient-args
(list recipe-name)
(mapcar 'justl--arg-default recipe-args)))))
(vterm-insert (string-join args-list " ")))

Check warning on line 553 in justl.el

View workflow job for this annotation

GitHub Actions / check (29.3, false)

the function ‘vterm-insert’ is not known to be defined.

Check warning on line 553 in justl.el

View workflow job for this annotation

GitHub Actions / check (29.2, false)

the function ‘vterm-insert’ is not known to be defined.

Check warning on line 553 in justl.el

View workflow job for this annotation

GitHub Actions / check (29.1, false)

the function ‘vterm-insert’ is not known to be defined.

Check warning on line 553 in justl.el

View workflow job for this annotation

GitHub Actions / check (28.2, false)

the function ‘vterm-insert’ is not known to be defined.
(unless no-send
(vterm-send-return))))

Check warning on line 555 in justl.el

View workflow job for this annotation

GitHub Actions / check (29.3, false)

the function ‘vterm-send-return’ is not known to be defined.

Check warning on line 555 in justl.el

View workflow job for this annotation

GitHub Actions / check (29.2, false)

the function ‘vterm-send-return’ is not known to be defined.

Check warning on line 555 in justl.el

View workflow job for this annotation

GitHub Actions / check (29.1, false)

the function ‘vterm-send-return’ is not known to be defined.

Check warning on line 555 in justl.el

View workflow job for this annotation

GitHub Actions / check (28.2, false)

the function ‘vterm-send-return’ is not known to be defined.

(defun justl-no-exec-vterm ()
"Open vterm with the recipe but do not execute it."
Expand Down
Loading