* compile and the current directory
@ 2004-01-16 10:28 Kai Grossjohann
2004-01-16 11:22 ` Alfred M. Szmidt
[not found] ` <mailman.760.1074252175.928.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 4+ messages in thread
From: Kai Grossjohann @ 2004-01-16 10:28 UTC (permalink / raw)
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.
(Actually, I'm running another command, not make.)
The problem with "just" running make from the current directory is
that it is a different directory depending on the file I'm editing.
Has somebody made something that would allow me to just invoke M-x
compile RET from any directory and that makes sure that the command is
invoked from the right directory, and that Emacs knows about it?
(I could specify "make -C $HOME/work/foo" as the command if I was
using make.)
Kai
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: compile and the current directory
2004-01-16 10:28 compile and the current directory Kai Grossjohann
@ 2004-01-16 11:22 ` Alfred M. Szmidt
2004-01-18 17:12 ` Kai Grossjohann
[not found] ` <mailman.760.1074252175.928.help-gnu-emacs@gnu.org>
1 sibling, 1 reply; 4+ messages in thread
From: Alfred M. Szmidt @ 2004-01-16 11:22 UTC (permalink / raw)
Cc: help-gnu-emacs
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: compile and the current directory
[not found] ` <mailman.760.1074252175.928.help-gnu-emacs@gnu.org>
@ 2004-01-16 18:40 ` Kevin Rodgers
0 siblings, 0 replies; 4+ messages in thread
From: Kevin Rodgers @ 2004-01-16 18:40 UTC (permalink / raw)
Alfred M. Szmidt wrote:
> --- compile.el~ Sun Nov 23 21:57:47 2003
> +++ compile.el Fri Jan 16 12:20:32 2004
...
> @@ -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)))
> +
This is a little bit cleaner:
(let ((default-directory (or compilation-directory default-directory)))
(apply 'compile-internal ...))
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: compile and the current directory
2004-01-16 11:22 ` Alfred M. Szmidt
@ 2004-01-18 17:12 ` Kai Grossjohann
0 siblings, 0 replies; 4+ messages in thread
From: Kai Grossjohann @ 2004-01-18 17:12 UTC (permalink / raw)
Cc: help-gnu-emacs
"Alfred M. Szmidt" <ams@kemisten.nu> writes:
> 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.
Interesting approach. This reminds me that it is probably possible to
go to the *compilation* buffer and do `g' or `M-x revert-buffer RET'.
That might be rather convenient. Hm. Yeah, why not make a private
keybinding that pops me into the *compilation* buffer. Then I could
do C-c c g or somesuch. (C-c c goes to the *compilation* buffer,
say.)
Kai
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-01-18 17:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-16 10:28 compile and the current directory Kai Grossjohann
2004-01-16 11:22 ` Alfred M. Szmidt
2004-01-18 17:12 ` Kai Grossjohann
[not found] ` <mailman.760.1074252175.928.help-gnu-emacs@gnu.org>
2004-01-16 18:40 ` Kevin Rodgers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).