From: Eric Ludlam <eric@siege-engine.com>
To: emacs-devel@gnu.org
Subject: Compatibility patches for EDE / EIEIO
Date: Sun, 10 Jan 2021 11:52:50 -0500 [thread overview]
Message-ID: <5cf47a13-e71f-6f3b-f763-335696989942@siege-engine.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1232 bytes --]
Hi,
Attached are two proposed patches related to compatibility for EIEIO and
EDE.
The EIEIO patch helps with loading old EDE save files. It updates
existing compatibility for the 1st object name argument to constructor
during object loading from a file. In older versions of EIEIO, objects
were saved with a 'name'. New EIEIO skips the name on load. This patch
will apply the name to the :object-name slot if it is a subclass of
eieio-named. This will compatibly bring in old objects and maintain the
name.
I tried it with the existing eieio tests which passed.
The EDE patch brings over a change from the CEDET repository on Source
Forge that enables project types detected via a function. The function
based project types were never integrated into Emacs. This patch allows
these old project types from SourceForge to work with built-in EDE.
There are no uses of this feature in Emacs, but it is useful for
integrating new project types that are not easily identified by a
string, such as android, arduino, fitbit and other tools that usually
provide their own 'studio' thing.
The EDE patch was written by me before the last 'release' I had signed
from my company. The EIEIO patch is new.
Thanks
Eric
[-- Attachment #2: 0001-cedet-ede-auto.el.patch --]
[-- Type: text/x-patch, Size: 1945 bytes --]
From c2e4ef56934fc08746cb8fb629f67b01fbd8a734 Mon Sep 17 00:00:00 2001
From: Eric Ludlam <zappo@gnu.org>
Date: Sun, 10 Jan 2021 10:37:50 -0500
Subject: [PATCH 1/2] cedet/ede/auto.el:
(ede-calc-fromconfig): New method. Support functions in addition to
string matchers.
(ede-dirmatch-installed, ede-do-dirmatch):
Use `ede-calc-fromconfig' to do conversion.
Author: Eric Ludlam <zappo@gnu.org>
---
lisp/cedet/ede/auto.el | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/lisp/cedet/ede/auto.el b/lisp/cedet/ede/auto.el
index ee75e29799..e1417d7806 100644
--- a/lisp/cedet/ede/auto.el
+++ b/lisp/cedet/ede/auto.el
@@ -64,24 +64,22 @@ ede-project-autoload-dirmatch
can be used to define that match without loading the specific project
into memory.")
+(cl-defmethod ede-calc-fromconfig ((dirmatch ede-project-autoload-dirmatch))
+ "Calculate the value of :fromconfig from DIRMATCH."
+ (let* ((fc (oref dirmatch fromconfig))
+ (found (cond ((stringp fc) fc)
+ ((functionp fc) (funcall fc))
+ (t (error "Unknown dirmatch object match style.")))))
+ (expand-file-name found)
+ ))
+
(cl-defmethod ede-dirmatch-installed ((dirmatch ede-project-autoload-dirmatch))
"Return non-nil if the tool DIRMATCH might match is installed on the system."
- (let ((fc (oref dirmatch fromconfig)))
-
- (cond
- ;; If the thing to match is stored in a config file.
- ((stringp fc)
- (file-exists-p fc))
-
- ;; Add new types of dirmatches here.
-
- ;; Error for weird stuff
- (t (error "Unknown dirmatch type.")))))
-
+ (file-exists-p (ede-calc-fromconfig dirmatch)))
(cl-defmethod ede-do-dirmatch ((dirmatch ede-project-autoload-dirmatch) file)
"Does DIRMATCH match the filename FILE."
- (let ((fc (oref dirmatch fromconfig)))
+ (let ((fc (ede-calc-fromconfig dirmatch)))
(cond
;; If the thing to match is stored in a config file.
--
2.25.1
[-- Attachment #3: 0002-eieio-base.el.patch --]
[-- Type: text/x-patch, Size: 2498 bytes --]
From f15b0f11c0fb9689454d687e49c1d7edbc26f0fc Mon Sep 17 00:00:00 2001
From: Eric Ludlam <zappo@gnu.org>
Date: Sun, 10 Jan 2021 10:54:49 -0500
Subject: [PATCH 2/2] eieio-base.el:
(eieio-persistent-make-instance): Save the backward compatible 'name'
of objects saved in the file, and if the newly loaded class inherits
from 'eieio-named', restore the name of the object.
Author: Eric Ludlam <zappo@gnu.org>
---
lisp/emacs-lisp/eieio-base.el | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el
index 4ba72aea56..19809265ff 100644
--- a/lisp/emacs-lisp/eieio-base.el
+++ b/lisp/emacs-lisp/eieio-base.el
@@ -264,12 +264,17 @@ eieio-persistent-make-instance
(:method
((objclass (subclass eieio-default-superclass)) inputlist)
- (let ((slots (if (stringp (car inputlist))
- ;; Earlier versions of `object-write' added a
- ;; string name for the object, now obsolete.
- (cdr inputlist)
- inputlist))
- (createslots nil))
+ (let* ((name nil)
+ (slots (if (stringp (car inputlist))
+ (progn
+ ;; Earlier versions of `object-write' added a
+ ;; string name for the object, now obsolete.
+ ;; Save as 'name' in case this object is subclass
+ ;; of eieio-named with no :object-name slot specified.
+ (setq name (car inputlist))
+ (cdr inputlist))
+ inputlist))
+ (createslots nil))
;; If OBJCLASS is an eieio autoload object, then we need to
;; load it (we don't need the return value).
(eieio--full-class-object objclass)
@@ -286,7 +291,17 @@ eieio-persistent-make-instance
(setq slots (cdr (cdr slots))))
- (apply #'make-instance objclass (nreverse createslots)))))
+ (let ((newobj (apply #'make-instance objclass (nreverse createslots))))
+
+ ;; Check for special case of subclass of `eieio-named', and do
+ ;; name assignment.
+ (when (and eieio-backward-compatibility
+ (object-of-class-p newobj eieio-named)
+ (not (oref newobj object-name))
+ name)
+ (oset newobj object-name name))
+
+ newobj))))
(defun eieio-persistent-fix-value (proposed-value)
"Fix PROPOSED-VALUE.
--
2.25.1
next reply other threads:[~2021-01-10 16:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-10 16:52 Eric Ludlam [this message]
2021-01-11 21:21 ` Compatibility patches for EDE / EIEIO Stefan Monnier
2021-01-17 19:57 ` Eric Ludlam
2021-01-17 22:16 ` Stefan Monnier
2021-01-18 16:52 ` Eric Ludlam
2021-01-18 17:52 ` 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
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=5cf47a13-e71f-6f3b-f763-335696989942@siege-engine.com \
--to=eric@siege-engine.com \
--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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).