unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Andrey Tykhonov <atykhonov@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: help-gnu-emacs Digest, Vol 133, Issue 16
Date: Sun, 08 Dec 2013 05:58:29 +0200	[thread overview]
Message-ID: <87eh5oyowq.fsf@gmail.com> (raw)
In-Reply-To: <mailman.155.1386435649.1853.help-gnu-emacs@gnu.org>


> Date: Sat, 07 Dec 2013 09:06:50 +0100
> From: "Sebastien Vauban" <sva-news@mygooglest.com>
> To: help-gnu-emacs@gnu.org
> Subject: Rename Shell buffer with current directory
> Message-ID: <86ppp92ig5.fsf@somewhere.org>
> Content-Type: text/plain
>
> Hello,

Hello,

I don't see any reason why your code doesn't work. I'm new in emacs and
many things are new for me....


But I would like to suggest you using the following code:

(defun add-mode-line-dirtrack ()
  (add-to-list 'mode-line-buffer-identification
                   '(:propertize (" " default-directory " ") face dired-directory)
  )
)
(add-hook 'shell-mode-hook 'add-mode-line-dirtrack)

This code displays current directory in the shell's modeline.


If this code is not suitable for you then I would like to suggest to
bind RET to the your function `my-rename-to-curdir`. Then your function
could has (rename-buffer <...>) call as it has and also
(comint-send-input) (`commint-send-input` is currently binded to RET in
mine emacs):

(defun my-rename-to-curdir ()
  (interactive)
  (comint-send-input)
  (rename-buffer (concat "*shell " default-directory "*"))
)

(define-key shell-mode-map [remap comint-send-input] 'my-rename-to-curdir)


Best regards,
Andrey

>
> 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	other threads:[~2013-12-08  3:58 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <mailman.155.1386435649.1853.help-gnu-emacs@gnu.org>]

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=87eh5oyowq.fsf@gmail.com \
    --to=atykhonov@gmail.com \
    --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).