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

Emacs lisp question mark in function name can break coloring #42

Open
ghost opened this issue Oct 9, 2014 · 4 comments
Open

Emacs lisp question mark in function name can break coloring #42

ghost opened this issue Oct 9, 2014 · 4 comments

Comments

@ghost
Copy link

ghost commented Oct 9, 2014

Alright, so I took a quick look at why this is happening and I don't know if there is an easy fix. Basically, if you do(in emacs lisp):

(cond ((test?) (blah))))

Rainbow delimiters reads ?) as emacs lisp's character syntax and doesn't treat the ) as a pair, causing the color highlighting to break.

This may be hard to fix, I am not familiar enough with emacs lisp to know all the rules of when ?) should be interpreted as the character ) and when it should be interpreted as a delimiter.

My guess would be that if it is possible to check for ' ?)' versus '?)' then it would work, but i'm by no means sure. Basically the idea would be in perl regex form that you'd ignore

\s\?\)

but not

\S\?\)
@purcell
Copy link
Collaborator

purcell commented Oct 9, 2014

I'll leave it to @Fanael to comment authoritatively, but I believe that the syntax table will know the truth about how to interpret a particular occurrence of ?). rainbow-delimiters already uses info from the syntax table to help do the right thing: this is probably a case where a simple regexp is being relied upon too heavily.

@Fanael
Copy link
Collaborator

Fanael commented Oct 9, 2014

I believe that the syntax table will know the truth about how to interpret a particular occurrence of ?).

It won't. Go ahead and see what syntax-ppss returns at

(foo? ?) ?\))
    ^^^^   ^

In fact, (aref (syntax-table) ?\?) is (3), which means ) is just a symbol, with no additional flags. From syntax table POV, ? is basically the same as, say, -.

When I tried to solve this problem to fix Fanael/highlight-quoted#1, I came to the conclusion that to handle everything correctly you need to implement pretty much the Emacs Lisp reader, working in reverse.

I'm afraid that unless somebody can show me I'm wrong and there's no need for the reader in reverse, all I can do is to wait for a patch to magically appear.

Note to self: my Lisp shall use #"a" as the character literal syntax.

@Fanael
Copy link
Collaborator

Fanael commented Oct 9, 2014

My guess would be that if it is possible to check for ' ?)' versus '?)' then it would work, but i'm by no means sure.

Not really, consider:

;; I know ?\( is recommended instead, but ?( is still pretty commonly used.
(pcase foo
  (?( 
   (bar))
  (?)
   (qux)))

@Fanael
Copy link
Collaborator

Fanael commented Oct 26, 2014

Development has moved to https://github.com/Fanael/rainbow-delimiters. If the issue still persists, please report it there.

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

No branches or pull requests

2 participants