On 25/11/2023 10:33, Andrey Listopadov wrote:
And here's another aspect: the default built-in theme doesn't
distinguish many of the faces (and the same is true for many
other
built-in themes). E.g. it doesn't distinguish
variable-name-face from
variable-use-face or function-name-face from
function-call-face.
I'm wondering if font-lock.el needs a bit more generic faces,
as
packages often define their own faces, that aren't supported by
themes
in any way. Again, the example with elixir-mode isn't to bash
the
developers, but before 2019 elixir-mode (not elixir-ts-mode)
defined a
few faces with explicit colors. Here's a commit that fixed
that
https://github.com/elixir-editors/emacs-elixir/commit/f101c676cc9485aa22ec088a71d8afc72cda3d58
but before it, `elixir-atom-face' and `elixir-attribute-face'
were
`RoyalBlue4' and `MediumPurple4' no matter what theme you were
using.
IIRC the CIDER package also defines some faces like that, so
it's
somewhat common.
As long as the faces are for unusual contexts and have some
fallbacks
(or preferably inherit from some of the core ones), that's fair
practice.
I can't come up with missing faces, and most modes I use define
extra
faces in terms of inheritance to the inbuilt faces,
Right.
but maybe
font-lock-symbol-face is worth including, as some languages may
want to
distinguish these like elixir does right now with
`elixir-ts-atom-face'.
I agree we could add more. E.g. a face like that could
automatically
be used for "keywords" in Elisp (and Clojure, and other Lisps)
and
"symbols" in Elixir in Ruby.
What makes me pause is naming: the terminology is a mess here
across
languages. "symbols" usually mean something else in Emacs (and
in Lisp
languages in general), whereas "keywords" mean something else
across
most other languages. Using the name font-lock-symbol-face is
bound to
cause confusion at least across Lisp programmers. Luckily,
'font-lock-keyword-face' is already taken, so we don't have to
consider this alternative (which would puzzle the rest of the
programming world).
The docstring of 'font-lock-constant-face' says "Face name to
use for
constant and label names", but a name 'font-lock-label-name'
sounds
pretty bland... OTOH, there are labels in C, but nothing with
that
particular name in Elixir, Ruby or Lisp (aside from one macro, I
suppose).