all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Supporting newer Emacs features in older Emacs versions without warnings?
@ 2021-09-23  1:48 Adam Porter
  2021-09-23  8:58 ` Basil L. Contovounesios
  0 siblings, 1 reply; 10+ messages in thread
From: Adam Porter @ 2021-09-23  1:48 UTC (permalink / raw)
  To: emacs-devel

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




^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-09-28 17:07 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-23  1:48 Supporting newer Emacs features in older Emacs versions without warnings? Adam Porter
2021-09-23  8:58 ` 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

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.