summaryrefslogtreecommitdiff
path: root/test/lisp/electric-tests.el
diff options
context:
space:
mode:
authorJoão Távora <joaotavora@gmail.com>2019-05-15 13:10:22 +0100
committerJoão Távora <joaotavora@gmail.com>2019-07-02 16:10:45 +0100
commit5e88b50d542b6d1c4ff43f8ae0fabe8a647d842e (patch)
tree46c5c7e22127d8e6aad017f925514a0fb62c19ca /test/lisp/electric-tests.el
parent2a2a1bdb8f0f149aaf736a61685feec9380be1b1 (diff)
downloademacs-5e88b50d542b6d1c4ff43f8ae0fabe8a647d842e.tar.gz
Correctly reindent previous line in electric-indent-mode
Fixes: bug#35254 Do this even when electric-indent-inhibit is t, except when the newline insertion is being performed by electric-layout-mode. * lisp/electric.el (electric-indent-post-self-insert-function): Reindent previous line unless operating under electric-layout-mode. (electric-layout-post-self-insert-function-1): Bind electric-indent-inhibit to 'electric-layout-mode. * test/lisp/electric-tests.el (electric-layout-control-reindentation): New test.
Diffstat (limited to 'test/lisp/electric-tests.el')
-rw-r--r--test/lisp/electric-tests.el19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/lisp/electric-tests.el b/test/lisp/electric-tests.el
index 4f1e5729be1..86c9eff9cda 100644
--- a/test/lisp/electric-tests.el
+++ b/test/lisp/electric-tests.el
@@ -876,6 +876,25 @@ baz\"\""
(call-interactively (key-binding `[,last-command-event])))
(should (equal (buffer-string) "int main () {\n \n}"))))
+(ert-deftest electric-layout-control-reindentation ()
+ "Same as `e-l-int-main-kernel-style', but checking Bug#35254."
+ (ert-with-test-buffer ()
+ (plainer-c-mode)
+ (electric-layout-local-mode 1)
+ (electric-pair-local-mode 1)
+ (electric-indent-local-mode 1)
+ (setq-local electric-layout-rules
+ '((?\{ . (after))
+ (?\} . (before))))
+ (insert "int main () ")
+ (let ((last-command-event ?\{))
+ (call-interactively (key-binding `[,last-command-event])))
+ (should (equal (buffer-string) "int main () {\n \n}"))
+ ;; insert an additional newline and check indentation and
+ ;; reindentation
+ (call-interactively 'newline)
+ (should (equal (buffer-string) "int main () {\n\n \n}"))))
+
(define-derived-mode plainer-c-mode c-mode "pC"
"A plainer/saner C-mode with no internal electric machinery."
(c-toggle-electric-state -1)