From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Rainer M Krug Newsgroups: gmane.emacs.help Subject: Re: Rename Shell buffer with current directory Date: Mon, 09 Dec 2013 13:56:38 +0100 Message-ID: <52A5BE06.8000605@krugs.de> References: <86ppp92ig5.fsf@somewhere.org> <86siu3f5bd.fsf@somewhere.org> <86d2l6mndo.fsf@somewhere.org> <52A58F09.1010409@krugs.de> <86k3fe43jl.fsf@somewhere.org> Reply-To: Rainer@krugs.de NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1386599855 3647 80.91.229.3 (9 Dec 2013 14:37:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 9 Dec 2013 14:37:35 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Sebastien Vauban Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Dec 09 15:37:41 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 1Vq1xs-0004pw-5I for geh-help-gnu-emacs@m.gmane.org; Mon, 09 Dec 2013 15:37:40 +0100 Original-Received: from localhost ([::1]:44185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vq1xr-0008Uw-O8 for geh-help-gnu-emacs@m.gmane.org; Mon, 09 Dec 2013 09:37:39 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53302) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vq0OP-0007i0-Gs for help-gnu-emacs@gnu.org; Mon, 09 Dec 2013 07:57:02 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vq0OB-0005vH-OT for help-gnu-emacs@gnu.org; Mon, 09 Dec 2013 07:56:57 -0500 Original-Received: from mail-we0-f175.google.com ([74.125.82.175]:54319) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vq0OB-0005v4-I8 for help-gnu-emacs@gnu.org; Mon, 09 Dec 2013 07:56:43 -0500 Original-Received: by mail-we0-f175.google.com with SMTP id t60so3336584wes.6 for ; Mon, 09 Dec 2013 04:56:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=message-id:date:from:reply-to:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=+2e7ds1pSCyQ3/5BfYenlil4/3uLfCRzN6/3qb9qmjM=; b=Efjss3xSNk1DVSI9JkP6vN/4HUWipvs4tOuuRTaCER44iSy5sPgm1zk9gQW9MWoJhV p6rnCi3XerWsth+XSrAN863rasS3PyGwjlx4HQ3h+VY8BCT8HQkt9r5CJoZpwbNLTWW2 1vUJm7Q+aees5gvKMXZmDL5vL84DfjEGVx1dshUqRGLusfXJSIH+RzN5gwIOL6hWSV4I x17/zltv27qsvxgqfNmQ29U3RCLSmxa12imxec18ADlcJ10eVgPUJz/JSQ4zfY/ziL0e llcRGtR/BzsmLdgb1RvXi27xdjEfjKHLX58G3kIwFM9OcrZ82qzzA36Qq33cee/o9/bx EJUw== X-Received: by 10.194.202.230 with SMTP id kl6mr15541719wjc.9.1386593802433; Mon, 09 Dec 2013 04:56:42 -0800 (PST) Original-Received: from Rainers-MacBook-Pro-2.local (arn78-1-88-186-171-7.fbx.proxad.net. [88.186.171.7]) by mx.google.com with ESMTPSA id d2sm24598996wik.11.2013.12.09.04.56.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 09 Dec 2013 04:56:38 -0800 (PST) User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 In-Reply-To: <86k3fe43jl.fsf@somewhere.org> X-Enigmail-Version: 1.6 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 74.125.82.175 X-Mailman-Approved-At: Mon, 09 Dec 2013 09:37:18 -0500 X-BeenThere: help-gnu-emacs@gnu.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@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:94905 Archived-At: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 12/09/13, 13:22 , Sebastien Vauban wrote: > 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. I realized the same - that's why I disabled it just now. Please post your enhancements here, as this is a very useful function. > > 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. True - realised the same with the R buffers... Cheers, Rainer > > Best regards, Seb > - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Stellenbosch University South Africa Tel : +33 - (0)9 53 10 27 44 Cell: +33 - (0)6 85 62 59 98 Fax : +33 - (0)9 58 10 27 44 Fax (D): +49 - (0)3 21 21 25 22 44 email: Rainer@krugs.de Skype: RMkrug -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSpb4FAAoJENvXNx4PUvmCK/wIAKDoskc3ItfwfEBuXgeotAcT RnKav0JkULQDSmldaSuCuH25bmo3/k1+BJRYiffHKCmO5tY1KSLmC3GuBwLC1tpy YmwA0TZO7kQ7PLAreKgC5nW2Qb3dhyCol4RjeqsHeApCnPCRSV8Rhv/cd9fN3GbI Mfsx/HPjjM/DuPYq0kL13nX1IIzbINdEBk6gCdCoo6y3lgXWRU0iiOAAdq5XkxHF 9f2m64e58rPI/u3Bo7o14wyOxUtyg1NxM1Qc5d+hdGW3e4bxEc7gPMVOLt2/YX+D p8vuVqGlHwZP4/akwJn7C7e72wiQhFLcW1rbyjbgm5Wu1rlL1wzK4uzA5hzHMro= =GHKH -----END PGP SIGNATURE-----