emacs-devel
[Top][All Lists]
Advanced

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

RE: bind faces?


From: Drew Adams
Subject: RE: bind faces?
Date: Sat, 13 May 2006 20:13:15 -0700

    >     Why exactly do you want to do this?
    >
    > I thought I explained that.... Why does anyone want
    > to bind variables and functions, as opposed to using
    > `unwind-protect', assigning new definitions, and
    > restoring afterward?

    "By analogy with" isn't a very compelling reason for a feature.  What
    I'm asking is: "What is a real-world problem where you would need
    such a thing?"

Emacs-Lisp programming. Any situation where you might want to redefine a
face only temporarily, for use in a particular context. Is that hard to
imagine?

    My impression is that faces in general reflect a more permanent sort
    of state

Precisely. You might want to change some properties of a face temporarily in
a function, without affecting its "more permanent" nature. You might want to
use existing code that employs a particular face (e.g. hard-coded - there
are examples of `region' and `highlight' in the standard Emacs code, for
instance), substituting another face, with different face properties, for
it. You might want to use existing code that employs a face, but not have
that face appear (be noticeable) at all.

    and that the idea of "binding" face definitions is a bit
    alien to the way they are used.

There is not only one way that faces are used - "the way". Binding a face
would be similar to binding a global variable. Like faces, many global
variables (including most user options) have a "more permanent sort of
state", but that doesn't mean it isn't useful sometimes to bind them to
different values locally.

It's precisely because we don't want to change the more permanent state of
global variables that we bind them to new values instead of assigning them
those values. Imagine that you had no `let' binding and you wanted to get a
similar effect. You would use `unwind-protect', save the value, assign the
new value, execute the body, and then restore the original value. That's
where we are today with faces.

"When you have only a hammer, everything looks like a nail", as they say. If
there were no `let', there would be a lot less temporary changing of global
variables (not worth the hassle; lack of appreciation of the
possibility/need), and someone suggesting to add `let' would be asked "Why
do you need that in the real world? Global variables have a permanent sort
of state. That is a bit alien to the way they are used."






reply via email to

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