Commit fae3e7c0 authored by João Távora's avatar João Távora

Test electric.el in plainer c-mode without c-electric-{brace,paren}

If cc-mode ever drops/changes its usage of c-electric-{brace,paren}
test that electric pairing, layout and indentation based on
electric.el keep working.

* test/lisp/electric-tests.el
(electric-layout-int-main-kernel-style)
(electric-layout-int-main-allman-style): Change order of after and
after-stay.
(plainer-c-mode): New test mode.
(electric-modes-in-c-mode-with-self-insert-command): New test.
parent e4ef7a2e
......@@ -823,7 +823,7 @@ baz\"\""
(electric-pair-local-mode 1)
(electric-indent-local-mode 1)
(setq-local electric-layout-rules
'((?\{ . (after after-stay))))
'((?\{ . (after-stay after))))
(insert "int main () ")
(let ((last-command-event ?\{))
(call-interactively (key-binding `[,last-command-event])))
......@@ -837,7 +837,26 @@ baz\"\""
(electric-pair-local-mode 1)
(electric-indent-local-mode 1)
(setq-local electric-layout-rules
'((?\{ . (before after after-stay))))
'((?\{ . (before after-stay after))))
(insert "int main () ")
(let ((last-command-event ?\{))
(call-interactively (key-binding `[,last-command-event])))
(should (equal (buffer-string) "int main ()\n{\n \n}")))))
(define-derived-mode plainer-c-mode c-mode "pC"
"A plainer C-mode")
(ert-deftest electric-modes-in-c-mode-with-self-insert-command ()
(save-electric-modes
(ert-with-test-buffer ()
(plainer-c-mode)
(electric-layout-local-mode 1)
(electric-pair-local-mode 1)
(electric-indent-local-mode 1)
(dolist (key '(?\" ?\' ?\{ ?\} ?\( ?\) ?\[ ?\]))
(local-set-key (vector key) 'self-insert-command))
(setq-local electric-layout-rules
'((?\{ . (before after-stay after))))
(insert "int main () ")
(let ((last-command-event ?\{))
(call-interactively (key-binding `[,last-command-event])))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment