[Top][All Lists]

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

bug#30786: Save text properties in desktop

From: Juri Linkov
Subject: bug#30786: Save text properties in desktop
Date: Mon, 02 Apr 2018 22:41:13 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)

>>> If the only problem is with non-readable property values then we could
>>> check for such values and not to write them to the desktop file.
>>> > Maybe solving Bug#24982 would help?

There is also bug#17090.

>>> This would help on reading the desktop, but maybe better not to save
>>> non-readable values in the first place.
>> No.  If the problem is reading then that's where the solution
>> should be located - not writing.  It has happened quite a few
>> times that something unreadable by Emacs has later become
>> readable.
> You mean the print syntax changes to become readable?  But not that
> Emacs can later read some unreadable #<...> syntax, right?

Even when the print syntax becomes readable in later versions, we still
can't write such syntax because earlier Emacs versions should be able
to read the same desktop file.

> That could be useful in general, but solving this particular bug by
> avoiding writing unreadable objects as Juri suggests seems okay too (and
> much less work, hence more likely to actually happen instead of just
> sitting for years).

Do you think this patch covers all possible unreadable cases on writing?

diff --git a/lisp/desktop.el b/lisp/desktop.el
index 55ec71c..4f98658 100644
--- a/lisp/desktop.el
+++ b/lisp/desktop.el
@@ -841,10 +841,12 @@ desktop--v2s
     ((or (numberp value) (null value) (eq t value) (keywordp value))
      (cons 'may value))
     ((stringp value)
-     (let ((copy (copy-sequence value)))
-       (set-text-properties 0 (length copy) nil copy)
-       ;; Get rid of text properties because we cannot read them.
-       (cons 'may copy)))
+     ;; Get rid of unreadable text properties.
+     (if (ignore-errors (read (format "%S" value)))
+         (cons 'may value)
+       (let ((copy (copy-sequence value)))
+         (set-text-properties 0 (length copy) nil copy)
+         (cons 'may copy))))
     ((symbolp value)
      (cons 'must value))
     ((vectorp value)

reply via email to

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