From 1f6fae3a9799dbb58b742095480917c2e3b99a7f Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Sat, 2 Sep 2023 16:52:31 -0700 Subject: [PATCH 2/5] Add persist-hash-equal See bug#63671. --- persist.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/persist.el b/persist.el index d80943d19e..fd0d750161 100644 --- a/persist.el +++ b/persist.el @@ -187,5 +187,22 @@ (defun persist--save-all () (add-hook 'kill-emacs-hook 'persist--save-all) +(defun persist-hash-equal (hash1 hash2) + "Return non-nil when the contents of HASH1 and HASH2 are equal. +Table values are compared using `equal' unless they are both hash +tables themselves, in which case `persist-hash-equal' is used. +Does not compare equality predicates." + (and (= (hash-table-count hash1) + (hash-table-count hash2)) + (catch 'flag (maphash (lambda (key hash1-value) + (let ((hash2-value (gethash key hash2))) + (or (if (and (hash-table-p hash1-value) + (hash-table-p hash2-value)) + (persist-hash-equal hash1-value hash2-value) + (equal hash1-value hash2-value)) + (throw 'flag nil)))) + hash1) + t))) + (provide 'persist) ;;; persist.el ends here -- 2.41.0