2

It's kind of weird how un-ergonomically placed the parenthesis keys are. I'd like a function that smartly brackets my stuff for me based on context:

  • If the mark is active, the region should be enclosed by ()
  • If the mark is not active and the cursor is in the middle of a symbol, it should enclose the region between the cursor and the next whitespace: foo|bar bla -> foo(|bar) bla.
  • Consecutive calls should result in cycling the bracket type, i.e. (x) -> [x] -> {x} -> ('x') -> ("x") -> ...

This would be awesome. Does there exist a package/function that does something similar already?

1

Item one is provided by simple-paren

The first step of the last request for the moment is realized via keys:

(global-set-key [(super \()] 'simple-paren-parentize)

(global-set-key [(super \[)] 'simple-paren-bracket)

etc.

Item two: push mark at point, forward-word followed by one of the commands above - done.

WRT cycling you may consider a feature request.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.