Is there a better alternative to this function I use to remove parens around a region? I'm looking for an Emacs builtin, or something better written, something that will remove any pairs around the selected region (ex: brackets, curly brackets, double quotes, single quotes)
(defun my-delete-surrounded-parens () (interactive) ;; save where region begins & ends (let ((beginning (region-beginning)) (end (region-end))) (cond ((not (eq (char-after beginning) ?\()) ;; if region not begins by (, trigger error (error "Char at region-begin not an open-parens")) ((not (eq (char-before end) ?\))) ;; if region not ends by ), trigger error (error "Char at region-end not a close-parens")) ;; save mark, pt, current buffer & execute body ((save-excursion (goto-char beginning) (forward-sexp) (not (eq (point) end))) ;; if parens are not balanced, trigger error (error "parens not balanced")) (t (save-excursion (goto-char end) (delete-char -1) (goto-char beginning) (delete-char 1))))))