[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: xref in GNU ELPA broken on Emacs 26
From: |
Stefan Monnier |
Subject: |
Re: xref in GNU ELPA broken on Emacs 26 |
Date: |
Tue, 19 Oct 2021 09:27:45 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> -(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