Extend electric-layout-mode to handle more complex layouts
Also, have it play nice with electric-pair-mode.
Multiple matching entries in `electric-layout-rules' are executed in
order of appearance. When inserting a newline in the 'after-stay
rule, ensure electric-pair-open-newline-between-pairs is nil.
Arguably the logic behind electric-pair-open-newline-between-pairs
should be moved to electric-layout-mode, but the current rule-matching
engine doesn't allow for it. The current solution seems to be good
enough for the situations reported in bug#33794.
* lisp/electric.el (electric-layout-rules): Adjust docstring.
(electric-layout-post-self-insert-function): Loop through rules. Bind
electric-pair-open-newline-between-pairs to nil when handling
after-stay.