From 0621591687c6f032077213e85280936e35e45af0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Fri, 18 Jan 2019 22:05:36 +0000 Subject: [PATCH] Ensure fns in electric-layout-rules are called in right position * lisp/electric.el (electric-layout-rules): Ensure rules are called from right spot. --- lisp/electric.el | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lisp/electric.el b/lisp/electric.el index 4791f8e18c4..6977a950349 100644 --- a/lisp/electric.el +++ b/lisp/electric.el @@ -383,8 +383,8 @@ in the same place. Instead of the (CHAR . WHERE) form, a rule can also be just a function of a single argument, the character just inserted. It -should return a value compatible with WHERE if the rule matches, -or nil if it doesn't match. +is called at that position, and should return a value compatible with +WHERE if the rule matches, or nil if it doesn't match. If multiple rules match, only first one is executed.") @@ -408,7 +408,11 @@ If multiple rules match, only first one is executed.") (save-excursion (goto-char (or pos (setq pos (electric--after-char-pos)))) - (funcall probe last-command-event)))) + ;; Ensure probe is called at the + ;; promised place. FIXME: maybe warn if + ;; it isn't + (when (eq (char-before) last-command-event) + (funcall probe last-command-event))))) (when res (throw 'done res))))))))) (when (and rule (or pos (setq pos (electric--after-char-pos))) -- 2.39.2