1

I'm trying to build a major mode for xwiki, where I'm defining

{{{
verbatim
}}}

as a comment.

So far, I've done

    (eval-when-compile
      (defconst xwiki-syntax-propertize-rules
        (syntax-propertize-precompile-rules
         ("{{{" (0 "< b"))
         ("}}}" (0 "> b")))))

     (setq-local syntax-propertize-function (syntax-propertize-rules xwiki-syntax-propertize-rules))

When I do describe-char, on any of the characters in {{{, I see that it is identified as a comment style b. I also see }}} identified as comment style b.

However, under text properties, there's nothing set for face. Am I missing something?

2
  • Has font-lock even started? Have you defined font-lock-defaults? Commented Nov 7, 2021 at 19:52
  • I believe so, I did a (setq-local font-lock-defaults '(xwiki-mode-font-lock-keywords t)) in a define-derived-mode, and then I did an eval-buffer, and I switched into another buffer with xwiki text and did xwiki-mode Commented Nov 8, 2021 at 0:54

1 Answer 1

2

The above code will indeed set something for face. @Lindydancer helped me realize that I had set font-lock-defaults with the second parameter (keywords-only) of the list as t).

Unsetting keywords-only fixed the above and enabled highlighting.

Also, with

(eval-when-compile
  (defconst xwiki-syntax-propertize-rules
    (syntax-propertize-precompile-rules
     ("{{{" (0 "< b"))
     ("}}}" (0 "> b")))))

The last two }} did not get fontified with the comment face, but with

(eval-when-compile
  (defconst xwiki-syntax-propertize-rules
    (syntax-propertize-precompile-rules
     ("\\({\\){{" (1 "< b"))
     ("}}\\(}\\)" (1 "> b")))))

It gets fontified correctly - {{{, }}}, and everything between those get fontified as comments.

1
  • 1
    I'm glad that you figured it out! If you are planning to add font-lock keywords, you can use my package font-lock-studio to debug them. (It wouldn't have helped in this case, though, since it work for debugging keywords, not the syntactic function.) If you run into more problems, feel free to ask! Commented Nov 8, 2021 at 6:44

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.