Subject: Re: bug#64275: 30.0.50; [PATCH] Improve sigil font-lock match for elixir-ts-mode

From: Wilhelm Kirschbaum <[email-masked]>
Date: Sat, 07 Oct 2023 10:46:57 +0200

Dmitry Gutov <[email-masked]> writes:

> On 02/08/2023 09:38, Wilhelm Kirschbaum wrote:
>> Dmitry Gutov <[email-masked]> writes:
>> 
>>> On 31/07/2023 10:22, Wilhelm Kirschbaum wrote:
>>>> I think it is worth keeping the default/fallback case as 
>>>> simple as
>>>> possible and if there is a need to add special font to more 
>>>> specific
>>>> cases.
>>>
>>> But the font is called elixir-ts-font-sigil-name-face. It 
>>> should apply
>>> to all sigils, shouldn't it?
>>>
>>> At least if we just go by the name.
>> Sure, but need to tweak it a bit when I have time.  Maybe there 
>> is a
>> way
>> to match in the query without applying a font, then it will 
>> look a bit
>> more sensible.
>
> I'm not sure what you meant by the last sentence, sorry. What do 
> you
> think about the below?
>
>   (sigil (sigil_name) @elixir-ts-font-sigil-name-face)
>   @font-lock-string-face)

Sorry for the late reply.  I believe the following patch is more
appropriate as it will apply the sigil font to the entire sigil, 
but
also respect the regex face.  We can add string specific matches 
later,
but happy just to simplify what we have and fix apply appropriate 
font
to previously unmatched sigils.

>From 9f6e5f143c2d247541172851ac9f09dcc6add010 Mon Sep 17 00:00:00 2001
From: Wilhelm H Kirschbaum <[email-masked]>
Date: Sat, 7 Oct 2023 10:37:49 +0200
Subject: [PATCH] Simplify sigil font-lock match for elixir-ts-mode

There is no need to match on specific sigils, except for regex.

* lisp/progmodes/elixir-ts-mode.el
(elixir-ts--font-lock-settings): Update sigil match.
---
 lisp/progmodes/elixir-ts-mode.el | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/lisp/progmodes/elixir-ts-mode.el b/lisp/progmodes/elixir-ts-mode.el
index 2ddce3de105..8a678b110e2 100644
--- a/lisp/progmodes/elixir-ts-mode.el
+++ b/lisp/progmodes/elixir-ts-mode.el
@@ -468,21 +468,10 @@ elixir-ts--font-lock-settings
    :feature 'elixir-sigil
    :override t
    `((sigil
-      (sigil_name) @elixir-ts-font-sigil-name-face
-      (:match "^[sSwWpPUD]$" @elixir-ts-font-sigil-name-face))
-     @font-lock-string-face
-     (sigil
-      "~" @font-lock-string-face
-      (sigil_name) @elixir-ts-font-sigil-name-face
-      (:match "^[rR]$" @elixir-ts-font-sigil-name-face))
+      (sigil_name) @font-lock-regexp-face
+      (:match "^[rR]$" @font-lock-regexp-face))
      @font-lock-regexp-face
-     (sigil
-      "~" @font-lock-string-face
-      (sigil_name) @elixir-ts-font-sigil-name-face
-      quoted_start: _ @font-lock-string-face
-      quoted_end: _ @font-lock-string-face
-      (:match "^[HF]$" @elixir-ts-font-sigil-name-face)))
-
+     (sigil) @elixir-ts-font-sigil-name-face)
    :language 'elixir
    :feature 'elixir-string-escape
    :override t
-- 
2.42.0