help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rename Shell buffer with current directory


From: Rainer M Krug
Subject: Re: Rename Shell buffer with current directory
Date: Mon, 09 Dec 2013 13:56:38 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.1.1

-----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-----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]