[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Loading files at startup (desktop) and revert-buffer leave buffers *
From: |
Eli Zaretskii |
Subject: |
Re: Loading files at startup (desktop) and revert-buffer leave buffers **. |
Date: |
Mon, 25 Nov 2002 08:22:09 +0200 (IST) |
On Sun, 24 Nov 2002, Alan Mackenzie wrote:
> > Text properties are considered an integral part of the buffer's text
> > because you want them to be copied together with that text. Thus, any
> > change in text properties causes the buffer to be marked as modified.
>
> Hmm... That still doesn't make much sense to me. What does it mean for
> a buffer to be marked as modified? It surely means "The buffer isn't the
> same as the file it was loaded from any more.".
No, it means the text in the buffer has changed in some way. For
example, copying the text into a string will yield a different string.
If the buffer is in Enriched mode, saving it after changing text
properties will actually change the file on disk.
In other words, the connection with the file the buffer is visiting is
not the only one. There are other examples of this in Emacs. For
starters, a buffer does not need to be visiting a file. More to the
point, text is decoded when it's read from file, so in general the buffer
_never_ holds the same stuff as the file. As another example, "C-x RET f"
also marks the buffer modified, although it does nothing to the buffer
contents. Etc., etc.
> I think the principal use of text properties is for font-locking.
That's a wrong assumption, actually. Perhaps that's why you have a
difficulty to accept the fact that Emacs marks the buffer modified when
text properties change. Please read the chapter in the ELisp manual that
describes text properties and see how many non-face-related properties
are there.
> Are there any uses of text properties where
> applying them to an otherwise unmodified buffer would necessitate the
> buffer being saved to its file?
See the example of Enriched mode above.
> Ah, overlays. What are they? The elisp manual just says "they're a bit
> like text properties in some ways, but otherwise totally different.".
> Other than the fact that they don't set the buffer-changed flag, I can't
> see any uses for them distinct from those of text properties.
The main differences is exactly what bothered you: overlays aren't
considered part of the text, only a display feature.