[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

address@hidden: Re: compile and the current directory]

From: Alfred M. Szmidt
Subject: address@hidden: Re: compile and the current directory]
Date: Sun, 18 Jan 2004 15:19:40 +0100 (MET)


It would be nice to see the following in future emacsen, I know that I
often have to edit several files that are all over the place, but
always want to run the same command, in the same directory.  The
current `recompile' doesn't restore the working directory where you
actually ran `compile' in, with this patch it saves the value, and
then restores the working directory when doing `recompile'.


------- Start of forwarded message -------
Date: Fri, 16 Jan 2004 12:22:08 +0100 (MET)
From: "Alfred M. Szmidt" <address@hidden>
To: Kai Grossjohann <address@hidden>
Cc: address@hidden
Subject: Re: compile and the current directory

   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
+(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'."
   (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.

Help-gnu-emacs mailing list
------- End of forwarded message -------

reply via email to

[Prev in Thread] Current Thread [Next in Thread]