From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Sebastien Vauban" Newsgroups: gmane.emacs.help Subject: Re: Rename Shell buffer with current directory Date: Mon, 09 Dec 2013 13:22:38 +0100 Organization: Sebastien Vauban Message-ID: <86k3fe43jl.fsf@somewhere.org> References: <86ppp92ig5.fsf@somewhere.org> <86siu3f5bd.fsf@somewhere.org> <86d2l6mndo.fsf@somewhere.org> <52A58F09.1010409@krugs.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1386591827 4931 80.91.229.3 (9 Dec 2013 12:23:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 9 Dec 2013 12:23:47 +0000 (UTC) Cc: help-gnu-emacs-mXXj517/zsQ@public.gmane.org To: Rainer M Krug Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Mon Dec 09 13:23:53 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VpzsM-00086l-KS for geh-help-gnu-emacs@m.gmane.org; Mon, 09 Dec 2013 13:23:50 +0100 Original-Received: from localhost ([::1]:43192 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VpzsM-0008JZ-7S for geh-help-gnu-emacs@m.gmane.org; Mon, 09 Dec 2013 07:23:50 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47301) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vpzs4-0008JR-HR for help-gnu-emacs-mXXj517/zsQ@public.gmane.org; Mon, 09 Dec 2013 07:23:38 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vpzry-0004ex-Ho for help-gnu-emacs-mXXj517/zsQ@public.gmane.org; Mon, 09 Dec 2013 07:23:32 -0500 Original-Received: from dd5e0353a.access.telenet.be ([213.224.53.58]:55391 helo=mail.missioncriticalit.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vpzry-0004dt-CD for help-gnu-emacs-mXXj517/zsQ@public.gmane.org; Mon, 09 Dec 2013 07:23:26 -0500 Original-Received: from MUNDANEUM.i-did-not-set--mail-host-address--so-tickle-me (unknown [10.10.4.62]) by mail.missioncriticalit.com (Postfix) with ESMTPS id 067175009B1; Mon, 9 Dec 2013 13:26:02 +0100 (CET) X-Url: Under construction... X-Archive: encrypt In-Reply-To: <52A58F09.1010409-vfylz/Ys1k4@public.gmane.org> (Rainer M. Krug's message of "Mon, 09 Dec 2013 10:36:09 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 213.224.53.58 X-BeenThere: help-gnu-emacs-mXXj517/zsQ@public.gmane.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Xref: news.gmane.org gmane.emacs.help:94900 Archived-At: Hi Rainer, Rainer M Krug wrote: >> Michael Heerdegen wrote: >>>> (defun my-rename-buffer-to-curdir (&optional _string) "Change >>>> Shell buffer's name to current directory." (message "%s" >>>> default-directory) (rename-buffer (concat "*shell " >>>> default-directory "*"))) >>>> >>>> (add-hook 'shell-mode-hook 'my-rename-buffer-to-curdir) >>>> >>>> (add-hook 'comint-output-filter-functions >>>> 'my-rename-buffer-to-curdir nil t) >>> ^ >>>> However, that does not change the end result: the name of the >>>> buffer is unchanged. >>> >>> Why do you use a non-nil LOCAL parameter for `add-hook'? Without >>> it, your code works for me. >> >> So does it for me -- thanks for your help! >> >> Though, I still don't understand why making the >> `my-rename-buffer-to-curdir' function buffer-local makes the above >> fail... Remember that that function gets called (see the message >> displayed in the echo area), only the function `rename-buffer' >> fails... > > Thanks - I am using your code, and it works very nicely - very useful. You're welcome. Though, I just realized it also renames R buffers (as it is bound to comint mode). I'll have to make some exceptions there. As well, it does not handle (yet) the problem of two Shell buffers in the same directory, as the name won't be unique. Not sure what's the most straightforward approach for this one. Maybe looking at `uniquify' or so. Best regards, Seb -- Sebastien Vauban