unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* saving buffer with text properties
@ 2007-06-03  2:33 Drew Adams
  2007-06-03  9:45 ` Thien-Thi Nguyen
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Drew Adams @ 2007-06-03  2:33 UTC (permalink / raw)
  To: Emacs-Devel

Is there any plan to enable users to save text with all of its properties?

The Emacs manual says that `invisible' and `intangible' are not saved. It
would be useful to be able to save a file and, upon reopening, restore all
of the Emacs text properties, including properties that are not predefined.

For instance, I have a library that implements conditional text, as in a
desktop publishing system such as Framemaker: easily hide/show arbitrary
sets of faces in regions etc. However, upon saving, all of this info is
lost.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: saving buffer with text properties
  2007-06-03  2:33 saving buffer with text properties Drew Adams
@ 2007-06-03  9:45 ` Thien-Thi Nguyen
  2007-06-03 14:15   ` Drew Adams
  2007-06-03 21:27 ` Richard Stallman
  2007-06-05  1:32 ` Michael Olson
  2 siblings, 1 reply; 17+ messages in thread
From: Thien-Thi Nguyen @ 2007-06-03  9:45 UTC (permalink / raw)
  To: Drew Adams; +Cc: Emacs-Devel

() "Drew Adams" <drew.adams@oracle.com>
() Sat, 2 Jun 2007 19:33:56 -0700

   Is there any plan to enable users to save text
   with all of its properties?

"all" is a big word!

on the trunk, see (info "(elisp) Format Conversion").

perhaps if/when you write code to handle your specific
properties, we can look at their generality and extend
emacs w/ that functionality.

thi

^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: saving buffer with text properties
  2007-06-03  9:45 ` Thien-Thi Nguyen
@ 2007-06-03 14:15   ` Drew Adams
  2007-06-03 14:47     ` Chong Yidong
  2007-06-03 16:43     ` Thien-Thi Nguyen
  0 siblings, 2 replies; 17+ messages in thread
From: Drew Adams @ 2007-06-03 14:15 UTC (permalink / raw)
  To: Emacs-Devel

>    Is there any plan to enable users to save text
>    with all of its properties?
>
> "all" is a big word!

Perhaps. If a text property were represented in the saved form by its
property name as well as its value, why couldn't arbitrary, user-defined
properties be accomodated too? That's a question, not a claim; I'm no expert
in this. (`buffer-invisiblity-spec' would also need to be saved in the
file.)

> on the trunk, see (info "(elisp) Format Conversion").

Good to know. IIUC, that explains how one might implement what I'm asking
for, and it is not specific to text properties. I was wondering if there was
already a plan to define a saved representation that would take text
properties into account - similar to (or perhaps an extension of) enriched
text, for instance.

> perhaps if/when you write code to handle your specific
> properties, we can look at their generality and extend
> emacs w/ that functionality.

My code just uses:

* a `face' property
* a `highlight' property with the same value as `face'
* possibly an `invisible' property

(Likewise for overlays, with a priority also, but I'm thinking only about
text properties here.)

The `highlight' property is just so the code can distinguish face properties
that it manages from other face properties. The code doesn't do anything
special. It just lets you easily apply highlighting in different faces and
then show/hide it.

User can already do some of these things from the Special Properties menu of
Text Properties; my code just tries to add a little flexibility, letting you
show/hide a given face or set of faces everywhere, in a region, etc.

The code is here: http://www.emacswiki.org/cgi-bin/wiki/highlight.el.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: saving buffer with text properties
  2007-06-03 14:15   ` Drew Adams
@ 2007-06-03 14:47     ` Chong Yidong
  2007-06-03 16:20       ` Drew Adams
  2007-06-03 16:43     ` Thien-Thi Nguyen
  1 sibling, 1 reply; 17+ messages in thread
From: Chong Yidong @ 2007-06-03 14:47 UTC (permalink / raw)
  To: Drew Adams; +Cc: Emacs-Devel

"Drew Adams" <drew.adams@oracle.com> writes:

>>    Is there any plan to enable users to save text
>>    with all of its properties?
>>
>> "all" is a big word!

I think the way to do this is to build hooks into the desktop.el
system, so that external packages can specify a list of text
properties to re-apply to each file when it is re-opened.  This
information would be saved in .emacs.d, and the cache can be cleared
out for files that have not been re-opened for N days.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: saving buffer with text properties
  2007-06-03 14:47     ` Chong Yidong
@ 2007-06-03 16:20       ` Drew Adams
  2007-06-03 17:05         ` Chong Yidong
  0 siblings, 1 reply; 17+ messages in thread
From: Drew Adams @ 2007-06-03 16:20 UTC (permalink / raw)
  To: Emacs-Devel

> >>    Is there any plan to enable users to save text
> >>    with all of its properties?
> >>
> >> "all" is a big word!
>
> I think the way to do this is to build hooks into the desktop.el
> system, so that external packages can specify a list of text
> properties to re-apply to each file when it is re-opened.  This
> information would be saved in .emacs.d, and the cache can be cleared
> out for files that have not been re-opened for N days.

But the per-file information about applied text properties needs to be saved
with the file, no? The problem is not just re-applying properties;
currently, they are not saved in any way AFAICT.

Or did you mean that desktop would save a list of files and their text
properties (including property values and locations)?

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: saving buffer with text properties
  2007-06-03 14:15   ` Drew Adams
  2007-06-03 14:47     ` Chong Yidong
@ 2007-06-03 16:43     ` Thien-Thi Nguyen
  2007-06-03 17:08       ` Drew Adams
  1 sibling, 1 reply; 17+ messages in thread
From: Thien-Thi Nguyen @ 2007-06-03 16:43 UTC (permalink / raw)
  To: Drew Adams; +Cc: Emacs-Devel

() "Drew Adams" <drew.adams@oracle.com>
() Sun, 3 Jun 2007 07:15:54 -0700

   If a text property were represented in the saved form by its property
   name as well as its value, why couldn't arbitrary, user-defined
   properties be accomodated too? That's a question, not a claim; I'm no
   expert in this. (`buffer-invisiblity-spec' would also need to be
   saved in the file.)

everything can be accomodated in the current situation (w/ a SMOP).  the
question is not of feasability, it is of design.  consider the property
name: under sane usage it is a symbol or a keyword, but guess what,
emacs has no qualms w/ `(put-text-property 1 2 "foo" "bar")'.  what if
the property name is a circular structure?, a hash?, something tricky to
serialize?  same question goes for the property value, of course.

when serialization is required, ordering comes into play.  ordering
implies priority and thus specific design for specific purposes.  all
the mechanisms to support ordering are in place, hence the pointer:

   > on the trunk, see (info "(elisp) Format Conversion").

   Good to know. IIUC, that explains how one might implement what I'm
   asking for, and it is not specific to text properties.

you are right, but that is irrelevant.  text properties are key/value
object pairs; format conversion is parsing/rendering of such pairs (as
well as other kinds of info) serially, given an ordering.

   I was wondering if there was already a plan to define a saved
   representation that would take text properties into account - similar
   to (or perhaps an extension of) enriched text, for instance.

you are (again) invited to design, codify and characterize a good plan.
probably a first step is to restrict the types of the text property name
and value to avoid the hair mentioned above.  you have already begun:

   My code just uses:

   * a `face' property
   * a `highlight' property with the same value as `face'
   * possibly an `invisible' property

your design should also handle properties your code does NOT use.

thi

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: saving buffer with text properties
  2007-06-03 16:20       ` Drew Adams
@ 2007-06-03 17:05         ` Chong Yidong
  2007-06-03 17:15           ` Drew Adams
  0 siblings, 1 reply; 17+ messages in thread
From: Chong Yidong @ 2007-06-03 17:05 UTC (permalink / raw)
  To: Drew Adams; +Cc: Emacs-Devel

"Drew Adams" <drew.adams@oracle.com> writes:

>> >>    Is there any plan to enable users to save text
>> >>    with all of its properties?
>> >>
>> >> "all" is a big word!
>>
>> I think the way to do this is to build hooks into the desktop.el
>> system, so that external packages can specify a list of text
>> properties to re-apply to each file when it is re-opened.  This
>> information would be saved in .emacs.d, and the cache can be cleared
>> out for files that have not been re-opened for N days.
>
> But the per-file information about applied text properties needs to be saved
> with the file, no?

That would interfere with third-party programs, such as other text
editors, that want to edit the file.

> Or did you mean that desktop would save a list of files and their text
> properties (including property values and locations)?

Basically.  Desktop should provide hooks that other packages (such as
major modes) can use, i.e. a major mode should be able to tell desktop
"save the following data when closing this file, then run this
function with that data when the file is reopened".

^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: saving buffer with text properties
  2007-06-03 16:43     ` Thien-Thi Nguyen
@ 2007-06-03 17:08       ` Drew Adams
  0 siblings, 0 replies; 17+ messages in thread
From: Drew Adams @ 2007-06-03 17:08 UTC (permalink / raw)
  To: Emacs-Devel

> you are (again) invited to design, codify and characterize a good plan.
> probably a first step is to restrict the types of the text property name
> and value to avoid the hair mentioned above.  you have already begun:
...
> your design should also handle properties your code does NOT use.

I do appreciate the info you provided, Thi. I don't really intend to design
or implement such a thing myself, however. I don't have the resources or the
expertise to do that. I'm not averse to learning, of course, but I don't
expect to focus on that.

I was just asking if there were perhaps already plans afoot to do something
like this (I take it that the answer is no). I don't foreswear contributing
questions or comments to a discussion, if some such initiative develops, but
I don't intend to be a big part of it.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: saving buffer with text properties
  2007-06-03 17:05         ` Chong Yidong
@ 2007-06-03 17:15           ` Drew Adams
  0 siblings, 0 replies; 17+ messages in thread
From: Drew Adams @ 2007-06-03 17:15 UTC (permalink / raw)
  To: Emacs-Devel

> > But the per-file information about applied text properties
> > needs to be saved with the file, no?
>
> That would interfere with third-party programs, such as other text
> editors, that want to edit the file.

Perhaps you're right about that. I don't know much about this stuff. We
already provide metadata in the form of local-variable declarations in
comments, but I recognize that this should also be applicable to files that
aren't necessarily code and don't necessarily have a comment syntax.
(Besides, trying to record this stuff in comments would likely be a
nightmare, if not also problematic.)

> > Or did you mean that desktop would save a list of files and their text
> > properties (including property values and locations)?
>
> Basically.  Desktop should provide hooks that other packages (such as
> major modes) can use, i.e. a major mode should be able to tell desktop
> "save the following data when closing this file, then run this
> function with that data when the file is reopened".

That sounds reasonable to me, from the little I know of this. As I mentioned
to Thi, this is not something that I expect to work on, so I'll generally
bow out of trying to design and implement this. I was really just trying to
find out if something already existed, or was planned, which I might be able
to take advantage of for my highlighting code.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: saving buffer with text properties
  2007-06-03  2:33 saving buffer with text properties Drew Adams
  2007-06-03  9:45 ` Thien-Thi Nguyen
@ 2007-06-03 21:27 ` Richard Stallman
  2007-06-03 22:09   ` Drew Adams
  2007-06-04  6:29   ` Jason Rumney
  2007-06-05  1:32 ` Michael Olson
  2 siblings, 2 replies; 17+ messages in thread
From: Richard Stallman @ 2007-06-03 21:27 UTC (permalink / raw)
  To: Drew Adams; +Cc: emacs-devel

    Is there any plan to enable users to save text with all of its properties?

The plan for how to do this is to use the format conversion feature as
a basis, and implement conversion to and from existing formats that
can record markup.  We could also invent our own new format, but that
would be less useful than interoperation with other programs.

One existing format we want to support is RTF.  Would RTF do this job?

I don't think this should be connected with desktop.el.
That is not a clean design.  desktop.el has a job to do,
and that includes revisiting files that you were looking at.
Making saving and visiting handle text properties is a different job
and the two should be kept independent.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: saving buffer with text properties
  2007-06-03 21:27 ` Richard Stallman
@ 2007-06-03 22:09   ` Drew Adams
  2007-06-04  5:01     ` Richard Stallman
  2007-06-04  6:29   ` Jason Rumney
  1 sibling, 1 reply; 17+ messages in thread
From: Drew Adams @ 2007-06-03 22:09 UTC (permalink / raw)
  To: emacs-devel

>     Is there any plan to enable users to save text with all of
>     its properties?
>
> The plan for how to do this is to use the format conversion feature as
> a basis, and implement conversion to and from existing formats that
> can record markup.  We could also invent our own new format, but that
> would be less useful than interoperation with other programs.
>
> One existing format we want to support is RTF.  Would RTF do this job?

I don't know. Would it allow for user-defined text properties? invisible?
intangible?

> I don't think this should be connected with desktop.el.
> That is not a clean design.  desktop.el has a job to do,
> and that includes revisiting files that you were looking at.
> Making saving and visiting handle text properties is a different job
> and the two should be kept independent.

That makes sense to me.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: saving buffer with text properties
  2007-06-03 22:09   ` Drew Adams
@ 2007-06-04  5:01     ` Richard Stallman
  2007-06-04  7:38       ` M Jared Finder
  0 siblings, 1 reply; 17+ messages in thread
From: Richard Stallman @ 2007-06-04  5:01 UTC (permalink / raw)
  To: Drew Adams; +Cc: emacs-devel

    > One existing format we want to support is RTF.  Would RTF do this job?

    I don't know. Would it allow for user-defined text properties? invisible?
    intangible?

I do not know much about RTF.  I can't tell you.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: saving buffer with text properties
  2007-06-03 21:27 ` Richard Stallman
  2007-06-03 22:09   ` Drew Adams
@ 2007-06-04  6:29   ` Jason Rumney
  2007-06-04 23:20     ` Richard Stallman
  1 sibling, 1 reply; 17+ messages in thread
From: Jason Rumney @ 2007-06-04  6:29 UTC (permalink / raw)
  To: rms; +Cc: Drew Adams, emacs-devel

Richard Stallman wrote:
> I don't think this should be connected with desktop.el.
>   

There's enriched.el, it mentions support for other formats like RTF and
HTML in its TODO list (currently it uses a format defined for MIME mail,
which is little used these days).

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: saving buffer with text properties
  2007-06-04  5:01     ` Richard Stallman
@ 2007-06-04  7:38       ` M Jared Finder
  2007-06-04 23:20         ` Richard Stallman
  0 siblings, 1 reply; 17+ messages in thread
From: M Jared Finder @ 2007-06-04  7:38 UTC (permalink / raw)
  To: emacs-devel

Richard Stallman wrote:
>     > One existing format we want to support is RTF.  Would RTF do this job?
> 
>     I don't know. Would it allow for user-defined text properties? invisible?
>     intangible?
> 
> I do not know much about RTF.  I can't tell you.

A suggestion from an Emacs user, not a developer.... YOU HAVE BEEN WARNED!

How about using HTML?  You could save user defined symbol properties as 
HTML <emacs-symbol> tags, and they'd end up ignored by web browsers, 
while common tags like <b> and <i> would work just fine.

   -- MJF

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: saving buffer with text properties
  2007-06-04  7:38       ` M Jared Finder
@ 2007-06-04 23:20         ` Richard Stallman
  0 siblings, 0 replies; 17+ messages in thread
From: Richard Stallman @ 2007-06-04 23:20 UTC (permalink / raw)
  To: M Jared Finder; +Cc: emacs-devel

    How about using HTML?  You could save user defined symbol properties as 
    HTML <emacs-symbol> tags, and they'd end up ignored by web browsers, 
    while common tags like <b> and <i> would work just fine.

It would be good to support saving as HTML too.
We just need someone to implement it.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: saving buffer with text properties
  2007-06-04  6:29   ` Jason Rumney
@ 2007-06-04 23:20     ` Richard Stallman
  0 siblings, 0 replies; 17+ messages in thread
From: Richard Stallman @ 2007-06-04 23:20 UTC (permalink / raw)
  To: Jason Rumney; +Cc: drew.adams, emacs-devel

    There's enriched.el, it mentions support for other formats like RTF and
    HTML in its TODO list (currently it uses a format defined for MIME mail,
    which is little used these days).

enriched.el is the basic mechanism on which support for RTF
or HTML would be based.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: saving buffer with text properties
  2007-06-03  2:33 saving buffer with text properties Drew Adams
  2007-06-03  9:45 ` Thien-Thi Nguyen
  2007-06-03 21:27 ` Richard Stallman
@ 2007-06-05  1:32 ` Michael Olson
  2 siblings, 0 replies; 17+ messages in thread
From: Michael Olson @ 2007-06-05  1:32 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 1078 bytes --]

"Drew Adams" <drew.adams@oracle.com> writes:

> Is there any plan to enable users to save text with all of its properties?
>
> The Emacs manual says that `invisible' and `intangible' are not saved. It
> would be useful to be able to save a file and, upon reopening, restore all
> of the Emacs text properties, including properties that are not predefined.
>
> For instance, I have a library that implements conditional text, as in a
> desktop publishing system such as Framemaker: easily hide/show arbitrary
> sets of faces in regions etc. However, upon saving, all of this info is
> lost.

This would be something best handled by format.el.

At some point I plan to extend format.el (as requested by RMS in October
2006) to handle overlapping text properties, and then switch muse-mode
over to it.

-- 
       Michael Olson -- FSF Associate Member #652     |
 http://mwolson.org/ -- Jabber: mwolson_at_hcoop.net  |  /` |\ | | |
            Sysadmin -- Hobbies: Lisp, GP2X, HCoop    | |_] | \| |_|
Projects: Emacs, Muse, ERC, EMMS, ErBot, DVC, Planner |

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2007-06-05  1:32 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-03  2:33 saving buffer with text properties Drew Adams
2007-06-03  9:45 ` Thien-Thi Nguyen
2007-06-03 14:15   ` Drew Adams
2007-06-03 14:47     ` Chong Yidong
2007-06-03 16:20       ` Drew Adams
2007-06-03 17:05         ` Chong Yidong
2007-06-03 17:15           ` Drew Adams
2007-06-03 16:43     ` Thien-Thi Nguyen
2007-06-03 17:08       ` Drew Adams
2007-06-03 21:27 ` Richard Stallman
2007-06-03 22:09   ` Drew Adams
2007-06-04  5:01     ` Richard Stallman
2007-06-04  7:38       ` M Jared Finder
2007-06-04 23:20         ` Richard Stallman
2007-06-04  6:29   ` Jason Rumney
2007-06-04 23:20     ` Richard Stallman
2007-06-05  1:32 ` Michael Olson

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).