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

font lock string face #64

Open
DanGrayson opened this issue Jun 6, 2022 · 8 comments
Open

font lock string face #64

DanGrayson opened this issue Jun 6, 2022 · 8 comments

Comments

@DanGrayson
Copy link
Member

I use the code

(defconst M2-mode-font-lock-keywords ' ( "///\\(/?/?[^/]\\|\\(//\\)*////[^/]\\)*\\(//\\)*///" . 'font-lock-string-face) )

to try to highlight strings delimited by /// ... ///, but the regular expression is so complicated (with backtracking) that it can sometimes cause a delay up to 45 seconds when using C-s to search through a file, as @mikestillman has observed.

We could simplify the regular expression drastically to "///.*///", and not worry about getting every single case correct.

@d-torrance
Copy link
Member

I was working on some code a few months ago that might help out with this. Check out #31.

@mahrud
Copy link
Member

mahrud commented Jun 6, 2022

We could simplify the regular expression drastically to "///.*///", and not worry about getting every single case correct.

You could use "lookarounds" instead.

@DanGrayson
Copy link
Member Author

We could simplify the regular expression drastically to "///.*///", and not worry about getting every single case correct.

You could use "lookarounds" instead.

Does emacs implement those?

@DanGrayson
Copy link
Member Author

I was working on some code a few months ago that might help out with this. Check out Macaulay2/M2-emacs#31.

Would (could) that be ready soon?

@d-torrance
Copy link
Member

I was working on some code a few months ago that might help out with this. Check out Macaulay2/M2-emacs#31.

Would (could) that be ready soon?

The part that highlights ///-delimited strings is ready, with the big caveat that it currently breaks syntax highlighting inside doc and TEST strings. That's why I left it as a draft -- I'm not sure if that's a dealbreaker or not.

@DanGrayson
Copy link
Member Author

The desire to highlight the contents of such big strings is perhaps a good argument against doing any highlighting of
those big strings as strings.

@d-torrance
Copy link
Member

The desire to highlight the contents of such big strings is perhaps a good argument against doing any highlighting of those big strings as strings.

That makes sense! I removed the ///-related commits from M2-emacs#31..

@d-torrance
Copy link
Member

Is this still an issue after #31?

@mahrud mahrud transferred this issue from Macaulay2/M2 Jun 25, 2024
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

3 participants