1

As far as I understand there is syntax flags only for comment delimiters made up of two characters but if I have comment delimiters of length greater than two characters is it possible to change syntax table accordingly? And if not, how can I resolve this kind of situation? Just change colors and indentation of comment block and forget about syntax table?

2
  • 1
    You can try digging in a mode like html-mode, which uses more complex comments.
    – user12563
    Aug 14, 2017 at 6:51
  • @DoMiNeLa10, ah, of course, I completely forgot about all those languages with which I am not very familiar (there is also ruby I think). Thanks, I'll gonna check this.
    – vonaka
    Aug 14, 2017 at 17:24

1 Answer 1

1

So in case if someone seeks for an answer, as @DoMiNeLa10 suggested, I looked in html-mode and ruby-mode and realised that we can set syntax-propertize-function which is

intended to be used by major modes to install a function which applies syntax-table properties in some mode-appropriate way.

So it would be something like this:

(setq-local syntax-propertize-function
    (syntax-propertize-rules ("complex regexp comment-start" (0 "< b")))
    (syntax-propertize-rules ("complex regexp comment-end"   (0 "> b"))))

In case if regexp contains some groups you need to precise which group to use starting with 1 (0 is reserved for whole expression).

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.