From a658be774268577cc8283ee05998d8b4225d7368 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Sat, 5 Mar 2022 04:32:54 +0200 Subject: [PATCH] project-shell: Ensure the resulting buffer is live * lisp/progmodes/project.el (project-shell): Make sure to recreate the shell if the buffer exists but not live (https://lists.gnu.org/archive/html/emacs-devel/2022-03/msg00017.html). --- lisp/progmodes/project.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index b44f4618bea..daaf86f3277 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1007,6 +1007,8 @@ directories listed in `vc-directory-exclusion-list'." (interactive) (vc-dir (project-root (project-current t)))) +(declare-function comint-check-proc "comint") + ;;;###autoload (defun project-shell () "Start an inferior shell in the current project's root directory. @@ -1015,11 +1017,14 @@ switch to it. Otherwise, create a new shell buffer. With \\[universal-argument] prefix arg, create a new inferior shell buffer even if one already exists." (interactive) + (require 'comint) (let* ((default-directory (project-root (project-current t))) (default-project-shell-name (project-prefixed-buffer-name "shell")) (shell-buffer (get-buffer default-project-shell-name))) (if (and shell-buffer (not current-prefix-arg)) - (pop-to-buffer shell-buffer (bound-and-true-p display-comint-buffer-action)) + (if (comint-check-proc shell-buffer) + (pop-to-buffer shell-buffer (bound-and-true-p display-comint-buffer-action)) + (shell shell-buffer)) (shell (generate-new-buffer-name default-project-shell-name))))) ;;;###autoload -- 2.39.5