all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* region sensitive Makefile compile-command
@ 2004-11-27  1:12 Dan Jacobson
  2004-12-01 20:37 ` Juri Linkov
  0 siblings, 1 reply; 9+ messages in thread
From: Dan Jacobson @ 2004-11-27  1:12 UTC (permalink / raw)


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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: region sensitive Makefile compile-command
  2004-11-27  1:12 region sensitive Makefile compile-command Dan Jacobson
@ 2004-12-01 20:37 ` Juri Linkov
  2004-12-02 23:33   ` Dan Jacobson
  0 siblings, 1 reply; 9+ messages in thread
From: Juri Linkov @ 2004-12-01 20:37 UTC (permalink / raw)
  Cc: bug-gnu-emacs

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/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: region sensitive Makefile compile-command
  2004-12-01 20:37 ` Juri Linkov
@ 2004-12-02 23:33   ` Dan Jacobson
  2004-12-05 20:52     ` Juri Linkov
       [not found]     ` <mailman.3743.1102280901.27204.bug-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 9+ messages in thread
From: Dan Jacobson @ 2004-12-02 23:33 UTC (permalink / raw)


Juri> a simple option to turn this off.
Just have defvar make-region-sensitive-or-whatever t or nil
Plus add documentation.
Tell us the URL when it's ready. Patch no good as I use Debian.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: region sensitive Makefile compile-command
  2004-12-02 23:33   ` Dan Jacobson
@ 2004-12-05 20:52     ` Juri Linkov
       [not found]     ` <mailman.3743.1102280901.27204.bug-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 9+ messages in thread
From: Juri Linkov @ 2004-12-05 20:52 UTC (permalink / raw)
  Cc: bug-gnu-emacs

Dan Jacobson <jidanni@jidanni.org> writes:
> Patch no good as I use Debian.

You can happily put in your .emacs:

(add-hook 'makefile-mode-hook
          (lambda ()
            (set (make-local-variable '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))))))

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: region sensitive Makefile compile-command
       [not found]     ` <mailman.3743.1102280901.27204.bug-gnu-emacs@gnu.org>
@ 2004-12-06 17:04       ` Kevin Rodgers
  2004-12-06 23:40         ` Juri Linkov
                           ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Kevin Rodgers @ 2004-12-06 17:04 UTC (permalink / raw)


Juri Linkov wrote:
 > Dan Jacobson <jidanni@jidanni.org> writes:
 >
 >>Patch no good as I use Debian.

Not true, as Debian must provide Emacs source code, including
lisp/progmodes/compile.el.  You could patch that and recompile it, since
compile.elc isn't dumped into the emacs executable.  Or you could copy
it to your site-lisp directory (or other directory in your load-path),
then patch and compile the copy.

 > You can happily put in your .emacs:
 >
 > (add-hook 'makefile-mode-hook
 >           (lambda ()
 >             (set (make-local-variable '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))))))

Wow, I didn't know compile-command could be an expression that is
evaluated dynamically!  That feature is not documented in the variable's
doc string, the Emacs manual, or the NEWS file -- which in itself is a
bug.

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: region sensitive Makefile compile-command
  2004-12-06 17:04       ` Kevin Rodgers
@ 2004-12-06 23:40         ` Juri Linkov
       [not found]         ` <mailman.4029.1102377320.27204.bug-gnu-emacs@gnu.org>
  2004-12-09  0:33         ` Dan Jacobson
  2 siblings, 0 replies; 9+ messages in thread
From: Juri Linkov @ 2004-12-06 23:40 UTC (permalink / raw)
  Cc: bug-gnu-emacs, jidanni

Kevin Rodgers <ihs_4664@yahoo.com> writes:
> Wow, I didn't know compile-command could be an expression that is
> evaluated dynamically!  That feature is not documented in the
> variable's doc string, the Emacs manual, or the NEWS file -- which
> in itself is a bug.

It is documented in the docstring only implicitly by showing an
example where `concat' is evaluated dynamically.

I'm not sure about the Emacs manual, but the docstring could be fixed
like this:

Index: lisp/progmodes/compile.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/compile.el,v
retrieving revision 1.342
diff -u -r1.342 compile.el
--- lisp/progmodes/compile.el	25 Nov 2004 03:02:18 -0000	1.342
+++ lisp/progmodes/compile.el	6 Dec 2004 23:33:33 -0000
@@ -415,6 +415,12 @@
 (defcustom compile-command "make -k "
   "*Last shell command used to do a compilation; default for next compilation.
 
+If it is an expression, it is evaluated to the command string before
+`compile' prompts for the command.  When the value of the command
+specified at the command prompt is not the same as evaluated from
+the expression, then this variable gets overwritten with the value
+of the last specified command string.
+
 Sometimes it is useful for files to supply local values for this variable.
 You might also use mode hooks to specify it in certain modes, like this:

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: region sensitive Makefile compile-command
       [not found]         ` <mailman.4029.1102377320.27204.bug-gnu-emacs@gnu.org>
@ 2004-12-07  0:20           ` Kevin Rodgers
  2004-12-07  1:23             ` Juri Linkov
  0 siblings, 1 reply; 9+ messages in thread
From: Kevin Rodgers @ 2004-12-07  0:20 UTC (permalink / raw)


Juri Linkov wrote:
 > Kevin Rodgers <ihs_4664@yahoo.com> writes:
 >
 >>Wow, I didn't know compile-command could be an expression that is
 >>evaluated dynamically!  That feature is not documented in the
 >>variable's doc string, the Emacs manual, or the NEWS file -- which
 >>in itself is a bug.
 >
 > It is documented in the docstring only implicitly by showing an
 > example where `concat' is evaluated dynamically.

No, in the example (concat ...) is evaluated when the hook is run, not
when `M-x compile' is run:

,----[ C-h v compile-command RET ]
| compile-command's value is "make -k "
|
| Documentation:
| *Last shell command used to do a compilation; default for next 
compilation.
|
| Sometimes it is useful for files to supply local values for this variable.
| You might also use mode hooks to specify it in certain modes, like this:
|
|     (add-hook 'c-mode-hook
|        (lambda ()
| 	 (unless (or (file-exists-p "makefile")
| 		     (file-exists-p "Makefile"))
| 	   (set (make-local-variable 'compile-command)
| 		(concat "make -k "
| 		        (file-name-sans-extension buffer-file-name))))))
|
| You can customize this variable.
|
| Defined in `compile'.
`----

 > I'm not sure about the Emacs manual, but the docstring could be fixed
 > like this:
 >
 > Index: lisp/progmodes/compile.el
 > ===================================================================
 > RCS file: /cvsroot/emacs/emacs/lisp/progmodes/compile.el,v
 > retrieving revision 1.342
 > diff -u -r1.342 compile.el
 > --- lisp/progmodes/compile.el	25 Nov 2004 03:02:18 -0000	1.342
 > +++ lisp/progmodes/compile.el	6 Dec 2004 23:33:33 -0000
 > @@ -415,6 +415,12 @@
 >  (defcustom compile-command "make -k "
 >    "*Last shell command used to do a compilation; default for next 
compilation.
 >
 > +If it is an expression, it is evaluated to the command string before
 > +`compile' prompts for the command.  When the value of the command
 > +specified at the command prompt is not the same as evaluated from
 > +the expression, then this variable gets overwritten with the value
 > +of the last specified command string.
 > +
 >  Sometimes it is useful for files to supply local values for this 
variable.
 >  You might also use mode hooks to specify it in certain modes, like this:

No, compile-command is eval'ed unconditionally:

(defun compile (command)
...
   (interactive
    (if (or compilation-read-command current-prefix-arg)
        (list (read-from-minibuffer "Compile command: "
                                  (eval compile-command) nil nil
                                  '(compile-history . 1)))
      (list (eval compile-command))))
   (unless (equal command (eval compile-command))
     (setq compile-command command))
   (save-some-buffers (not compilation-ask-about-save) nil)
   (compile-internal command "No more errors"))

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: region sensitive Makefile compile-command
  2004-12-07  0:20           ` Kevin Rodgers
@ 2004-12-07  1:23             ` Juri Linkov
  0 siblings, 0 replies; 9+ messages in thread
From: Juri Linkov @ 2004-12-07  1:23 UTC (permalink / raw)
  Cc: bug-gnu-emacs

Kevin Rodgers <ihs_4664@yahoo.com> writes:
> No, in the example (concat ...) is evaluated when the hook is run,
> not when `M-x compile' is run:

I didn't notice it has no quote.  It could be added to the example
before (concat ...) to demonstrate this feature.

> No, compile-command is eval'ed unconditionally:

Strictly speaking, there is no condition.  On the other hand, it
correctly describes the behavior.  In any case, wording could be
improved, e.g.

"It can be any expression, not just a string.  It is evaluated
to the command string before `compile' prompts for the command.
When the value of the command specified at the command prompt is
not the same as evaluated from the expression, then this variable
gets overwritten with the value of the last specified command string."

I see also that this feature conflicts with the defcustom type
of this variable which currently is :type 'string.  It should
be changed to :type 'sexp.

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: region sensitive Makefile compile-command
  2004-12-06 17:04       ` Kevin Rodgers
  2004-12-06 23:40         ` Juri Linkov
       [not found]         ` <mailman.4029.1102377320.27204.bug-gnu-emacs@gnu.org>
@ 2004-12-09  0:33         ` Dan Jacobson
  2 siblings, 0 replies; 9+ messages in thread
From: Dan Jacobson @ 2004-12-09  0:33 UTC (permalink / raw)


>>> Patch no good as I use Debian.
K> Not true, as Debian must provide Emacs source code
Yes, but as Debian only uses official Emacs releases, so when one sees
two 2004's
 > --- lisp/progmodes/compile.el	25 Nov 2004 03:02:18 -0000	1.342
 > +++ lisp/progmodes/compile.el	6 Dec 2004 23:33:33 -0000
one knows it's not for whiners like me. Or else we would run out of whine fuel.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-12-09  0:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-27  1:12 region sensitive Makefile compile-command Dan Jacobson
2004-12-01 20:37 ` Juri Linkov
2004-12-02 23:33   ` Dan Jacobson
2004-12-05 20:52     ` Juri Linkov
     [not found]     ` <mailman.3743.1102280901.27204.bug-gnu-emacs@gnu.org>
2004-12-06 17:04       ` Kevin Rodgers
2004-12-06 23:40         ` Juri Linkov
     [not found]         ` <mailman.4029.1102377320.27204.bug-gnu-emacs@gnu.org>
2004-12-07  0:20           ` Kevin Rodgers
2004-12-07  1:23             ` Juri Linkov
2004-12-09  0:33         ` Dan Jacobson

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.