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: Kevin Rodgers
Subject: Re: region sensitive Makefile compile-command
Date: Mon, 06 Dec 2004 17:20:46 -0700
User-agent: Mozilla Thunderbird 0.9 (X11/20041105)

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




reply via email to

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