]> git.eshelyaron.com Git - emacs.git/commit
Extend electric-layout-mode to handle more complex layouts (bug#33794)
authorJoão Távora <joaotavora@gmail.com>
Fri, 21 Dec 2018 18:00:08 +0000 (18:00 +0000)
committerJoão Távora <joaotavora@gmail.com>
Wed, 2 Jan 2019 12:55:16 +0000 (12:55 +0000)
commit949295ae1a8a79a181b2bf614b9c69849f2fd667
tree6c1570504f7f43a2c47f1651dae18323b229cdc7
parent0515b223c2158984e135e84be97c01d5b8d0ae75
Extend electric-layout-mode to handle more complex layouts (bug#33794)

Entries in electric-layout-rules can specify multiple
newline-related actions which are executed in order of appearance.

Also, have it play nice with electric-pair-mode when inserting a
newlines, particularly with electric-pair-open-newline-between-pairs.

Entries in electric-layout-rules can also be functions.  Among other
things, the logic behind electric-pair-open-newline-between-pairs
could now be moved to electric-layout-mode, but this commit doesn't do
that yet.

This change was motivated by bug#33794 and is an alternative solution
to the problem reported in that bug.

* lisp/electric.el (electric-layout-rules): Adjust docstring.
(electric-layout-post-self-insert-function): Call
electric-layout-post-self-insert-function-1.
(electric-layout-post-self-insert-function-1): Rename from
electric-layout-post-self-insert-function.  Redesign.
(electric-layout-local-mode): New minor mode.

* test/lisp/electric-tests.el (electric-layout-int-main-kernel-style)
(electric-layout-int-main-allman-style)
(electric-modes-in-c-mode-with-self-insert-command)
(electric-pair-mode-newline-between-parens)
(electric-layout-mode-newline-between-parens-without-e-p-m)
(electric-layout-mode-newline-between-parens-without-e-p-m-2): New
tests.
(plainer-c-mode): New helper.
lisp/electric.el
test/lisp/electric-tests.el