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: Sebastien Vauban
Subject: Re: Rename Shell buffer with current directory
Date: Mon, 09 Dec 2013 13:22:38 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt)

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



reply via email to

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