Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lisp] Rescopes parens to be consistent with the guidelines and Clojure. #2312

Closed
wants to merge 5 commits into from

Conversation

s-clerc
Copy link

@s-clerc s-clerc commented Mar 18, 2020

Changes

  1. parens is changed from punctuation.definition... to punctuation.section.
  2. () is included as a language constant.
  3. Tests for both.

Rationale

  1. This is to more strictly follow the scoping guidelines which state that blocks of code delineated in brackets should be scoped in meta.parens with punctuation.section.parens for the brackets.
    The use of the .definition scope led to (perceived) incorrect colouring in Monokai Pro, and this change brings Lisp.sublime-syntax in line with Clojure.sublime-syntax which currently uses punctuation.section.parens.

  2. Adding () as a language.constant because ()nil for the sake of consistency.

  3. By necessity.

@s-clerc s-clerc mentioned this pull request Jul 13, 2020
36 tasks
Copy link
Collaborator

@deathaxe deathaxe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As scope naming guidelines explicitly allow the usasge of meta.group and meta.parens ("based on appropriate semantics"), I'd be curious about the motivation to change meta.group to meta.parens.

I am not a Lisp expert, but with regards to other syntaxes meta.group seems to be used more frequently and appears to be the common meta scope for groups of expressions.

@s-clerc
Copy link
Author

s-clerc commented Jul 19, 2020

I think I switched to parens because the guidelines aren't too clear, so my thinking was that group was more used in cases like the grouping of the arguments after a function f(x, y z) or overriding operator precedence (8 – 2) × 3. While the former use case is quite common in lisp, the latter isn't. As s-expressions are very general — grouping, but also denoting blocks, assignment, lists, and most other data types — I felt it was inappropriate to treat them the same way as simple grouping operators.

I'm not a Sublime Syntax expert by any means. If you think that it would be better to use meta.group instead, we could change it to that. My main concern really is that if schemes want to colour s-expressions particularly, then it might be difficult as Clojure could use meta.group.clojure but Common Lisp uses meta.group.lisp and Racket meta.group.rkt whereas there is unification under meta.parens, although this is under the assumption that Color Schemes cannot use regular expressions.

@deathaxe
Copy link
Collaborator

Agree with scope naming guidelines being a bit unclear at this point. As I didn't follow/attend the discussion about when which of them is appropriate, I'd propably wait for someone who did.

But with regards to your description, your choice feels more appropriate. I'd use groups for operator precedence like use cases only, as well.

Not sure about your concerns about color schemes as they can use parts of scopes as selectors. If a selector in a color scheme addresses meta.group, all scopes beginning with that token would match. Hence all of your examples would (meta.group.closure, meta.group.lisp, meta.group.rkt, etc.).

@s-clerc
Copy link
Author

s-clerc commented Jul 19, 2020

Not sure about your concerns about color schemes as they can use parts of scopes as selectors. If a selector in a color scheme addresses meta.group, all scopes beginning with that token would match. Hence all of your examples would (meta.group.closure, meta.group.lisp, meta.group.rkt, etc.).

I was talking about if a colour scheme wanted to colour things like print() in Python differently from (print) in Lisp. Although, we could probably solve it if we standardised on meta.group.lisp.dialect , and then changed the Clojure syntax file to follow this standard.

@wbond
Copy link
Member

wbond commented Jul 21, 2020

I'd love to converge the work on Lisp by a few different people to a single course of action, if only to try and make the integration process easier. I see you've already been providing feedback on #2387 @s-clerc. Is that in a state where it supersedes this here?

As a comment about meta.parens, that is left generally vague as in some situations languages have very clear semantics about things like parens and braces, and in others the lexing is rather ambiguous. Here with lisp it would seem to me that there is probably a fair bit of ambiguity, so I'd opt for meta.parens instead of meta.group.

@deathaxe
Copy link
Collaborator

Closing as superseded by #3896.

@deathaxe deathaxe closed this Feb 10, 2024
deathaxe added a commit that referenced this pull request Apr 19, 2024
Resolves #1968 

Supersedes #2387
Supersedes #2312

Inspired by #2387 

This PR actually started with #2387 but ended up being a complete rewrite. 
Hence opening a new PR seems more reasonable.

It uses rules from https://www.lispworks.com/documentation/common-lisp.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants