* [ams@kemisten.nu: Re: compile and the current directory]
@ 2004-01-18 14:19 Alfred M. Szmidt
2004-01-19 10:01 ` Richard Stallman
0 siblings, 1 reply; 3+ messages in thread
From: Alfred M. Szmidt @ 2004-01-18 14:19 UTC (permalink / raw)
Hi,
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'.
Cheers.
------- Start of forwarded message -------
Date: Fri, 16 Jan 2004 12:22:08 +0100 (MET)
From: "Alfred M. Szmidt" <ams@kemisten.nu>
To: Kai Grossjohann <kai@emptydomain.de>
Cc: help-gnu-emacs@gnu.org
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
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.
_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://mail.gnu.org/mailman/listinfo/help-gnu-emacs
------- End of forwarded message -------
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [ams@kemisten.nu: Re: compile and the current directory]
2004-01-18 14:19 [ams@kemisten.nu: Re: compile and the current directory] Alfred M. Szmidt
@ 2004-01-19 10:01 ` Richard Stallman
2004-01-20 7:12 ` Alfred M. Szmidt
0 siblings, 1 reply; 3+ messages in thread
From: Richard Stallman @ 2004-01-19 10:01 UTC (permalink / raw)
Cc: Daniel Pfeiffer, emacs-devel
+ (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 roundabout and unreliable way to bind default-directory.
Why not just bind it with let?
(let ((default-directory (or compilation-directory default-directory)))
(apply 'compile-internal (or compilation-arguments
`(,(eval compile-command) "No more errors"))))
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [ams@kemisten.nu: Re: compile and the current directory]
2004-01-19 10:01 ` Richard Stallman
@ 2004-01-20 7:12 ` Alfred M. Szmidt
0 siblings, 0 replies; 3+ messages in thread
From: Alfred M. Szmidt @ 2004-01-20 7:12 UTC (permalink / raw)
Cc: dapfy, emacs-devel
+ (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 roundabout and unreliable way to bind default-directory.
Why not just bind it with let?
(let ((default-directory (or compilation-directory default-directory)))
(apply 'compile-internal (or compilation-arguments
`(,(eval compile-command) "No more errors"))))
There wasn't any particular reason not to use let, here is a updated
version with the above suggestion, thanks.
*** compile.el.~1.282.~ Sun Nov 23 21:57:47 2003
--- compile.el Tue Jan 20 08:10:23 2004
***************
*** 386,391 ****
--- 386,394 ----
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,583 ****
--- 581,587 ----
(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,594 ****
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"))))
(defcustom compilation-scroll-output nil
"*Non-nil to scroll the *compilation* buffer window as output appears.
--- 591,599 ----
original use. Otherwise, it recompiles using `compile-command'."
(interactive)
(save-some-buffers (not compilation-ask-about-save) nil)
! (let ((default-directory (or compilation-directory default-directory)))
! (apply 'compile-internal (or compilation-arguments
! `(,(eval compile-command) "No more errors")))))
(defcustom compilation-scroll-output nil
"*Non-nil to scroll the *compilation* buffer window as output appears.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-01-20 7:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-18 14:19 [ams@kemisten.nu: Re: compile and the current directory] Alfred M. Szmidt
2004-01-19 10:01 ` Richard Stallman
2004-01-20 7:12 ` Alfred M. Szmidt
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.