emacs-devel
[Top][All Lists]
Advanced

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

default for read-face-name


From: Drew Adams
Subject: default for read-face-name
Date: Tue, 22 Jun 2010 18:31:38 -0700

`read-face-name' accepts an optional arg STRING-DESCRIBING-DEFAULT, which is
used only if (ahem) no real defaulting can be done (!) - a catch-all description
such as "all faces" is passed and added to the prompt.

Normally, however, default faces are picked up, from all of these sources (and
then STRING-DESCRIBING-DEFAULT is ignored):

1. face symbols named at point (using thing-at-point)
2. a `read-face-name' text property on the char at point
3. a `face' text property on the char at point

I think we should also let callers specify a default face to use: Change
STRING-DESCRIBING-DEFAULT to DEFAULT, and give it precedence over the other ways
of defaulting. If the calling code knows the best default, let it easily DTRT.

We could add DEFAULT as an additional arg, but the current
STRING-DESCRIBING-DEFAULT is pretty useless anyway, as the doc string suggests:
"you can omit it".  So I'd suggest just replacing it with a new DEFAULT arg.

Reason for a DEFAULT arg: Sometimes a significant default face is known to the
calling code, and it should be possible to specify it (pass it to the user).

For example, if a face is saved somewhere as the current face to use for
something, and the code calls `read-face-name' to let you enter a different face
to override that, it can be helpful to provide the old face as the default, in
order to: (a) show you what it is and (b) let you edit it to a similar face name
(or confirm its use by hitting RET).

The current design pretty much assumes that such a "current" face would in fact
be used already at point, so the `face' property would pick it up.  But that is
not always the case - it is a bad assumption.

And it seems silly to have to temporarily add a text property (`read-face-name')
at point, just to be able to provide a proper default.  That kind of thing can
make sense for a static display such as `list-faces-display' but it is silly as
a general way to pass a default value to the function.

In sum, a read function deserves a default, and it is reasonable to be able to
provide the default as an arg.

The code change needed would be straightforward.  And there seem to be only a
couple of places in the existing source files where STRING-DESCRIBING-DEFAULT is
used.  My guess is that the change I'm suggesting would not have a negative
impact.

WDOT?




reply via email to

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