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

Indentation issue : "\in" #757

Open
KimayaBedarkar opened this issue Apr 4, 2024 · 2 comments
Open

Indentation issue : "\in" #757

KimayaBedarkar opened this issue Apr 4, 2024 · 2 comments
Labels
kind: bug part: indentation Problems with indentation feature of PG

Comments

@KimayaBedarkar
Copy link

SSReflect uses \in as opposed to the unicode to indicate membership in lists. However, the former is not indented correctly.
Example:

Lemma test:
  forall a : nat,
    a \in [::] ->
          False. (* indented by 4 spaces*)

as opposed to:

Lemma test:
  forall a : nat,
    a ∈ [::] ->
    False. (* not indented *)
@Matafou
Copy link
Contributor

Matafou commented Sep 9, 2024

Hi. Sadly the coq-smie-user-tokens variable that usually can solve this kind of problem does not work in this case because "\" is not considered as part f a token by PG's lexer. I will think about a way to include this characters in lexing but this will not happen in a short future I am afraid. Sorry...

Poor work around: put parenthesis around a \n [::].

Matafou added a commit to Matafou/PG that referenced this issue Sep 10, 2024
The lexer now glues a "\" to an immediately following word if it is
itself preceded by a space.

Note that for really good indentation you should try to add something
like this to your configuration:

(setq coq-smie-user-tokens '(("\\in" . "=")))

to tell the indentation grammar that \in has the same precedence as
"=".
@Matafou
Copy link
Contributor

Matafou commented Sep 10, 2024

Actually I think I found a simple way to fix this. @KimayaBedarkar can you test this?
I get this indentation now:

Require Import mathcomp.ssreflect.ssrbool.

Definition xx := nat.
Module foo.
  (* from PG issue #757 *)
  Lemma test:
    forall a : nat,
      a \in [::] ->  (* "\in" should be detected as one token *)
      False.
  Proof.
  Abort.

  Lemma test2:
    forall a : nat,
      a \in  (* "\in" should be detected as one token *)
        [::] ->
      False.
End foo.

@erikmd erikmd added kind: bug part: smie-indentation part: indentation Problems with indentation feature of PG and removed part: smie-indentation labels Sep 10, 2024
Matafou added a commit that referenced this issue Sep 11, 2024
The lexer now glues a "\" to an immediately following word if it is
itself preceded by a space.

Note that for really good indentation you should try to add something
like this to your configuration:

(setq coq-smie-user-tokens '(("\\in" . "=")))

to tell the indentation grammar that \in has the same precedence as
"=".

Test added.
Matafou added a commit to Matafou/PG that referenced this issue Sep 11, 2024
The lexer now glues a "\" to an immediately following word if it is
itself preceded by a space.

Note that for really good indentation you should try to add something
like this to your configuration:

(setq coq-smie-user-tokens '(("\\in" . "=")))

to tell the indentation grammar that \in has the same precedence as
"=".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug part: indentation Problems with indentation feature of PG
Projects
None yet
Development

No branches or pull requests

3 participants