Subject: RE: [External] : bug#43265: 28.0.50; Inconsistent fontifying in elisp-mode

From: Drew Adams <[email-masked]>
Date: Sun, 24 Jan 2021 21:58:34 +0000

Oh boy - font-lock bikeshedding!

> Skimming that thread, I can't see any explanation for why we don't check
> that special forms are in a function position, while we do that for
> macros? I.e.,
> 
> (setq a '(if a b))   is currently fontified incorrectly, while
> (setq a '(when a b)) is fontified correctly.

Really?  Are you sure one is correct and the other not,
and that you have it the right way round? 

 (setq a '(setq b d))
 (setq a '(if a b))
 (setq a '(when a b))
 (setq a '(and a b))

Nowadays, all of those `setq's, the `if', and the `and'
are highlighted; poor-boy `when' isn't. :-(
___

But is it really "correct" to fontify _any_ of the names
in those quoted sexps as if they were being used with
their active meanings - as code?  In that context they're
just data - list elements.

It was Emacs 25 that started highlighting all of those
`setq's, and `and'.  Up through Emacs 24, `setq' and
`and' weren't highlighted anywhere - and both `if' and
`when' were highlighted (everywhere).

Emacs 25 made `when' a special case (unhighlighted), and
it made `setq' and `and' unspecial (highlighted).  That
new behavior is no more "correct" than what it replaced.

If any highlightings could be considered more correct
than others, I'd think a more correct one would _at
least_ not highlight function/macro/special-form names
when used as elements of a list (i.e. quoted) or as
plain-quoted atoms.

Consider:

 (defun foo (x y) 42) ; or (defmacro foo (x y) 42)
 (setq a '(foo a b))
 (setq a '(if a b))

`foo' in the quoted list isn't highlighted; `if' is.
Why?

In sum:

1. We're not very consistent (before or since Emacs 25).

2. The behavior's changed over time: sometimes to add
highlighting (`setq', `and'), sometimes to remove it
(`when').  Why?  Maybe (or maybe not) there were some
good reasons.  In any case, for a _user_ things are not
so clear.

3. IMO, it could make sense to not highlight such names
when they're not syntactically seen as being _used_ as
function/macro/special-form, but are instead seen as
data (e.g. quoted).

(When the use isn't obvious, pick a direction to err on,
and be relatively consistent about it.)

Now the question becomes, What constitutes "use" as a
function/macro/special-form?  Plain-quoting doesn't,
IMO; but what about #'?

How many angels fit on the head of a pin?  (Depends on
the angels and the pin.)