From: Sam Peterson <skpeterson@nospam.please.ucdavis.edu>
Subject: Re: current directory
Date: Fri, 20 Oct 2006 09:46:44 -0700 [thread overview]
Message-ID: <m1irifhr4b.fsf@Sams-Baby.local> (raw)
In-Reply-To: mailman.74.1161208352.2130.help-gnu-emacs@gnu.org
>>>>> "help-gnu-emacs" == help-gnu-emacs <help-gnu-emacs@vsbe.com> writes:
> This is about unix-like environment.
> Say I start emacs with a file in a certain directory, say
> /a/b/c:
> cd ~ emacs /a/b/c/file
> then, while in emacs, I open another file, say /g/d/f/file1.
> It looks like after this emacs moves its "current directory" to
> /g/d/f. Now, if I start a shell script through call-process, the
> shell script's current directory is also /g/d/f, but it depends
> on being run somewhere in /a/b/c tree. In fact, it looks like
> emacs changes its internal 'current directory' each time I
> switch to a file in a different directory, even a previously
> opened file.
> Is there a way to prevent emacs from changing its current
> directory when opening a new file or changing between files
> being visited?
> TIA, /vb
To my knowledge, the working directory of the process is not changed
per se, rather, rather the value of the lisp variable
default-directory is different in each buffer.
There may be a way to set this variable in find-file-hooks, although
there's a chance there could be an awful lot of plumbing in Emacs that
assumes default-directory contains the name of the directory that the
current buffer's file refers to. Worth a shot anyway.
(add-hook 'find-file-hooks
(lambda () (setq default-directory "dir-name"))
This of course statically sets it. I'm sure there's a way through the
magic of elisp to set the hook so it uses the dir of the requested
file. Any suggestions elisp gurus?
The preferred way in the GNU Emacs world is to just deal with shell
commands via a shell buffer. If you absolutely need to to use M-! for
whatever reason, whether that be to just run something quickly or
insert the output in the current buffer, shell-mode plus
killing/yanking text via a macro is one way I often go about it.
There is almost always a back-door in Emacs. It can require writing
an awful lot of elisp sometimes though ;).
--
Sam Peterson
skpeterson At nospam ucdavis.edu
"if programmers were paid to remove code instead of adding it,
software would be much better" -- unknown
next parent reply other threads:[~2006-10-20 16:46 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.74.1161208352.2130.help-gnu-emacs@gnu.org>
2006-10-20 16:46 ` Sam Peterson [this message]
[not found] <mailman.83.1161235004.2130.help-gnu-emacs@gnu.org>
2006-10-19 16:01 ` current directory Fang lun gang
2006-10-19 16:52 ` vb
2006-10-20 6:22 ` Eli Zaretskii
[not found] ` <mailman.100.1161276782.2130.help-gnu-emacs@gnu.org>
2006-10-19 19:22 ` rgb
2006-10-19 21:00 ` vb
2006-10-21 18:38 ` don provan
2006-10-23 17:24 ` vb
2006-10-23 19:17 ` John Sullivan
2006-10-23 19:57 ` Eli Zaretskii
2006-10-23 20:36 ` vb
2006-10-23 21:47 ` Dieter Wilhelm
2006-10-24 4:26 ` Eli Zaretskii
2006-10-24 5:24 ` Dieter Wilhelm
[not found] ` <mailman.178.1161635783.27805.help-gnu-emacs@gnu.org>
2006-10-23 21:52 ` Maarten Bergvelt
2006-10-23 20:32 ` Kevin Rodgers
2006-10-23 20:59 ` vb
[not found] ` <mailman.166.1161624291.27805.help-gnu-emacs@gnu.org>
2006-10-23 17:48 ` David Kastrup
2006-10-23 20:03 ` Eli Zaretskii
2006-10-23 18:33 ` Colin S. Miller
2006-10-23 18:58 ` vb
[not found] ` <mailman.169.1161629903.27805.help-gnu-emacs@gnu.org>
2006-10-23 19:46 ` Peter Boettcher
2006-10-19 5:16 help-gnu-emacs
2006-10-20 5:49 ` Eli Zaretskii
-- strict thread matches above, loose matches on Subject: below --
2006-10-18 21:52 help-gnu-emacs
2006-10-18 22:32 ` Peter Dyballa
2006-10-18 23:12 ` vb
2006-10-19 4:25 ` Eli Zaretskii
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=m1irifhr4b.fsf@Sams-Baby.local \
--to=skpeterson@nospam.please.ucdavis.edu \
/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).