emacs-devel
[Top][All Lists]
Advanced

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

Re: eval-when-compile help?


From: Stefan Monnier
Subject: Re: eval-when-compile help?
Date: Tue, 05 Oct 2021 11:05:35 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

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

Better use `with-suppressed-warnings` than `with-no-warnings` (or at
least add a comment explaining what warning you're silencing).

BTW, maybe a better option is to use a macro like:

    (defmacro if-when-compile (test then else)
      (if (eval test t) then else))

and then do

    (if-when-compile (version< emacs-version "28")
        (progn
          (require 'eieio)
          
          (defclass xref-location () ()
            :documentation
            "(Obsolete) location represents a position in a file or buffer.")))


-- Stefan




reply via email to

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