From ec645b83818d0d691493b944b03ffeab70b112bb Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 1 Dec 2024 15:48:52 -0500 Subject: [PATCH] fix(lib): 'unknown specializer record' error on Emacs <30 Seems the 'record' specializer wasn't introduced until Emacs 30, so users on earlier versions will see this error on startup. Fix: #8186 --- lisp/doom-lib.el | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lisp/doom-lib.el b/lisp/doom-lib.el index 2c6640517..33cfa0098 100644 --- a/lisp/doom-lib.el +++ b/lisp/doom-lib.el @@ -331,19 +331,17 @@ TRIGGER-HOOK is a list of quoted hooks and/or sharp-quoted functions." ;; ;;; Deep copying -(cl-defgeneric doom-copy (val &optional _deep?) +(cl-defgeneric doom-copy (val &optional deep?) "Return a (optionally deep) copy of VAL." - (cl-check-type val (or integer float boolean symbol null)) - val) - -(cl-defmethod doom-copy ((val record) &optional deep?) - "Return a (optionally deep) copy of record VAL." - (if deep? - (cl-loop with newval = (copy-sequence val) - for idx from 1 to (length (cdr (cl-struct-slot-info (type-of val)))) - do (aset newval idx (doom-copy (aref newval idx) t)) - finally return newval) - (copy-sequence val))) + (if (recordp val) ; `record' specializer not supported until Emacs 30 + (if deep? + (cl-loop with newval = (copy-sequence val) + for idx from 1 to (length (cdr (cl-struct-slot-info (type-of val)))) + do (aset newval idx (doom-copy (aref newval idx) t)) + finally return newval) + (copy-sequence val)) + (cl-check-type val (or integer float boolean symbol null)) + val)) (cl-defmethod doom-copy ((val sequence) &optional deep?) "Return a (optionally deep) copy of sequence VAL."