GNU bug report logs -
#30786
Save text properties in desktop
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Mon, 12 Mar 2018 22:00:02 UTC
Severity: normal
Fixed in version 27.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 30786 in the body.
You can then email your comments to 30786 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30786
; Package
emacs
.
(Mon, 12 Mar 2018 22:00:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Juri Linkov <juri <at> linkov.net>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Mon, 12 Mar 2018 22:00:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Why does desktop.el not save text properties?
Maybe for some historical reasons?
This is required for bug#22479.
I can't find a problem while trying this patch:
diff --git a/lisp/desktop.el b/lisp/desktop.el
index 8bd4465..a7e549f 100644
--- a/lisp/desktop.el
+++ b/lisp/desktop.el
@@ -852,10 +852,7 @@ 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)))
+ (cons 'may value))
((symbolp value)
(cons 'must value))
((vectorp value)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30786
; Package
emacs
.
(Tue, 13 Mar 2018 01:17:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 30786 <at> debbugs.gnu.org (full text, mbox):
Juri Linkov <juri <at> linkov.net> writes:
> Why does desktop.el not save text properties?
> Maybe for some historical reasons?
> This is required for bug#22479.
> I can't find a problem while trying this patch:
> - (let ((copy (copy-sequence value)))
> - (set-text-properties 0 (length copy) nil copy)
> - ;; Get rid of text properties because we cannot read them.
I guess this comment is relevant, you can easily have non-readable
property values, e.g.: (put-text-property 1 2 'foo (point-marker)).
Maybe solving Bug#24982 would help?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30786
; Package
emacs
.
(Tue, 13 Mar 2018 22:00:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 30786 <at> debbugs.gnu.org (full text, mbox):
>> Why does desktop.el not save text properties?
>> Maybe for some historical reasons?
>> This is required for bug#22479.
>> I can't find a problem while trying this patch:
>
>> - (let ((copy (copy-sequence value)))
>> - (set-text-properties 0 (length copy) nil copy)
>> - ;; Get rid of text properties because we cannot read them.
>
> I guess this comment is relevant, you can easily have non-readable
> property values, e.g.: (put-text-property 1 2 'foo (point-marker)).
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?
This would help on reading the desktop, but maybe better not to save
non-readable values in the first place.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30786
; Package
emacs
.
(Wed, 14 Mar 2018 01:11:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 30786 <at> debbugs.gnu.org (full text, mbox):
> > I guess this comment is relevant, you can easily have non-readable
> > property values, e.g.: (put-text-property 1 2 'foo (point-marker)).
>
> 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?
>
> 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.
One of the important motivations behind bug #24982 is to let
Emacs version N be able to read (by ignoring) constructs that
it finds are unreadable but that are readable in Emacs version
N + M.
The sooner we get that bug fixed, the more versions of Emacs
will be able to benefit from it. Users and code should be
able to make Emacs tolerant of read errors (by ignoring them).
We have `condition-case' for most errors. We have little or
no control over read errors.
Dunno whether we need a complete read-error-handling construct
a la `condition-case', but we at least need a way to let Emacs
ignore all read errors. And preferably within some scope (e.g.
let-bind a variable).
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30786
; Package
emacs
.
(Wed, 14 Mar 2018 02:38:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 30786 <at> debbugs.gnu.org (full text, mbox):
Drew Adams <drew.adams <at> oracle.com> writes:
>> 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?
>>
>> 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?
> We have `condition-case' for most errors. We have little or
> no control over read errors.
>
> Dunno whether we need a complete read-error-handling construct
> a la `condition-case', but we at least need a way to let Emacs
> ignore all read errors. And preferably within some scope (e.g.
> let-bind a variable).
`condition-case' works for read errors too, afaik, but you're suggesting
a different kind of control is needed. Something more like Common Lisp
restart-case, I guess?
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).
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30786
; Package
emacs
.
(Wed, 14 Mar 2018 20:10:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 30786 <at> debbugs.gnu.org (full text, mbox):
> >> > Maybe solving Bug#24982 would help?
> >>
> >> 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?
I mean what I said further down: a given syntax is not readable
in Emacs version N (e.g. 20), and so raises an error there, but
it is readable in Emacs N+M (e.g. 22). If we had provided a
way in version N of ignoring such error raising then that would
let you read the rest of a file (for example), ignoring syntax
that is illegal in Emacs N.
> > We have `condition-case' for most errors. We have little or
> > no control over read errors.
> >
> > Dunno whether we need a complete read-error-handling construct
> > a la `condition-case', but we at least need a way to let Emacs
> > ignore all read errors. And preferably within some scope (e.g.
> > let-bind a variable).
>
> `condition-case' works for read errors too, afaik,
Can you specify a particular read error to handle/ignore?
> but you're suggesting a different kind of control is needed.
> Something more like Common Lisp restart-case, I guess?
Dunno. I actually am not familiar with CL `restart-case', or
else I've forgotten it. Perhaps it was added after CLTL1?
> 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).
It's fine not to write unreadable objects here.
It's better to provide a simple way to not provoke a read
error for such objects. It's a read problem, not a write
problem.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30786
; Package
emacs
.
(Mon, 02 Apr 2018 19:56:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 30786 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
>>> 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?
[desktop-text-properties.patch (text/x-diff, inline)]
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)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30786
; Package
emacs
.
(Mon, 02 Apr 2018 21:49:01 GMT)
Full text and
rfc822 format available.
Message #26 received at 30786 <at> debbugs.gnu.org (full text, mbox):
Juri Linkov <juri <at> linkov.net> writes:
> 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.
> Do you think this patch covers all possible unreadable cases on writing?
> + ;; 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))))
I think it won't cover the case where an object's print syntax is only
readable by the current Emacs version, and not an earlier one. To
handle that you'll need to call desktop--v2s recursively, like in the
vectorp and consp branches.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30786
; Package
emacs
.
(Tue, 03 Apr 2018 20:15:02 GMT)
Full text and
rfc822 format available.
Message #29 received at 30786 <at> debbugs.gnu.org (full text, mbox):
>> Do you think this patch covers all possible unreadable cases on writing?
>>
>> + ;; 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))))
>
> I think it won't cover the case where an object's print syntax is only
> readable by the current Emacs version, and not an earlier one. To
> handle that you'll need to call desktop--v2s recursively, like in the
> vectorp and consp branches.
I don't understand how calling desktop--v2s recursively will ensure its
readability in earlier versions? For example, if Emacs 27 will write to
the desktop file ‘#("foo" 0 3 (bar 42))’ how Emacs 19 can read it?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30786
; Package
emacs
.
(Tue, 03 Apr 2018 22:02:02 GMT)
Full text and
rfc822 format available.
Message #32 received at 30786 <at> debbugs.gnu.org (full text, mbox):
Juri Linkov <juri <at> linkov.net> writes:
>>> Do you think this patch covers all possible unreadable cases on writing?
>>>
>>> + ;; 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))))
>>
>> I think it won't cover the case where an object's print syntax is only
>> readable by the current Emacs version, and not an earlier one. To
>> handle that you'll need to call desktop--v2s recursively, like in the
>> vectorp and consp branches.
>
> I don't understand how calling desktop--v2s recursively will ensure its
> readability in earlier versions? For example, if Emacs 27 will write to
> the desktop file ‘#("foo" 0 3 (bar 42))’ how Emacs 19 can read it?
Ah, I wasn't thinking of the #(...) specifically, rather about the
values of text properties, e.g.,
(cl-defstruct foo f1 f2)
(desktop--v2s (make-foo :f1 1 :f2 2)) ;=> (may . "Unprintable entity")
So desktop--v2s considers structs as unprintable, unlike read, hence
using desktop--v2s recursively instead of read will catch properties
that would otherwise be unreadable in Emacs 25.
If we want to support Emacs versions that don't even know about #(...)
then we can't write string properties at all, I guess.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30786
; Package
emacs
.
(Wed, 04 Apr 2018 20:04:02 GMT)
Full text and
rfc822 format available.
Message #35 received at 30786 <at> debbugs.gnu.org (full text, mbox):
>>>> Do you think this patch covers all possible unreadable cases on writing?
>>>>
>>>> + ;; 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))))
>>>
>>> I think it won't cover the case where an object's print syntax is only
>>> readable by the current Emacs version, and not an earlier one. To
>>> handle that you'll need to call desktop--v2s recursively, like in the
>>> vectorp and consp branches.
>>
>> I don't understand how calling desktop--v2s recursively will ensure its
>> readability in earlier versions? For example, if Emacs 27 will write to
>> the desktop file ‘#("foo" 0 3 (bar 42))’ how Emacs 19 can read it?
>
> Ah, I wasn't thinking of the #(...) specifically, rather about the
> values of text properties, e.g.,
>
> (cl-defstruct foo f1 f2)
> (desktop--v2s (make-foo :f1 1 :f2 2)) ;=> (may . "Unprintable entity")
>
> So desktop--v2s considers structs as unprintable, unlike read, hence
> using desktop--v2s recursively instead of read will catch properties
> that would otherwise be unreadable in Emacs 25.
>
> If we want to support Emacs versions that don't even know about #(...)
> then we can't write string properties at all, I guess.
If we can afford continuing incrementing the desktop file version in
‘desktop-file-version’ doing this every time when support for reading more
syntaxes is added, thus preventing incompatibilities, then the patch above
would be the most reliable solution.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30786
; Package
emacs
.
(Sat, 07 Apr 2018 13:09:01 GMT)
Full text and
rfc822 format available.
Message #38 received at 30786 <at> debbugs.gnu.org (full text, mbox):
Juri Linkov <juri <at> linkov.net> writes:
>>>>> + ;; 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))))
> If we can afford continuing incrementing the desktop file version in
> ‘desktop-file-version’ doing this every time when support for reading more
> syntaxes is added, thus preventing incompatibilities, then the patch above
> would be the most reliable solution.
You would also have to strip text properties according to the value of
desktop-file-version, right?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30786
; Package
emacs
.
(Sat, 07 Apr 2018 20:52:02 GMT)
Full text and
rfc822 format available.
Message #41 received at 30786 <at> debbugs.gnu.org (full text, mbox):
>>>>>> + ;; 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))))
>
>> If we can afford continuing incrementing the desktop file version in
>> ‘desktop-file-version’ doing this every time when support for reading more
>> syntaxes is added, thus preventing incompatibilities, then the patch above
>> would be the most reliable solution.
>
> You would also have to strip text properties according to the value of
> desktop-file-version, right?
This won't help for the counterexample that you demonstrated earlier with
(put-text-property 1 2 'foo (point-marker)). Whereas this patch does.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30786
; Package
emacs
.
(Sun, 08 Apr 2018 01:55:02 GMT)
Full text and
rfc822 format available.
Message #44 received at 30786 <at> debbugs.gnu.org (full text, mbox):
Juri Linkov <juri <at> linkov.net> writes:
>>>>>>> + ;; 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))))
>>
>>> If we can afford continuing incrementing the desktop file version in
>>> ‘desktop-file-version’ doing this every time when support for reading more
>>> syntaxes is added, thus preventing incompatibilities, then the patch above
>>> would be the most reliable solution.
>>
>> You would also have to strip text properties according to the value of
>> desktop-file-version, right?
>
> This won't help for the counterexample that you demonstrated earlier with
> (put-text-property 1 2 'foo (point-marker)). Whereas this patch does.
Sorry, I don't think I explained my point very well above.
Using `read' to check readability can only test which objects are
readable in the current Emacs version. So if we rely on that, then we
can only reliably produce desktop files compatible with the current
version. Which means the only thing that desktop-file-version helps
with is giving a slightly better error message, yes?
(I don't think this is necessarily a deal-breaker, as long as it's well
documented)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30786
; Package
emacs
.
(Sun, 08 Apr 2018 20:16:02 GMT)
Full text and
rfc822 format available.
Message #47 received at 30786 <at> debbugs.gnu.org (full text, mbox):
>>>>>>>> + ;; 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))))
>>>
>>>> If we can afford continuing incrementing the desktop file version in
>>>> ‘desktop-file-version’ doing this every time when support for reading more
>>>> syntaxes is added, thus preventing incompatibilities, then the patch above
>>>> would be the most reliable solution.
>>>
>>> You would also have to strip text properties according to the value of
>>> desktop-file-version, right?
>>
>> This won't help for the counterexample that you demonstrated earlier with
>> (put-text-property 1 2 'foo (point-marker)). Whereas this patch does.
>
> Sorry, I don't think I explained my point very well above.
>
> Using `read' to check readability can only test which objects are
> readable in the current Emacs version. So if we rely on that, then we
> can only reliably produce desktop files compatible with the current
> version. Which means the only thing that desktop-file-version helps
> with is giving a slightly better error message, yes?
>
> (I don't think this is necessarily a deal-breaker, as long as it's well
> documented)
Yes, just better error handling (like what in bug#24982 was asked to do),
nothing more, so it's not a deal-breaker.
Currently I see no better way than in the aforementioned patch.
At least it provides 100% guarantee of readability of the desktop file
in the same version that wrote it.
But earlier versions will have an incompatibility problem anyway.
Let's suppose that Emacs 27 will support reading point-markers and writes
them to the desktop file for good. Then naturally Emacs 26 will fail
to read such desktop files either way: explicitly by comparing
version numbers, or implicitly by inability to parse the new syntax.
Reply sent
to
Juri Linkov <juri <at> linkov.net>
:
You have taken responsibility.
(Thu, 19 Apr 2018 20:34:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Juri Linkov <juri <at> linkov.net>
:
bug acknowledged by developer.
(Thu, 19 Apr 2018 20:34:03 GMT)
Full text and
rfc822 format available.
Message #52 received at 30786-done <at> debbugs.gnu.org (full text, mbox):
Version: 27.0.50
> Currently I see no better way than in the aforementioned patch.
> At least it provides 100% guarantee of readability of the desktop file
> in the same version that wrote it.
Additionally I found out that savehist uses the same solution,
so it's consistent to do the same, pushed to master as 99de04e.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 18 May 2018 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 7 years and 32 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.