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

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

Re: Sincronise eshell directory to file


From: Andreas Politz
Subject: Re: Sincronise eshell directory to file
Date: Thu, 13 Nov 2008 15:57:49 +0100
User-agent: Mozilla-Thunderbird 2.0.0.17 (X11/20081018)

Lorenzo Isella wrote:
Dear All,
My typical working pattern in emacs is to have an eshell + a buffer
(showing one of the program I intend to modify).
I switch between several of these code buffers and it would be very
useful for me to automatically change directory (within eshell) to the
one corresponding to the file I am visiting though the buffer.
Does anyone know how this can be achieved?
Cheers

Lorenzo




Here is a basic solution which uses `window-configuration-change-hook'.
What's left is getting eshell to play along, change the prompt and
handle partial input for example.

(defun eshell-follow-dir-hook nil
  (when (not (eq major-mode 'eshell-mode))
    (let ((pwd default-directory))
      (walk-windows #'(lambda (win)
                        (with-selected-window win
                          (when (and (eq major-mode 'eshell-mode)
                                     (not (equal pwd default-directory)))
                            (cd pwd))))
                    'no-minibuffer))))

(add-hook 'window-configuration-change-hook 'eshell-follow-dir-hook)


-ap


reply via email to

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