[Top][All Lists]

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

[elpa] externals/embark 6e064fc 2/2: Merge pull request #411 from minad/

From: ELPA Syncer
Subject: [elpa] externals/embark 6e064fc 2/2: Merge pull request #411 from minad/fix-var-export2
Date: Thu, 18 Nov 2021 11:57:15 -0500 (EST)

branch: externals/embark
commit 6e064fcff8b65c94daae88a11894da4c70e01c73
Merge: 514b130 47bec29
Author: Omar AntolĂ­n Camarena <omar.antolin@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #411 from minad/fix-var-export2
    Instead of a serialization check, overwrite `read`
 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 
+  (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 
 (defun embark-export-ibuffer (buffers)
   "Create an ibuffer buffer listing BUFFERS."

reply via email to

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