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 19:22:50 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0

On 05.10.2021 18:05, Stefan Monnier wrote:
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).

with-suppressed-warnings was added in 27, and xref.el is still targeting 26+. A comment sounds fine.

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

That gives me

  Wrong number of arguments: (3 . 3), 2

What would I put in the 'else' branch anyway?



reply via email to

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