unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* default for read-face-name
@ 2010-06-23  1:31 Drew Adams
  2010-06-24 21:59 ` Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: Drew Adams @ 2010-06-23  1:31 UTC (permalink / raw)
  To: emacs-devel

`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?




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

end of thread, other threads:[~2010-06-30  8:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-23  1:31 default for read-face-name Drew Adams
2010-06-24 21:59 ` Juri Linkov
2010-06-24 22:23   ` Drew Adams
2010-06-25 19:59     ` Juri Linkov
2010-06-25 21:14       ` Drew Adams
2010-06-29 20:03         ` Juri Linkov
2010-06-29 20:17           ` Drew Adams
2010-06-30  8:09             ` Juri Linkov

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