>From b1512983fb82b9800ab6d0d1c9ca359e1251e94a Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Sun, 14 May 2023 22:32:16 -0700 Subject: [PATCH] Make persist-defvar work with records and hash tables Previously, when persist-defvar received a record or hash table for an initial value, updated values were not persisted. This was because the value and default value shared the same structure. --- persist.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/persist.el b/persist.el index d80943d19e..a40fc2b297 100644 --- a/persist.el +++ b/persist.el @@ -118,7 +118,9 @@ (defun persist-symbol (symbol &optional initvalue) (let ((initvalue (or initvalue (symbol-value symbol)))) (add-to-list 'persist--symbols symbol) (put symbol 'persist t) - (put symbol 'persist-default initvalue))) + (if (eq 'hash-table (type-of initvalue)) + (put symbol 'persist-default (copy-hash-table initvalue)) + (put symbol 'persist-default (copy-tree initvalue t))))) (defun persist--persistant-p (symbol) "Return non-nil if SYMBOL is a persistant variable." -- 2.40.1