Hot answers tagged

5

So: have there been changes to eieio (specifically, cl-defmethod) in Emacs 27 that break previous code? It's not a change in eieio or cl-defmethod directly; what's changed is the handling of the &key symbol in cl-def* macros. (cl-defmethod initialize-instance :after ((sc simple-class) &key)) In Emacs 26 and earlier this produces a function which ...


5

The short answer is no. Once you declare a class, Emacs will define a function with the name of that class as a creation function, thereby replacing your old function definition. In Emacs, eieio.el has a macro for defclass that goes like so: (defmacro defclass (name superclasses slots &rest options-and-doc) ;; A lot of stuff here... ;; Non-...


3

While waiting for a better answer, I wrote a with-slots macro that seems to work with defstruct instances: (defmacro my-with-slots (class-name slots obj &rest body) "Bind slot names SLOTS in an instance OBJ of class CLASS-NAME, and execute BODY." (declare (indent 3)) `(cl-symbol-macrolet ,(cl-loop for slot in slots collect `...


3

Actually, the cl-defstruct macro does preserve enough info to make such a function possible, but I don't think anyone has written such a beast yet. The way this info is stored has changed in Emacs-25: now the macro expands to various other things plus a call to cl-struct-define which creates a class object (itself a struct). You can inspect it with C-h o ...


Only top voted, non community-wiki answers of a minimum length are eligible