Update of bracket auto edit strategy

The old behavior was inconsistent, thus it is changed to follow these
two rules:

1. An opening brace is always closed except when it is inserted directly
   before non white space:

     xs map ^(_+1) ==> xs map {^(_+1)

2. Furthermore, an opening brace is not closed if there are unmatched
   closing braces after the caret position:

     xs map {^}} ==> xs map {{^}}