From: Yuan Fu <casouri@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Standardizing tree-sitter fontification features
Date: Thu, 24 Nov 2022 22:34:12 -0800 [thread overview]
Message-ID: <ED4186C6-478B-4797-93D4-6A3719AA1DEB@gmail.com> (raw)
In-Reply-To: <jwvsfi7u553.fsf-monnier+emacs@gnu.org>
> On Nov 24, 2022, at 6:56 PM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
>> Basic tokens:
>>
>> delimiter ,.;
>> operator = != ||
>
> From the grammar point of view, both of these are simply infix thingies.
> Defining precisely the difference between them can be a bit more
> delicate, tho. I guess intuitively the idea is that "operator"
> corresponds to some kind of run-time operation whereas "delimiter"
> serves only to figure out where things start and end but doesn't do
> anything in itself.
Maybe think in semantics? If it produces some value, it’s an operator, otherwise it’s a delimiter/punctuation. And I should have used == instead of = in the example. I was thinking of ==.
>
> Not clear where the `=` used for definitions (as in "let x = foo in
> bar") should fall. Same for the "," used to construct pairs
> or the conjunction/disjunction in Prolog written `,` and `;`
> respectively :-)
I think stuff like `:` in Haskell (I only know Haskell) can be considered operator, but `::` would be punctuation. With that said, I didn’t put much thought into delimiters, and it seems to be a slippery slope (as shown in your `=` example). Maybe we should limit it to the narrowest scope for now, just things like , ; that truly are delimiting things.
>
>> string-interpolation f"text {variable}"
>> escape-sequence "\n\t\\"
>> function every function identifier
>
> I think we definitely need to distinguish a reference/use of a function
> from a definition of a function. I do want my function identifiers
> highlighted in my function definitions but *not* in my function calls.
That’s when assignment/definition come in. See my reply to Randy.
>
>> variable every variable identifier
>
> Same here.
> [ Note that in many languages (e.g. Scheme and C), functions and
> "variables" are the same (i.e. Lisp-1 in the world of Lisp). ]
We can say that if the symbol is used as a function, highlight in function face, and if it is used as a value, highlight in variables face.
>
>> type every type identifier
>
> And same here as well.
> [ I will spare you the discussion of what should happen for dependently
> typed languages where types are "normal" values. ]
“Anything capitalized in type face”, I guess ;-)
>
>> Also, some of the features are very busy, it would be good if we can disable
>> they by default. The default value of font-lock-maximum-decoration is t,
>> meaning use everything, which is not very helpful...
>
> If you compare the "style" of font-lock rules used until now to those
> provide in the new tree-sitter modes, I think it makes sense for
> tree-sitter modes to default to "medium" decorations.
Like setting font-lock-maximum-decoration to a number in major mode body, it its default value is t? That changes the meaning of t in font-lock-maximum-decoration. Can we change its default value to 3, and put the busy features at level 4? I need to survey existing major modes and see how many levels do they have right now.
Yuan
next prev parent reply other threads:[~2022-11-25 6:34 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-24 22:16 Standardizing tree-sitter fontification features Yuan Fu
2022-11-25 1:13 ` Randy Taylor
2022-11-25 6:15 ` Yuan Fu
2022-11-25 19:03 ` Randy Taylor
2022-11-25 20:55 ` Yuan Fu
2022-11-26 3:35 ` Randy Taylor
2022-12-05 21:17 ` Yuan Fu
2022-11-25 8:13 ` Eli Zaretskii
2022-11-25 19:14 ` Randy Taylor
2022-11-26 14:07 ` Stephen Leake
2022-11-25 2:56 ` Stefan Monnier
2022-11-25 6:34 ` Yuan Fu [this message]
2022-11-25 14:52 ` Stefan Monnier
2022-11-26 14:03 ` Stephen Leake
2022-11-26 14:29 ` [SPAM UNSURE] " Stephen Leake
2022-11-26 22:05 ` [SPAM UNSURE] " Yuan Fu
[not found] ` <2AEA8AB6-593E-4D89-AB05-0C8EB2BCE327@gmail.com>
2022-12-03 1:12 ` Yuan Fu
2022-12-03 14:34 ` Mattias Engdegård
2022-12-05 8:58 ` Theodor Thornhill
2022-12-05 10:26 ` Mattias Engdegård
2022-12-05 11:30 ` Theodor Thornhill
2022-12-05 21:02 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ED4186C6-478B-4797-93D4-6A3719AA1DEB@gmail.com \
--to=casouri@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.