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

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

Rename Shell buffer with current directory


From: Sebastien Vauban
Subject: Rename Shell buffer with current directory
Date: Sat, 07 Dec 2013 09:06:50 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt)

Hello,

In order to rename the Shell buffer with the information of the current
directory, I've come up with the following:

--8<---------------cut here---------------start------------->8---
(defun my-rename-to-curdir ()
  (message "%s" default-directory)      ; does work
  (rename-buffer (concat "*shell " default-directory "*")) ; DOESN'T WORK
  )

(add-hook 'shell-mode-hook 'my-rename-to-curdir)

(add-hook 'comint-output-filter-functions 'my-rename-to-curdir nil t)
--8<---------------cut here---------------end--------------->8---

Depending on where you first launch Shell, the name is correctly created, so it
mostly works.

But, when changing of directory, in the shell session, does not update the name
of the buffer -- while the variable `default-directory' is correctly updated...

It's like if `rename-buffer' would fail. But I see no reason for that. Do you?

Best regards,
  Seb

-- 
Sebastien Vauban


reply via email to

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