bug-gnu-emacs
[Top][All Lists]
Advanced

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

Re: region sensitive Makefile compile-command


From: Juri Linkov
Subject: Re: region sensitive Makefile compile-command
Date: Wed, 01 Dec 2004 22:37:52 +0200
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

Dan Jacobson <jidanni@jidanni.org> writes:
> You guys just got to implement this, so I'm rereqesting it as it is so
> cool.  Make a new variable that we can turn on to enable this:
>
> Here we are in a Makefile,
> a:
>         bla bla
> b:
>         bla bla
>
> Well, if the cursor is anywhere in the a: region, all two lines of it,
> then compile-command should be "make a" (or "make -k a"). If anywhere
> in the b: region, then compile-command should be "make b".
>
> That way when one hits M-x compile, one gets prompted with something
> relevant, not just "make -k" which may not always be what you want.
>
> Currently sadly, one can even put the cursor right on top of the a:
> and normally highly sensitive emacs (especially after enabling ffap)
> still doesn't get the hint.

Good idea.  How about such patch?  However, it doesn't provide
a simple option to turn this off.  I wonder if someone might not like
this behavior?

Index: lisp/progmodes/make-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/make-mode.el,v
retrieving revision 1.88
diff -u -r1.88 make-mode.el
--- lisp/progmodes/make-mode.el 20 Sep 2004 15:45:31 -0000      1.88
+++ lisp/progmodes/make-mode.el 1 Dec 2004 20:18:44 -0000
@@ -640,6 +640,17 @@
 
   ;; Real TABs are important in makefiles
   (setq indent-tabs-mode t)
+
+  (make-local-variable 'compile-command)
+  (setq compile-command
+       '(save-excursion
+          (beginning-of-line)
+          (if (or (looking-at makefile-macroassign-regex)
+                  (looking-at makefile-dependency-regex)
+                  (makefile-previous-dependency))
+              (concat "make -k " (match-string-no-properties 1))
+            (car compile-history))))
+
   (run-hooks 'makefile-mode-hook))
 
-- 
Juri Linkov
http://www.jurta.org/emacs/





reply via email to

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