]> git.eshelyaron.com Git - emacs.git/commitdiff
Pop to an existing Eshell buffer by default
authorTheodor Thornhill <theo@thornhill.no>
Sat, 20 Jun 2020 09:54:22 +0000 (11:54 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Sun, 21 Jun 2020 01:07:44 +0000 (04:07 +0300)
* lisp/progmodes/project.el (project-shell): Improve docstring to
include information about an implementation detail.

* list/progmodes/project.el (project-eshell): Modelled after
'project-shell', change default behavior such that we don't create too
many eshell buffers by default.  Use universal argument to create
subsequent buffers.

lisp/progmodes/project.el

index d35bdf6ce0c81520dcc88ba9f8c7a2c5bf0772eb..3a9e8bcee54c744e67cd56c3ce57a56290534208 100644 (file)
@@ -716,8 +716,9 @@ PREDICATE, HIST, and DEFAULT have the same meaning as in
 ;;;###autoload
 (defun project-shell ()
   "Start an inferior shell in the current project's root directory.
-With \\[universal-argument] prefix, create subsequent shell buffers
-with uniquified names."
+With \\[universal-argument] prefix, create subsequent shell
+buffers with uniquified names.  If several Shell buffers exists,
+this command jumps to the first created such buffer."
   (interactive)
   (let* ((default-directory (project-root (project-current t)))
          (default-project-shell-name
@@ -732,10 +733,21 @@ with uniquified names."
 
 ;;;###autoload
 (defun project-eshell ()
-  "Start Eshell in the current project's root directory."
+  "Start Eshell in the current project's root directory.
+With \\[universal-argument] prefix, create subsequent shell
+buffers with uniquified names.  If several Eshell buffers exists,
+this command jumps to the first created such buffer."
   (interactive)
-  (let ((default-directory (project-root (project-current t))))
-    (eshell t)))
+  (let* ((default-directory (project-root (project-current t)))
+         (eshell-buffer-name
+           (concat "*" (file-name-nondirectory
+                        (directory-file-name
+                         (file-name-directory default-directory)))
+                   "-eshell*"))
+         (eshell-buffer (get-buffer eshell-buffer-name)))
+    (if (and eshell-buffer (not current-prefix-arg))
+        (pop-to-buffer eshell-buffer)
+      (eshell t))))
 
 (declare-function fileloop-continue "fileloop" ())