unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: help-gnu-emacs@gnu.org
Subject: Re: Rename Shell buffer with current directory
Date: Sat, 07 Dec 2013 21:58:26 +0100	[thread overview]
Message-ID: <87txekgyz1.fsf@web.de> (raw)
In-Reply-To: 86ppp92ig5.fsf@somewhere.org

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

> Hello,
>
> In order to rename the Shell buffer with the information of the current
> directory, I've come up with the following:
>
> (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)
>
> 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...

Without knowing if renaming the buffer all the time breaks anything:
`comint-output-filter-functions' is an abnormal hook (that's why it is
called ""...-functions"" and not "...-hook"").  In contrast to normal
hooks, functions in abnormal hooks take arguments.  The doc of the hook
says how many and what they mean.  `comint-output-filter-functions'
functions need to accept one argument.  Just don't use it in the
function body if you don't need it.


Regards,

Michael.




  reply	other threads:[~2013-12-07 20:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-07  8:06 Rename Shell buffer with current directory Sebastien Vauban
2013-12-07 20:58 ` Michael Heerdegen [this message]
     [not found] ` <mailman.8479.1386449940.10748.help-gnu-emacs@gnu.org>
2013-12-08 20:36   ` Sebastien Vauban
2013-12-08 21:32     ` Michael Heerdegen
     [not found]     ` <mailman.8618.1386538352.10748.help-gnu-emacs@gnu.org>
2013-12-09  8:36       ` Sebastien Vauban
2013-12-09  9:36         ` Rainer M Krug
     [not found]           ` <52A58F09.1010409-vfylz/Ys1k4@public.gmane.org>
2013-12-09 12:22             ` Sebastien Vauban
2013-12-09 12:56               ` Rainer M Krug
2013-12-09 18:16               ` Michael Heerdegen
     [not found]               ` <mailman.8695.1386613044.10748.help-gnu-emacs@gnu.org>
2013-12-09 18:44                 ` Sebastien Vauban
2013-12-09 19:31                   ` Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87txekgyz1.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).