Improve buffer name default for C-u M-x shell.
authorChong Yidong <cyd@gnu.org>
Fri, 30 Nov 2012 08:06:04 +0000 (16:06 +0800)
committerChong Yidong <cyd@gnu.org>
Fri, 30 Nov 2012 08:06:04 +0000 (16:06 +0800)
* shell.el (shell): For C-u M-x shell, use an inactive shell
buffer as the default.

Fixes: debbugs:1975

lisp/ChangeLog
lisp/shell.el

index 5740d79..4a128e1 100644 (file)
@@ -1,3 +1,8 @@
+2012-11-30  Chong Yidong  <cyd@gnu.org>
+
+       * shell.el (shell): For C-u M-x shell, use an inactive shell
+       buffer as the default (Bug#1975).
+
 2012-11-30  Yuriy Vostrikov  <delamonpansie@gmail.com>  (tiny change)
 
        * vc/vc-git.el (vc-git-command): Disable the pager (Bug#6137).
index 77a4238..3827331 100644 (file)
@@ -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