Emacs/Guix: Wait for process termination when install profiles.

master
Pierre Neidhardt 2020-06-09 11:10:37 +02:00
parent 293197b88f
commit c04fd76c12
2 changed files with 25 additions and 10 deletions

View File

@ -128,19 +128,34 @@ If MANIFEST is nil, it is queried from the manifests found in `ambrevar/guix-man
(defun ambrevar/run-in-eshell (command)
(let ((eshell-buffer-name "*guix*"))
(eshell)
(when (eshell-interactive-process)
(eshell t))
(eshell)
(when (eshell-interactive-process)
(eshell t))
(if (get-buffer-process (current-buffer))
(message "Try again after current process termination.")
(eshell-interrupt-process)
(insert command)
(eshell-send-input)))
(eshell-send-input))))
(defun ambrevar/run-in-shell (command)
(shell (generate-new-buffer (generate-new-buffer-name "*guix*")))
(goto-char (point-max))
(comint-delete-input)
(insert command)
(comint-send-input))
(shell (get-buffer-create "*guix*"))
(let ((process (get-buffer-process (current-buffer))))
(when process
(accept-process-output process 0.1)))
(if (ambrevar/helm-ff-shell-alive-p)
(message "Try again after current process termination.")
(goto-char (point-max))
(comint-delete-input)
(insert command)
(comint-send-input)))
(defun ambrevar/helm-ff-shell-alive-p () ; TODO: Use function from Helm 3.6.3 once out.
"Returns non nil when a process is running inside `shell-mode' buffer."
(save-excursion
(comint-goto-process-mark)
(or (null comint-last-prompt)
(not (eql (point)
(marker-position (cdr comint-last-prompt)))))))
(defun ambrevar/guix-install-manifest (&optional manifest channel)
"Install Guix manifest to `ambrevar/guix-extra-profiles'.

View File

@ -35,10 +35,10 @@ prefix arg shell buffer doesn't exists, create it and switch to it."
(car bufs)))
(switch-to-buffer it)
(shell))
;; TODO: Can we check if a process is currently running within the running shell?
(funcall cd-shell)))
(advice-add 'helm-ff-switch-to-eshell :override 'ambrevar/helm-ff-switch-to-shell)
;; TODO: Above code can be removed with Helm 3.6.3.
(defun ambrevar/shell-setup ()
(set (make-variable-buffer-local 'comint-input-history-ignore)