From 82cfe98ccc0c759c15ac9f87008b1ed4128ed416 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 3 Dec 2024 17:42:52 -0500 Subject: [PATCH] fix(lib): doom-copy: copy first level of records Regardless of DEEP?, a record's fields should be copied one level deep at least, to ensure shallow changes to shallow copies don't affect the original. Amend: 169540ad3b19 --- lisp/doom-lib.el | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lisp/doom-lib.el b/lisp/doom-lib.el index 33cfa0098..8874a9edb 100644 --- a/lisp/doom-lib.el +++ b/lisp/doom-lib.el @@ -334,12 +334,10 @@ TRIGGER-HOOK is a list of quoted hooks and/or sharp-quoted functions." (cl-defgeneric doom-copy (val &optional deep?) "Return a (optionally deep) copy of 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-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) deep?)) + finally return newval) (cl-check-type val (or integer float boolean symbol null)) val))