Paul typed:

> The cd "command" that you see in the compile buffer, inherited from
> compile mode, is misleading. Actually, it's not a command at all
> but an informational message posing as a command. Compile mode 
> creates the message by concatenating "cd" with the name of the 
> current working directory, which is determined by Emacs and 
> is the directory containing the text displayed in the current buffer, 
> which in this case is the Java source file to be compiled.
> 
> Others have asked that the compile command change to some other
> directory, for example, the parent of the package specified in
> the source file's package statement, before launching javac. For 
> example, suppose you had the source for a class Widget in a 
> package com.myco.myapp, which is stored at 
> 
> /usr/home/me/java/projects/myapp/src/com/myco/myapp
> 
> Then, the JDE would parse the package statement in Widget.java,
> determine that the package is com/myco/myapp, walk its way up
> the directory tree to find the parent of the package root,
> namely, 
> 
> /usr/home/me/java/projects/myapp/src/
> 
> somehow switch Emacs' working directory to the root, and
> issue the command
> 
> javac com.myco.myapp.Widget.java
> 
> (Does javac accept a qualified class name like that? I don't know.
> I've never tried it.)
> 
> The problem with this scenario is that I'm not sure that Emacs Lisp
> affords a way to switch the working directory, which would be
> required to make this scenario work.
> 
> I'd be interested if anyone else has any suggestions or insights on how
> to address this issue.
> 
> 
> - Paul

I think I found it, Paul.

Here's how:
M-x apropos
directory

Then I did M-x lisp-interaction-mode
Then I C-x C-e 'd a bunch of variables to find the one that matches
the execution directory.

The variable is "default-directory" and it is tied to the current buffer.

So, in scratch I tried this:

(setf default-directory "/tmp/")
C-x C-e

Then, M-x shell
ta-dah! the shell opens in /tmp/

By the way, the trailing slash is necessary for whatever perverse reason.

-Bill

Reply via email to