From: Dmitry Gutov Date: Sat, 5 Mar 2022 02:32:54 +0000 (+0200) Subject: project-shell: Ensure the resulting buffer is live X-Git-Tag: emacs-29.0.90~2012 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a658be774268577cc8283ee05998d8b4225d7368;p=emacs.git 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). --- 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