unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* buffer-modified indicator in mode line - distinguish savable from unsavable changes
@ 2006-07-02  2:42 Drew Adams
  2006-07-02  9:03 ` Alan Mackenzie
  2006-07-02 22:30 ` Richard Stallman
  0 siblings, 2 replies; 4+ messages in thread
From: Drew Adams @ 2006-07-02  2:42 UTC (permalink / raw)


The buffer-modified indicator in the mode line reflects two kinds of changes
to the buffer: 1) changes that will make a difference if the buffer is saved
and 2) changes that will not make any difference (the saved file will be the
same, whether or not the buffer was changed in this way only).

An example of a type 1 change is typing or deleting text. An example of a
type 2 change is changing the face of a some text (e.g. using the facemenu).

Type 1 changes let you rely upon interpreting ** in the mode line to mean
that the buffer has not been saved since the last change. Well, that's true
for type 2 changes too, but in that case saving makes no difference: type 2
changes are not saved.

I think it would be more useful to distinguish these two kinds of changes in
some way, in the mode line. While it can sometimes be useful to know if a
type 2 change actually took effect, most of the time I only want to see if
the buffer needs saving, and for that type 2 changes are irrelevant.

I would like to have the buffer-modified flag show 3 states: 1) unchanged,
2) type 2 changes only, 3) at least one type 1 change. The indicator might
show this, for example: -- for unchanged (1), ++ for type 2 changes only
(2), ** for at least one type 1 change (3). That way, ++ would show that
something unsavable has changed, and ** would show that something savable
has changed. For -- and ++, there is no need to save the buffer. When
undoing, it is enough, for purposes of getting back to the saved buffer, to
undo until ** changes to ++ (or --).

WDOT? If others don't like that idea, how about at least having a user
option that let's the buffer-modified indicator ignore type 2 changes, if a
user prefers that (which I do)? With that option turned on, ** would always
mean that a savable change has been made since the last save, and -- would
always mean that the buffer does not need to be saved (any changes made so
far are unsavable).

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

* Re: buffer-modified indicator in mode line - distinguish savable from unsavable changes
  2006-07-02  2:42 buffer-modified indicator in mode line - distinguish savable from unsavable changes Drew Adams
@ 2006-07-02  9:03 ` Alan Mackenzie
  2006-07-02 15:14   ` Drew Adams
  2006-07-02 22:30 ` Richard Stallman
  1 sibling, 1 reply; 4+ messages in thread
From: Alan Mackenzie @ 2006-07-02  9:03 UTC (permalink / raw)
  Cc: Emacs-Devel

Hi, Drew!

On Sat, Jul 01, 2006 at 07:42:25PM -0700, Drew Adams wrote:
> The buffer-modified indicator in the mode line reflects two kinds of changes
> to the buffer: 1) changes that will make a difference if the buffer is saved
> and 2) changes that will not make any difference (the saved file will be the
> same, whether or not the buffer was changed in this way only).

> An example of a type 1 change is typing or deleting text. An example of a
> type 2 change is changing the face of a some text (e.g. using the facemenu).
 
> Type 1 changes let you rely upon interpreting ** in the mode line to mean
> that the buffer has not been saved since the last change. Well, that's true
> for type 2 changes too, but in that case saving makes no difference: type 2
> changes are not saved.
 
> I think it would be more useful to distinguish these two kinds of changes in
> some way, in the mode line. While it can sometimes be useful to know if a
> type 2 change actually took effect, most of the time I only want to see if
> the buffer needs saving, and for that type 2 changes are irrelevant.
 
> I would like to have the buffer-modified flag show 3 states: 1) unchanged,
> 2) type 2 changes only, 3) at least one type 1 change. The indicator might
> show this, for example: -- for unchanged (1), ++ for type 2 changes only
> (2), ** for at least one type 1 change (3). That way, ++ would show that
> something unsavable has changed, and ** would show that something savable
> has changed. For -- and ++, there is no need to save the buffer. When
> undoing, it is enough, for purposes of getting back to the saved buffer, to
> undo until ** changes to ++ (or --).
 
> WDOT? If others don't like that idea, how about at least having a user
> option that let's the buffer-modified indicator ignore type 2 changes, if a
> user prefers that (which I do)? With that option turned on, ** would always
> mean that a savable change has been made since the last save, and -- would
> always mean that the buffer does not need to be saved (any changes made so
> far are unsavable).

Before anybody else says it, we are talking about Emacs 23 here, aren't
we?

My own opinion is that we're suffering a conceptual problem here -
nobody seems to have firmly defined "changed".  Currently "changed"
seems to mean something like "there are entries in the undo list".  I
think it would be better redefined as "a state in which saving the buffer
would change the file".

Thus setting faces would set the changed flag in Enriched Mode, but not
in Emacs Lisp Mode.

Is there any benefit whatsoever in regarding a "type 2 change" as a
change at all?  I don't see one.

The consequences of the current (lack of) definition are seen in
font-lock.el in the existence of the ugly macro `save-buffer-state'.  We
shouldn't need macros like this.

All in Emacs 23, of course.

-- 
Alan Mackenzie (Munich, Germany)

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

* RE: buffer-modified indicator in mode line - distinguish savable from unsavable changes
  2006-07-02  9:03 ` Alan Mackenzie
@ 2006-07-02 15:14   ` Drew Adams
  0 siblings, 0 replies; 4+ messages in thread
From: Drew Adams @ 2006-07-02 15:14 UTC (permalink / raw)


    Before anybody else says it, we are talking about Emacs 23 here, aren't
    we?

23, 24,... I don't know - after the incipient 22, in any case.

    nobody seems to have firmly defined "changed".  Currently "changed"
    seems to mean something like "there are entries in the undo list".  I
    think it would be better redefined as "a state in which saving
    the buffer would change the file".

That's what I was saying is (to me) the most important distinction: savable
changes. I allow, however, that seeing an indication of non-savable might
also could be interesting, at least to some people, in some contexts (some
of the time).

    Thus setting faces would set the changed flag in Enriched Mode, but not
    in Emacs Lisp Mode.

Good point. I hadn't thought about Enriched Mode (I'm not familiar with it).

    Is there any benefit whatsoever in regarding a "type 2 change" as a
    change at all?  I don't see one.

It can let you know that a face change, for instance, actually took place.
Depending on the context, some face changes might not be noticeable. And
there are other buffer changes that are always invisible.

A buffer, even a buffer associated with a file, is not just an unsaved file.
A buffer has lots of properties. I imagine that it can sometimes be useful
to know if the buffer has changed in any way.

However, that brings up another point. IIUC, there are some changes of
buffer properties that are not undoable, so they are not reflected in the
mode line. If that's true, then there are these four conditions:

 -- no changes
 == only non-undoable changes
 ++ only non-undoable and non-savable changes
 ** savable changes (plus, perhaps other types)

There is probably no point, and probably no mechanism for, indicating the ==
condition. Today, we don't distinguish -- from ==.

There is a point in distinguishing ++ from ** (see my previous email).
Today, we don't distinguish them. If we don't allow a third mode-line
indicator (++), then I would rather have ++ subsumed by -- than by ** - I am
most interested in knowing whether or not the buffer needs to be saved.

    The consequences of the current (lack of) definition are seen in
    font-lock.el in the existence of the ugly macro `save-buffer-state'.  We
    shouldn't need macros like this.

I'm not familiar with that. Can you elaborate?

    All in Emacs 23, of course.

Not 22, anyway.

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

* Re: buffer-modified indicator in mode line - distinguish savable from unsavable changes
  2006-07-02  2:42 buffer-modified indicator in mode line - distinguish savable from unsavable changes Drew Adams
  2006-07-02  9:03 ` Alan Mackenzie
@ 2006-07-02 22:30 ` Richard Stallman
  1 sibling, 0 replies; 4+ messages in thread
From: Richard Stallman @ 2006-07-02 22:30 UTC (permalink / raw)
  Cc: emacs-devel

    An example of a type 1 change is typing or deleting text. An example of a
    type 2 change is changing the face of a some text (e.g. using the facemenu).

In the future, we want to be able to save text properties.  However,
in most buffers that is impossible.

buffer-modified-p could, in principle, consider text property changes
insignificant in buffers that cannot save them.  It is something to consider
trying out after the release.

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

end of thread, other threads:[~2006-07-02 22:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-02  2:42 buffer-modified indicator in mode line - distinguish savable from unsavable changes Drew Adams
2006-07-02  9:03 ` Alan Mackenzie
2006-07-02 15:14   ` Drew Adams
2006-07-02 22:30 ` Richard Stallman

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