bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#67246: 30.0.50; elixir-ts-mode uses faces inconsistently


From: Wilhelm Kirschbaum
Subject: bug#67246: 30.0.50; elixir-ts-mode uses faces inconsistently
Date: Mon, 27 Nov 2023 19:59:37 +0200
User-agent: mu4e 1.9.3; emacs 30.0.50


Dmitry Gutov <dmitry@gutov.dev> writes:

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


Here is a patch to address numerous issues flagged on Elixir slack,
Github and in this thread.  It will not be perfect, but since the
changes are pretty large I want to get this in and then we can pick on
specific issues afterwards if that makes sense?

I am making the assumption that it is okay to rename custom faces as
elixir-ts-mode is only for 30.

One thing I tried to get right is to ensure that each level works
relatively well, which means a bit more brute forcing queries. I have not seen a major performance issue on massic Elixir files, so think its
fine.

Attachment: 0001-Various-improvements-to-font-lock-settings-for-elixi.patch
Description: Text Data


reply via email to

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