From d9c90e83b6ae6525fa733116edbe7634f143fd92 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 13 Jun 2026 01:31:32 -0500 Subject: fix(snippets): stop electric-pair from stranding ">" after "<"-key snippets Most of the yasnippet keys start with "<" (" wherever the mode's syntax table gives "<" paren syntax, which org and the pairing-enabled prog modes both do. So typing "", and expanding the "" after the snippet. The cj-comment block came out with a "#+end_src>" close fence, which breaks the cj-scan fence parser and made every respond-to-cj-comments pass hand-parse around it. I set electric-pair-inhibit-predicate globally to inhibit the open angle bracket and defer to the default for every other character. That keeps the "<"-prefixed snippet convention intact across all 14 of them, at the cost of "<>" auto-pairing where it might otherwise be wanted (C++ templates). The snippet convention is universal, so it wins. Surfaced from the smoke project, which kept hitting the malformed fence in its todo.org. --- modules/prog-general.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'modules') diff --git a/modules/prog-general.el b/modules/prog-general.el index a4be72050..8b4dedda4 100644 --- a/modules/prog-general.el +++ b/modules/prog-general.el @@ -298,6 +298,22 @@ This is what makes universal snippets like =" wherever the mode's +;; syntax table gives "<" paren syntax (org, and the prog modes that enable +;; pairing), so typing ""; expanding the "" after the snippet — the cj-comment fence comes out as +;; "#+end_src>", which breaks the cj-scan fence parser. Inhibit pairing for the +;; open angle bracket globally; defer to the default for every other character. +(defun cj/--electric-pair-inhibit-angle (char) + "Return non-nil to stop `electric-pair-mode' from pairing the angle CHAR. +Inhibit the open angle bracket so \"<\"-prefixed yasnippet keys expand cleanly; +defer to `electric-pair-default-inhibit' for any other CHAR." + (or (eq char ?<) + (electric-pair-default-inhibit char))) + +(setq electric-pair-inhibit-predicate #'cj/--electric-pair-inhibit-angle) + ;; --------------------- Display Color On Color Declaration -------------------- ;; display the actual color as highlight to color hex code -- cgit v1.2.3