* saving/restoring text and overlays
@ 2020-03-26 4:14 Leo Butler
2020-03-26 22:23 ` Michael Heerdegen
0 siblings, 1 reply; 8+ messages in thread
From: Leo Butler @ 2020-03-26 4:14 UTC (permalink / raw)
To: help-gnu-emacs
If I have a buffer with, e.g. display properties set to images, how can
I save that to disk and re-open the saved data so that emacs displays the
same "stuff"? I am not looking to export the buffer using html or latex
or any other markup. I just want to be able to save the formatting
information so that another emacs instance can display exactly the same
document.
I can see how this might be cobbled together by a save-file hook that
stuffs (buffer-substring) of a narrowed buffer into an Eval: stanza at
the end of file. But I am hoping that there is a pre-existing mode that
does what I want.
TIA,
Leo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: saving/restoring text and overlays
2020-03-26 4:14 saving/restoring text and overlays Leo Butler
@ 2020-03-26 22:23 ` Michael Heerdegen
2020-03-29 20:21 ` Leo Butler
0 siblings, 1 reply; 8+ messages in thread
From: Michael Heerdegen @ 2020-03-26 22:23 UTC (permalink / raw)
To: Leo Butler; +Cc: help-gnu-emacs
Leo Butler <leo.butler@umanitoba.ca> writes:
> If I have a buffer with, e.g. display properties set to images, how can
> I save that to disk and re-open the saved data so that emacs displays the
> same "stuff"? I am not looking to export the buffer using html or latex
> or any other markup.
Without _any_ form of markup? No, Emacs can't save buffers containing
images directly to a file.
We often had a discussion whether `enriched-mode' should be improved, or
something new could be created, to do what you want (among other things
like saving text properties). But nobody has done it yet.
Michael.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: saving/restoring text and overlays
2020-03-26 22:23 ` Michael Heerdegen
@ 2020-03-29 20:21 ` Leo Butler
2020-03-30 0:14 ` Michael Heerdegen
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Leo Butler @ 2020-03-29 20:21 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: help-gnu-emacs
Michael Heerdegen <michael_heerdegen@web.de> writes:
> ********************************************************
> Caution: This message was sent from outside the University of Manitoba.
> ********************************************************
>
> Leo Butler <leo.butler@umanitoba.ca> writes:
>
>> If I have a buffer with, e.g. display properties set to images, how can
>> I save that to disk and re-open the saved data so that emacs displays the
>> same "stuff"? I am not looking to export the buffer using html or latex
>> or any other markup.
>
> Without _any_ form of markup? No, Emacs can't save buffers containing
> images directly to a file.
Yes, what I mean is that I want something like enriched text mode or a
wysiwyg mode that let's me copy text with properties from other buffers
(or create it and insert it), including images, save the buffer to disk
and when I open it in another emacs I see the same thing and can
continue editing the document if need be. In other words, I am not
looking to export to another document format using e.g. html or latex.
My use case is copying snippets from *imaxima* (a front-end for Maxima
that uses latex to create its output) into another buffer that contains
text and so on.
>
> We often had a discussion whether `enriched-mode' should be improved, or
> something new could be created, to do what you want (among other things
> like saving text properties). But nobody has done it yet.
>
> Michael.
Well, after poking around a bit, I found this in NEWS.25:
* Changes in Emacs 25.3
This is an emergency release to fix a security vulnerability in Emacs.
** Security vulnerability related to Enriched Text mode is removed.
*** Enriched Text mode has its support for decoding 'x-display' disabled.
This feature allows saving 'display' properties as part of text.
Emacs 'display' properties support evaluation of arbitrary Lisp forms
as part of instantiating the property, so decoding 'x-display' is
vulnerable to executing arbitrary malicious Lisp code included in the
text (e.g., sent as part of an email message).
So it appears that enriched text mode did do what I want, but the way
Emacs handles display properties is too permissive...
This leads me to ask why the feature was nuked rather than handling it
like file variables
(https://www.gnu.org/software/emacs/manual/html_node/emacs/File-Variables.html).
Leo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: saving/restoring text and overlays
2020-03-29 20:21 ` Leo Butler
@ 2020-03-30 0:14 ` Michael Heerdegen
2020-03-30 0:23 ` Michael Heerdegen
2020-03-30 1:23 ` Noam Postavsky
2020-03-30 2:25 ` Eli Zaretskii
2 siblings, 1 reply; 8+ messages in thread
From: Michael Heerdegen @ 2020-03-30 0:14 UTC (permalink / raw)
To: Leo Butler; +Cc: help-gnu-emacs
Leo Butler <leo.butler@umanitoba.ca> writes:
> So it appears that enriched text mode did do what I want, but the way
> Emacs handles display properties is too permissive...
Oh - indeed! I tested quickly, and it even seems that simple stuff that
doesn't need to evaluate "arbitrary" Lisp still works out of the box.
Images at least work for me in emacs -Q, without changing any defaults.
> This leads me to ask why the feature was nuked rather than handling it
> like file variables
> (https://www.gnu.org/software/emacs/manual/html_node/emacs/File-Variables.html).
Doesn't using `enriched-allow-eval-in-display-props' (the option
mentioned in the text you cited but later) as file-local var work?
Michael.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: saving/restoring text and overlays
2020-03-30 0:14 ` Michael Heerdegen
@ 2020-03-30 0:23 ` Michael Heerdegen
0 siblings, 0 replies; 8+ messages in thread
From: Michael Heerdegen @ 2020-03-30 0:23 UTC (permalink / raw)
To: Leo Butler; +Cc: help-gnu-emacs
Michael Heerdegen <michael_heerdegen@web.de> writes:
> Images at least work for me in emacs -Q, without changing any defaults.
"Works" here means: worked with a locally saved file after ignoring lots
of warnings printed to *Messages*. An image yanked from an *eww* buffer
didn't work, after opening the file Emacs only showed an empty box.
Michael.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: saving/restoring text and overlays
2020-03-29 20:21 ` Leo Butler
2020-03-30 0:14 ` Michael Heerdegen
@ 2020-03-30 1:23 ` Noam Postavsky
2020-03-30 2:25 ` Eli Zaretskii
2 siblings, 0 replies; 8+ messages in thread
From: Noam Postavsky @ 2020-03-30 1:23 UTC (permalink / raw)
To: Leo Butler; +Cc: Michael Heerdegen, Help Gnu Emacs mailing list
On Sun, 29 Mar 2020 at 16:21, Leo Butler <leo.butler@umanitoba.ca> wrote:
> Well, after poking around a bit, I found this in NEWS.25:
> *** Enriched Text mode has its support for decoding 'x-display' disabled.
> So it appears that enriched text mode did do what I want, but the way
> Emacs handles display properties is too permissive...
>
> This leads me to ask why the feature was nuked rather than handling it
> like file variables
> (https://www.gnu.org/software/emacs/manual/html_node/emacs/File-Variables.html).
You might want to check NEWS for Emacs 26:
* Changes in Emacs 26.1
** Security vulnerability related to Enriched Text mode is removed.
*** Enriched Text mode does not evaluate Lisp in 'display' properties.
[...] decoded by Enriched Text mode is now disabled by default. Customize
the new option 'enriched-allow-eval-in-display-props' to a non-nil
value to allow Lisp evaluation in decoded 'display' properties.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: saving/restoring text and overlays
2020-03-29 20:21 ` Leo Butler
2020-03-30 0:14 ` Michael Heerdegen
2020-03-30 1:23 ` Noam Postavsky
@ 2020-03-30 2:25 ` Eli Zaretskii
2020-03-30 20:14 ` Leo Butler
2 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2020-03-30 2:25 UTC (permalink / raw)
To: help-gnu-emacs
> From: Leo Butler <leo.butler@umanitoba.ca>
> Date: Sun, 29 Mar 2020 15:21:39 -0500
> Cc: help-gnu-emacs@gnu.org
>
> So it appears that enriched text mode did do what I want, but the way
> Emacs handles display properties is too permissive...
>
> This leads me to ask why the feature was nuked rather than handling it
> like file variables
> (https://www.gnu.org/software/emacs/manual/html_node/emacs/File-Variables.html).
It wasn't nuked, you are reading too much into that NEWS entry. Only
the dangerous part was disabled, and even that can be enabled if you
trust the source of the file.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: saving/restoring text and overlays
2020-03-30 2:25 ` Eli Zaretskii
@ 2020-03-30 20:14 ` Leo Butler
0 siblings, 0 replies; 8+ messages in thread
From: Leo Butler @ 2020-03-30 20:14 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
Eli Zaretskii <eliz@gnu.org> writes:
> ********************************************************
> Caution: This message was sent from outside the University of Manitoba.
> ********************************************************
>
>> From: Leo Butler <leo.butler@umanitoba.ca>
>> Date: Sun, 29 Mar 2020 15:21:39 -0500
>> Cc: help-gnu-emacs@gnu.org
>>
>> So it appears that enriched text mode did do what I want, but the way
>> Emacs handles display properties is too permissive...
>>
>> This leads me to ask why the feature was nuked rather than handling it
>> like file variables
>> (https://www.gnu.org/software/emacs/manual/html_node/emacs/File-Variables.html).
>
> It wasn't nuked, you are reading too much into that NEWS entry. Only
> the dangerous part was disabled, and even that can be enabled if you
> trust the source of the file.
You are right.
After more investigation, I find that Emacs 25.2.2 on Ubuntu 18.04
is not saving the x-display properties while Emacs 26.1 on Debian
testing does.
Inspection of enriched.el on each system shows that on Ubuntu
enriched-translations is missing the portions
(FUNCTION (enriched-decode-foreground "x-color")
(enriched-decode-background "x-bg-color")
(enriched-decode-display-prop "x-display"))
(display (nil enriched-handle-display-prop))
Sigh.
Apologies, I should have looked more carefully.
Leo
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-03-30 20:14 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-26 4:14 saving/restoring text and overlays Leo Butler
2020-03-26 22:23 ` Michael Heerdegen
2020-03-29 20:21 ` Leo Butler
2020-03-30 0:14 ` Michael Heerdegen
2020-03-30 0:23 ` Michael Heerdegen
2020-03-30 1:23 ` Noam Postavsky
2020-03-30 2:25 ` Eli Zaretskii
2020-03-30 20:14 ` Leo Butler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).