mickeynp / combobulate

Structured Editing and Navigation in Emacs with Tree-Sitter
GNU General Public License v3.0
907 stars 53 forks source link

Unwrap envelope #34

Open phuhl opened 1 year ago

phuhl commented 1 year ago

I found the envelope functions very nice to use. But I did not find a way to unwrap something.

I.e. when using M-( to wrap <div/> in parenthesis it would be great to also have M-) to remove the parenthesis again. Similar for the other envelope types.

mickeynp commented 1 year ago

Good idea! I stole this snippet from emacwiki 20 years ago that does something like that if you hit C-backspace next to an open brace. Might tide you over until I can find the time to add this :)

(defadvice backward-kill-word (around delete-pair activate)
  (if (eq (char-syntax (char-before)) ?\()
      (progn
    (backward-char 1)
    (save-excursion
      (forward-sexp 1)
      (delete-char -1))
    (forward-char 1)
    (append-next-kill)
    (kill-backward-chars 1))
    ad-do-it))