* Reusing dead shell buffers
@ 2009-01-11 20:19 jemarch
2009-01-13 23:27 ` Juri Linkov
2010-11-17 15:16 ` Stefan Monnier
0 siblings, 2 replies; 3+ messages in thread
From: jemarch @ 2009-01-11 20:19 UTC (permalink / raw)
To: emacs-devel
Hi.
Just a tiny patch for shell.
The patch assumes that the person launching M-xshell while in a
shell-mode buffer with a terminated process really wants to launch a
shell process in the current buffer instead to switch to "*shell*".
The semantics of C-uM-xshell are not changed by the patch.
Index: shell.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/shell.el,v
retrieving revision 1.165
diff -u -r1.165 shell.el
--- shell.el 5 Jan 2009 03:19:45 -0000 1.165
+++ shell.el 11 Jan 2009 19:46:35 -0000
@@ -555,6 +555,9 @@
(read-file-name
"Default directory: " default-directory default-directory
t nil 'file-directory-p))))))))
+ ;; If the current buffer is a dead shell buffer, use it.
+ (if (and (not buffer) (eq major-mode 'shell-mode))
+ (setq buffer (current-buffer)))
(setq buffer (get-buffer-create (or buffer "*shell*")))
;; Pop to buffer, so that the buffer's window will be correctly set
;; when we call comint (so that comint sets the COLUMNS env var properly).
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Reusing dead shell buffers
2009-01-11 20:19 Reusing dead shell buffers jemarch
@ 2009-01-13 23:27 ` Juri Linkov
2010-11-17 15:16 ` Stefan Monnier
1 sibling, 0 replies; 3+ messages in thread
From: Juri Linkov @ 2009-01-13 23:27 UTC (permalink / raw)
To: jemarch; +Cc: emacs-devel
> Just a tiny patch for shell.
>
> The patch assumes that the person launching M-x shell while in a
> shell-mode buffer with a terminated process really wants to launch a
> shell process in the current buffer instead to switch to "*shell*".
>
> The semantics of C-u M-x shell are not changed by the patch.
>
> Index: shell.el
> ===================================================================
> RCS file: /cvsroot/emacs/emacs/lisp/shell.el,v
> retrieving revision 1.165
> diff -u -r1.165 shell.el
> --- shell.el 5 Jan 2009 03:19:45 -0000 1.165
> +++ shell.el 11 Jan 2009 19:46:35 -0000
> @@ -555,6 +555,9 @@
> (read-file-name
> "Default directory: " default-directory default-directory
> t nil 'file-directory-p))))))))
> + ;; If the current buffer is a dead shell buffer, use it.
> + (if (and (not buffer) (eq major-mode 'shell-mode))
> + (setq buffer (current-buffer)))
> (setq buffer (get-buffer-create (or buffer "*shell*")))
Some other modes do similar things (e.g. compilation/grep) reusing the
current buffer, so I think it would be natural to revive the current buffer
with `M-x shell' unless a numeric prefix is given.
BTW, what I still desperately need from shell.el is using a prefix arg
to add a numeric suffix to the shell buffer name in the same way as
eshell already does:
"A numeric prefix arg (as in `C-u 42 M-x eshell RET') switches
to the session with that number, creating it if necessary."
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Reusing dead shell buffers
2009-01-11 20:19 Reusing dead shell buffers jemarch
2009-01-13 23:27 ` Juri Linkov
@ 2010-11-17 15:16 ` Stefan Monnier
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2010-11-17 15:16 UTC (permalink / raw)
To: jemarch; +Cc: emacs-devel
> The patch assumes that the person launching M-xshell while in a
> shell-mode buffer with a terminated process really wants to launch a
> shell process in the current buffer instead to switch to "*shell*".
The problem with this patch if that if the user really wanted to jump
from *shell*<2> to the *shell* buffer instead (current behavior), he'll
be surprised because the command will end up not doing anything.
I think your idea is right, but it needs two fixes:
- check that the process is indeed dead.
- replace (eq major-mode 'shell-mode) with (derived-mode-p 'shell-mode)
I promise that I'll install such a patch much quicker than it took me to
reply to this email.
Stefan "going through some of his voluminous backlog"
> The semantics of C-uM-xshell are not changed by the patch.
> Index: shell.el
> ===================================================================
> RCS file: /cvsroot/emacs/emacs/lisp/shell.el,v
> retrieving revision 1.165
> diff -u -r1.165 shell.el
> --- shell.el 5 Jan 2009 03:19:45 -0000 1.165
> +++ shell.el 11 Jan 2009 19:46:35 -0000
> @@ -555,6 +555,9 @@
> (read-file-name
> "Default directory: " default-directory default-directory
> t nil 'file-directory-p))))))))
> + ;; If the current buffer is a dead shell buffer, use it.
> + (if (and (not buffer) (eq major-mode 'shell-mode))
> + (setq buffer (current-buffer)))
> (setq buffer (get-buffer-create (or buffer "*shell*")))
> ;; Pop to buffer, so that the buffer's window will be correctly set
> ;; when we call comint (so that comint sets the COLUMNS env var properly).
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-11-17 15:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-11 20:19 Reusing dead shell buffers jemarch
2009-01-13 23:27 ` Juri Linkov
2010-11-17 15:16 ` Stefan Monnier
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.