2

Java SE 15 adds (finally) support for multiline string literals that start with """\n and end with """.

Has anyone updated java-mode (CC Mode) to recognize this construct?

3
  • It used to work for me, then regressed on upgrading from 26.3 to 27.1. (A triple delimited string would fontify as three separate strings by default, and should look fine. Maybe that’s how it worked in the past.) Mar 21, 2021 at 6:39
  • Maybe look at python-mode for an implementation?
    – Jeremy
    May 28, 2021 at 2:54
  • If you have a problem, it won't get fixed until someone files a proper bug report.
    – Dmitry
    Jan 10, 2022 at 21:14

1 Answer 1

0

I've updated my java mode hook to use mmm-mode here:

(require 'mmm-auto)
(setq mmm-global-mode 'maybe)
(mmm-add-classes
 '((java-text-block
    :submode fundamental-mode
    :front ".+\"\"\"$"
    :back ".*\"\"\".*"
    :face mmm-code-submode-face
    )))
(mmm-add-mode-ext-class 'java-mode "\\.java$" 'java-text-block)

works well enough, although I'd like a better way to make mmm-mode smarter to the content of the block. e.g. entering json-mode for json text, xml-mode for xml, etc...

I've done this previously in ruby with ruby's unique heredoc string syntax, but I can't figure out a clean way to make it work in Java.

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.