unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#41963: 28.0.50; [PATCH] Pop to an existing Eshell buffer in project by default
@ 2020-06-20 10:10 Theodor Thornhill
  2020-06-21  1:21 ` Dmitry Gutov
  0 siblings, 1 reply; 2+ messages in thread
From: Theodor Thornhill @ 2020-06-20 10:10 UTC (permalink / raw)
  To: 41963

[-- Attachment #1: Type: text/plain, Size: 300 bytes --]


Hi!

I added the same default behavior recently added to 'project-shell' to
'project-eshell'. It is a fairly straight-forward version based on what
is now found in 'project-shell'.

Also, I added a small docstring change, to mention an implementation
detail in project-shell.

Theo




[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Pop-to-an-existing-Eshell-buffer-by-default.patch --]
[-- Type: text/x-patch; name=0001-Pop-to-an-existing-Eshell-buffer-by-default.patch, Size: 2381 bytes --]

From 8e5ec6384beaee3ebc6772c741dc31d1cb2ae6e6 Mon Sep 17 00:00:00 2001
From: Theodor Thornhill <theo@thornhill.no>
Date: Sat, 20 Jun 2020 11:54:22 +0200
Subject: [PATCH] Pop to an existing Eshell buffer by default

* 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 | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index d35bdf6ce0..3a9e8bcee5 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -716,8 +716,9 @@ project-vc-dir
 ;;;###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 @@ project-shell
 
 ;;;###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" ())
 
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-21  1:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-20 10:10 bug#41963: 28.0.50; [PATCH] Pop to an existing Eshell buffer in project by default Theodor Thornhill
2020-06-21  1:21 ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).