Macaulay2 / M2-emacs

Macaulay2 emacs files
GNU General Public License v3.0
5 stars 3 forks source link

font lock string face #64

Open DanGrayson opened 2 years ago

DanGrayson commented 2 years ago

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 commented 2 years ago

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

mahrud commented 2 years ago

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

You could use "lookarounds" instead.

DanGrayson commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 4 months ago

Is this still an issue after https://github.com/Macaulay2/M2-emacs/pull/31?