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

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

Re: How to not change the working directory when opening a file


From: Kevin Rodgers
Subject: Re: How to not change the working directory when opening a file
Date: Tue, 15 Jan 2008 19:56:02 -0700
User-agent: Thunderbird 1.5.0.14 (Macintosh/20071210)

Francis Moreau wrote:
Hello list,

I'd like Emacs to not changing the working directory when opening
a file.

For example when doing:

$ pwd
/home/fmoreau/tmp
$ emacs /tmp/foo.txt

I'd like the current working directory to be "/home/fmoreau/tmp"
when editing "/tmp/foo.txt" in emacs.

This is useful when composing an email. I sometime need to
include the output of a shell command but this shell command
must be executed in the directory where emacs was launched.

Does anybody can give me a hint to do that ?

(add-hook 'find-file-hook
          (lambda ()
            (setq default-directory
                  (buffer-local-value 'default-directory
                                      (get-buffer "*scratch*")))))
--
Kevin Rodgers
Denver, Colorado, USA





reply via email to

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