]> git.eshelyaron.com Git - emacs.git/commitdiff
Another iteration for an improved electric-layout-mode scratch/fix-33794-extend-electric-layout-mode
authorJoão Távora <joaotavora@gmail.com>
Sat, 29 Dec 2018 18:34:53 +0000 (18:34 +0000)
committerJoão Távora <joaotavora@gmail.com>
Sat, 29 Dec 2018 18:34:53 +0000 (18:34 +0000)
* lisp/electric.el (electric-layout-rules): Add nil back to
symbols list.
(electric-layout-post-self-insert-function-1): Call function in
correct position.

lisp/electric.el

index b52efb07c7b7a40df3a8f0b5da6923ddad84a443..0484319ed47b7e40a0f3078c8f7a301d84b6c16c 100644 (file)
@@ -372,7 +372,8 @@ just inserted was CHAR.
 
 WHERE can be:
 
-* one of the symbols `before', `after', `around', `after-stay'.
+* one of the symbols `before', `after', `around', `after-stay',
+  or nil.
 
 * a list of the preceding symbols, processed in order of
   appearance to insert multiple newlines;
@@ -408,10 +409,14 @@ If multiple rules match, only first one is executed.")
                           (eq (car probe) last-command-event))
                      (throw 'done (cdr probe)))
                     ((functionp probe)
-                     (let ((res (funcall probe last-command-event)))
+                     (let ((res
+                            (save-excursion
+                              (goto-char
+                               (or pos (setq pos (electric--after-char-pos))))
+                              (funcall probe last-command-event))))
                        (when res (throw 'done res)))))))))
     (when (and rule
-               (setq pos (electric--after-char-pos))
+               (or pos (setq pos (electric--after-char-pos)))
                ;; Not in a string or comment.
                (not (nth 8 (save-excursion (syntax-ppss pos)))))
       (goto-char pos)