GNU bug report logs -
#32896
27.0.50; wishlist: Delete matching pairs
Previous Next
Reported by: Alex Branham <alex.branham <at> gmail.com>
Date: Mon, 1 Oct 2018 14:35:02 UTC
Severity: wishlist
Found in version 27.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
Message #16 received at 32896 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
>> Fortunately, Emacs already has such a command named ‘delete-pair’:
>> it deletes the parens around the let function as in your first
>> example as well as the quotes in your second example. It makes
>> sense to bind this command to e.g. ‘C-x M-(’ to be the inverse of
>> ‘M-(’ (insert-pair)
>
> Yay! I didn't know about that command (and I really did search before
> reporting this bug, no idea how I missed it!). It doesn't work backward
> though as far as I can tell:
>
> (let (message "%s" "foobar")|)
With a simple twist in the patch attached, it will be able to work backward
with M-- M-x delete-pair, i.e. with a negative prefix argument.
[delete-pair.patch (text/x-diff, inline)]
diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el
index 5a89923f8f..fd6018988e 100644
--- a/lisp/emacs-lisp/lisp.el
+++ b/lisp/emacs-lisp/lisp.el
@@ -723,11 +723,12 @@ insert-parentheses
(interactive "P")
(insert-pair arg ?\( ?\)))
-(defun delete-pair ()
+(defun delete-pair (&optional arg)
"Delete a pair of characters enclosing the sexp that follows point."
- (interactive)
- (save-excursion (forward-sexp 1) (delete-char -1))
- (delete-char 1))
+ (interactive "p")
+ (unless arg (setq arg 1))
+ (save-excursion (forward-sexp arg) (delete-char (if (> arg 0) -1 1)))
+ (delete-char (if (> arg 0) 1 -1)))
(defun raise-sexp (&optional arg)
"Raise ARG sexps higher up the tree."
This bug report was last modified 6 years and 223 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.