[Top][All Lists]

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

Re: font-lock-keywords uses only facename

From: Stefan Monnier
Subject: Re: font-lock-keywords uses only facename
Date: 03 Jun 2004 23:33:38 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

> It's just historical stupidity.

Well, I wouldn't put it qute like this.  Given the fact that any expression
is allowed, and that quoting can be used to get the "unevaluated" behavior,
the current behavior has the advantage of being general and simple.

> If it were being designed today, it would probably just use face names
> directly,

If I were writing it today, I'd just do an `eval' as did Simon Marshall:
it's simpler and there is no loss of generality.  And adding a quote is
really not that difficult.

> but font-lock is _really_ old...

Indeed.  A complete overhaul is long overdue.

> I presume you're asking whether it could do something like:

>    (if (and (symbolp expr) (not (boundp expr)))
>        expr      ; use face name directly
>      (eval expr))  ; evaluate EXPR to get face name

> ?

> It seems like it would work, though I wonder if it could cause more
> confusion...

I think if we really care about it (although it hasn't bothered us that
much for the last however many years, so I doubt it's worth the trouble),
we could do something like:

- when "compiling" the keywords, do something like

    (if (and (symbolp expr) (not (boundp expr)) (facep expr))
        (list 'quote expr)

- put a condition-case around font-lock-fontify-keywords-region like

    (condition-case unbound-err
        (let ((var (cadr unbound-err)))
          (if (and (symbolp var) (not (boundp var)) (facep var))
              (error "Face %s needs to be quoted in font-lock-keywords" var)
            (signal (car unbound-err) (cdr unbound-err))))))

-- Stefan

reply via email to

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