nim-lang / nim-mode

An emacs major mode for the Nim programming language
138 stars 46 forks source link

Font-locking fails when `font-lock-maximum-decoration` is an alist #228

Closed zk-phi closed 4 years ago

zk-phi commented 4 years ago

Conforming Bugs

Please tell us below:

And describe your problem:

When font-lock-maximum-decoration is an alist (((cperl-mode . 1) (t . t)) in my environment), nim-mode fails to font-lock the buffer with invalid-function error (seen in the *Messages* buffer).

I also tried to call font-lock-fontify-region manually and got following backtrace:

Debugger entered--Lisp error: (invalid-function ("\\(?:^\\|;\\) *\\_<\\(?:\\(?:converter\\|func\\|iterator\\|m\\(?:acro\\|ethod\\)\\|proc\\|template\\)\\)\\_> +\\(\\(?:[[:alpha:]]\\(?:_\\|[[:alnum:]]\\)*\\|`[]-_!$-&*-/<-@[|~[:alnum:]]+?`\\) *\\(\\*\\)?\\)" (1 (if (match-string 2) 'nim-font-lock-export-face font-lock-function-name-face) keep t)))
("\\(?:^\\|;\\) *\\_<\\(?:\\(?:converter\\|func\\|iterator\\|m\\(?:acro\\|ethod\\)\\|proc\\|template\\)\\)\\_> +\\(\\(?:[[:alpha:]]\\(?:_\\|[[:alnum:]]\\)*\\|`[]-_!$-&*-/<-@[|~[:alnum:]]+?`\\) *\\(\\*\\)?\\)" (1 (if (match-string 2) 'nim-font-lock-export-face font-lock-function-name-face) keep t))(184)
font-lock-fontify-keywords-region(1 184 nil)
font-lock-default-fontify-region(1 184 nil)
font-lock-fontify-region(1 184)
eval((font-lock-fontify-region (point-min) (point-max)) nil)

This does not occur when font-lock-maximum-decoration is t, which is the default value.

krux02 commented 4 years ago

Thanks a lot for the feedback. I think this should be easy to fix.