[Top][All Lists]

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

bug#17507: Documentation for `add-text-property' and relatives

From: Eli Zaretskii
Subject: bug#17507: Documentation for `add-text-property' and relatives
Date: Fri, 16 Aug 2019 11:46:08 +0300

> From: Eli Barzilay <address@hidden>
> Date: Fri, 16 Aug 2019 04:35:35 +0300
> Cc: Lars Ingebrigtsen <address@hidden>, address@hidden
> In lisps you can mutate properties of an object, but you cannot change
> the pointer itself.  I think that another way to clarify it would be
> to say that "foo" is actually shorthand for #("foo") but the #() is
> omitted for brevity.  But at this point this is subjective enough to
> be ignorable...

Sorry for prolonging this discussion, but I still don't think I
understand the difficulty.

Allow me to step back a notch and look at this from a higher-level

In Emacs, text properties are stored separately from the text itself.
In particular, text properties of a string are not part of the string
text, they live in a separate structure, and a string only maintains a
reference to that structure.  When Emacs needs to display the string,
it consults that structure and renders the string characters
accordingly.  When the Lisp interpreter needs to print the string, it
prints the properties as well, to make them visible.

It sounds like your mental model of a string was that it included the
properties, and therefore you were surprised that add-text-property
etc. appeared to modify the string by side effect.  Is that what
surprised you?  If so, would saying that these functions modify the
properties of a string without mutating the string itself resolve the

reply via email to

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