unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#41858: 28.0.50; [PATCH]: Make project-shell use universal argument
@ 2020-06-14 18:29 Theodor Thornhill
  2020-06-14 18:46 ` Dmitry Gutov
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Theodor Thornhill @ 2020-06-14 18:29 UTC (permalink / raw)
  To: 41858

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


Hello,

Attached is a patch to change the default behaviour of 'project-shell'.

My use case is:

- Edit some file in some project.
- 'M-x project-shell'
- Do something, then "C-x 0"
- Oops forgot to read output.
- 'M-x project-shell'
- See the same buffer.

Right now 'project-shell' opens a new buffer every time it is invoked. Now I have to find it in the buffer list. Putting previous behaviour on universal argument will in addition enable this workflow

- Edit some file in some project.
- 'M-x project-shell'
- 'C-u M-x project-shell'
- Now emacs is split it two, with two separate shell processes


In addition, I let default name be *'project-root-dir'-shell* to signify this shell buffer to be unique from other shell buffers invoked by 'M-x shell'.

All the best,
Theodor Thornhill


[-- Attachment #2: project-shell --]
[-- Type: application/octet-stream, Size: 1268 bytes --]

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index f3df44fa7b..50e3dc3c8a 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -686,11 +686,21 @@ project-vc-dir
 
 ;;;###autoload
 (defun project-shell ()
-  "Open Shell in the current project."
+  "Open Shell in the current project.
+With \\[universal-argument] prefix, create subsequent shell buffers
+with uniquified names."
   (interactive)
-  (let ((default-directory (project-root (project-current t))))
-    ;; Use ‘create-file-buffer’ to uniquify shell buffer names.
-    (shell (create-file-buffer "*shell*"))))
+  (let* ((default-directory (project-root (project-current t)))
+         (default-project-shell-name
+           (concat "*" (file-name-nondirectory
+                        (directory-file-name
+                         (file-name-directory default-directory)))
+                   "-shell*"))
+         (shell-buffer (get-buffer default-project-shell-name)))
+    (if (and shell-buffer (not current-prefix-arg))
+        (switch-to-buffer-other-window shell-buffer)
+      ;; Use ‘create-file-buffer’ to uniquify shell buffer names.
+      (shell (create-file-buffer default-project-shell-name)))))
 
 ;;;###autoload
 (defun project-eshell ()

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

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

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-14 18:29 bug#41858: 28.0.50; [PATCH]: Make project-shell use universal argument Theodor Thornhill
2020-06-14 18:46 ` Dmitry Gutov
2020-06-14 18:51 ` bug#41858: Add the patch as a .patch Theodor Thornhill
2020-06-14 22:46 ` bug#41858: 28.0.50; [PATCH]: Make project-shell use universal argument Juri Linkov
2020-06-15  6:50   ` Theodor Thornhill
2020-06-15 23:01     ` Juri Linkov
2020-06-18  9:57       ` Theodor Thornhill
2020-06-18 13:28         ` Eli Zaretskii
2020-06-18 18:00           ` Theodor Thornhill
2020-06-20  1:03             ` Dmitry Gutov
2020-06-15 13:05   ` Dmitry Gutov
2020-06-15 14:53     ` Theodor Thornhill

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).