From a813fe3fb8d13abe234169361ba2c5b0c747c5e9 Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Fri, 30 Nov 2012 16:06:04 +0800 Subject: [PATCH] Improve buffer name default for C-u M-x shell. * shell.el (shell): For C-u M-x shell, use an inactive shell buffer as the default. Fixes: debbugs:1975 --- lisp/ChangeLog | 5 +++++ lisp/shell.el | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5740d796f3..4a128e1092 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-11-30 Chong Yidong + + * shell.el (shell): For C-u M-x shell, use an inactive shell + buffer as the default (Bug#1975). + 2012-11-30 Yuriy Vostrikov (tiny change) * vc/vc-git.el (vc-git-command): Disable the pager (Bug#6137). diff --git a/lisp/shell.el b/lisp/shell.el index 77a4238978..38273311b6 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -671,7 +671,12 @@ Otherwise, one argument `-i' is passed to the shell. (and current-prefix-arg (prog1 (read-buffer "Shell buffer: " - (generate-new-buffer-name "*shell*")) + ;; If the current buffer is an inactive + ;; shell buffer, use it as the default. + (if (and (eq major-mode 'shell-mode) + (null (get-buffer-process (current-buffer)))) + (buffer-name) + (generate-new-buffer-name "*shell*"))) (if (file-remote-p default-directory) ;; It must be possible to declare a local default-directory. ;; FIXME: This can't be right: it changes the default-directory -- 2.20.1