unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: "Jostein Kjønigsen" <jostein@secure.kjonigsen.net>,
	"Eli Zaretskii" <eliz@gnu.org>
Cc: 60376@debbugs.gnu.org, casouri@gmail.com
Subject: bug#60376: 29.0.60; Standardize csharp-ts-mode's font-lock features
Date: Fri, 30 Dec 2022 20:30:43 +0100	[thread overview]
Message-ID: <87r0wgpu3g.fsf@thornhill.no> (raw)
In-Reply-To: <07332CE6-C6A9-469A-9C41-B47841D8798D@secure.kjonigsen.net>

[-- Attachment #1: Type: text/plain, Size: 1508 bytes --]

Jostein Kjønigsen <jostein@secure.kjonigsen.net> writes:

>> On 30 Dec 2022, at 16:46, Eli Zaretskii <eliz@gnu.org> wrote:
>> 
>> 
>>> 
>>> Date: Fri, 30 Dec 2022 15:39:20 +0100
>>> Cc: casouri@gmail.com, 60376@debbugs.gnu.org, theo@thornhill.no
>>> From: Jostein Kjønigsen <jostein@secure.kjonigsen.net>
>>> 
>>> To be clear: I think csharp-ts-mode works well beyond 85% (it's what I 
>>> use as my daily driver), but the syntax-highlighting at level 3 may be 
>>> more excessive than some people (like Stefan) prefer.
>>> 
>>> If we instead for these "major" changes suggested by Yuan, instead aim 
>>> for just moving some "smaller" implementation-detail 
>>> (function-invocations and property-highlighting) to level 4, I think we 
>>> she be able to get something which is mostly what Stefan would expect 
>>> and prefer, and it would be a much smaller change.
>>> 
>>> Then we can take a look at those bigger changes (standardized features, 
>>> enabling/disabling them individually, as end-users, etc) for Emacs-30.
>>> 
>>> I think that's a more realistic plan. Does that sound OK?
>> 
>> Yes, it does.  And I urge you to submit patches to that effect.
>> 
>> Thanks.
>
> Theo has offered to come up with some patches and I’ll do my best to battle-test them. 
>
> Hopefully we can get this done quickly enough to suit your taste ;)
>

Let's start here!

If you're satisfied, Jostein, report back, then you install, Yuan?

Then rinse repeat :-)

Theo


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Tweak-csharp-mode-font-lock-settings.patch --]
[-- Type: text/x-diff, Size: 4823 bytes --]

From 36ba718d0f4c528b7518da33d9c4e591f578ab10 Mon Sep 17 00:00:00 2001
From: Theodor Thornhill <theo@thornhill.no>
Date: Fri, 30 Dec 2022 20:26:09 +0100
Subject: [PATCH] Tweak csharp-mode font-lock-settings

* lisp/progmodes/csharp-mode.el (csharp-ts-mode--font-lock-settings):
Rearrange features.
(csharp-ts-mode): Rearrange features.
---
 lisp/progmodes/csharp-mode.el | 53 +++++++++++++++++++++--------------
 1 file changed, 32 insertions(+), 21 deletions(-)

diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el
index 66e4a65184..bd0e023db1 100644
--- a/lisp/progmodes/csharp-mode.el
+++ b/lisp/progmodes/csharp-mode.el
@@ -692,25 +692,47 @@ csharp-ts-mode--keywords
 
 (defvar csharp-ts-mode--font-lock-settings
   (treesit-font-lock-rules
+   :language 'c-sharp
+   :feature 'expression
+   '((conditional_expression (identifier) @font-lock-variable-name-face)
+     (postfix_unary_expression (identifier)* @font-lock-variable-name-face)
+     (assignment_expression (identifier) @font-lock-variable-name-face))
+
+   :language 'c-sharp
+   :feature 'bracket
+   '((["(" ")" "[" "]" "{" "}"]) @font-lock-bracket-face)
+
+   :language 'c-sharp
+   :feature 'delimiter
+   '((["," ":" ";"]) @font-lock-delimiter-face)
+
+   :language 'c-sharp
+   :feature 'error
+   '((ERROR) @font-lock-warning-face)
+
    :language 'c-sharp
    :override t
    :feature 'comment
-   '((comment)  @font-lock-comment-face)
+   '((comment) @font-lock-comment-face)
+
    :language 'c-sharp
    :override t
    :feature 'keyword
    `([,@csharp-ts-mode--keywords] @font-lock-keyword-face
      (modifier) @font-lock-keyword-face
      (this_expression) @font-lock-keyword-face)
+
    :language 'c-sharp
    :override t
-   :feature 'attribute
+   :feature 'property
    `((attribute (identifier) @font-lock-property-face (attribute_argument_list))
      (attribute (identifier) @font-lock-property-face))
+
    :language 'c-sharp
    :override t
    :feature 'escape-sequence
    '((escape_sequence) @font-lock-escape-face)
+
    :language 'c-sharp
    :override t
    :feature 'literal
@@ -718,6 +740,7 @@ csharp-ts-mode--font-lock-settings
      (real_literal) @font-lock-number-face
      (null_literal) @font-lock-constant-face
      (boolean_literal) @font-lock-constant-face)
+
    :language 'c-sharp
    :override t
    :feature 'string
@@ -730,6 +753,7 @@ csharp-ts-mode--font-lock-settings
       "$\""
       "@$\""
       "$@\""] @font-lock-string-face)
+
    :language 'c-sharp
    :override t
    :feature 'type
@@ -750,14 +774,14 @@ csharp-ts-mode--font-lock-settings
       target: (identifier) @font-lock-type-face)
      (type_of_expression (identifier) @font-lock-type-face)
      (object_creation_expression (identifier) @font-lock-type-face))
+
    :language 'c-sharp
    :feature 'definition
    :override t
    '((qualified_name (identifier) @font-lock-type-face)
      (using_directive (identifier) @font-lock-type-face)
      (using_directive (name_equals
-                       (identifier) @font-lock-type-face
-                       ["="] @default-face))
+                       (identifier) @font-lock-type-face))
 
      (enum_declaration (identifier) @font-lock-type-face)
      (enum_member_declaration (identifier) @font-lock-variable-name-face)
@@ -820,24 +844,11 @@ csharp-ts-mode--font-lock-settings
 
      (binary_expression (identifier) @font-lock-variable-name-face)
      (argument (identifier) @font-lock-variable-name-face))
-   :language 'c-sharp
-   :feature 'expression
-   '((conditional_expression (identifier) @font-lock-variable-name-face)
-     (postfix_unary_expression (identifier)* @font-lock-variable-name-face)
-     (assignment_expression (identifier) @font-lock-variable-name-face))
-   :language 'c-sharp
-   :feature 'bracket
-   '((["(" ")" "[" "]" "{" "}"]) @font-lock-bracket-face)
-
-   :language 'c-sharp
-   :feature 'delimiter
-   '((["," ":" ";"]) @font-lock-delimiter-face)
 
    :language 'c-sharp
    :feature 'escape-sequence
    :override t
-   '((escape_sequence) @font-lock-escape-face
-     (ERROR) @font-lock-warning-face)))
+   '((escape_sequence) @font-lock-escape-face)))
 
 ;;;###autoload
 (add-to-list 'auto-mode-alist '("\\.cs\\'" . csharp-mode))
@@ -903,9 +914,9 @@ csharp-ts-mode
   (setq-local treesit-font-lock-settings csharp-ts-mode--font-lock-settings)
   (setq-local treesit-font-lock-feature-list
               '(( comment definition)
-                ( keyword string escape-sequence type)
-                ( attribute constant expression literal)
-                ( bracket delimiter)))
+                ( keyword string type)
+                ( constant escape-sequence expression literal property)
+                ( bracket delimiter error)))
 
   ;; Imenu.
   (setq-local treesit-simple-imenu-settings
-- 
2.34.1


  reply	other threads:[~2022-12-30 19:30 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-28  8:25 bug#60376: 29.0.60; Standardize csharp-ts-mode's font-lock features Yuan Fu
2022-12-29 19:55 ` Yuan Fu
2022-12-29 21:03   ` Jostein Kjønigsen
2022-12-30  8:21     ` Eli Zaretskii
2022-12-29 22:16 ` Yuan Fu
2022-12-30  8:19   ` Eli Zaretskii
2022-12-30 13:35     ` Jostein Kjønigsen
2022-12-30 14:15       ` Eli Zaretskii
2022-12-30 14:39         ` Jostein Kjønigsen
2022-12-30 15:39           ` Eli Zaretskii
2022-12-30 17:35             ` Jostein Kjønigsen
2022-12-30 19:30               ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-12-31  9:53                 ` Jostein Kjønigsen
2022-12-31 10:32                   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-30 14:40         ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-30 15:04           ` Jostein Kjønigsen
2022-12-31 22:21 ` Yuan Fu
2023-01-01 16:29   ` Jostein Kjønigsen
2023-01-01 17:24     ` Jostein Kjønigsen
2023-01-01 18:14       ` Jostein Kjønigsen
2023-01-01 18:41         ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-02  0:12 ` Yuan Fu
2023-01-02  9:59   ` Jostein Kjønigsen
2023-01-03  5:43     ` Jostein Kjønigsen
2023-01-05 21:27       ` Jostein Kjønigsen
2023-01-03  6:51 ` Yuan Fu
2023-01-03  7:20   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-06  5:55 ` Yuan Fu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r0wgpu3g.fsf@thornhill.no \
    --to=bug-gnu-emacs@gnu.org \
    --cc=60376@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=eliz@gnu.org \
    --cc=jostein@secure.kjonigsen.net \
    --cc=theo@thornhill.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).