unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Possible problem with compile
@ 2022-04-21 10:06 Immanuel Litzroth
  2022-04-21 10:41 ` Philip Kaludercic
  2022-04-21 12:18 ` Stefan Monnier
  0 siblings, 2 replies; 5+ messages in thread
From: Immanuel Litzroth @ 2022-04-21 10:06 UTC (permalink / raw)
  To: emacs-devel

This triggers a problem
(compile '(error "you have a problem"))
;; here compile-command is (error "you have a problem")
;; and the next compilation(s) will eval that so they fail
(compile "ls")

This is the relevant code from compile.el:

 (unless (equal command (eval compile-command))
    (setq compile-command command))

I don't quite understand why the compile-command is evalled before setting
in this context. Documentation seems to suggest it should be a string whether
whether it is set via (compile something) or (setq compile-command something)
Immanuel


-- 
-- A man must either resolve to point out nothing new or to become a
slave to defend it. -- Sir Isaac Newton



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

* Re: Possible problem with compile
  2022-04-21 10:06 Possible problem with compile Immanuel Litzroth
@ 2022-04-21 10:41 ` Philip Kaludercic
  2022-04-21 12:18 ` Stefan Monnier
  1 sibling, 0 replies; 5+ messages in thread
From: Philip Kaludercic @ 2022-04-21 10:41 UTC (permalink / raw)
  To: Immanuel Litzroth; +Cc: emacs-devel

Immanuel Litzroth <immanuel.litzroth@gmail.com> writes:

> This triggers a problem
> (compile '(error "you have a problem"))
> ;; here compile-command is (error "you have a problem")
> ;; and the next compilation(s) will eval that so they fail
> (compile "ls")
>
> This is the relevant code from compile.el:
>
>  (unless (equal command (eval compile-command))
>     (setq compile-command command))
>
> I don't quite understand why the compile-command is evalled before setting
> in this context. Documentation seems to suggest it should be a string whether
> whether it is set via (compile something) or (setq compile-command something)

This seems to have been added in 5b6858da26e, but the commit message
doesn't help me understand why eval was added:

--8<---------------cut here---------------start------------->8---
commit 5b6858da26e4e6671ee93b67b921a86309b3d6a2
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Date:   Thu Jul 19 21:46:37 2001 +0000

    (compilation-parse-errors): `linenum' might return a this-error using
    the alternative format (a pair of markers).
--8<---------------cut here---------------end--------------->8---

I would guess the issue now is that with this been a 20+ year old
feature, there are enough people who depend on the behaviour, making it
difficult to remove.

> Immanuel

-- 
	Philip Kaludercic



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

* Re: Possible problem with compile
  2022-04-21 10:06 Possible problem with compile Immanuel Litzroth
  2022-04-21 10:41 ` Philip Kaludercic
@ 2022-04-21 12:18 ` Stefan Monnier
  2022-04-21 12:55   ` Immanuel Litzroth
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2022-04-21 12:18 UTC (permalink / raw)
  To: Immanuel Litzroth; +Cc: emacs-devel

Immanuel Litzroth [2022-04-21 12:06:42] wrote:
> This triggers a problem
> (compile '(error "you have a problem"))
> ;; here compile-command is (error "you have a problem")
> ;; and the next compilation(s) will eval that so they fail
> (compile "ls")

When it hurts don't do that?
Why would you pass that kind of argument to `compile`?  Maybe you should
describe the more general setting in which you bumped into this problem?


        Stefan




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

* Re: Possible problem with compile
  2022-04-21 12:18 ` Stefan Monnier
@ 2022-04-21 12:55   ` Immanuel Litzroth
  2022-04-21 13:25     ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Immanuel Litzroth @ 2022-04-21 12:55 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On Thu, Apr 21, 2022 at 2:18 PM Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
> Immanuel Litzroth [2022-04-21 12:06:42] wrote:
> > This triggers a problem
> > (compile '(error "you have a problem"))
> > ;; here compile-command is (error "you have a problem")
> > ;; and the next compilation(s) will eval that so they fail
> > (compile "ls")
>
> When it hurts don't do that?
> Why would you pass that kind of argument to `compile`?
It was a programming error in some code I was writing where
I forgot evaluating in a backquoted list.

> Maybe you should
> describe the more general setting in which you bumped into this problem?
I don't think it matters that much. I just think that behaviour could
be improved,
seeing that other people might run into it and I was quite confused as to why
it wouldn't compile anymore even though I fixed my bug.
It's still not clear to me why you would want to eval there?
Immanuel

-- 
-- A man must either resolve to point out nothing new or to become a
slave to defend it. -- Sir Isaac Newton



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

* Re: Possible problem with compile
  2022-04-21 12:55   ` Immanuel Litzroth
@ 2022-04-21 13:25     ` Stefan Monnier
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2022-04-21 13:25 UTC (permalink / raw)
  To: Immanuel Litzroth; +Cc: emacs-devel

> It's still not clear to me why you would want to eval there?

AFAICT it was an accident: the place where we do/did want to `eval` is
when `compile-command` is set (e.g. via Custom) to provide a useful
default for `M-x compile`.

For the command passed to the `compile` function, OTOH it's not of much
use since the callers could call `eval` if they wanted it (tho
admittedly, it wouldn't be run in the exact same context, so maybe
someone could cook up some hypothetical example where it could be used,
but it seems rather far-fetched).


        Stefan




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

end of thread, other threads:[~2022-04-21 13:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21 10:06 Possible problem with compile Immanuel Litzroth
2022-04-21 10:41 ` Philip Kaludercic
2022-04-21 12:18 ` Stefan Monnier
2022-04-21 12:55   ` Immanuel Litzroth
2022-04-21 13:25     ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).