From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Reusing dead shell buffers Date: Wed, 17 Nov 2010 10:16:07 -0500 Message-ID: References: <87hc454muu.wl%jemarch@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1290110404 15464 80.91.229.12 (18 Nov 2010 20:00:04 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 18 Nov 2010 20:00:04 +0000 (UTC) Cc: emacs-devel@gnu.org To: jemarch@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 18 20:59:59 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PJAeF-0000LN-B3 for ged-emacs-devel@m.gmane.org; Thu, 18 Nov 2010 20:59:59 +0100 Original-Received: from localhost ([127.0.0.1]:47017 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJAe0-00019f-SI for ged-emacs-devel@m.gmane.org; Thu, 18 Nov 2010 14:59:44 -0500 Original-Received: from [140.186.70.92] (port=50513 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJAb4-0007uX-RY for emacs-devel@gnu.org; Thu, 18 Nov 2010 14:56:44 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PJAb3-0004dy-P4 for emacs-devel@gnu.org; Thu, 18 Nov 2010 14:56:42 -0500 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:60420) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PJAb2-0004dW-K6; Thu, 18 Nov 2010 14:56:40 -0500 Original-Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id oAIJucnr006692; Thu, 18 Nov 2010 14:56:38 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id E707DA82C4; Wed, 17 Nov 2010 10:16:07 -0500 (EST) In-Reply-To: <87hc454muu.wl%jemarch@gnu.org> (jemarch@gnu.org's message of "Sun, 11 Jan 2009 21:19:21 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3683=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:132830 Archived-At: > 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).