New answers tagged

1

Adding an answer based on @gilles-so-stop-being-evil 's current answer which works when the point is on the opening bracket as well as the last bracket, it also error checks and prints useful status upon completion. (defun find-surrounding-brackets (pos) "Return a pair of buffer positions for the opening & closing bracket positions. Or nil when ...


3

Use up-list or backward-up-list to move forward or backward to the first enclosing bracket, then forward-list or backward-list to locate the matching bracket. Delete the closing bracket then the opening bracket (in this order, because deleting the opening bracket moves the position of the closing bracket. (defun delete-enclosing-parentheses (&optional ...


0

Brackets can be detected using forward-sexp and backward-sexp, this examples uses these functions to implement context sensitive bracket removal. (defun find-surrounding-brackets (pt &optional strict) "Find surrounding braces. Argument PT is the point which is checked for brackets. When argument STRICT is non-nil, only use braces at PT, otherwise ...


0

This is an answer I came up with, adding for completeness, however I'd rather not depend on evil-surround because it gives less control and is more likely to break. (defun delete-surround-at-point (arg) (interactive "p") (let ( (best-range most-positive-fixnum) (best-inner nil) (best-outer nil) (chars (list ?\( ?\[ ?\{ ?\" ?\'...


Top 50 recent answers are included