branch: externals/embark commit 47bec292ee1837ee8cb30ad4b071311bc876c9ad Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@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."