bug#81551: 31.0.91; Electric-pair-mode should support Java's text blocks in java-mode, java-ts-mode
Sean Whitton <[email protected]> Wed, 05 Aug 2026 10:32:49 +0100
| Newsgroups | gmane.emacs.bugs |
|---|---|
| Message-ID | <[email protected]> |
Rudi Schlatte [04/Aug 3:42pm +02] wrote:
> Java >= 15 has support for "text blocks", multi-line strings delimited
> by triple quotation marks similar to Python, e.g.:
>
> """
> This is how Java's
> multi-line strings look like.
> """
>
> In my configuration, I added support for this to electric-pair-mode like so:
>
> (add-hook 'java-mode-hook
> (lambda ()
> (setq-local electric-pair-pairs
> (cons '("\"\"\"" . "\"\"\"") electric-pair-pairs))))
>
> and similar for java-ts-mode. I could prepare a patch that adds this to
> java-ts-mode.el if this is the proper way to implement this.
>
> But is there a better way for mode-specific customization of
> electric-pair-mode? The docstring of electric-pair-pairs says that it's
> a fallback variable and that it can be overridden via a mode's syntax
> table, but do syntax tables support this type of multi-character
> delimiter?
>
> FWIW, python.el and other modes included in Emacs seem to implement
> multi-character electric pairs via adding a mode-specific function to
> `post-self-insert-hook' instead of this built-in functionality.
It's fine to go ahead and implement it in the same way that those others
modes in the tree already do, if you'd like to prepare a patch.
--
Sean Whitton