diff --git a/store.el b/store.el index ec33c3c530bbcf0ae64e6efe73e27c34e1884e88..6cb637322835d7c76ae3a39cd916f91355ae9581 100644 --- a/store.el +++ b/store.el @@ -51,6 +51,7 @@ (require 'cl-lib) (require 'cl-generic) +(require 'url) ;;; Customs (defgroup persistence nil "Persistence facility." @@ -153,7 +154,9 @@ Return the new list with VALUE removed." ;;; General Utilities (defsubst store--print (form) - (let ((print-length nil) (print-level nil)) + (let ((print-length nil) + (print-level nil) + (print-circle t)) (prin1 form (current-buffer))) (insert "\n")) @@ -318,9 +321,14 @@ Arrange for compacting if log count exceeds (compact-ratio * size-of-table)." ;; We normalize PATH right away, saving future hassles. (store-fs--make :path (file-name-as-directory path))) +;;We allow some more chars that is usually safe, and makes printed Lisp objects more readable +(defvar store-fs--path-allowed-chars (cl-list* ?\ ?\( ?\) ?\[ ?\] ?\# url-unreserved-chars)) (defsubst store-fs--key-to-path (key store) - ;; TODO: escape illegal characters - (concat (store-fs--path store) (prin1-to-string key))) + (concat (store-fs--path store) + (let ((print-length nil) + (print-level nil)) + (url-hexify-string (prin1-to-string key) store-fs--path-allowed-chars)))) + (cl-defmethod store-put (key value (store store-fs)) (with-temp-buffer (store--print value)