all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Adam Porter <adam@alphapapa.net>
To: emacs-devel@gnu.org
Subject: Supporting newer Emacs features in older Emacs versions without warnings?
Date: Wed, 22 Sep 2021 20:48:06 -0500	[thread overview]
Message-ID: <87ee9gjc4p.fsf@alphapapa.net> (raw)

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	other threads:[~2021-09-23  1:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-23  1:48 Adam Porter [this message]
2021-09-23  8:58 ` Supporting newer Emacs features in older Emacs versions without warnings? Basil L. Contovounesios
2021-09-24  6:08   ` Adam Porter
2021-09-24 13:14     ` Stefan Monnier
2021-09-24 22:22       ` Adam Porter
2021-09-26 16:49       ` Basil L. Contovounesios
2021-09-27 18:38         ` Stefan Monnier
2021-09-28 10:26           ` Basil L. Contovounesios
2021-09-28 12:51             ` Stefan Monnier
2021-09-28 17:07               ` Basil L. Contovounesios

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ee9gjc4p.fsf@alphapapa.net \
    --to=adam@alphapapa.net \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.