all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: emacs-devel@gnu.org
Subject: eval-when-compile help?
Date: Tue, 5 Oct 2021 06:01:43 +0300	[thread overview]
Message-ID: <8e532f35-729d-ed5a-c4f4-85e2d011c8eb@yandex.ru> (raw)

Hi all,

I need to add a piece of code to xref.el which will make it load eieio 
and define a class xref-location when [possibly byte-compiled and] 
loaded in Emacs 27 or older.

But preferably avoid loading EIEIO in Emacs 28+. Both at runtime when 
xref.el is loaded, and when it's compiled too.

The current patch is below. Am I overdoing it with 'eval-and-compile'?

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 1feb6ef915..c9334cfa04 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -74,6 +74,13 @@
  (require 'ring)
  (require 'project)

+(when (version< emacs-version "28")
+  (eval-and-compile
+    (require 'eieio)
+
+    (defclass xref-location () ()
+      :documentation "(Obsolete) location represents a position in a 
file or buffer.")))
+
  (defgroup xref nil "Cross-referencing commands."
    :version "25.1"
    :group 'tools)



             reply	other threads:[~2021-10-05  3:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-05  3:01 Dmitry Gutov [this message]
2021-10-05 12:19 ` eval-when-compile help? Stefan Monnier
2021-10-05 14:16   ` Dmitry Gutov
2021-10-05 15:05     ` Stefan Monnier
2021-10-05 16:22       ` Dmitry Gutov
2021-10-05 19:53         ` Stefan Monnier

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=8e532f35-729d-ed5a-c4f4-85e2d011c8eb@yandex.ru \
    --to=dgutov@yandex.ru \
    --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.