bug#81551: 31.0.91; Electric-pair-mode should support Java's text blocks in java-mode, java-ts-mode
Rudi Schlatte <[email protected]> Tue, 4 Aug 2026 15:42:50 +0200
| Newsgroups | gmane.emacs.bugs |
|---|---|
| Message-ID | <[email protected]> |
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.
Rudi