emacs-devel
[Top][All Lists]
Advanced

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

Re: eval-when-compile help?


From: Dmitry Gutov
Subject: Re: eval-when-compile help?
Date: Tue, 5 Oct 2021 17:16:58 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0

On 05.10.2021 15:19, Stefan Monnier wrote:
+(when (version< emacs-version "28")
+  (eval-and-compile
+    (require 'eieio)
+
+    (defclass xref-location () ()
+      :documentation "(Obsolete) location represents a position in a file or 
buffer.")))
[...]
Am I overdoing it with 'eval-and-compile'?

I suspect that "from the outside" you don't need the `eval-and-compile`
at all here.  But if you remove it, there's a good chance that
compilation of `defclass` will fail (because the `require` won't be
executed at compile-time).
This said, I'd recommend you hoist the `eval-and-compile` outside of the
`when` so that `eieio` is not loaded in Emacsā‰„28.

In my testing, this doesn't make `eieio` loaded in Emacs 28 at runtime. Though I suppose it gets loaded during byte-compilation.

Moving `eval-and-compile` to the top level makes a lot of sense, but now I get the compilation warnings back (when compiling in Emacs 28).

So I suppose this is the final form:

(eval-and-compile
  (when (version< emacs-version "28")
    (require 'eieio)

    (with-no-warnings
      (defclass xref-location () ()
:documentation "(Obsolete) location represents a position in a file or buffer."))))



reply via email to

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