From: Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: xref in GNU ELPA broken on Emacs 26
Date: Tue, 19 Oct 2021 09:27:45 -0400 [thread overview]
Message-ID: <jwv8ryp5evi.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: 19d4409e-c0c5-06a9-ba43-a58d220ec5a2@yandex.ru
> -(cl-defstruct (xref-item
> - (:constructor xref-make (summary location))
> - (:noinline t))
> - "An xref item describes a reference to a location somewhere."
> - summary location)
> -
> -(cl-defstruct (xref-match-item
> - (:include xref-item)
> - (:constructor xref-make-match (summary location length))
> - (:noinline t))
> - "A match xref item describes a search result."
> - length)
> +(eval-and-compile
> + (eval
> + (let ((ni-supported (version< "27" emacs-version)))
> + `(progn
> + (cl-defstruct (xref-item
> + (:constructor xref-make (summary location))
> + ,@(if ni-supported
> + '((:noinline t))
> + nil))
> + "An xref item describes a reference to a location somewhere."
> + summary location)
> +
> + (cl-defstruct (xref-match-item
> + (:include xref-item)
> + (:constructor xref-make-match (summary location
> length))
> + ,@(if ni-supported
> + '((:noinline t))
> + nil))
> + "A match xref item describes a search result."
> + length))))
> + t)
>
> (cl-defgeneric xref-match-length ((item xref-match-item))
> "Return the length of the match."
I suspect that you can get the same without `eval` with something like:
(defmacro xref--defstruct (name &rest fields)
(declare (indent 1))
`(cl-defstruct ,(if (>= 27 emacs-major-version) name
(remq (assq :noinline name) name))
,@fields))
(xref--defstruct (xref-item
(:noinline t)
(:constructor xref-make (summary location)))
"An xref item describes a reference to a location somewhere."
summary location)
(xref--defstruct (xref-match-item
(:noinline t)
(:include xref-item)
(:constructor xref-make-match (summary location length)))
"A match xref item describes a search result."
length))))
-- Stefan
next prev parent reply other threads:[~2021-10-19 13:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-19 10:55 xref in GNU ELPA broken on Emacs 26 Yuri Khan
2021-10-19 13:18 ` Dmitry Gutov
2021-10-19 13:27 ` Stefan Monnier via Users list for the GNU Emacs text editor [this message]
2021-10-19 14:23 ` Dmitry Gutov
2021-10-19 16:07 ` Yuri Khan
2021-10-20 10:45 ` Yuri Khan
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwv8ryp5evi.fsf-monnier+emacs@gnu.org \
--to=help-gnu-emacs@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).