emacs-devel
[Top][All Lists]
Advanced

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

Supporting newer Emacs features in older Emacs versions without warnings


From: Adam Porter
Subject: Supporting newer Emacs features in older Emacs versions without warnings?
Date: Wed, 22 Sep 2021 20:48:06 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Hi,

I recently added a shortdoc group to taxy.el for Emacs 28.  It works
fine in Emacs 28, but in older Emacs versions, it produces warnings at
compile time, because the shortdoc forms appear to be function calls
with incorrect arguments.  For example:

  ;;;; Documentation group

  ;; Available in Emacs 28.  NOTE: In earlier Emacs versions,
  ;; byte-compiling this section will produce warnings due to the
  ;; shortdoc forms that appear to be function calls.

  (eval-when-compile
    (require 'shortdoc nil t))

  (when (require 'shortdoc nil t)
    (with-no-warnings
      ;; TODO: Remove `with-no-warnings' when requiring Emacs 28+.
      (define-short-documentation-group taxy
        (taxy-flatten
         :eval (taxy-flatten
                (make-taxy
                 :items '(a b c)
                 :taxys (list (make-taxy
                               :items '(d e f)))))))))

This (minus the use of `with-no-warnings') produces warnings like:

  taxy.el:368:6: Warning: taxy-flatten called with 2 arguments, but
    accepts only 1

As well as:

  In end of data:
  taxy.el:367:4: Warning: the function
    ‘define-short-documentation-group’ is not known to be defined.

As you can see, I added `with-no-warnings' to the code, which should
hide these warnings.  But that will also obscure warnings in Emacs 28 if
I make any mistakes in that code, so it leaves me with an either/or
situation: either have false warnings in Emacs <28, or no legitimate
warnings in Emacs 28+.

Also, it's awkward to have to `require' shortdoc twice, first in
`eval-when-compile' for Emacs 28, and then in a `when' to avoid
evaluating the shortdoc definer in older versions.

Is there a cleaner way to do this?  Or could we have some kind of form
to aid the use of optional features in different versions of Emacs?
Maybe something like:

  (compile-when (version< "27.2" emacs-version)
    (define-short-documentation-group ...))

--
Thanks,
Adam




reply via email to

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