GNU bug report logs -
#4136
23.1; delete-pair
Previous Next
Reported by: Eli Barzilay <eli <at> barzilay.org>
Date: Thu, 13 Aug 2009 06:30:04 UTC
Severity: normal
Tags: fixed, moreinfo
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #100 received at 4136 <at> emacsbugs.donarmstrong.com (full text, mbox):
>> `insert-pair' inserts an opening character at point. So why
>> `delete-pair' shouldn't do the same? Why it shouldn't delete an
>> opening character at point instead of using some additional
>> heuristics to find the position of the opening character?
>
> We're going back in circles here: "delete *pair*" shouldn't delete an
> opening character unless it is part of a *pair*. If by the above you
> mean make it delete the character pair starting at the current point,
> then that seems fine -- as long as it verifies that there really is a
> pair.
We are in violent agreement. I didn't claim that `delete-pair'
shouldn't check `insert-pair-alist'. On the contrary, I think
`delete-pair' should verify if the character pair starting at the
current point is part of a pair according to `insert-pair-alist'.
"At the current point" - that's my point. It shouldn't try
finding the opening character somewhere else. So in your original
test case it should throw an error when the cursor is on some
whitespace that precedes an expression.
>> Why would I want to put cursor on a non-paren when I want to delete
>> a paren?
>
> You wouldn't, which is why throwing an error is the right thing.
I agree. So I'd like to close this issue with the following patch:
Index: lisp/emacs-lisp/lisp.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/lisp.el,v
retrieving revision 1.102
diff -u -r1.102 lisp.el
--- lisp/emacs-lisp/lisp.el 22 Jul 2009 02:45:37 -0000 1.102
+++ lisp/emacs-lisp/lisp.el 17 Aug 2009 21:16:32 -0000
@@ -530,7 +530,15 @@
(defun delete-pair ()
"Delete a pair of characters enclosing the sexp that follows point."
(interactive)
- (save-excursion (forward-sexp 1) (delete-char -1))
+ (let ((open-char (char-after)))
+ (save-excursion
+ (forward-sexp 1)
+ (unless (member (list open-char (char-before))
+ (mapcar (lambda (p)
+ (if (= (length p) 3) (cdr p) p))
+ insert-pair-alist))
+ (error "Not a matching pair"))
+ (delete-char -1)))
(delete-char 1))
(defun raise-sexp (&optional arg)
--
Juri Linkov
http://www.jurta.org/emacs/
This bug report was last modified 4 years and 181 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.