[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: compile and the current directory
From: |
Alfred M. Szmidt |
Subject: |
Re: compile and the current directory |
Date: |
Fri, 16 Jan 2004 12:22:08 +0100 (MET) |
I have a project which contains a Makefile at its root directory.
Running make for me means to change to that directory before
running make.
I have been meaning to implement something like that, but for
`recompile' instead. Make more sense to have `compile' record the
directory one compiles in, and then have `recompile' restore it.
Anyway, I whiped up the following patch, it seems to work.
--- compile.el~ Sun Nov 23 21:57:47 2003
+++ compile.el Fri Jan 16 12:20:32 2004
@@ -386,6 +386,9 @@
try; %s in the string is replaced by the text matching the FILE-IDX'th
subexpression.")
+(defvar compilation-directory nil
+ "Directory to restore to when doing `recompile'.")
+
(defvar compilation-enter-directory-regexp-alist
'(
;; Matches lines printed by the `-w' option of GNU Make.
@@ -578,6 +581,7 @@
(unless (equal command (eval compile-command))
(setq compile-command command))
(save-some-buffers (not compilation-ask-about-save) nil)
+ (setq compilation-directory default-directory)
(compile-internal command "No more errors"))
;; run compile with the default command line
@@ -587,8 +591,13 @@
original use. Otherwise, it recompiles using `compile-command'."
(interactive)
(save-some-buffers (not compilation-ask-about-save) nil)
- (apply 'compile-internal (or compilation-arguments
- `(,(eval compile-command) "No more errors"))))
+ (let (olddir default-directory)
+ (unless (eq compilation-directory nil)
+ (setq default-directory compilation-directory))
+ (apply 'compile-internal (or compilation-arguments
+ `(,(eval compile-command) "No more errors")))
+ (setq default-directory olddir)))
+
(defcustom compilation-scroll-output nil
"*Non-nil to scroll the *compilation* buffer window as output appears.