I frequently encounter the issue of having to insert an additional nest of parentheses (or some other delimiter) over an expression when misjudging how deep to nest my expression, especially for lisp. Is there a package or native emacs/slime function that will allow me to achieve the following:

Point is represented by .




or in other words duplicates the layer of parentheses the point is on.

I'm aware Vim/Evil has % which to allows one to move between opening and closing parentheses but is there a more elegant solution?

  • You can easily define a function that does that (if one does not exist already), but in practice, this is almost never a problem: the problem is usually having enough parentheses to close off a form. Blinking the matching paren and the movement-over-structure commands are far more useful IMO: see Parentheses in the Emacs manual. – NickD Jun 28 at 12:28
  • Another thing: although you can "easily" define a function that does what you ask in the situation you describe, the error cases are not so easily handled: you'd have to specify what the function should do e.g. if you call it on an expression like this: (foo.; or like this: ((foo) (bar.) or the many other situations where you don't have a well-formed s-expr to begin with. – NickD Jun 28 at 13:02

Your Answer

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

Browse other questions tagged or ask your own question.