Skip to content

Commit 700b09d

Browse files
Draft running uv commands in their own buffers
1 parent 3cec098 commit 700b09d

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

uv.el

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -672,24 +672,31 @@ suitable. Use `uv-lock' instead."
672672
(defun uv--do-command (command)
673673
"Perform COMMAND in a compint compile buffer in the project's root dir."
674674
(let* ((project (project-current))
675-
(default-directory (if project (project-root project) default-directory)))
676-
(let ((buf (compile command t))
677-
(hook uv--after-run-hook)
678-
(fail-hook uv--run-fail-hook))
679-
(with-current-buffer buf
680-
(add-hook 'compilation-finish-functions
681-
(lambda (buf msg)
682-
(when hook (funcall hook))
683-
(when (and fail-hook (string-match-p "exited abnormally" msg))
684-
(funcall fail-hook buf msg)))
685-
nil 'local)))))
675+
(default-directory (if project (project-root project) default-directory))
676+
(command (split-string-shell-command (string-trim command)))
677+
(proc-name (format "uv %s" (cadr command)))
678+
(buf (generate-new-buffer (format "*%s" proc-name))))
679+
(with-current-buffer buf
680+
(let ((inhibit-read-only t))
681+
(erase-buffer)
682+
(insert (string-join command " "))
683+
(insert "\n"))
684+
(apply #'make-comint-in-buffer proc-name buf (car command) nil (cdr command))
685+
(set-process-sentinel (get-buffer-process buf) #'uv--process-sentinel))
686+
buf))
687+
688+
(defun uv--process-sentinel (process event)
689+
(message "%s %s" (process-name process) (string-trim event))
690+
(if (string-suffix-p "finished\n" event)
691+
(when uv--after-run-hook (funcall uv--after-run-hook))
692+
(when uv--run-fail-hook (funcall uv--run-fail-hook))))
686693

687694
(defun uv--do-command-maybe-terminal (command terminal)
688695
"Perform COMMAND either as compile or if TERMINAL is non nil in `ansi-term'."
689696
(let ((default-directory (uv--project-root)))
690697
(if terminal
691698
(ansi-term command)
692-
(compile command t))))
699+
(temp-buffer-window-show (uv--do-command command)))))
693700

694701
(defun uv--group-arg (args)
695702
"Extract dependency groups and extras from transient ARGS."

0 commit comments

Comments
 (0)