branch: elpa/extmap commit 07223c2cd9885a2b8bf1b3c997792c773b91bd2f Author: Paul Pogonyshev <pogonys...@gmail.com> Commit: Paul Pogonyshev <pogonys...@gmail.com>
Add a workaround for value compression not working in some cases on Emacs 27. --- extmap.el | 8 +++++++- test/extmap-test.el | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/extmap.el b/extmap.el index 07bc93b701..a574b885d9 100644 --- a/extmap.el +++ b/extmap.el @@ -405,7 +405,13 @@ Only available on Emacs 25, as this requires `generator' package." (when canonical-subvalues (clrhash canonical-subvalues) (setq value (extmap--compress-value value canonical-subvalues))) - (prin1-to-string value))))) + ;; Workaround for Emacs (27?) not using the print circle for + ;; strings on the first level. At this point I no longer care to + ;; report bugs in Emacs. Fuck it, it's faster and easier to just + ;; add workarounds + (if (stringp value) + (prin1-to-string value) + (substring (prin1-to-string (list value)) 1 -1)))))) (unless (or (extmap--plain-string-p value) (condition-case _ (equal (read serialized) value) (error nil))) (error "Value for key `%s' cannot be saved in database: it cannot be read back or is different after reading" key)) ;; The whole point of this buffer is to be used for diff --git a/test/extmap-test.el b/test/extmap-test.el index b1d570609b..545cd56fa7 100644 --- a/test/extmap-test.el +++ b/test/extmap-test.el @@ -90,6 +90,13 @@ (should (eq (nth 2 bar) (cdr (nth 3 bar)))) (should-not (eq foo bar)))) +(ert-deftest extmap-compressed-values-2 () + ;; Targeted at a specific bug in Emacs. Extmap adds a workaround for it. + (let* ((extmap (extmap--test-alist `((foo . ("some long string" "some long string"))) + :compress-values t :max-inline-bytes 0)) + (foo (extmap-get extmap 'foo))) + (should (eq (nth 0 foo) (nth 1 foo))))) + (ert-deftest extmap-plain-string-p () (should (extmap--plain-string-p "foo"))