Subject: Directory change implicit in "M-x compil

From: Peter Breton <[email-masked]>
Date: Thu, 17 Oct 96 22:11:27 EDT

Bret> My major problem is that there is no way to pin any
 Bret> compilations you do to a particular directory for all your
 Bret> buffers in compile.el.  Short of that, the default behavior is
 Bret> getting in my way: When I do M-x compile, compile.el inserts
 Bret> (insert "cd " thisdir "\n" command "\n") in the buffer prior to
 Bret> compilation, where "thisdir" is set to default-directory.
 Bret> Unfortunately, due to all of our terrific expand-file-name
 Bret> code, this string uses forward-slashes instead of back-slashes,
 Bret> which of course cmd.exe chokes on.  Does anyone have a
 Bret> suggestion for cleanly getting around this?

The 'compile-internal' function uses the value of default-directory,
which suggests to me that you could wrap compile in another function,
like this:

  (defun my-compile ()
	(interactive)
	(let ((default-directory (convert-slashes default-directory)))
	(call-interactively 'compile)))

'Convert-slashes' is left as an exercise for the reader :)

If you know that you'll _always_ _always_ want backslashes, advice is
probably the cleanest way to do it, perhaps like this:

  (defadvice compile (around use-backslashes activate)
	"Convert default directory to all backslashes"
	(let ((default-directory (convert-slashes default-directory)))
	ad-do-it
	))		

Note that I haven't tested either of these.
You could extend this idea to compile in any directory.

			Peter