At 11:18 AM 7/12/2001 +1000, Craig McGeachie wrote:
>> However, the problem I'm having seems to be caused by the cd <makedir>
>> command having no effect, as with the person you previously responded
>> to.  I was able to cut and paste that command (from the build's
>> compilation buffer) into a regular emacs shell, and see it not work
>> there either:
>> 

It is a common misconception, derived from the first line of the
compilation buffer, that the Emacs compile command actually executes the
shell command cd before executing the target compile command, e.g., gcc or
grep or javac.

On the contrary, the so-called cd command in the compilation buffer is
totally bogus. The Emacs compile command on which the JDE compile command
is based simply constructs the string by concatenating "cd " with the value
of the variable default-directory and inserts this string to indicate the
working directory of the compile command. If you specify a value for
jde-make-working-directory, the JDE sets the value of the variable
default-directory to the value of jde-make-work-directory. The Emacs
compile command uses the emacs start-process command to launch javac or
make or grep or whatever other command. The start-process command changes
the working directory  to the value of default directory and then executes
the equivalent of 

SHELL CMDSWITCH COMMAND-LINE

where SHELL is the value of shell-file-name (e.g., cmd, command, bash, sh,
etc.), CMDSWITCH is the value of shell-command-switch (e.g., -c or /c), and
COMMAND-LINE is the command line to be executed, e.g., "make mymakefile" or
"javac Foo.java".

start-process is a built-in function and, as I do not have the source code
for Emacs, I cannot be certain how it sets the working directory of the
command that it executes. However, I suspect the NT/Emacs version of
start-process uses the standard Windows api function, chdir, to change the
working directory. This function accepts paths with forward or back slashes
or both. So the style of the path should not be an issue here.

To confirm this, I have done some experimentation on setting
default-directory on Win2K, using Unix style paths and Windows style paths.
As I suspected, it makes no difference which you use. They both work. You
can easily verify this yourself. Here is how.

1. Use Files->JDE New->Class to create an empty class named Test.java
   in your  d:\ directory.


   public class Test {
      public Test (){
    
    }
  
    }// Test


2. Compile this file. Note that it compiles without error.

Here is the output in the compilation buffer.

cd d:/
javac Test.java

Compilation finished at Thu Jul 12 01:58:42


3. Now with the Test.java buffer selected, execute

   M-x eval-expression (setq default-directory "c:/winnt")

   This changes the default directory of the source buffer.

4. Now compile again.


cd c:/winnt
javac  -g Test.java
error: cannot read: Test.java
1 error

Compilation exited abnormally with code 1 at Thu Jul 12 02:17:01

The compile fails because the working directory of the compile process has
changed.

Based on this, I don't believe the problem with jde-make-working directory
has anything to do with the shell of style of path that you are using.

- Paul


Reply via email to