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: Michael Heerdegen
Subject: Re: Rename Shell buffer with current directory
Date: Mon, 09 Dec 2013 19:16:40 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

"Sebastien Vauban" <sva-news@mygooglest.com>
writes:

> >>> Why do you use a non-nil LOCAL parameter for `add-hook'? Without
> >>> it, your code works for me.
> >> 

> Though, I just realized it also renames R buffers (as it is bound to comint
> mode). I'll have to make some exceptions there.

Oh, that's clear, silly me.  So, you must indeed use the local
parameter.  I think something like this should DTRT:

--8<---------------cut here---------------start------------->8---
(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
          (lambda ()
            (my-rename-buffer-to-curdir)
            (add-hook 'comint-output-filter-functions
                      #'my-rename-buffer-to-curdir nil t)))
--8<---------------cut here---------------end--------------->8---


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

How do you want it to behave?


Regards,

Michael.




reply via email to

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