]> git.eshelyaron.com Git - emacs.git/commitdiff
project-shell: Ensure the resulting buffer is live
authorDmitry Gutov <dgutov@yandex.ru>
Sat, 5 Mar 2022 02:32:54 +0000 (04:32 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Sat, 5 Mar 2022 02:33:10 +0000 (04:33 +0200)
* 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

index b44f4618bea38d1bc1532d77deb78febea9f6c9e..daaf86f3277dc7277a04bfe9e0de501a138e6d0c 100644 (file)
@@ -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