emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/embark 47bec29 1/2: Instead of a serialization check, o


From: ELPA Syncer
Subject: [elpa] externals/embark 47bec29 1/2: Instead of a serialization check, overwrite serialization/deserialization
Date: Thu, 18 Nov 2021 11:57:15 -0500 (EST)

branch: externals/embark
commit 47bec292ee1837ee8cb30ad4b071311bc876c9ad
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Instead of a serialization check, overwrite serialization/deserialization
---
 embark.el | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/embark.el b/embark.el
index 03c8495..8cf7e96 100644
--- a/embark.el
+++ b/embark.el
@@ -2904,16 +2904,22 @@ PRED is a predicate function used to filter the items."
 
 (defun embark-export-customize-variable (variables)
   "Create a customization buffer listing VARIABLES."
-  (embark--export-customize
-   variables "Variables" 'custom-variable
-   (lambda (sym)
-     (and (boundp sym)
-          (condition-case nil
-              ;; Check if variable can be properly deserialized.
-              ;; The customization widget relies on this.
-              (let ((val (symbol-value sym)))
-                (or (read (format "%S" val)) t))
-            (t nil))))))
+  ;; The widget library serializes/deserializes the values.
+  ;; We advise the serialization in order to avoid errors for nonserializable 
variables.
+  (cl-letf* ((ht (make-hash-table :test #'equal))
+             (orig-read (symbol-function #'read))
+             (orig-write (symbol-function #'widget-sexp-value-to-internal))
+             ((symbol-function #'read)
+              (lambda (&optional str)
+                (condition-case nil
+                    (funcall orig-read str)
+                  (error (gethash str ht)))))
+             ((symbol-function #'widget-sexp-value-to-internal)
+              (lambda (widget val)
+                (let ((str (funcall orig-write widget val)))
+                  (puthash str val ht)
+                  str))))
+    (embark--export-customize variables "Variables" 'custom-variable 
#'boundp)))
 
 (defun embark-export-ibuffer (buffers)
   "Create an ibuffer buffer listing BUFFERS."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]