all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Theodor Thornhill <theo@thornhill.no>
To: 41858@debbugs.gnu.org
Subject: bug#41858: 28.0.50; [PATCH]: Make project-shell use universal argument
Date: Sun, 14 Jun 2020 18:29:28 +0000	[thread overview]
Message-ID: <87tuzd33i3.fsf@thornhill.no> (raw)

[-- 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 ()

             reply	other threads:[~2020-06-14 18:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-14 18:29 Theodor Thornhill [this message]
2020-06-14 18:46 ` bug#41858: 28.0.50; [PATCH]: Make project-shell use universal argument 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tuzd33i3.fsf@thornhill.no \
    --to=theo@thornhill.no \
    --cc=41858@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.