From 2ebac3ccfc183bbc4e05ad139766288b5902817b Mon Sep 17 00:00:00 2001 From: kovan Date: Fri, 13 Feb 2026 22:39:42 +0100 Subject: [PATCH] fix(electric): reorder electric-quote hook to run before smartparens When `electric-quote-mode' is enabled with smartparens, the `electric-quote-inhibit-functions' check (e.g. `org-in-src-block-p') fails because smartparens' post-self-insert handler runs first and interferes with buffer state. Re-add the electric-quote handler at depth -50 so it runs before smartparens (depth 0). Fix: #5051 Co-authored-by: Claude Opus 4.6 --- modules/emacs/electric/config.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/emacs/electric/config.el b/modules/emacs/electric/config.el index 82188a6d2..e53914b4d 100644 --- a/modules/emacs/electric/config.el +++ b/modules/emacs/electric/config.el @@ -15,4 +15,13 @@ current line.") (when (and (eolp) +electric-indent-words) (save-excursion (backward-word) - (looking-at-p (concat "\\<" (regexp-opt +electric-indent-words)))))))) + (looking-at-p (concat "\\<" (regexp-opt +electric-indent-words))))))) + + ;; Fix #5051: Ensure electric-quote's handler runs before smartparens' on + ;; `post-self-insert-hook', so that `electric-quote-inhibit-functions' + ;; (e.g. `org-in-src-block-p') is respected in org src blocks. + (add-hook! 'electric-quote-mode-hook + (defun +electric-quote-reorder-post-self-insert-h () + (when electric-quote-mode + (remove-hook 'post-self-insert-hook #'electric-quote-post-self-insert-function) + (add-hook 'post-self-insert-hook #'electric-quote-post-self-insert-function -50)))))