From unknown Sat Sep 06 05:55:35 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#63513 <63513@debbugs.gnu.org> To: bug#63513 <63513@debbugs.gnu.org> Subject: Status: [PATCH] Make persist-defvar work with records and hash tables Reply-To: bug#63513 <63513@debbugs.gnu.org> Date: Sat, 06 Sep 2025 12:55:35 +0000 retitle 63513 [PATCH] Make persist-defvar work with records and hash tables reassign 63513 emacs submitter 63513 Joseph Turner severity 63513 wishlist tag 63513 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Mon May 15 02:21:21 2023 Received: (at submit) by debbugs.gnu.org; 15 May 2023 06:21:21 +0000 Received: from localhost ([127.0.0.1]:42580 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pyRaC-00016Q-UE for submit@debbugs.gnu.org; Mon, 15 May 2023 02:21:21 -0400 Received: from lists.gnu.org ([209.51.188.17]:47924) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pyRaB-00016I-Bz for submit@debbugs.gnu.org; Mon, 15 May 2023 02:21:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pyRaB-0002Wt-4l for bug-gnu-emacs@gnu.org; Mon, 15 May 2023 02:21:19 -0400 Received: from out-61.mta0.migadu.com ([2001:41d0:1004:224b::3d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pyRa8-0001T7-AP for bug-gnu-emacs@gnu.org; Mon, 15 May 2023 02:21:18 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1684131673; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=/J+Wuhx9Z07WLBqIvRsD91bExLO9ACZRI2vfr7W7GA4=; b=MUqWPHoNx8/jzosYXYwKG5P/tUNebiotXbp8+jF4surQVXmPMRyDE94NFLPlEZLhtXMow1 geLCx55M9fjQvTH65bTnL3evvLnSho2e2twUfrAzKgf0SHRYho65p3iPdPlc4SdOA5I5Yz o3/d8kR6bLIkyJ6Ymg+o2E78lp/o6xE= From: Joseph Turner To: bug-gnu-emacs@gnu.org Subject: [PATCH] Make persist-defvar work with records and hash tables Date: Sun, 14 May 2023 22:56:20 -0700 Message-ID: <87wn1axgh6.fsf@breatheoutbreathe.in> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:1004:224b::3d; envelope-from=joseph@breatheoutbreathe.in; helo=out-61.mta0.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit Cc: Adam Porter X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) --=-=-= Content-Type: text/plain Hello! persist-defvar does not persist records or hash tables correctly. Here's a minimal example with a hash table: (progn (persist-defvar foo (make-hash-table :test #'equal) "docstring") (puthash 'bar t foo) (persist-save 'foo) (gethash 'bar (persist-default 'foo))) ;; Expected nil, got t This patch fixes persisting records by using copy-tree. Currently, copy-tree does not work with records (see ). The following snippet will return the expected value only when both this patch and the above-linked patch are applied: (progn (cl-defstruct baz a) (persist-defvar quux (make-baz :a nil) "docstring") (setf (baz-a quux) t) (persist-save 'quux) (baz-a (persist-default 'quux))) ;; Expected nil, got t Before applying this patch, the updated values in both cases are not persisted to disk. With the patch, the updated values are persisted as expected. Best, Joseph --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Make-persist-defvar-work-with-records-and-hash-table.patch >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 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon May 15 07:31:46 2023 Received: (at 63513) by debbugs.gnu.org; 15 May 2023 11:31:46 +0000 Received: from localhost ([127.0.0.1]:42901 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pyWQb-0004Gc-VZ for submit@debbugs.gnu.org; Mon, 15 May 2023 07:31:46 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39532) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pyWQZ-0004GM-8M for 63513@debbugs.gnu.org; Mon, 15 May 2023 07:31:44 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pyWQS-0003v8-5p; Mon, 15 May 2023 07:31:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=TZP/mbs4VuVCVqwaB13T7KytZM7Bfvo7pDVjAb+sPqc=; b=epwrfkRoLh+O TnASfmC1H1xZk+VHUYRPmNAhLOn1pT8aDwj/GSJ4GGEbw762XY0mU2IUcvcCfg/qZUDXA4lQFYWp8 NUpmdjeamU0XBlXf48WTp9MNAVS4hPRw9VBfH9Hs3yoW3ya0wasX18SHeWNGOTdQ6dhxD8tmxAFV3 N6dxZRNWrkKxE5JSPDSL+u6bAHI4BY5RkaoCDJrTRcK/lAp1GZejVssISNKh9rSXVjV6nHh9LhHLe TwZ4tbN+MgDEJAb/61nselSfrSIf9qLIwzrAZ1olw548GHj8ZrtCM3e+nObfLghFbwYcG+x/NeKn0 z9Msjstl/w1p+zh9MaUJLA==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pyWQR-0006E0-LW; Mon, 15 May 2023 07:31:35 -0400 Date: Mon, 15 May 2023 14:31:40 +0300 Message-Id: <83jzx925lv.fsf@gnu.org> From: Eli Zaretskii To: Joseph Turner , Phillip Lord , Stefan Monnier In-Reply-To: <87wn1axgh6.fsf@breatheoutbreathe.in> (bug-gnu-emacs@gnu.org) Subject: Re: bug#63513: [PATCH] Make persist-defvar work with records and hash tables References: <87wn1axgh6.fsf@breatheoutbreathe.in> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63513 Cc: adam@alphapapa.net, 63513@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Cc: Adam Porter > Date: Sun, 14 May 2023 22:56:20 -0700 > From: Joseph Turner via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > persist-defvar does not persist records or hash tables correctly. > > Here's a minimal example with a hash table: > > (progn > (persist-defvar foo (make-hash-table :test #'equal) "docstring") > (puthash 'bar t foo) > (persist-save 'foo) > (gethash 'bar (persist-default 'foo))) ;; Expected nil, got t > > This patch fixes persisting records by using copy-tree. Currently, > copy-tree does not work with records (see > ). > The following snippet will return the expected value only when both this > patch and the above-linked patch are applied: > > (progn > (cl-defstruct baz a) > (persist-defvar quux (make-baz :a nil) "docstring") > (setf (baz-a quux) t) > (persist-save 'quux) > (baz-a (persist-default 'quux))) ;; Expected nil, got t > > Before applying this patch, the updated values in both cases are not > persisted to disk. With the patch, the updated values are persisted as > expected. Philip, any comments? From debbugs-submit-bounces@debbugs.gnu.org Tue May 23 16:49:21 2023 Received: (at 63513) by debbugs.gnu.org; 23 May 2023 20:49:21 +0000 Received: from localhost ([127.0.0.1]:40507 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1Ywb-00024T-5s for submit@debbugs.gnu.org; Tue, 23 May 2023 16:49:21 -0400 Received: from out-33.mta0.migadu.com ([91.218.175.33]:37064) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1YwY-00024J-2B for 63513@debbugs.gnu.org; Tue, 23 May 2023 16:49:19 -0400 References: <87wn1axgh6.fsf@breatheoutbreathe.in> <83jzx925lv.fsf@gnu.org> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1684874955; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Re+owwpIy1KS+pF22gwxWCuHaQXMtabk4QPOna1vJzY=; b=bpZ2GLPz3riFR+MrYvjYx3zUhXvhOmM1AvyKjzTj4/ANK6ucyUMTF349voGtE6Y4fwGukT rfB+1CLj2j7cscqxzrmqM+ZECuF59W7sshNW4cSyNPokd2YqqdmExTFknOcKfLo+ptO38B NiBfSDIvkObOIXAT1VvtrsWK2+8tgCA= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: Eli Zaretskii Subject: Re: bug#63513: [PATCH] Make persist-defvar work with records and hash tables Date: Tue, 23 May 2023 13:14:29 -0700 In-reply-to: <83jzx925lv.fsf@gnu.org> Message-ID: <87a5xubwoo.fsf@breatheoutbreathe.in> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63513 Cc: adam@alphapapa.net, 63513@debbugs.gnu.org, Stefan Monnier , Phillip Lord X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain The patch should now work on Emacs versions before Emacs 30. I also added tests for persisting records and hash tables. Instead of copying the updated behavior of copy-tree into persist.el, would it be more appropriate to require compat.el? Best, Joseph --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-test-persist-save-macro.patch >From 7907521e72e2e99b883912f250b7afb14cbf5e80 Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Tue, 23 May 2023 12:57:02 -0700 Subject: [PATCH 1/5] Add test-persist-save macro --- test/persist-tests.el | 76 +++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 43 deletions(-) diff --git a/test/persist-tests.el b/test/persist-tests.el index b6645a9297..0a85b78767 100644 --- a/test/persist-tests.el +++ b/test/persist-tests.el @@ -25,51 +25,41 @@ (ert-deftest test-persist-save-only-persistant () :type 'error :exclude-subtypes t)) -(ert-deftest test-persist-save () - (with-local-temp-persist - (let ((sym (cl-gensym))) - ;; precondition - (should-not (file-exists-p (persist--file-location sym))) - (set sym 10) - (persist-symbol sym 10) - (persist-save sym) - (should t) - (should-not (file-exists-p (persist--file-location sym))) - (set sym 20) - (persist-save sym) - (should (file-exists-p (persist--file-location sym))) - (should - (string-match-p - "20" - (with-temp-buffer - (insert-file-contents (persist--file-location sym)) - (buffer-string)))) - (set sym 10) - (persist-save sym) - (should-not (file-exists-p (persist--file-location sym))) - (should-error - (persist-save 'fred))))) +(defmacro test-persist-save (init default change printed-changed) + "Test persisting symbols. +- symbol is not persisted when value is set to INIT and default + value is set to DEFAULT. +- symbol is persisted when value is changed according to CHANGE. +- persisted file contents match PRINTED-CHANGED. +- symbol is not persisted after value is set back to DEFAULT." + `(with-local-temp-persist + (let ((sym (cl-gensym))) + (should-not (file-exists-p (persist--file-location sym))) + (set sym ,init) + (persist-symbol sym ,default) + (persist-save sym) + (should t) + (should-not (file-exists-p (persist--file-location sym))) + ,change + (persist-save sym) + (should (file-exists-p (persist--file-location sym))) + (should + (string-match-p + ,printed-changed + (with-temp-buffer + (insert-file-contents (persist--file-location sym)) + (buffer-string)))) + (set sym ,default) + (persist-save sym) + (should-not (file-exists-p (persist--file-location sym)))))) -(ert-deftest test-persist-save-non-number () - "Test saving something that is not a number. +(ert-deftest test-persist-save-number () + "Test saving number." + (test-persist-save 1 1 (set sym 2) "2")) -`test-persist-save' missed " - (with-local-temp-persist - (let ((sym (cl-gensym))) - (set sym "fred") - (persist-symbol sym "fred") - (persist-save sym) - (should t) - (should-not (file-exists-p (persist--file-location sym))) - (set sym "george") - (persist-save sym) - (should (file-exists-p (persist--file-location sym))) - (should - (string-match-p - "george" - (with-temp-buffer - (insert-file-contents (persist--file-location sym)) - (buffer-string))))))) +(ert-deftest test-persist-save-string () + "Test saving string." + (test-persist-save "foo" "foo" (set sym "bar") "bar")) (ert-deftest test-persist-load () (with-local-temp-persist -- 2.40.1 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-Add-persist-hash-equal.patch >From 41f90ac59a26018382d1bb9153af08ce4b9423ff Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Tue, 23 May 2023 12:52:24 -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..0069273ca2 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 `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)) + (hash-equal hash1-value hash2-value) + (equal hash1-value hash2-value)) + (throw 'flag nil)))) + hash1) + t))) + (provide 'persist) ;;; persist.el ends here -- 2.40.1 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0003-Make-persist-defvar-work-with-hash-tables.patch >From 53e166cb0c7c2624a5a54edafe8828d7b7edc612 Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Tue, 23 May 2023 13:09:29 -0700 Subject: [PATCH 3/5] Make persist-defvar work with hash tables Previously, when persist-defvar received a hash table for an initial value, updated values were not persisted. --- persist.el | 16 +++++++++++----- test/persist-tests.el | 8 ++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/persist.el b/persist.el index 0069273ca2..725f2f71cf 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 (hash-table-p initvalue) + (put symbol 'persist-default (copy-hash-table initvalue)) + (put symbol 'persist-default initvalue)))) (defun persist--persistant-p (symbol) "Return non-nil if SYMBOL is a persistant variable." @@ -132,9 +134,13 @@ (defun persist-save (symbol) (unless (persist--persistant-p symbol) (error (format "Symbol %s is not persistant" symbol))) - (let ((symbol-file-loc (persist--file-location symbol))) - (if (equal (symbol-value symbol) - (persist-default symbol)) + (let ((symbol-file-loc (persist--file-location symbol)) + (value (symbol-value symbol)) + (default (persist-default symbol))) + (if (if (and (hash-table-p value) + (hash-table-p default)) + (persist-hash-equal value default) + (equal value default)) (when (file-exists-p symbol-file-loc) (delete-file symbol-file-loc)) (let ((dir-loc @@ -148,7 +154,7 @@ (defun persist-save (symbol) (print-escape-control-characters t) (print-escape-nonascii t) (print-circle t)) - (print (symbol-value symbol) (current-buffer))) + (print value (current-buffer))) (write-region (point-min) (point-max) symbol-file-loc nil 'quiet)))))) diff --git a/test/persist-tests.el b/test/persist-tests.el index 0a85b78767..8a30a24e23 100644 --- a/test/persist-tests.el +++ b/test/persist-tests.el @@ -61,6 +61,14 @@ (ert-deftest test-persist-save-string () "Test saving string." (test-persist-save "foo" "foo" (set sym "bar") "bar")) +(ert-deftest test-persist-save-hash () + "Test saving hash table." + (let* ((hash (make-hash-table)) + (default (copy-hash-table hash))) + (test-persist-save hash default + (puthash 'foo "bar" (symbol-value sym)) + "#s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data (foo \"bar\"))"))) + (ert-deftest test-persist-load () (with-local-temp-persist (let ((sym (cl-gensym))) -- 2.40.1 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0004-Add-persist-copy-tree.patch >From ccc1be590b6c7b71aaa4ee3dd3bf25184ea7c122 Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Tue, 23 May 2023 13:43:02 -0700 Subject: [PATCH 4/5] Add persist-copy-tree The behavior of copy-tree was changed in Emacs 30. This function will ensure that persist works correctly for previous Emacs versions. --- persist.el | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/persist.el b/persist.el index 725f2f71cf..eb408b5dca 100644 --- a/persist.el +++ b/persist.el @@ -210,5 +210,34 @@ (defun persist-hash-equal (hash1 hash2) hash1) t))) + +(defun persist-copy-tree (tree &optional vectors-and-records) + "Make a copy of TREE. +If TREE is a cons cell, this recursively copies both its car and its cdr. +Contrast to `copy-sequence', which copies only along the cdrs. +With the second argument VECTORS-AND-RECORDS non-nil, this +traverses and copies vectors and records as well as conses." + (declare (side-effect-free error-free)) + (if (consp tree) + (let (result) + (while (consp tree) + (let ((newcar (car tree))) + (if (or (consp (car tree)) + (and vectors-and-records + (or (vectorp (car tree)) (recordp (car tree))))) + (setq newcar (copy-tree (car tree) vectors-and-records))) + (push newcar result)) + (setq tree (cdr tree))) + (nconc (nreverse result) + (if (and vectors-and-records (or (vectorp tree) (recordp tree))) + (copy-tree tree vectors-and-records) + tree))) + (if (and vectors-and-records (or (vectorp tree) (recordp tree))) + (let ((i (length (setq tree (copy-sequence tree))))) + (while (>= (setq i (1- i)) 0) + (aset tree i (copy-tree (aref tree i) vectors-and-records))) + tree) + tree))) + (provide 'persist) ;;; persist.el ends here -- 2.40.1 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0005-Make-persist-defvar-work-with-records.patch >From 4658bde147253d2f070b14c6f54300f640da063e Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Tue, 23 May 2023 13:44:40 -0700 Subject: [PATCH 5/5] Make persist-defvar work with records Previously, when persist-defvar received a record for an initial value, updated values were not persisted. --- persist.el | 2 +- test/persist-tests.el | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/persist.el b/persist.el index eb408b5dca..39ce54bbf0 100644 --- a/persist.el +++ b/persist.el @@ -120,7 +120,7 @@ (defun persist-symbol (symbol &optional initvalue) (put symbol 'persist t) (if (hash-table-p initvalue) (put symbol 'persist-default (copy-hash-table initvalue)) - (put symbol 'persist-default initvalue)))) + (put symbol 'persist-default (persist-copy-tree initvalue t))))) (defun persist--persistant-p (symbol) "Return non-nil if SYMBOL is a persistant variable." diff --git a/test/persist-tests.el b/test/persist-tests.el index 8a30a24e23..18b8af2b89 100644 --- a/test/persist-tests.el +++ b/test/persist-tests.el @@ -69,6 +69,14 @@ (ert-deftest test-persist-save-hash () (puthash 'foo "bar" (symbol-value sym)) "#s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data (foo \"bar\"))"))) +(ert-deftest test-persist-save-record () + "Test saving record." + (let* ((rec (record 'foo 'a 'b)) + (default (copy-sequence rec))) + (test-persist-save rec default + (setf (aref (symbol-value sym) 2) 'quux) + "#s(foo a quux)"))) + (ert-deftest test-persist-load () (with-local-temp-persist (let ((sym (cl-gensym))) -- 2.40.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 02 19:55:10 2023 Received: (at 63513) by debbugs.gnu.org; 2 Sep 2023 23:55:10 +0000 Received: from localhost ([127.0.0.1]:38906 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcaSK-0000rA-Jw for submit@debbugs.gnu.org; Sat, 02 Sep 2023 19:55:09 -0400 Received: from out-229.mta1.migadu.com ([2001:41d0:203:375::e5]:33236) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcaSE-0000qk-W4 for 63513@debbugs.gnu.org; Sat, 02 Sep 2023 19:55:07 -0400 References: <87wn1axgh6.fsf@breatheoutbreathe.in> <83jzx925lv.fsf@gnu.org> <87a5xubwoo.fsf@breatheoutbreathe.in> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1693698891; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nLl40YAhp6WQxZVAMl93dLtZgJlU88PhsUpAESaI2Qk=; b=HgwSr0ljFi7xh/ba58j3d9oOx9Gb/P4xCL1xinsIg2JIrbULVrh8ck5EJxqeiSm6LfFc/E X8oWvCVEdlZFX7ouGylfoMbp0lWM+WVAKv8azKlDK0p4tQAMkzbgt/YHzVgzmilFDecc31 taQP0AXWZ4D53aTa4badVOOBABP0D+4= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: Eli Zaretskii , Phillip Lord , Stefan Monnier , 63513@debbugs.gnu.org, adam@alphapapa.net Subject: Re: bug#63513: [PATCH] Make persist-defvar work with records and hash tables Date: Sat, 02 Sep 2023 16:54:00 -0700 In-reply-to: <87a5xubwoo.fsf@breatheoutbreathe.in> Message-ID: <87v8csku60.fsf@breatheoutbreathe.in> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63513 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain I fixed the definition of persist-hash-equal, and rebased. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-test-persist-save-macro.patch >From 6ec3955a521266e0661bbd0b2a6d1984875ae1a1 Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Tue, 23 May 2023 12:57:02 -0700 Subject: [PATCH 1/5] Add test-persist-save macro --- test/persist-tests.el | 76 +++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 43 deletions(-) diff --git a/test/persist-tests.el b/test/persist-tests.el index b6645a9297..0a85b78767 100644 --- a/test/persist-tests.el +++ b/test/persist-tests.el @@ -25,51 +25,41 @@ (ert-deftest test-persist-save-only-persistant () :type 'error :exclude-subtypes t)) -(ert-deftest test-persist-save () - (with-local-temp-persist - (let ((sym (cl-gensym))) - ;; precondition - (should-not (file-exists-p (persist--file-location sym))) - (set sym 10) - (persist-symbol sym 10) - (persist-save sym) - (should t) - (should-not (file-exists-p (persist--file-location sym))) - (set sym 20) - (persist-save sym) - (should (file-exists-p (persist--file-location sym))) - (should - (string-match-p - "20" - (with-temp-buffer - (insert-file-contents (persist--file-location sym)) - (buffer-string)))) - (set sym 10) - (persist-save sym) - (should-not (file-exists-p (persist--file-location sym))) - (should-error - (persist-save 'fred))))) +(defmacro test-persist-save (init default change printed-changed) + "Test persisting symbols. +- symbol is not persisted when value is set to INIT and default + value is set to DEFAULT. +- symbol is persisted when value is changed according to CHANGE. +- persisted file contents match PRINTED-CHANGED. +- symbol is not persisted after value is set back to DEFAULT." + `(with-local-temp-persist + (let ((sym (cl-gensym))) + (should-not (file-exists-p (persist--file-location sym))) + (set sym ,init) + (persist-symbol sym ,default) + (persist-save sym) + (should t) + (should-not (file-exists-p (persist--file-location sym))) + ,change + (persist-save sym) + (should (file-exists-p (persist--file-location sym))) + (should + (string-match-p + ,printed-changed + (with-temp-buffer + (insert-file-contents (persist--file-location sym)) + (buffer-string)))) + (set sym ,default) + (persist-save sym) + (should-not (file-exists-p (persist--file-location sym)))))) -(ert-deftest test-persist-save-non-number () - "Test saving something that is not a number. +(ert-deftest test-persist-save-number () + "Test saving number." + (test-persist-save 1 1 (set sym 2) "2")) -`test-persist-save' missed " - (with-local-temp-persist - (let ((sym (cl-gensym))) - (set sym "fred") - (persist-symbol sym "fred") - (persist-save sym) - (should t) - (should-not (file-exists-p (persist--file-location sym))) - (set sym "george") - (persist-save sym) - (should (file-exists-p (persist--file-location sym))) - (should - (string-match-p - "george" - (with-temp-buffer - (insert-file-contents (persist--file-location sym)) - (buffer-string))))))) +(ert-deftest test-persist-save-string () + "Test saving string." + (test-persist-save "foo" "foo" (set sym "bar") "bar")) (ert-deftest test-persist-load () (with-local-temp-persist -- 2.41.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-Add-persist-hash-equal.patch >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 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0003-Make-persist-defvar-work-with-hash-tables.patch >From ae35177b30bf1fabbc56ebf315b25a6074102201 Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Tue, 23 May 2023 13:09:29 -0700 Subject: [PATCH 3/5] Make persist-defvar work with hash tables Previously, when persist-defvar received a hash table for an initial value, updated values were not persisted. --- persist.el | 17 ++++++++++++----- test/persist-tests.el | 8 ++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/persist.el b/persist.el index fd0d750161..9a0ee33a65 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 (hash-table-p initvalue) + (put symbol 'persist-default (copy-hash-table initvalue)) + (put symbol 'persist-default initvalue)))) (defun persist--persistant-p (symbol) "Return non-nil if SYMBOL is a persistant variable." @@ -132,9 +134,14 @@ (defun persist-save (symbol) (unless (persist--persistant-p symbol) (error (format "Symbol %s is not persistant" symbol))) - (let ((symbol-file-loc (persist--file-location symbol))) - (if (equal (symbol-value symbol) - (persist-default symbol)) + (let* ((symbol-file-loc (persist--file-location symbol)) + (value (symbol-value symbol)) + (default (persist-default symbol)) + (value-unchanged-p (if (and (hash-table-p value) + (hash-table-p default)) + (persist-hash-equal value default) + (equal value default)))) + (if value-unchanged-p (when (file-exists-p symbol-file-loc) (delete-file symbol-file-loc)) (let ((dir-loc @@ -148,7 +155,7 @@ (defun persist-save (symbol) (print-escape-control-characters t) (print-escape-nonascii t) (print-circle t)) - (print (symbol-value symbol) (current-buffer))) + (print value (current-buffer))) (write-region (point-min) (point-max) symbol-file-loc nil 'quiet)))))) diff --git a/test/persist-tests.el b/test/persist-tests.el index 0a85b78767..8a30a24e23 100644 --- a/test/persist-tests.el +++ b/test/persist-tests.el @@ -61,6 +61,14 @@ (ert-deftest test-persist-save-string () "Test saving string." (test-persist-save "foo" "foo" (set sym "bar") "bar")) +(ert-deftest test-persist-save-hash () + "Test saving hash table." + (let* ((hash (make-hash-table)) + (default (copy-hash-table hash))) + (test-persist-save hash default + (puthash 'foo "bar" (symbol-value sym)) + "#s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data (foo \"bar\"))"))) + (ert-deftest test-persist-load () (with-local-temp-persist (let ((sym (cl-gensym))) -- 2.41.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0004-Add-persist-copy-tree.patch >From 1b06fc7efb7339c390170e2bc26e298153221f2e Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Tue, 23 May 2023 13:43:02 -0700 Subject: [PATCH 4/5] Add persist-copy-tree The behavior of copy-tree was changed in Emacs 30. This function will ensure that persist works correctly for previous Emacs versions. --- persist.el | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/persist.el b/persist.el index 9a0ee33a65..8eb0e7ba51 100644 --- a/persist.el +++ b/persist.el @@ -211,5 +211,33 @@ (defun persist-hash-equal (hash1 hash2) hash1) t))) +(defun persist-copy-tree (tree &optional vectors-and-records) + "Make a copy of TREE. +If TREE is a cons cell, this recursively copies both its car and its cdr. +Contrast to `copy-sequence', which copies only along the cdrs. +With the second argument VECTORS-AND-RECORDS non-nil, this +traverses and copies vectors and records as well as conses." + (declare (side-effect-free error-free)) + (if (consp tree) + (let (result) + (while (consp tree) + (let ((newcar (car tree))) + (if (or (consp (car tree)) + (and vectors-and-records + (or (vectorp (car tree)) (recordp (car tree))))) + (setq newcar (copy-tree (car tree) vectors-and-records))) + (push newcar result)) + (setq tree (cdr tree))) + (nconc (nreverse result) + (if (and vectors-and-records (or (vectorp tree) (recordp tree))) + (copy-tree tree vectors-and-records) + tree))) + (if (and vectors-and-records (or (vectorp tree) (recordp tree))) + (let ((i (length (setq tree (copy-sequence tree))))) + (while (>= (setq i (1- i)) 0) + (aset tree i (copy-tree (aref tree i) vectors-and-records))) + tree) + tree))) + (provide 'persist) ;;; persist.el ends here -- 2.41.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0005-Make-persist-defvar-work-with-records.patch >From afd6ea405efb1cba0ad1b1601f4af8efc796c1d7 Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Tue, 23 May 2023 13:44:40 -0700 Subject: [PATCH 5/5] Make persist-defvar work with records Previously, when persist-defvar received a record for an initial value, updated values were not persisted. --- persist.el | 2 +- test/persist-tests.el | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/persist.el b/persist.el index 8eb0e7ba51..2f3885f80e 100644 --- a/persist.el +++ b/persist.el @@ -120,7 +120,7 @@ (defun persist-symbol (symbol &optional initvalue) (put symbol 'persist t) (if (hash-table-p initvalue) (put symbol 'persist-default (copy-hash-table initvalue)) - (put symbol 'persist-default initvalue)))) + (put symbol 'persist-default (persist-copy-tree initvalue t))))) (defun persist--persistant-p (symbol) "Return non-nil if SYMBOL is a persistant variable." diff --git a/test/persist-tests.el b/test/persist-tests.el index 8a30a24e23..18b8af2b89 100644 --- a/test/persist-tests.el +++ b/test/persist-tests.el @@ -69,6 +69,14 @@ (ert-deftest test-persist-save-hash () (puthash 'foo "bar" (symbol-value sym)) "#s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data (foo \"bar\"))"))) +(ert-deftest test-persist-save-record () + "Test saving record." + (let* ((rec (record 'foo 'a 'b)) + (default (copy-sequence rec))) + (test-persist-save rec default + (setf (aref (symbol-value sym) 2) 'quux) + "#s(foo a quux)"))) + (ert-deftest test-persist-load () (with-local-temp-persist (let ((sym (cl-gensym))) -- 2.41.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 03 02:08:48 2023 Received: (at 63513) by debbugs.gnu.org; 3 Sep 2023 06:08:48 +0000 Received: from localhost ([127.0.0.1]:39093 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcgHv-0007dm-Sv for submit@debbugs.gnu.org; Sun, 03 Sep 2023 02:08:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46324) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcgHt-0007da-Vf for 63513@debbugs.gnu.org; Sun, 03 Sep 2023 02:08:46 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcgHb-0003wQ-WE; Sun, 03 Sep 2023 02:08:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=JHvwXv2kgfS1TRMIS5lJ25glpHIcrvpJN03C4G8GCP0=; b=QRVw7tgDAFWk owpBdmYP9qirq4LGAxR2KftaD7Nxz7n3VyyEnQow76aeWCm1X6u0aK8W0Zi5svbxG6w7txBG5bH5Z G+Rhxn3DXOCJUb6KqW0j23jyboXBCKmnSZRYAPbnvx3T80d0w2RptX8TMmjKwU4lhT+iiR70r7YFL mEQQoTqxRHjwea1IJZuKS7pFbo4XMEovcJaEpVhISpEtOR18ZjpCu5RmlCudvku+gwFO1VI1qp04X tFi4YAuQdR48hu2N5SR8qWHZeTcYjnfIUKvKzKIehTrWWxyDRb2pE0sldat+Stb76+bu3+ukQ/Bof mnlbfx80tO+pDIecKtRyDw==; Date: Sun, 03 Sep 2023 09:08:09 +0300 Message-Id: <83cyyz94c6.fsf@gnu.org> From: Eli Zaretskii To: Joseph Turner In-Reply-To: <87v8csku60.fsf@breatheoutbreathe.in> (message from Joseph Turner on Sat, 02 Sep 2023 16:54:00 -0700) Subject: Re: bug#63513: [PATCH] Make persist-defvar work with records and hash tables References: <87wn1axgh6.fsf@breatheoutbreathe.in> <83jzx925lv.fsf@gnu.org> <87a5xubwoo.fsf@breatheoutbreathe.in> <87v8csku60.fsf@breatheoutbreathe.in> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63513 Cc: adam@alphapapa.net, 63513@debbugs.gnu.org, monnier@iro.umontreal.ca, phillip.lord@russet.org.uk X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Joseph Turner > Date: Sat, 02 Sep 2023 16:54:00 -0700 > > I fixed the definition of persist-hash-equal, and rebased. Thanks, but this lacks the commit log messages (see CONTRIBUTE). Also, I think the new features warrant a NEWS entry. From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 03 20:33:08 2023 Received: (at 63513) by debbugs.gnu.org; 4 Sep 2023 00:33:08 +0000 Received: from localhost ([127.0.0.1]:47824 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcxWd-0007vS-Hy for submit@debbugs.gnu.org; Sun, 03 Sep 2023 20:33:08 -0400 Received: from out-223.mta0.migadu.com ([91.218.175.223]:16253) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcxWZ-0007uy-P4 for 63513@debbugs.gnu.org; Sun, 03 Sep 2023 20:33:06 -0400 References: <87wn1axgh6.fsf@breatheoutbreathe.in> <83jzx925lv.fsf@gnu.org> <87a5xubwoo.fsf@breatheoutbreathe.in> <87v8csku60.fsf@breatheoutbreathe.in> <83cyyz94c6.fsf@gnu.org> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1693787580; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IQCdd6iY749KC/QkB+FODHm8QJ70anOzncJs0tgOFGU=; b=SYFYyk0EXx+k1Ou5V/qZOZYgf2lFi4GvYVRlN68oCRbN0ETDDKrtg/fmoDb/nYQ9WuXa8B mxLAlZuI+1UMz58VE3RxE/6N/gj9566UY2yepZmjExhHJoLpMlgYf6dPUQJ5voRfBFM3HF qAovM40OBAhHO57WsaTWK9RcZP894Do= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: Eli Zaretskii Subject: Re: bug#63513: [PATCH] Make persist-defvar work with records and hash tables Date: Sun, 03 Sep 2023 17:29:22 -0700 In-reply-to: <83cyyz94c6.fsf@gnu.org> Message-ID: <87a5u2ydzg.fsf@breatheoutbreathe.in> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63513 Cc: Adam Porter , 63513@debbugs.gnu.org, monnier@iro.umontreal.ca, phillip.lord@russet.org.uk X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Eli Zaretskii writes: > Thanks, but this lacks the commit log messages (see CONTRIBUTE). I have added commit log messages. See attached patches. > Also, I think the new features warrant a NEWS entry. Should that go in the NEWS file in the main Emacs repo? I don't see a NEWS file in either of the main or externals/persist ELPA branches. Joseph --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-test-persist-save-macro.patch >From 2ca778a44c10f11059f16ef5922cf1eff9118105 Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Tue, 23 May 2023 12:57:02 -0700 Subject: [PATCH 1/5] Add test-persist-save macro * test/persist-tests.el (persist-test-persist-save): Consolidate logic of test-persist-save and test-persist-save-non-number. (test-persist-save-number test-persist-save-string): Simple wrappers over persist-test-persist-save --- test/persist-tests.el | 76 +++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 43 deletions(-) diff --git a/test/persist-tests.el b/test/persist-tests.el index b6645a9297..f2b04769ef 100644 --- a/test/persist-tests.el +++ b/test/persist-tests.el @@ -25,51 +25,41 @@ (ert-deftest test-persist-save-only-persistant () :type 'error :exclude-subtypes t)) -(ert-deftest test-persist-save () - (with-local-temp-persist - (let ((sym (cl-gensym))) - ;; precondition - (should-not (file-exists-p (persist--file-location sym))) - (set sym 10) - (persist-symbol sym 10) - (persist-save sym) - (should t) - (should-not (file-exists-p (persist--file-location sym))) - (set sym 20) - (persist-save sym) - (should (file-exists-p (persist--file-location sym))) - (should - (string-match-p - "20" - (with-temp-buffer - (insert-file-contents (persist--file-location sym)) - (buffer-string)))) - (set sym 10) - (persist-save sym) - (should-not (file-exists-p (persist--file-location sym))) - (should-error - (persist-save 'fred))))) +(defmacro persist-test-persist-save (init default change printed-changed) + "Test persisting symbols. +- symbol is not persisted when value is set to INIT and default + value is set to DEFAULT. +- symbol is persisted when value is changed according to CHANGE. +- persisted file contents match PRINTED-CHANGED. +- symbol is not persisted after value is set back to DEFAULT." + `(with-local-temp-persist + (let ((sym (cl-gensym))) + (should-not (file-exists-p (persist--file-location sym))) + (set sym ,init) + (persist-symbol sym ,default) + (persist-save sym) + (should t) + (should-not (file-exists-p (persist--file-location sym))) + ,change + (persist-save sym) + (should (file-exists-p (persist--file-location sym))) + (should + (string-match-p + ,printed-changed + (with-temp-buffer + (insert-file-contents (persist--file-location sym)) + (buffer-string)))) + (set sym ,default) + (persist-save sym) + (should-not (file-exists-p (persist--file-location sym)))))) -(ert-deftest test-persist-save-non-number () - "Test saving something that is not a number. +(ert-deftest test-persist-save-number () + "Test saving number." + (persist-test-persist-save 1 1 (set sym 2) "2")) -`test-persist-save' missed " - (with-local-temp-persist - (let ((sym (cl-gensym))) - (set sym "fred") - (persist-symbol sym "fred") - (persist-save sym) - (should t) - (should-not (file-exists-p (persist--file-location sym))) - (set sym "george") - (persist-save sym) - (should (file-exists-p (persist--file-location sym))) - (should - (string-match-p - "george" - (with-temp-buffer - (insert-file-contents (persist--file-location sym)) - (buffer-string))))))) +(ert-deftest test-persist-save-string () + "Test saving string." + (persist-test-persist-save "foo" "foo" (set sym "bar") "bar")) (ert-deftest test-persist-load () (with-local-temp-persist -- 2.41.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-Add-persist-equal.patch >From b379d8d1779e0190541ef7f8adf39dfe4d4c551a 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-equal * persist.el (persist-hash-equal): Like equal, but compares hash tables also. See bug#63671 for a discussion of built-in hash table comparison. --- persist.el | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/persist.el b/persist.el index d80943d19e..a707d038cd 100644 --- a/persist.el +++ b/persist.el @@ -187,5 +187,25 @@ (defun persist--save-all () (add-hook 'kill-emacs-hook 'persist--save-all) +(defun persist-equal (a b) + "Return non-nil when the values of A and B are equal. +A and B are compared using `equal' unless they are both hash +tables. In that case, the following are compared: + +- hash table count +- hash table predicate +- values, using `persist-equal'" + (if (and (hash-table-p a) (hash-table-p b)) + (and (= (hash-table-count a) (hash-table-count b)) + (eq (hash-table-test a) (hash-table-test b)) + (catch 'done + (maphash + (lambda (key a-value) + (unless (persist-equal a-value (gethash key b (not a-value))) + (throw 'done nil))) + a) + t)) + (equal a b))) + (provide 'persist) ;;; persist.el ends here -- 2.41.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0003-Make-persist-defvar-work-with-hash-tables.patch >From 11194569423dcdf8778a55f59dbca8f49e8b7b37 Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Sun, 3 Sep 2023 17:10:38 -0700 Subject: [PATCH 3/5] Make persist-defvar work with hash tables Previously, when persist-defvar received a hash table for an initial value, updated values were not persisted. * persist.el (persist-symbol): Use hash table copy as default so that the original table can be modified without modifying the default value. (persist-save): Use persist-equal to ensure that hash tables are correctly compared * test/persist-tests.el (test-persist-save-hash): Test hash tables persistence. --- persist.el | 8 +++++--- test/persist-tests.el | 8 ++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/persist.el b/persist.el index a707d038cd..7b2ab491d7 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 (hash-table-p initvalue) + (put symbol 'persist-default (copy-hash-table initvalue)) + (put symbol 'persist-default initvalue)))) (defun persist--persistant-p (symbol) "Return non-nil if SYMBOL is a persistant variable." @@ -133,8 +135,8 @@ (defun persist-save (symbol) (error (format "Symbol %s is not persistant" symbol))) (let ((symbol-file-loc (persist--file-location symbol))) - (if (equal (symbol-value symbol) - (persist-default symbol)) + (if (persist-equal (symbol-value symbol) + (persist-default symbol)) (when (file-exists-p symbol-file-loc) (delete-file symbol-file-loc)) (let ((dir-loc diff --git a/test/persist-tests.el b/test/persist-tests.el index f2b04769ef..90adf1c6d6 100644 --- a/test/persist-tests.el +++ b/test/persist-tests.el @@ -61,6 +61,14 @@ (ert-deftest test-persist-save-string () "Test saving string." (persist-test-persist-save "foo" "foo" (set sym "bar") "bar")) +(ert-deftest test-persist-save-hash () + "Test saving hash table." + (let* ((hash (make-hash-table)) + (default (copy-hash-table hash))) + (persist-test-persist-save hash default + (puthash 'foo "bar" (symbol-value sym)) + "#s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data (foo \"bar\"))"))) + (ert-deftest test-persist-load () (with-local-temp-persist (let ((sym (cl-gensym))) -- 2.41.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0004-Add-persist-copy-tree.patch >From f360f7ae53125a847c2a8d5762ca5f08d16445b9 Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Tue, 23 May 2023 13:43:02 -0700 Subject: [PATCH 4/5] Add persist-copy-tree The behavior of copy-tree was changed in Emacs 30. This function will ensure that persist works correctly for previous Emacs versions. * persist.el (persist-copy-tree): Add copy-tree, so that records can be compared. --- persist.el | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/persist.el b/persist.el index 7b2ab491d7..93444995f2 100644 --- a/persist.el +++ b/persist.el @@ -209,5 +209,33 @@ (defun persist-equal (a b) t)) (equal a b))) +(defun persist-copy-tree (tree &optional vectors-and-records) + "Make a copy of TREE. +If TREE is a cons cell, this recursively copies both its car and its cdr. +Contrast to `copy-sequence', which copies only along the cdrs. +With the second argument VECTORS-AND-RECORDS non-nil, this +traverses and copies vectors and records as well as conses." + (declare (side-effect-free error-free)) + (if (consp tree) + (let (result) + (while (consp tree) + (let ((newcar (car tree))) + (if (or (consp (car tree)) + (and vectors-and-records + (or (vectorp (car tree)) (recordp (car tree))))) + (setq newcar (persist-copy-tree (car tree) vectors-and-records))) + (push newcar result)) + (setq tree (cdr tree))) + (nconc (nreverse result) + (if (and vectors-and-records (or (vectorp tree) (recordp tree))) + (persist-copy-tree tree vectors-and-records) + tree))) + (if (and vectors-and-records (or (vectorp tree) (recordp tree))) + (let ((i (length (setq tree (copy-sequence tree))))) + (while (>= (setq i (1- i)) 0) + (aset tree i (persist-copy-tree (aref tree i) vectors-and-records))) + tree) + tree))) + (provide 'persist) ;;; persist.el ends here -- 2.41.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0005-Make-persist-defvar-work-with-records.patch >From ea57e6205b10678b9c26f7dcf3704e2a7acb25a7 Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Tue, 23 May 2023 13:44:40 -0700 Subject: [PATCH 5/5] Make persist-defvar work with records Previously, when persist-defvar received a record for an initial value, updated values were not persisted. * persist.el (persist-symbol): Set default to a copy of initvalue so when initvalue is a record, the original can be modified without modifying the default. * test/persist-tests.el: Test persist-save with a record. --- persist.el | 2 +- test/persist-tests.el | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/persist.el b/persist.el index 93444995f2..e43171459e 100644 --- a/persist.el +++ b/persist.el @@ -120,7 +120,7 @@ (defun persist-symbol (symbol &optional initvalue) (put symbol 'persist t) (if (hash-table-p initvalue) (put symbol 'persist-default (copy-hash-table initvalue)) - (put symbol 'persist-default initvalue)))) + (put symbol 'persist-default (persist-copy-tree initvalue t))))) (defun persist--persistant-p (symbol) "Return non-nil if SYMBOL is a persistant variable." diff --git a/test/persist-tests.el b/test/persist-tests.el index 90adf1c6d6..62d8501493 100644 --- a/test/persist-tests.el +++ b/test/persist-tests.el @@ -69,6 +69,14 @@ (ert-deftest test-persist-save-hash () (puthash 'foo "bar" (symbol-value sym)) "#s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data (foo \"bar\"))"))) +(ert-deftest test-persist-save-record () + "Test saving record." + (let* ((rec (record 'foo 'a 'b)) + (default (copy-sequence rec))) + (persist-test-persist-save rec default + (setf (aref (symbol-value sym) 2) 'quux) + "#s(foo a quux)"))) + (ert-deftest test-persist-load () (with-local-temp-persist (let ((sym (cl-gensym))) -- 2.41.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 04 04:28:09 2023 Received: (at control) by debbugs.gnu.org; 4 Sep 2023 08:28:09 +0000 Received: from localhost ([127.0.0.1]:48329 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qd4wL-0005Hn-9y for submit@debbugs.gnu.org; Mon, 04 Sep 2023 04:28:09 -0400 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]:53365) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qd4wJ-0005H7-JA for control@debbugs.gnu.org; Mon, 04 Sep 2023 04:28:07 -0400 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-500cfb168c6so1977613e87.2 for ; Mon, 04 Sep 2023 01:28:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693816082; x=1694420882; darn=debbugs.gnu.org; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=/xlOKBzmM10wrYiHalwpGpuX7ZmpVDXyJiJXE+2dEaU=; b=cQg0iUPKHt5JKGSgwKKHhM3WEX1Hn3fRVv24g4cqhKvZCbdmTNu7+gkJSVOY4OptE9 sA0uFeZuPvU+saKAItdPqV91mTUZ+z7Oeoe03Kvk85SGlcqkPYlfs34T8V9/z9JVPWf1 k9upOiNhEh05gvfud7+eS2UshNhoOa+CIjia/myFI33FsD2ifjL0m2gc64MmvC0oOHkL +cAHM4p0T3WP5GcygOajLRxxL3q7koPUR5R025C+0AzJWj3capqdHB7KjcfFeA2uNigm 6qAWXlX/F6qWhNusYViZxcSUZxPI36kiA4ixrCR5xTmSRGAPEyX5C7u45riNZdSKtnI7 YTVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693816082; x=1694420882; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=/xlOKBzmM10wrYiHalwpGpuX7ZmpVDXyJiJXE+2dEaU=; b=gbQrV75VudiPPSNUrOkljW+7odCuCDsXnRt1+hCnVFmzZB/qJ4LdDXti2M6TJlknRi cEGdXhRMmn52hOKTS2qfsgjs/vfn/cNbKvpzf1mPQaPjSfXFxyCeNpbkVI5rFIZrgrN7 fCnuXyz3EpsJevK3OilNm+FyweSnQLsSTRY7UBL4T6T2LQy6wY/0l4oGOjLlBxn95nBr S2Wwx1WtTpmqf3qskBsBnkuPAKm1khiDei3vgxFcLc0Aol5qVpbwxq8R1AT+7kxgLEYI 87xm0VjK6+eJry4SKHru+jELZLv9psPqHZHflxXEGZp/8/53nzCxsJYzNXEfwMHLs1U/ IE9Q== X-Gm-Message-State: AOJu0YyxECWrR6KpGducJ8sPtBGGHkUDRfkXegyYOZEpagQZV4wEHE7q 3rj0P/uswTM+eIl7DRh3VbJdVnkdpQgsVSpl/U9+zaGZXqQ= X-Google-Smtp-Source: AGHT+IFKQL+Bbzzgx9iEupRb9TLdVHIuQbviSD1+5RSc1aNe6JZGsf+rK36uWc4ofTAxdSq4XSalyCbqv9pNM+s7ItE= X-Received: by 2002:a19:4f4f:0:b0:500:a1e4:fc44 with SMTP id a15-20020a194f4f000000b00500a1e4fc44mr5673933lfk.61.1693816081622; Mon, 04 Sep 2023 01:28:01 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 4 Sep 2023 01:28:01 -0700 From: Stefan Kangas MIME-Version: 1.0 Date: Mon, 4 Sep 2023 01:28:01 -0700 Message-ID: Subject: control message for bug #63513 To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) severity 63513 wishlist quit From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 04 07:34:50 2023 Received: (at 63513) by debbugs.gnu.org; 4 Sep 2023 11:34:50 +0000 Received: from localhost ([127.0.0.1]:48948 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qd7r0-0001aw-Ai for submit@debbugs.gnu.org; Mon, 04 Sep 2023 07:34:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43564) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qd7qy-0001ai-8R for 63513@debbugs.gnu.org; Mon, 04 Sep 2023 07:34:49 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qd7qo-00041n-Gq; Mon, 04 Sep 2023 07:34:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=6Kj5Y50jopOWlZ+sIzCz8p5UVakY8hmNI9ujwAV7dD4=; b=K2JPxyPdpDdz snPZ5x+KCqE3rl+uIboJHNY7krDTXMePqVuAuVPSPZKyG2mqrJRFsXJJnEs13XJfCs4Wmk+B53iC4 C/f/0+q90RCbyo/dIuFARUpMNj86T+SDINWDk7j4SFmeCVNSCW7zcAwCTnJyaMmUlEAwLEMDNChI3 6NyO4Y0AUAK4FKeB5+9zUcmQiz91QwSg6is4MN1saBb8mYCn3hofP1chIjenBifAuDmBW8MOvuaHm k+otab6I8YuJyrBKcJR6pTTTRhdpTLbkCWmqXJVW4Xg9M8mXfkJwpjm4bBcFoqcHjOYhGkOiZiP2K h0v1hQCR3ZB9DV3E+iPJ8g==; Date: Mon, 04 Sep 2023 14:33:55 +0300 Message-Id: <83msy25g0s.fsf@gnu.org> From: Eli Zaretskii To: Joseph Turner In-Reply-To: <87a5u2ydzg.fsf@breatheoutbreathe.in> (message from Joseph Turner on Sun, 03 Sep 2023 17:29:22 -0700) Subject: Re: bug#63513: [PATCH] Make persist-defvar work with records and hash tables References: <87wn1axgh6.fsf@breatheoutbreathe.in> <83jzx925lv.fsf@gnu.org> <87a5xubwoo.fsf@breatheoutbreathe.in> <87v8csku60.fsf@breatheoutbreathe.in> <83cyyz94c6.fsf@gnu.org> <87a5u2ydzg.fsf@breatheoutbreathe.in> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63513 Cc: adam.porter@47ap.net, 63513@debbugs.gnu.org, monnier@iro.umontreal.ca, phillip.lord@russet.org.uk X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Joseph Turner > Cc: phillip.lord@russet.org.uk, monnier@iro.umontreal.ca, > 63513@debbugs.gnu.org, Adam Porter > Date: Sun, 03 Sep 2023 17:29:22 -0700 > > > Also, I think the new features warrant a NEWS entry. > > Should that go in the NEWS file in the main Emacs repo? I don't see a > NEWS file in either of the main or externals/persist ELPA branches. I'm terribly sorry: I haven't realized this is for ELPA, I thought it was for emacs.git. My bad Please ignore what I wrote in my previous message. From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 04 11:57:20 2023 Received: (at 63513) by debbugs.gnu.org; 4 Sep 2023 15:57:20 +0000 Received: from localhost ([127.0.0.1]:52354 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qdBx1-0006T6-SZ for submit@debbugs.gnu.org; Mon, 04 Sep 2023 11:57:20 -0400 Received: from out-228.mta1.migadu.com ([95.215.58.228]:32883) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qdBwy-0006Sw-Pk for 63513@debbugs.gnu.org; Mon, 04 Sep 2023 11:57:18 -0400 Date: Mon, 04 Sep 2023 08:57:13 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1693843035; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uhVGiid+kZKF42xZiMtFqjLDEtGIqlpPTuhcxrYO5FM=; b=Ja98pqG5/1l9Nem4PuaAJCODyV0qBJWB/YffLZWVE9XjMsvhKbQonfb+VPPHQqcQZVcRqk aOm1JdxKU+/wK41Qj5DRvbnsxE8qVvKLRrqQ7/U8qGJP7nAEc2wXxPMmf7JNM/WfOXGm1D fAkNuvocOlwqesBY1lHOgk877OyjU2Q= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: Eli Zaretskii Subject: =?US-ASCII?Q?Re=3A_bug=2363513=3A_=5BPATCH=5D_Make_persist-de?= =?US-ASCII?Q?fvar_work_with_records_and_hash_tables?= In-Reply-To: <83msy25g0s.fsf@gnu.org> References: <87wn1axgh6.fsf@breatheoutbreathe.in> <83jzx925lv.fsf@gnu.org> <87a5xubwoo.fsf@breatheoutbreathe.in> <87v8csku60.fsf@breatheoutbreathe.in> <83cyyz94c6.fsf@gnu.org> <87a5u2ydzg.fsf@breatheoutbreathe.in> <83msy25g0s.fsf@gnu.org> Message-ID: <624CBB7F-1442-400D-8D4D-1B26EBE9DACB@breatheoutbreathe.in> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63513 Cc: adam.porter@47ap.net, 63513@debbugs.gnu.org, monnier@iro.umontreal.ca, phillip.lord@russet.org.uk X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On September 4, 2023 4:33:55 AM PDT, Eli Zaretskii wrote: >> From: Joseph Turner >> Cc: phillip=2Elord@russet=2Eorg=2Euk, monnier@iro=2Eumontreal=2Eca, >> 63513@debbugs=2Egnu=2Eorg, Adam Porter >> Date: Sun, 03 Sep 2023 17:29:22 -0700 >>=20 >> > Also, I think the new features warrant a NEWS entry=2E >>=20 >> Should that go in the NEWS file in the main Emacs repo? I don't see a >> NEWS file in either of the main or externals/persist ELPA branches=2E > >I'm terribly sorry: I haven't realized this is for ELPA, I thought it >was for emacs=2Egit=2E My bad Please ignore what I wrote in my previous >message=2E No problem! It gave me a chance to do a final editing pass=2E What's the n= ext step? I would be glad for Phillip's review, if possible=2E From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 04 13:05:27 2023 Received: (at 63513) by debbugs.gnu.org; 4 Sep 2023 17:05:27 +0000 Received: from localhost ([127.0.0.1]:52454 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qdD0w-0008M3-Ka for submit@debbugs.gnu.org; Mon, 04 Sep 2023 13:05:26 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:58244) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qdD0s-0008Li-6n for 63513@debbugs.gnu.org; Mon, 04 Sep 2023 13:05:25 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 5676680729; Mon, 4 Sep 2023 13:05:16 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1693847114; bh=hqngYgonNaHLj4B9gjXfdczJun+SD/9WtWntPaTdGyg=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=NT/5wwfRuZsGs8wb2JbBpawrpzOXCkR4g+NUM/iJda+qMyk/pAeyvM9YMn1gOXG8e K0z3TO9ESZ1CBGWQ0YOahNGUfPxaiTrQd8aTygtPsN6NllNP1AF0IEgoIodN/Q0vK3 5qXq7J5OsNYxyDJZXexTQPUqtEAQcWZqYciVHHQWqnUfVotlOMFeLW9pKIiUUXfmar MMopbSF1BXJld476B30a6m69lqWTb30oXV5dscSmX8Ofs1cZG1f5AaDXbWLek6/rGv 7EKmcA3Oa1L9f75/O7kKcLeqjGYZN0Af0yQUXIZ29NqIskDtDtAkOFlqiwQW8S3uZh BMGTqBDNwtIwg== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id A4C9A8037F; Mon, 4 Sep 2023 13:05:14 -0400 (EDT) Received: from pastel (69-165-136-223.dsl.teksavvy.com [69.165.136.223]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 4BD8D12023D; Mon, 4 Sep 2023 13:05:14 -0400 (EDT) From: Stefan Monnier To: Joseph Turner Subject: Re: bug#63513: [PATCH] Make persist-defvar work with records and hash tables In-Reply-To: <624CBB7F-1442-400D-8D4D-1B26EBE9DACB@breatheoutbreathe.in> (Joseph Turner's message of "Mon, 04 Sep 2023 08:57:13 -0700") Message-ID: References: <87wn1axgh6.fsf@breatheoutbreathe.in> <83jzx925lv.fsf@gnu.org> <87a5xubwoo.fsf@breatheoutbreathe.in> <87v8csku60.fsf@breatheoutbreathe.in> <83cyyz94c6.fsf@gnu.org> <87a5u2ydzg.fsf@breatheoutbreathe.in> <83msy25g0s.fsf@gnu.org> <624CBB7F-1442-400D-8D4D-1B26EBE9DACB@breatheoutbreathe.in> User-Agent: Gnus/5.13 (Gnus v5.13) Date: Mon, 04 Sep 2023 13:05:13 -0400 MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.033 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63513 Cc: adam.porter@47ap.net, Eli Zaretskii , 63513@debbugs.gnu.org, phillip.lord@russet.org.uk X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Joseph Turner [2023-09-04 08:57:13] wrote: > On September 4, 2023 4:33:55 AM PDT, Eli Zaretskii wrote: >>> From: Joseph Turner >>> Cc: phillip.lord@russet.org.uk, monnier@iro.umontreal.ca, >>> 63513@debbugs.gnu.org, Adam Porter >>> Date: Sun, 03 Sep 2023 17:29:22 -0700 >>> >>> > Also, I think the new features warrant a NEWS entry. >>> >>> Should that go in the NEWS file in the main Emacs repo? I don't see a >>> NEWS file in either of the main or externals/persist ELPA branches. >> >>I'm terribly sorry: I haven't realized this is for ELPA, I thought it >>was for emacs.git. My bad Please ignore what I wrote in my previous >>message. > > No problem! It gave me a chance to do a final editing pass. What's the next > step? I would be glad for Phillip's review, if possible. I was about to ping Phil over on https://gitlab.com/phillord/persist/ but was reminded along the way that Phil gave me write access to that repository. Could you send me the result of your final editing pass? Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 04 18:29:38 2023 Received: (at 63513) by debbugs.gnu.org; 4 Sep 2023 22:29:38 +0000 Received: from localhost ([127.0.0.1]:52893 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qdI4f-0004yk-KR for submit@debbugs.gnu.org; Mon, 04 Sep 2023 18:29:38 -0400 Received: from out-216.mta0.migadu.com ([2001:41d0:1004:224b::d8]:12570) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qdI4c-0004yX-0j for 63513@debbugs.gnu.org; Mon, 04 Sep 2023 18:29:36 -0400 References: <87wn1axgh6.fsf@breatheoutbreathe.in> <83jzx925lv.fsf@gnu.org> <87a5xubwoo.fsf@breatheoutbreathe.in> <87v8csku60.fsf@breatheoutbreathe.in> <83cyyz94c6.fsf@gnu.org> <87a5u2ydzg.fsf@breatheoutbreathe.in> <83msy25g0s.fsf@gnu.org> <624CBB7F-1442-400D-8D4D-1B26EBE9DACB@breatheoutbreathe.in> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1693866571; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Sa4/ugtu5rW2CaQ3gIjH/YwM0qZGTQVdEqiAYNjZCLg=; b=kLYr46vtuicBQx36qKWFK19iA8R4BSkOUBesLE6rzCZgVFpG7VxopaRTAlBpj8cmUmhAKt q8w6QO7lPnJhqSYFdQxDb/sP88ZeeNpeAqDnmD+l7Jui+088lSjATbO6tR4pDq3J3f7ejH whVTJFs0Zs34VN68ZeuCvAPv9cQ1Yg0= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: Stefan Monnier Subject: Re: bug#63513: [PATCH] Make persist-defvar work with records and hash tables Date: Mon, 04 Sep 2023 15:28:15 -0700 In-reply-to: Message-ID: <877cp5bmig.fsf@breatheoutbreathe.in> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63513 Cc: Adam Porter , Eli Zaretskii , 63513@debbugs.gnu.org, phillip.lord@russet.org.uk X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Stefan Monnier writes: > I was about to ping Phil over on https://gitlab.com/phillord/persist/ > but was reminded along the way that Phil gave me write access to > that repository. > > Could you send me the result of your final editing pass? Here you go! --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-test-persist-save-macro.patch >From 2ca778a44c10f11059f16ef5922cf1eff9118105 Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Tue, 23 May 2023 12:57:02 -0700 Subject: [PATCH 1/5] Add test-persist-save macro * test/persist-tests.el (persist-test-persist-save): Consolidate logic of test-persist-save and test-persist-save-non-number. (test-persist-save-number test-persist-save-string): Simple wrappers over persist-test-persist-save --- test/persist-tests.el | 76 +++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 43 deletions(-) diff --git a/test/persist-tests.el b/test/persist-tests.el index b6645a9297..f2b04769ef 100644 --- a/test/persist-tests.el +++ b/test/persist-tests.el @@ -25,51 +25,41 @@ (ert-deftest test-persist-save-only-persistant () :type 'error :exclude-subtypes t)) -(ert-deftest test-persist-save () - (with-local-temp-persist - (let ((sym (cl-gensym))) - ;; precondition - (should-not (file-exists-p (persist--file-location sym))) - (set sym 10) - (persist-symbol sym 10) - (persist-save sym) - (should t) - (should-not (file-exists-p (persist--file-location sym))) - (set sym 20) - (persist-save sym) - (should (file-exists-p (persist--file-location sym))) - (should - (string-match-p - "20" - (with-temp-buffer - (insert-file-contents (persist--file-location sym)) - (buffer-string)))) - (set sym 10) - (persist-save sym) - (should-not (file-exists-p (persist--file-location sym))) - (should-error - (persist-save 'fred))))) +(defmacro persist-test-persist-save (init default change printed-changed) + "Test persisting symbols. +- symbol is not persisted when value is set to INIT and default + value is set to DEFAULT. +- symbol is persisted when value is changed according to CHANGE. +- persisted file contents match PRINTED-CHANGED. +- symbol is not persisted after value is set back to DEFAULT." + `(with-local-temp-persist + (let ((sym (cl-gensym))) + (should-not (file-exists-p (persist--file-location sym))) + (set sym ,init) + (persist-symbol sym ,default) + (persist-save sym) + (should t) + (should-not (file-exists-p (persist--file-location sym))) + ,change + (persist-save sym) + (should (file-exists-p (persist--file-location sym))) + (should + (string-match-p + ,printed-changed + (with-temp-buffer + (insert-file-contents (persist--file-location sym)) + (buffer-string)))) + (set sym ,default) + (persist-save sym) + (should-not (file-exists-p (persist--file-location sym)))))) -(ert-deftest test-persist-save-non-number () - "Test saving something that is not a number. +(ert-deftest test-persist-save-number () + "Test saving number." + (persist-test-persist-save 1 1 (set sym 2) "2")) -`test-persist-save' missed " - (with-local-temp-persist - (let ((sym (cl-gensym))) - (set sym "fred") - (persist-symbol sym "fred") - (persist-save sym) - (should t) - (should-not (file-exists-p (persist--file-location sym))) - (set sym "george") - (persist-save sym) - (should (file-exists-p (persist--file-location sym))) - (should - (string-match-p - "george" - (with-temp-buffer - (insert-file-contents (persist--file-location sym)) - (buffer-string))))))) +(ert-deftest test-persist-save-string () + "Test saving string." + (persist-test-persist-save "foo" "foo" (set sym "bar") "bar")) (ert-deftest test-persist-load () (with-local-temp-persist -- 2.41.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-Add-persist-equal.patch >From b379d8d1779e0190541ef7f8adf39dfe4d4c551a 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-equal * persist.el (persist-hash-equal): Like equal, but compares hash tables also. See bug#63671 for a discussion of built-in hash table comparison. --- persist.el | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/persist.el b/persist.el index d80943d19e..a707d038cd 100644 --- a/persist.el +++ b/persist.el @@ -187,5 +187,25 @@ (defun persist--save-all () (add-hook 'kill-emacs-hook 'persist--save-all) +(defun persist-equal (a b) + "Return non-nil when the values of A and B are equal. +A and B are compared using `equal' unless they are both hash +tables. In that case, the following are compared: + +- hash table count +- hash table predicate +- values, using `persist-equal'" + (if (and (hash-table-p a) (hash-table-p b)) + (and (= (hash-table-count a) (hash-table-count b)) + (eq (hash-table-test a) (hash-table-test b)) + (catch 'done + (maphash + (lambda (key a-value) + (unless (persist-equal a-value (gethash key b (not a-value))) + (throw 'done nil))) + a) + t)) + (equal a b))) + (provide 'persist) ;;; persist.el ends here -- 2.41.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0003-Make-persist-defvar-work-with-hash-tables.patch >From 11194569423dcdf8778a55f59dbca8f49e8b7b37 Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Sun, 3 Sep 2023 17:10:38 -0700 Subject: [PATCH 3/5] Make persist-defvar work with hash tables Previously, when persist-defvar received a hash table for an initial value, updated values were not persisted. * persist.el (persist-symbol): Use hash table copy as default so that the original table can be modified without modifying the default value. (persist-save): Use persist-equal to ensure that hash tables are correctly compared * test/persist-tests.el (test-persist-save-hash): Test hash tables persistence. --- persist.el | 8 +++++--- test/persist-tests.el | 8 ++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/persist.el b/persist.el index a707d038cd..7b2ab491d7 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 (hash-table-p initvalue) + (put symbol 'persist-default (copy-hash-table initvalue)) + (put symbol 'persist-default initvalue)))) (defun persist--persistant-p (symbol) "Return non-nil if SYMBOL is a persistant variable." @@ -133,8 +135,8 @@ (defun persist-save (symbol) (error (format "Symbol %s is not persistant" symbol))) (let ((symbol-file-loc (persist--file-location symbol))) - (if (equal (symbol-value symbol) - (persist-default symbol)) + (if (persist-equal (symbol-value symbol) + (persist-default symbol)) (when (file-exists-p symbol-file-loc) (delete-file symbol-file-loc)) (let ((dir-loc diff --git a/test/persist-tests.el b/test/persist-tests.el index f2b04769ef..90adf1c6d6 100644 --- a/test/persist-tests.el +++ b/test/persist-tests.el @@ -61,6 +61,14 @@ (ert-deftest test-persist-save-string () "Test saving string." (persist-test-persist-save "foo" "foo" (set sym "bar") "bar")) +(ert-deftest test-persist-save-hash () + "Test saving hash table." + (let* ((hash (make-hash-table)) + (default (copy-hash-table hash))) + (persist-test-persist-save hash default + (puthash 'foo "bar" (symbol-value sym)) + "#s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data (foo \"bar\"))"))) + (ert-deftest test-persist-load () (with-local-temp-persist (let ((sym (cl-gensym))) -- 2.41.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0004-Add-persist-copy-tree.patch >From f360f7ae53125a847c2a8d5762ca5f08d16445b9 Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Tue, 23 May 2023 13:43:02 -0700 Subject: [PATCH 4/5] Add persist-copy-tree The behavior of copy-tree was changed in Emacs 30. This function will ensure that persist works correctly for previous Emacs versions. * persist.el (persist-copy-tree): Add copy-tree, so that records can be compared. --- persist.el | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/persist.el b/persist.el index 7b2ab491d7..93444995f2 100644 --- a/persist.el +++ b/persist.el @@ -209,5 +209,33 @@ (defun persist-equal (a b) t)) (equal a b))) +(defun persist-copy-tree (tree &optional vectors-and-records) + "Make a copy of TREE. +If TREE is a cons cell, this recursively copies both its car and its cdr. +Contrast to `copy-sequence', which copies only along the cdrs. +With the second argument VECTORS-AND-RECORDS non-nil, this +traverses and copies vectors and records as well as conses." + (declare (side-effect-free error-free)) + (if (consp tree) + (let (result) + (while (consp tree) + (let ((newcar (car tree))) + (if (or (consp (car tree)) + (and vectors-and-records + (or (vectorp (car tree)) (recordp (car tree))))) + (setq newcar (persist-copy-tree (car tree) vectors-and-records))) + (push newcar result)) + (setq tree (cdr tree))) + (nconc (nreverse result) + (if (and vectors-and-records (or (vectorp tree) (recordp tree))) + (persist-copy-tree tree vectors-and-records) + tree))) + (if (and vectors-and-records (or (vectorp tree) (recordp tree))) + (let ((i (length (setq tree (copy-sequence tree))))) + (while (>= (setq i (1- i)) 0) + (aset tree i (persist-copy-tree (aref tree i) vectors-and-records))) + tree) + tree))) + (provide 'persist) ;;; persist.el ends here -- 2.41.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0005-Make-persist-defvar-work-with-records.patch >From ea57e6205b10678b9c26f7dcf3704e2a7acb25a7 Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Tue, 23 May 2023 13:44:40 -0700 Subject: [PATCH 5/5] Make persist-defvar work with records Previously, when persist-defvar received a record for an initial value, updated values were not persisted. * persist.el (persist-symbol): Set default to a copy of initvalue so when initvalue is a record, the original can be modified without modifying the default. * test/persist-tests.el: Test persist-save with a record. --- persist.el | 2 +- test/persist-tests.el | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/persist.el b/persist.el index 93444995f2..e43171459e 100644 --- a/persist.el +++ b/persist.el @@ -120,7 +120,7 @@ (defun persist-symbol (symbol &optional initvalue) (put symbol 'persist t) (if (hash-table-p initvalue) (put symbol 'persist-default (copy-hash-table initvalue)) - (put symbol 'persist-default initvalue)))) + (put symbol 'persist-default (persist-copy-tree initvalue t))))) (defun persist--persistant-p (symbol) "Return non-nil if SYMBOL is a persistant variable." diff --git a/test/persist-tests.el b/test/persist-tests.el index 90adf1c6d6..62d8501493 100644 --- a/test/persist-tests.el +++ b/test/persist-tests.el @@ -69,6 +69,14 @@ (ert-deftest test-persist-save-hash () (puthash 'foo "bar" (symbol-value sym)) "#s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data (foo \"bar\"))"))) +(ert-deftest test-persist-save-record () + "Test saving record." + (let* ((rec (record 'foo 'a 'b)) + (default (copy-sequence rec))) + (persist-test-persist-save rec default + (setf (aref (symbol-value sym) 2) 'quux) + "#s(foo a quux)"))) + (ert-deftest test-persist-load () (with-local-temp-persist (let ((sym (cl-gensym))) -- 2.41.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 05 11:08:26 2023 Received: (at 63513) by debbugs.gnu.org; 5 Sep 2023 15:08:26 +0000 Received: from localhost ([127.0.0.1]:57799 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qdXfG-0006Ka-8s for submit@debbugs.gnu.org; Tue, 05 Sep 2023 11:08:26 -0400 Received: from cloud103.planethippo.com ([78.129.138.219]:37042) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qdXf9-0006KF-OX for 63513@debbugs.gnu.org; Tue, 05 Sep 2023 11:08:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=russet.org.uk; s=default; h=Content-Transfer-Encoding:Content-Type: Message-ID:References:In-Reply-To:Subject:Cc:To:From:Date:MIME-Version:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=6lMtNNI0TY/yrNWVoBjWTKOYWRMtwEOoHy339eCG8lQ=; b=bdrT7UkwMSFHtv1tDlwKLefj11 xXESKrXTbAzsKglYDYv+1/W+zSnOK5QrOMZm/Nx4rvVSMk/cGxImH2Sxx5WF+kazAlSFFebAyPz3c XeddxHHRKyZlvkzKuUDkdG5fS0W/u39VMWfpIaFHKvgM34Qzcqo6qlXjU0W8GTjvvFUCnVHcu4Mvg szVyciHx9q1nWzjBU+kc+fq84/fPl7hxfwSGYZt+cFH83FKIBsExZGCRCi1MEvEqJfb62I/F1Xpr0 RrEqQ5ANCaG5KIdCQaFvYFXH9VzU4WW1F0xlyR5z9QkJ9+Z/FhgDq6G8F9HeD53Rz0hR9t8SszpkP 65LPE7Kg==; Received: from [::1] (port=35838 helo=cloud103.planethippo.com) by cloud103.planethippo.com with esmtpa (Exim 4.96) (envelope-from ) id 1qdXf3-0007se-2C; Tue, 05 Sep 2023 16:08:12 +0100 MIME-Version: 1.0 Date: Tue, 05 Sep 2023 16:08:11 +0100 From: phillip.lord@russet.org.uk To: Stefan Monnier Subject: Re: bug#63513: [PATCH] Make persist-defvar work with records and hash tables In-Reply-To: References: <87wn1axgh6.fsf@breatheoutbreathe.in> <83jzx925lv.fsf@gnu.org> <87a5xubwoo.fsf@breatheoutbreathe.in> <87v8csku60.fsf@breatheoutbreathe.in> <83cyyz94c6.fsf@gnu.org> <87a5u2ydzg.fsf@breatheoutbreathe.in> <83msy25g0s.fsf@gnu.org> <624CBB7F-1442-400D-8D4D-1B26EBE9DACB@breatheoutbreathe.in> User-Agent: Roundcube Webmail/1.6.0 Message-ID: <876f684b5d05e7fa75e5978900b0e61f@russet.org.uk> X-Sender: phillip.lord@russet.org.uk Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cloud103.planethippo.com X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - russet.org.uk X-Get-Message-Sender-Via: cloud103.planethippo.com: authenticated_id: phillip.lord@russet.org.uk X-Authenticated-Sender: cloud103.planethippo.com: phillip.lord@russet.org.uk X-Source: X-Source-Args: X-Source-Dir: X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63513 Cc: adam.porter@47ap.net, Eli Zaretskii , 63513@debbugs.gnu.org, Joseph Turner X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 2023-09-04 18:05, Stefan Monnier wrote: > Joseph Turner [2023-09-04 08:57:13] wrote: >> On September 4, 2023 4:33:55 AM PDT, Eli Zaretskii >> wrote: >>>> From: Joseph Turner >>>> Cc: phillip.lord@russet.org.uk, monnier@iro.umontreal.ca, >>>> 63513@debbugs.gnu.org, Adam Porter >>>> Date: Sun, 03 Sep 2023 17:29:22 -0700 >>>> >>>> > Also, I think the new features warrant a NEWS entry. >>>> >>>> Should that go in the NEWS file in the main Emacs repo? I don't see >>>> a >>>> NEWS file in either of the main or externals/persist ELPA branches. >>> >>> I'm terribly sorry: I haven't realized this is for ELPA, I thought it >>> was for emacs.git. My bad Please ignore what I wrote in my previous >>> message. >> >> No problem! It gave me a chance to do a final editing pass. What's the >> next >> step? I would be glad for Phillip's review, if possible. > > I was about to ping Phil over on https://gitlab.com/phillord/persist/ > but was reminded along the way that Phil gave me write access to > that repository. > > Could you send me the result of your final editing pass? Indeed! I am afraid I am fairly unresponsive these days ("real life" intrudes), but I am more than happy for you to update there. Phil From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 05 17:07:40 2023 Received: (at 63513-done) by debbugs.gnu.org; 5 Sep 2023 21:07:40 +0000 Received: from localhost ([127.0.0.1]:59628 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qddGp-00049S-Fh for submit@debbugs.gnu.org; Tue, 05 Sep 2023 17:07:40 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:43310) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qddGj-00049A-Du for 63513-done@debbugs.gnu.org; Tue, 05 Sep 2023 17:07:34 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 236444446A7; Tue, 5 Sep 2023 17:07:23 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1693948037; bh=F0HzwgfiYbnCyKe+mDnqMwJaPH76py4O2FAAJfhcDDM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=NKcTe8g9SnivmrhFavZkyE+IKDqQ4hHizPn2q9f853uYNH97YUOqP6W7BwOzSZE/R Ok9o8g5O8QAwp2wdczWhdX4/65EMtIf18fPZywBiZJMj2Hy8SVSgq+k+h5mbmM0C3y nygjDp5Dj9JTQGAZBYt4xxWi4gv6EZkTz8Bvc34fe9zX0MhlFq69PzKa4/DrjbzWcV 2vcr39zz4ibjyhD2/1Gr3QZMA+4QrxOJw6br7mw+NCQjP5LRO+HhT+CmomuJfVlP0N nv1i/wGSLJb/BJvsrfbnPukbrxQnjnv0i0aPBnsEuP2w8IiqzvnTooRCyHLqeirYQT ItYee+cIXNwCg== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id C5DFF4446B6; Tue, 5 Sep 2023 17:07:17 -0400 (EDT) Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 7CA8112027A; Tue, 5 Sep 2023 17:07:17 -0400 (EDT) From: Stefan Monnier To: Joseph Turner Subject: Re: bug#63513: [PATCH] Make persist-defvar work with records and hash tables In-Reply-To: <877cp5bmig.fsf@breatheoutbreathe.in> (Joseph Turner's message of "Mon, 04 Sep 2023 15:28:15 -0700") Message-ID: References: <87wn1axgh6.fsf@breatheoutbreathe.in> <83jzx925lv.fsf@gnu.org> <87a5xubwoo.fsf@breatheoutbreathe.in> <87v8csku60.fsf@breatheoutbreathe.in> <83cyyz94c6.fsf@gnu.org> <87a5u2ydzg.fsf@breatheoutbreathe.in> <83msy25g0s.fsf@gnu.org> <624CBB7F-1442-400D-8D4D-1B26EBE9DACB@breatheoutbreathe.in> <877cp5bmig.fsf@breatheoutbreathe.in> Date: Tue, 05 Sep 2023 17:06:17 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.117 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63513-done Cc: Adam Porter , Eli Zaretskii , phillip.lord@russet.org.uk, 63513-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Here you go! Thanks, pushed! Stefan From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 08 07:30:13 2023 Received: (at 63513-done) by debbugs.gnu.org; 8 Sep 2023 11:30:13 +0000 Received: from localhost ([127.0.0.1]:42355 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeZgj-0005dP-1o for submit@debbugs.gnu.org; Fri, 08 Sep 2023 07:30:13 -0400 Received: from mout02.posteo.de ([185.67.36.66]:48517) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeZge-0004yy-JM for 63513-done@debbugs.gnu.org; Fri, 08 Sep 2023 07:30:12 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id B5D50240105 for <63513-done@debbugs.gnu.org>; Fri, 8 Sep 2023 13:29:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1694172599; bh=awtcoXGbILG31DHAVkZ/2Xew9p/VWbWPsFiUOOmDsic=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=k7+N31nCiVQRaOPuXRH899rUsxF6GEumlxm68xxRON2UHpf99vCWNeVP4+L05kmxq tXUhu9+OnJrD+VcotL8HUO5kSxhAHpofFeqWxOzB2imML/U/cVXETxD7Xcmx01dEKe RcPGNBpL/Mg/yoKRKEQDgTk/Q9z2Vn8yYujH7qPBVA5pFKZrJrmZ24g67jQFCX50HE mk9NugbqZfi0/ygy3z+rS/jmm55GUJ4dwuhD+M9A9Rank4OGmWG91PaGAtz7FbVyQS 5MqZi/U+WBRkMNIgXDVy7Oj+HC7fg1W1/3/uZJP5It5vOFf21eMsVY6CSYP1Z/sTld maooS5NCxbj9w== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Rhv6G14Ppz9rxF; Fri, 8 Sep 2023 13:29:57 +0200 (CEST) From: Ihor Radchenko To: Stefan Monnier Subject: Re: bug#63513: [PATCH] Make persist-defvar work with records and hash tables In-Reply-To: References: <87wn1axgh6.fsf@breatheoutbreathe.in> <83jzx925lv.fsf@gnu.org> <87a5xubwoo.fsf@breatheoutbreathe.in> <87v8csku60.fsf@breatheoutbreathe.in> <83cyyz94c6.fsf@gnu.org> <87a5u2ydzg.fsf@breatheoutbreathe.in> <83msy25g0s.fsf@gnu.org> <624CBB7F-1442-400D-8D4D-1B26EBE9DACB@breatheoutbreathe.in> <877cp5bmig.fsf@breatheoutbreathe.in> References: <871qvz4kdw.fsf@localhost> Date: Fri, 08 Sep 2023 11:30:52 +0000 Message-ID: <8734zoaolv.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63513-done Cc: Adam Porter , Eli Zaretskii , phillip.lord@russet.org.uk, 63513-done@debbugs.gnu.org, Joseph Turner X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" writes: >> Here you go! > > Thanks, pushed! May it be possible to promote `persist-hash-equal' and `persist-copy-tree' to common subr.el functions? The topic of comparing hash tables has been previously discussed in https://yhetil.org/emacs-devel/871qvz4kdw.fsf@localhost/ -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 08 07:58:59 2023 Received: (at 63513-done) by debbugs.gnu.org; 8 Sep 2023 11:58:59 +0000 Received: from localhost ([127.0.0.1]:42440 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qea8Y-0008Qv-O6 for submit@debbugs.gnu.org; Fri, 08 Sep 2023 07:58:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37704) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qea8W-0008Qj-Uh for 63513-done@debbugs.gnu.org; Fri, 08 Sep 2023 07:58:57 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qea8M-0006il-H1; Fri, 08 Sep 2023 07:58:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=ftXrFLNSx3YufHV2q+rrPI99XMt2moLJRSO0AWjHwKo=; b=TkW3Q8sugeE5 le0AQLuk4SPQ3fq0Ny5kkGU/oYwHTDuM94e1iqlGVXe88ryhY5onqO+EzALc5cFhIlIJug9sHCiNJ EufLvCKRfEsNUpJUYq9mZQkAvCk/oDolcGZsoppTuQYVaaZqChy4F0T4S8fGAp4atAxx1/13PnSMp 5RwbExNpfXobtaHWR0TSglEuULidGMjvckNkjpWtCZtqHgFVIyHWbVSwsZ7HgWgWNaaxGuG89ySw8 hl5VJ7kSudKa8z++5QSELoMU/wy4rq5P872fbXoDg60KtQfwcHGw3HcJgpbB0yHIyGyLZfDN0+yrp KlitOrtjJO6S8w1aeY2nbQ==; Date: Fri, 08 Sep 2023 14:58:37 +0300 Message-Id: <83zg1wx4eq.fsf@gnu.org> From: Eli Zaretskii To: Ihor Radchenko In-Reply-To: <8734zoaolv.fsf@localhost> (message from Ihor Radchenko on Fri, 08 Sep 2023 11:30:52 +0000) Subject: Re: bug#63513: [PATCH] Make persist-defvar work with records and hash tables References: <871qvz4kdw.fsf@localhost> <87wn1axgh6.fsf@breatheoutbreathe.in> <83jzx925lv.fsf@gnu.org> <87a5xubwoo.fsf@breatheoutbreathe.in> <87v8csku60.fsf@breatheoutbreathe.in> <83cyyz94c6.fsf@gnu.org> <87a5u2ydzg.fsf@breatheoutbreathe.in> <83msy25g0s.fsf@gnu.org> <624CBB7F-1442-400D-8D4D-1B26EBE9DACB@breatheoutbreathe.in> <877cp5bmig.fsf@breatheoutbreathe.in> <8734zoaolv.fsf@localhost> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63513-done Cc: adam@alphapapa.net, phillip.lord@russet.org.uk, 63513-done@debbugs.gnu.org, monnier@iro.umontreal.ca, joseph@breatheoutbreathe.in X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Ihor Radchenko > Cc: Joseph Turner , Adam Porter > , Eli Zaretskii , > phillip.lord@russet.org.uk, 63513-done@debbugs.gnu.org > Date: Fri, 08 Sep 2023 11:30:52 +0000 > > May it be possible to promote `persist-hash-equal' and > `persist-copy-tree' to common subr.el functions? Why do we need them in subr.el, i.e. preloaded? Why cannot these functions be autoloaded instead? From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 08 08:05:46 2023 Received: (at 63513-done) by debbugs.gnu.org; 8 Sep 2023 12:05:46 +0000 Received: from localhost ([127.0.0.1]:42449 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeaEt-0002on-W3 for submit@debbugs.gnu.org; Fri, 08 Sep 2023 08:05:46 -0400 Received: from mout02.posteo.de ([185.67.36.66]:59659) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeaEg-0002oB-DY for 63513-done@debbugs.gnu.org; Fri, 08 Sep 2023 08:05:30 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id BBD9E240103 for <63513-done@debbugs.gnu.org>; Fri, 8 Sep 2023 14:05:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1694174709; bh=b3C/Kx2JBQTzF76/hDhBgTH6yFhxTOpexqHjXjcNX24=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=IA948hTtN2000j5rbV0XHRPi2vnTSIf6XkcLpJoLYV+uc2CLZZBADBhrplHUuI8fD PuM8Vwz80cA7MP2+33EuOUQrMVlyQTsbuPsFgpyfqjrPnk5p7gClgK/WbXcNQ+FqIA ZimbM0Qxj2msgxPlLz1N5VHy5LWrQ0nPQjnKlxOcMq/wWqb2/ZGiagIhHCQszIGPe0 umPljarSOYz7ERvFbIj4nh+62sHw08nnzB0pOnngKIuAvU2U9wIwMbP+sV9O8TECL9 4bRs0+io7xCtoNitJ+XSLxg0RatEM0ddAp7SghK5MEcZ1nP1GtYYXAcBjlfxOQOHWh 6HU9NQuZSwtaQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Rhvtq6XJJz9rxN; Fri, 8 Sep 2023 14:05:07 +0200 (CEST) From: Ihor Radchenko To: Eli Zaretskii Subject: Re: bug#63513: [PATCH] Make persist-defvar work with records and hash tables In-Reply-To: <83zg1wx4eq.fsf@gnu.org> References: <871qvz4kdw.fsf@localhost> <87wn1axgh6.fsf@breatheoutbreathe.in> <83jzx925lv.fsf@gnu.org> <87a5xubwoo.fsf@breatheoutbreathe.in> <87v8csku60.fsf@breatheoutbreathe.in> <83cyyz94c6.fsf@gnu.org> <87a5u2ydzg.fsf@breatheoutbreathe.in> <83msy25g0s.fsf@gnu.org> <624CBB7F-1442-400D-8D4D-1B26EBE9DACB@breatheoutbreathe.in> <877cp5bmig.fsf@breatheoutbreathe.in> <8734zoaolv.fsf@localhost> <83zg1wx4eq.fsf@gnu.org> Date: Fri, 08 Sep 2023 12:06:06 +0000 Message-ID: <87wmx098ep.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63513-done Cc: adam@alphapapa.net, phillip.lord@russet.org.uk, 63513-done@debbugs.gnu.org, monnier@iro.umontreal.ca, joseph@breatheoutbreathe.in X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> May it be possible to promote `persist-hash-equal' and >> `persist-copy-tree' to common subr.el functions? > > Why do we need them in subr.el, i.e. preloaded? Why cannot these > functions be autoloaded instead? Similar functions - `string-equal-ignore-case' and `copy-tree' - are already in subr.el. I do not see why the new functions discussed here should be any different. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 08 08:46:38 2023 Received: (at 63513-done) by debbugs.gnu.org; 8 Sep 2023 12:46:38 +0000 Received: from localhost ([127.0.0.1]:42538 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeasf-0003sd-Lz for submit@debbugs.gnu.org; Fri, 08 Sep 2023 08:46:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45348) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qease-0003sR-6I for 63513-done@debbugs.gnu.org; Fri, 08 Sep 2023 08:46:36 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeasS-0006Qv-Jb; Fri, 08 Sep 2023 08:46:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=js/rDTzQbABt9fHmTEt1x2HGX3VfELXA+dorm8uvt0Y=; b=NCxTbSYxkPLg aeOq2jkg6uNRW6h/BO9JlwXt1p4XxImda0Iwrhj2cZH/hg1zuDxJUEA0kBe08Z9qNU5dU18MQmedK ly96bquUTTOqm+ZsDdhiJAhcUjqGWQ9l5gDQHa/dLkt8doPyXrRWMWLBXA8gngwLdRfXs9OtIWZK9 YRlhRDxE6CntmX+859DboKoc3636NH1YGBRQH3sYU9xIhRVkOmVxJtutLenbFYRS+NBzcZ8BfAqbA LsbvqtQusUgvF8SIvrOQqz3Ikj9Qjy0I+BLf6E6srIvK3JZpD3+HIxXEfKBs9zeEkn9/U0ANzq5rj pXoRQxktI94ZW4DomKlvLA==; Date: Fri, 08 Sep 2023 15:46:14 +0300 Message-Id: <83sf7ox27d.fsf@gnu.org> From: Eli Zaretskii To: Ihor Radchenko In-Reply-To: <87wmx098ep.fsf@localhost> (message from Ihor Radchenko on Fri, 08 Sep 2023 12:06:06 +0000) Subject: Re: bug#63513: [PATCH] Make persist-defvar work with records and hash tables References: <871qvz4kdw.fsf@localhost> <87wn1axgh6.fsf@breatheoutbreathe.in> <83jzx925lv.fsf@gnu.org> <87a5xubwoo.fsf@breatheoutbreathe.in> <87v8csku60.fsf@breatheoutbreathe.in> <83cyyz94c6.fsf@gnu.org> <87a5u2ydzg.fsf@breatheoutbreathe.in> <83msy25g0s.fsf@gnu.org> <624CBB7F-1442-400D-8D4D-1B26EBE9DACB@breatheoutbreathe.in> <877cp5bmig.fsf@breatheoutbreathe.in> <8734zoaolv.fsf@localhost> <83zg1wx4eq.fsf@gnu.org> <87wmx098ep.fsf@localhost> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63513-done Cc: adam@alphapapa.net, phillip.lord@russet.org.uk, 63513-done@debbugs.gnu.org, monnier@iro.umontreal.ca, joseph@breatheoutbreathe.in X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Ihor Radchenko > Cc: monnier@iro.umontreal.ca, joseph@breatheoutbreathe.in, > adam@alphapapa.net, phillip.lord@russet.org.uk, 63513-done@debbugs.gnu.org > Date: Fri, 08 Sep 2023 12:06:06 +0000 > > Eli Zaretskii writes: > > >> May it be possible to promote `persist-hash-equal' and > >> `persist-copy-tree' to common subr.el functions? > > > > Why do we need them in subr.el, i.e. preloaded? Why cannot these > > functions be autoloaded instead? > > Similar functions - `string-equal-ignore-case' and `copy-tree' - are > already in subr.el. I do not see why the new functions discussed here > should be any different. We make the decision whether a function must be preloaded in a case by case basis, to avoid making the memory footprint of an Emacs session larger than it needs to be. So arguments "by similarity" are not useful in this case; you need to explain why you think these functions are needed right from the startup. Valid reasons include, among others: . function is used by the startup code or during dumping . function is used by all or many important configurations immediately after startup From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 08 08:50:56 2023 Received: (at 63513-done) by debbugs.gnu.org; 8 Sep 2023 12:50:56 +0000 Received: from localhost ([127.0.0.1]:42543 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeawq-00043H-FN for submit@debbugs.gnu.org; Fri, 08 Sep 2023 08:50:56 -0400 Received: from mout02.posteo.de ([185.67.36.66]:42183) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeawm-000431-Jb for 63513-done@debbugs.gnu.org; Fri, 08 Sep 2023 08:50:55 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 76B00240101 for <63513-done@debbugs.gnu.org>; Fri, 8 Sep 2023 14:50:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1694177444; bh=i4bEbkqakMyYypFMjRGiEGCWDfq8ykgYQJLbxaIHVbA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=NF3IdIVkQe1J+lqXlpfyp8wlpgiyNzl3lvnubw10dXS14x7akTkp2MgW1SjgRWjf+ M2H5moabvg34yjReYInl04I5NVP+Q0mWvAotXL2KqdiBTfMDRZxSBz6L6wk3Ju3HBO 6skCcYCdc9oHHdIZVW/1GAJ+/FzMJigsW0RuyJJXkOVsSQqOdGs82GOYaF5K5R1LTZ sqjiN9coIXSGpyGxt23plm6/qG6XvnEm9AuhT3M09kVX0iegWSVFZgWAl3FHi76REM 0oneX3gB5qfU4x7UOhIEVxqCGvW1Ea6pWH6r32pK1GSzyOpaMvLbbQIMiiElQ9umDr DuL0kEFfoy2ig== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4RhwvQ2yVhz6tvZ; Fri, 8 Sep 2023 14:50:42 +0200 (CEST) From: Ihor Radchenko To: Eli Zaretskii Subject: Re: bug#63513: [PATCH] Make persist-defvar work with records and hash tables In-Reply-To: <83sf7ox27d.fsf@gnu.org> References: <871qvz4kdw.fsf@localhost> <87wn1axgh6.fsf@breatheoutbreathe.in> <83jzx925lv.fsf@gnu.org> <87a5xubwoo.fsf@breatheoutbreathe.in> <87v8csku60.fsf@breatheoutbreathe.in> <83cyyz94c6.fsf@gnu.org> <87a5u2ydzg.fsf@breatheoutbreathe.in> <83msy25g0s.fsf@gnu.org> <624CBB7F-1442-400D-8D4D-1B26EBE9DACB@breatheoutbreathe.in> <877cp5bmig.fsf@breatheoutbreathe.in> <8734zoaolv.fsf@localhost> <83zg1wx4eq.fsf@gnu.org> <87wmx098ep.fsf@localhost> <83sf7ox27d.fsf@gnu.org> Date: Fri, 08 Sep 2023 12:51:41 +0000 Message-ID: <87msxw96aq.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63513-done Cc: adam@alphapapa.net, phillip.lord@russet.org.uk, 63513-done@debbugs.gnu.org, monnier@iro.umontreal.ca, joseph@breatheoutbreathe.in X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Eli Zaretskii writes: >> > Why do we need them in subr.el, i.e. preloaded? Why cannot these >> > functions be autoloaded instead? >> >> Similar functions - `string-equal-ignore-case' and `copy-tree' - are >> already in subr.el. I do not see why the new functions discussed here >> should be any different. > > We make the decision whether a function must be preloaded in a case by > case basis, to avoid making the memory footprint of an Emacs session > larger than it needs to be. So arguments "by similarity" are not > useful in this case; you need to explain why you think these functions > are needed right from the startup. > ... Got it. Then, I do not insist on subr.el specifically. Autoloading is fine. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 08 12:36:48 2023 Received: (at 63513-done) by debbugs.gnu.org; 8 Sep 2023 16:36:48 +0000 Received: from localhost ([127.0.0.1]:45352 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeeTQ-0001Zz-Iq for submit@debbugs.gnu.org; Fri, 08 Sep 2023 12:36:48 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:21198) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeeTO-0001Zl-44 for 63513-done@debbugs.gnu.org; Fri, 08 Sep 2023 12:36:47 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 1982780861; Fri, 8 Sep 2023 12:36:38 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1694190996; bh=v1OcwmwBpoBvTswgqGSoFTHUQaP9EiO1wshch6JUOCU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=IgEq2cw5X2G2Lh4ZRf9jtlkArWc+N2bo1E0VN+I5I51RuuvG7MKnCzr8VMMCZZOFO SBqdRX87X7hiThXDBfunLFvcCY6IvlvwvfP6o+AmdlXyN41z4C6rWZt5dCsD9i2J40 hSVNEkTdUxJYr56x5wkU29Vm/hgNEKnXK/PLjU2BD72J1RfYxSwc0ATMl5IAMZsBRx TAeFLmw0T7YCHhH7ZuiPn1ikBCw/hpS7DZKIuVsEk+qaKjQxVfI/clwmc9W4IIu7Is O0CgH/OWvUOgz3fUamYmPdRdcPJnamzm912LdK35dA8tp4qtM2nOiRz270Fj2HHQPx w3HDOwqnuSGXg== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 90DB38014C; Fri, 8 Sep 2023 12:36:36 -0400 (EDT) Received: from alfajor (unknown [23.233.149.155]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 39F3A120264; Fri, 8 Sep 2023 12:36:36 -0400 (EDT) From: Stefan Monnier To: Ihor Radchenko Subject: Re: bug#63513: [PATCH] Make persist-defvar work with records and hash tables In-Reply-To: <8734zoaolv.fsf@localhost> (Ihor Radchenko's message of "Fri, 08 Sep 2023 11:30:52 +0000") Message-ID: References: <87wn1axgh6.fsf@breatheoutbreathe.in> <83jzx925lv.fsf@gnu.org> <87a5xubwoo.fsf@breatheoutbreathe.in> <87v8csku60.fsf@breatheoutbreathe.in> <83cyyz94c6.fsf@gnu.org> <87a5u2ydzg.fsf@breatheoutbreathe.in> <83msy25g0s.fsf@gnu.org> <624CBB7F-1442-400D-8D4D-1B26EBE9DACB@breatheoutbreathe.in> <877cp5bmig.fsf@breatheoutbreathe.in> <871qvz4kdw.fsf@localhost> <8734zoaolv.fsf@localhost> Date: Fri, 08 Sep 2023 12:36:35 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.032 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63513-done Cc: Adam Porter , Eli Zaretskii , phillip.lord@russet.org.uk, 63513-done@debbugs.gnu.org, Joseph Turner X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >>> Here you go! >> Thanks, pushed! > May it be possible to promote `persist-hash-equal' and > `persist-copy-tree' to common subr.el functions? > The topic of comparing hash tables has been previously discussed in > https://yhetil.org/emacs-devel/871qvz4kdw.fsf@localhost/ Hmm... AFAICT `persist-copy-tree` is a copy of our current `copy-tree`, so there's nothing to do there :-) As for `persist-hash-equal` (which is actually called `persist-equal`, AFAICT), I think if we want to move it out of `persist.el` we need to improve it so it also looks inside hash-tables that occur within vectors, conses, etc... Maybe, like Sam Steingold suggested, we should simply consider the current treatment of `equal` on hash-tables to be a bug. Stefan From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 08 13:05:28 2023 Received: (at 63513-done) by debbugs.gnu.org; 8 Sep 2023 17:05:28 +0000 Received: from localhost ([127.0.0.1]:45443 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeevA-00059k-3C for submit@debbugs.gnu.org; Fri, 08 Sep 2023 13:05:28 -0400 Received: from mout02.posteo.de ([185.67.36.66]:55243) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeev6-00059G-FD for 63513-done@debbugs.gnu.org; Fri, 08 Sep 2023 13:05:26 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 05069240101 for <63513-done@debbugs.gnu.org>; Fri, 8 Sep 2023 19:05:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1694192716; bh=EytoX/f6Dt6gDSYr+WqS4lG8meXTKPZ8sSn6ytTrJMg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=ZLCAu+a0vcaPAisp0qVcLHAqLq0kPxf723JeEC/Q/ePhNW+jgcr6grp/XrDZgji0B F/D7Xh4d+BVthyCUJGyAMmLT4DNUk6ieCXLt+7vRMjTygHTrwSXR0B4EMfcr3PxCGR 4JWZOYLb4q7g1lQRhP+J3RdAujafyTcIqByILUeu3dZxcGMV/aJGLxeWPeAHYRm+J4 aqdXriqaEJ4fCkH4VlKxzolRdNCiau5aOoAUYy6wHrXRGHphgUDPUXmdbHq5O2T809 JOkQ6Tslrw3KY5dxclN6jVTuVbK0xMSoSP+d0nTY2oG0m13ykUiYRSY/gpog9dOFd9 7coL5E2o1Hfww== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Rj2Y64t0Tz6twC; Fri, 8 Sep 2023 19:05:14 +0200 (CEST) From: Ihor Radchenko To: Stefan Monnier Subject: Re: bug#63513: [PATCH] Make persist-defvar work with records and hash tables In-Reply-To: References: <87wn1axgh6.fsf@breatheoutbreathe.in> <83jzx925lv.fsf@gnu.org> <87a5xubwoo.fsf@breatheoutbreathe.in> <87v8csku60.fsf@breatheoutbreathe.in> <83cyyz94c6.fsf@gnu.org> <87a5u2ydzg.fsf@breatheoutbreathe.in> <83msy25g0s.fsf@gnu.org> <624CBB7F-1442-400D-8D4D-1B26EBE9DACB@breatheoutbreathe.in> <877cp5bmig.fsf@breatheoutbreathe.in> <871qvz4kdw.fsf@localhost> <8734zoaolv.fsf@localhost> Date: Fri, 08 Sep 2023 17:06:10 +0000 Message-ID: <87fs3o8uil.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63513-done Cc: Adam Porter , Eli Zaretskii , phillip.lord@russet.org.uk, 63513-done@debbugs.gnu.org, Joseph Turner X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Stefan Monnier writes: >>>> Here you go! >>> Thanks, pushed! >> May it be possible to promote `persist-hash-equal' and >> `persist-copy-tree' to common subr.el functions? >> The topic of comparing hash tables has been previously discussed in >> https://yhetil.org/emacs-devel/871qvz4kdw.fsf@localhost/ > > Hmm... AFAICT `persist-copy-tree` is a copy of our current `copy-tree`, > so there's nothing to do there :-) Err... Then, wouldn't it be better to contribute this function to compat.el and use it from there? > As for `persist-hash-equal` (which is actually called `persist-equal`, > AFAICT), I think if we want to move it out of `persist.el` we need to > improve it so it also looks inside hash-tables that occur within > vectors, conses, etc... > > Maybe, like Sam Steingold suggested, we should simply consider the > current treatment of `equal` on hash-tables to be a bug. That thread had no progress for quite a while. I thought that having `hash-equal' function could at least be an improvement (clearly, it is being used =F0=9F=99=82). But if you have an idea how to move the original discussion forward, please share it. AFAIU, no actionable conclusion have been reached in the linked thread. --=20 Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 08 13:17:36 2023 Received: (at 63513-done) by debbugs.gnu.org; 8 Sep 2023 17:17:36 +0000 Received: from localhost ([127.0.0.1]:45473 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qef6t-0005Tv-Sw for submit@debbugs.gnu.org; Fri, 08 Sep 2023 13:17:36 -0400 Received: from out-230.mta1.migadu.com ([2001:41d0:203:375::e6]:10413) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qef6p-0005Tf-Lw for 63513-done@debbugs.gnu.org; Fri, 08 Sep 2023 13:17:33 -0400 References: <87wn1axgh6.fsf@breatheoutbreathe.in> <83jzx925lv.fsf@gnu.org> <87a5xubwoo.fsf@breatheoutbreathe.in> <87v8csku60.fsf@breatheoutbreathe.in> <83cyyz94c6.fsf@gnu.org> <87a5u2ydzg.fsf@breatheoutbreathe.in> <83msy25g0s.fsf@gnu.org> <624CBB7F-1442-400D-8D4D-1B26EBE9DACB@breatheoutbreathe.in> <877cp5bmig.fsf@breatheoutbreathe.in> <871qvz4kdw.fsf@localhost> <8734zoaolv.fsf@localhost> <87fs3o8uil.fsf@localhost> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1694193446; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Hlx0gFIEstxnXX7baduMM/IaMyn+hZkQR20L21IaRGk=; b=nDdL1K1L2IS3pA61RZWKzTa2F3QXQVwbhS2LTbqQrKvbYbWYhDPdVMdysrGcq1qv/WPlNT qOLUaFKIy73OCqXp24mGz67vGkS0yswK504MSUxhzaAAjZiek6/zc7tp3OCYgMvMkprYWq 9+erxpVzLbPuqYwIiuzwIM8oUrKFn3I= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: Ihor Radchenko Subject: Re: bug#63513: [PATCH] Make persist-defvar work with records and hash tables Date: Fri, 08 Sep 2023 10:10:58 -0700 In-reply-to: <87fs3o8uil.fsf@localhost> Message-ID: <87msxwa8kd.fsf@breatheoutbreathe.in> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63513-done Cc: Adam Porter , Eli Zaretskii , 63513-done@debbugs.gnu.org, Stefan Monnier , phillip.lord@russet.org.uk X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Ihor Radchenko writes: > Stefan Monnier writes: > >>>>> Here you go! >>>> Thanks, pushed! >>> May it be possible to promote `persist-hash-equal' and >>> `persist-copy-tree' to common subr.el functions? >>> The topic of comparing hash tables has been previously discussed in >>> https://yhetil.org/emacs-devel/871qvz4kdw.fsf@localhost/ >> >> Hmm... AFAICT `persist-copy-tree` is a copy of our current `copy-tree`, >> so there's nothing to do there :-) > > Err... > Then, wouldn't it be better to contribute this function to compat.el and > use it from there? The new behavior of copy-tree has already been added to compat.el: https://github.com/emacs-compat/compat/pull/25 However, that change currently only exists in compat's emacs-30 branch. I did not know if it was acceptable for persist.el to require compat when I wrote these patches. If we agree that it is acceptable, then I'm happy to submit a patch to replace (persist-copy-tree ...) with (compat-call copy-tree ...), but we'll have to wait to apply the patch until after the compat.el emacs-30 branch is merged into master. From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 09 06:00:47 2023 Received: (at 63513-done) by debbugs.gnu.org; 9 Sep 2023 10:00:47 +0000 Received: from localhost ([127.0.0.1]:46167 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeulj-0002HW-1J for submit@debbugs.gnu.org; Sat, 09 Sep 2023 06:00:47 -0400 Received: from mout02.posteo.de ([185.67.36.66]:46821) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeulf-0002HH-FG for 63513-done@debbugs.gnu.org; Sat, 09 Sep 2023 06:00:45 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 9DD64240104 for <63513-done@debbugs.gnu.org>; Sat, 9 Sep 2023 12:00:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1694253634; bh=YSE3T6FlWNatdnEmS/qv1Jv5Q7IqQlUuSlfyknUd+OA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=KV9NIgISiPi3Dsv4wPAsJpc+oAMPdB4IcZbjJNJ4SVTdbujW6En8JOMM6JBwKG36f Vs1+yRWa+TCu7MpTLQMSlPtBdTVyNGdYvKZ2S58PFxznTg+dN85EuorAKxVZ27H3mj ozPJGBVlLB1QI1KpuqtC3ET9sfAUrLdAYWCVjzvzjvbeyTzL0te10VA2eLzz6Mmb3d 5oh25382puKjFVr7wvyAWsy4LLXZD73ldSO7RHTj/WTz4mU9I3q1RSuMddSgDdSOpR snT0Nz+zu15yCXlVDVcCl0j2wnBC62TlYFNauMLNDYCb4NcAqSxFa0tqJYAbJIJbs7 luFXtNreJa0mw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4RjT4d0xfpz6tsf; Sat, 9 Sep 2023 12:00:32 +0200 (CEST) From: Ihor Radchenko To: Joseph Turner Subject: Re: bug#63513: [PATCH] Make persist-defvar work with records and hash tables In-Reply-To: <87msxwa8kd.fsf@breatheoutbreathe.in> References: <87wn1axgh6.fsf@breatheoutbreathe.in> <83jzx925lv.fsf@gnu.org> <87a5xubwoo.fsf@breatheoutbreathe.in> <87v8csku60.fsf@breatheoutbreathe.in> <83cyyz94c6.fsf@gnu.org> <87a5u2ydzg.fsf@breatheoutbreathe.in> <83msy25g0s.fsf@gnu.org> <624CBB7F-1442-400D-8D4D-1B26EBE9DACB@breatheoutbreathe.in> <877cp5bmig.fsf@breatheoutbreathe.in> <871qvz4kdw.fsf@localhost> <8734zoaolv.fsf@localhost> <87fs3o8uil.fsf@localhost> <87msxwa8kd.fsf@breatheoutbreathe.in> Date: Sat, 09 Sep 2023 10:01:34 +0000 Message-ID: <87il8j7ji9.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63513-done Cc: 63513-done@debbugs.gnu.org, Daniel Mendler , Stefan Monnier , Adam Porter , Eli Zaretskii , phillip.lord@russet.org.uk X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Joseph Turner writes: >> Then, wouldn't it be better to contribute this function to compat.el and >> use it from there? > > The new behavior of copy-tree has already been added to compat.el: > > https://github.com/emacs-compat/compat/pull/25 > > However, that change currently only exists in compat's emacs-30 branch. I see. > I did not know if it was acceptable for persist.el to require compat > when I wrote these patches. If we agree that it is acceptable, then I'm > happy to submit a patch to replace (persist-copy-tree ...) with > (compat-call copy-tree ...), but we'll have to wait to apply the patch > until after the compat.el emacs-30 branch is merged into master. AFAIU, the recommended way to implement compat function definitions that are not yet added to compat.el is using `compat-defun' + `compat-call'. Then, one can simply drop `compat-defun' after the function is finally release with compat.el without touching the rest of the code. CCing Daniel. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 09 06:15:57 2023 Received: (at 63513-done) by debbugs.gnu.org; 9 Sep 2023 10:15:57 +0000 Received: from localhost ([127.0.0.1]:46179 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qev0O-0002cx-Su for submit@debbugs.gnu.org; Sat, 09 Sep 2023 06:15:57 -0400 Received: from server.qxqx.de ([2a01:4f8:121:346::180]:49937 helo=mail.qxqx.de) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qev0J-0002ch-NA for 63513-done@debbugs.gnu.org; Sat, 09 Sep 2023 06:15:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=qxqx.de; s=mail1392553390; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Iqa9ChEwncVV2n87uiy0ol2ablJYDUEjr7pQcQu7IFg=; b=IC6AeTs09LKff9j0IAPU2GVWj/ SOvqZDI61FiS0JVb46bT64UG8JoSz5z2gR9Xe52xN9XsiABa76BorDrZvPQ6EzuAmtbMslxTnq9Qy r6b2nXkOaSvKvXJvUXedcylNc4FyZOUNIhLy1Vwl4HA2IM66hMgu1SxZs93iw7LIzXEw=; Message-ID: <80479897-500e-fe60-6586-0a44ccb5993b@daniel-mendler.de> Date: Sat, 9 Sep 2023 12:15:31 +0200 MIME-Version: 1.0 Subject: Re: bug#63513: [PATCH] Make persist-defvar work with records and hash tables To: Ihor Radchenko , Joseph Turner References: <87wn1axgh6.fsf@breatheoutbreathe.in> <83jzx925lv.fsf@gnu.org> <87a5xubwoo.fsf@breatheoutbreathe.in> <87v8csku60.fsf@breatheoutbreathe.in> <83cyyz94c6.fsf@gnu.org> <87a5u2ydzg.fsf@breatheoutbreathe.in> <83msy25g0s.fsf@gnu.org> <624CBB7F-1442-400D-8D4D-1B26EBE9DACB@breatheoutbreathe.in> <877cp5bmig.fsf@breatheoutbreathe.in> <871qvz4kdw.fsf@localhost> <8734zoaolv.fsf@localhost> <87fs3o8uil.fsf@localhost> <87msxwa8kd.fsf@breatheoutbreathe.in> <87il8j7ji9.fsf@localhost> Content-Language: en-US From: Daniel Mendler In-Reply-To: <87il8j7ji9.fsf@localhost> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63513-done Cc: Adam Porter , Eli Zaretskii , 63513-done@debbugs.gnu.org, Stefan Monnier , phillip.lord@russet.org.uk X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) On 9/9/23 12:01, Ihor Radchenko wrote: > Joseph Turner writes: > >>> Then, wouldn't it be better to contribute this function to compat.el and >>> use it from there? >> >> The new behavior of copy-tree has already been added to compat.el: >> >> https://github.com/emacs-compat/compat/pull/25 >> >> However, that change currently only exists in compat's emacs-30 branch. > > I see. > >> I did not know if it was acceptable for persist.el to require compat >> when I wrote these patches. If we agree that it is acceptable, then I'm >> happy to submit a patch to replace (persist-copy-tree ...) with >> (compat-call copy-tree ...), but we'll have to wait to apply the patch >> until after the compat.el emacs-30 branch is merged into master. > > AFAIU, the recommended way to implement compat function definitions that > are not yet added to compat.el is using `compat-defun' + `compat-call'. > Then, one can simply drop `compat-defun' after the function is finally > release with compat.el without touching the rest of the code. `compat-call` is meant to be used to call "extended functions", for example functions with additional arguments. See the Compat manual for details. The macros from compat-macs.el (`compat-defun` etc.) are internal as documented in the file compat-macs.el. These macros must not be used outside Compat. So using Compat here has to wait until compat-30.x is released. Daniel From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 09 07:34:15 2023 Received: (at 63513-done) by debbugs.gnu.org; 9 Sep 2023 11:34:15 +0000 Received: from localhost ([127.0.0.1]:46296 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qewEA-0007Pt-Qd for submit@debbugs.gnu.org; Sat, 09 Sep 2023 07:34:15 -0400 Received: from mout01.posteo.de ([185.67.36.65]:45745) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qewE7-0007Pe-Ff for 63513-done@debbugs.gnu.org; Sat, 09 Sep 2023 07:34:13 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 078B624002A for <63513-done@debbugs.gnu.org>; Sat, 9 Sep 2023 13:34:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1694259243; bh=BGv4jTmjr0AxKLnsFMml2v1s75pD9v/38kohjQi8ueY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=ZI7rladmrHNb3NywYUMN57PMjo5AZ5RRqm4pY3ojrjTFtne0N+k8ZgEUcRFv1RWA9 tJ9aZZo16tdZQ0ojKbktoFNQhqdtZyvxJOAL8jvHlD0miTVeM4QhyujUyIy9/rSCBi xLdsjHQoyc4cJ2ycSG9VCb8vY9zB9UF30Rsvi1Wps4+oAGOrYb9nXK0YOHvlwHktrG U37HqA9HuyCfu5ER0hHHEZ8JkcEBs2ds1cGlxD859LTw4EDBs8iB35fSDN1FQX4/37 Z9Mf8ohk4m+DcS+hoELgJ+l2YgQKxZ6KTgWblr0DOwqepgUl+5r/A2mm7xEz1rhkVQ v04/LTgkK8fZw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4RjW8T5h9kz9rxG; Sat, 9 Sep 2023 13:34:01 +0200 (CEST) From: Ihor Radchenko To: Daniel Mendler Subject: Re: bug#63513: [PATCH] Make persist-defvar work with records and hash tables In-Reply-To: <80479897-500e-fe60-6586-0a44ccb5993b@daniel-mendler.de> References: <87wn1axgh6.fsf@breatheoutbreathe.in> <83jzx925lv.fsf@gnu.org> <87a5xubwoo.fsf@breatheoutbreathe.in> <87v8csku60.fsf@breatheoutbreathe.in> <83cyyz94c6.fsf@gnu.org> <87a5u2ydzg.fsf@breatheoutbreathe.in> <83msy25g0s.fsf@gnu.org> <624CBB7F-1442-400D-8D4D-1B26EBE9DACB@breatheoutbreathe.in> <877cp5bmig.fsf@breatheoutbreathe.in> <871qvz4kdw.fsf@localhost> <8734zoaolv.fsf@localhost> <87fs3o8uil.fsf@localhost> <87msxwa8kd.fsf@breatheoutbreathe.in> <87il8j7ji9.fsf@localhost> <80479897-500e-fe60-6586-0a44ccb5993b@daniel-mendler.de> Date: Sat, 09 Sep 2023 11:35:02 +0000 Message-ID: <877coz7f6h.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63513-done Cc: 63513-done@debbugs.gnu.org, Joseph Turner , Stefan Monnier , Adam Porter , Eli Zaretskii , phillip.lord@russet.org.uk X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Daniel Mendler writes: >> AFAIU, the recommended way to implement compat function definitions that >> are not yet added to compat.el is using `compat-defun' + `compat-call'. >> Then, one can simply drop `compat-defun' after the function is finally >> release with compat.el without touching the rest of the code. > > `compat-call` is meant to be used to call "extended functions", for > example functions with additional arguments. See the Compat manual for > details. > > The macros from compat-macs.el (`compat-defun` etc.) are internal as > documented in the file compat-macs.el. These macros must not be used > outside Compat. > > So using Compat here has to wait until compat-30.x is released. And do I understand correctly that compat-30 will only be released after Emacs 30 is released? If so, it is awkward for :core packages. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 09 07:57:57 2023 Received: (at 63513-done) by debbugs.gnu.org; 9 Sep 2023 11:57:57 +0000 Received: from localhost ([127.0.0.1]:46328 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qewb7-00082l-H0 for submit@debbugs.gnu.org; Sat, 09 Sep 2023 07:57:57 -0400 Received: from server.qxqx.de ([2a01:4f8:121:346::180]:48137 helo=mail.qxqx.de) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qewb3-00082W-Qm for 63513-done@debbugs.gnu.org; Sat, 09 Sep 2023 07:57:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=qxqx.de; s=mail1392553390; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=60Z+GC0HGqBpEDq9pVdiPizPfnPiisrEDIpG8C6kDN0=; b=EbKOp1AQVZGKaX0DONrXcIZuIc uO9J0JsR/pAc2NKAbXWV/J4PXWWi9qfMhv7p3RWAWMG50z9d8f+Eozq2134W26HkbR5KSW6kBuA2C zMSdcgdGctFkCoaEMl9wKZcengek8w3d9hDwOhryBmXYz/oDODGW4oDee7NsScnhvXi8=; Message-ID: <86d6e412-9e5b-9086-56ce-e3794085096a@daniel-mendler.de> Date: Sat, 9 Sep 2023 13:57:27 +0200 MIME-Version: 1.0 Subject: Re: bug#63513: [PATCH] Make persist-defvar work with records and hash tables To: Ihor Radchenko References: <87wn1axgh6.fsf@breatheoutbreathe.in> <83jzx925lv.fsf@gnu.org> <87a5xubwoo.fsf@breatheoutbreathe.in> <87v8csku60.fsf@breatheoutbreathe.in> <83cyyz94c6.fsf@gnu.org> <87a5u2ydzg.fsf@breatheoutbreathe.in> <83msy25g0s.fsf@gnu.org> <624CBB7F-1442-400D-8D4D-1B26EBE9DACB@breatheoutbreathe.in> <877cp5bmig.fsf@breatheoutbreathe.in> <871qvz4kdw.fsf@localhost> <8734zoaolv.fsf@localhost> <87fs3o8uil.fsf@localhost> <87msxwa8kd.fsf@breatheoutbreathe.in> <87il8j7ji9.fsf@localhost> <80479897-500e-fe60-6586-0a44ccb5993b@daniel-mendler.de> <877coz7f6h.fsf@localhost> Content-Language: en-US From: Daniel Mendler In-Reply-To: <877coz7f6h.fsf@localhost> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63513-done Cc: 63513-done@debbugs.gnu.org, Joseph Turner , Stefan Monnier , Adam Porter , Eli Zaretskii , phillip.lord@russet.org.uk X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) On 9/9/23 13:35, Ihor Radchenko wrote: >> So using Compat here has to wait until compat-30.x is released. > > And do I understand correctly that compat-30 will only be released after > Emacs 30 is released? If so, it is awkward for :core packages. compat-30 can be released as soon as Emacs 30 has been reasonably stabilized, e.g., when the emacs-30 branch has been frozen, or a bit before that. We cannot release much earlier since APIs may still change and it is probably undesired to release unfinished APIs to the public too early. For reference, I've created the compat-29.1.1 release around the day that Eli announced the emacs-29 branch freeze. Daniel From unknown Sat Sep 06 05:55:35 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 08 Oct 2023 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator