From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#4136: 23.1; delete-pair Date: Tue, 18 Aug 2009 00:17:11 +0300 Organization: JURTA Message-ID: <87ocqezdfd.fsf@mail.jurta.org> References: <19075.45378.67131.491453@winooski.ccs.neu.edu> <4A83E299.3060002@gmx.at> <87tz0bqqhm.fsf@mail.jurta.org> <4A850F6C.2080205@gmx.at> <873a7uc8mg.fsf@mail.jurta.org> <4A8689EE.9020402@gmx.at> <87ljlk4snf.fsf@mail.jurta.org> <87eirfs56q.fsf@mail.jurta.org> <19076.47996.128071.281272@winooski.ccs.neu.edu> <87pray9ezq.fsf@mail.jurta.org> <19078.4981.525959.210519@winooski.ccs.neu.edu> <87ab20znhd.fsf@mail.jurta.org> <19079.19478.357436.68768@winooski.ccs.neu.edu> <87k5131d3d.fsf@mail.jurta.org> <19080.51949.798286.416193@winooski.ccs.neu.edu> Reply-To: Juri Linkov , 4136@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1250797755 25988 80.91.229.12 (20 Aug 2009 19:49:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 20 Aug 2009 19:49:15 +0000 (UTC) Cc: 4136@emacsbugs.donarmstrong.com To: Eli Barzilay Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 20 21:49:00 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MeDd5-00028Y-Sr for geb-bug-gnu-emacs@m.gmane.org; Thu, 20 Aug 2009 21:49:00 +0200 Original-Received: from localhost ([127.0.0.1]:40118 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MeDd5-00032b-Cv for geb-bug-gnu-emacs@m.gmane.org; Thu, 20 Aug 2009 15:48:59 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MeDbp-0001xc-Bb for bug-gnu-emacs@gnu.org; Thu, 20 Aug 2009 15:47:41 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MeDbj-0001rI-RL for bug-gnu-emacs@gnu.org; Thu, 20 Aug 2009 15:47:40 -0400 Original-Received: from [199.232.76.173] (port=33860 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MeDbj-0001r5-HT for bug-gnu-emacs@gnu.org; Thu, 20 Aug 2009 15:47:35 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:46154) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MeDbi-0002T2-Ou for bug-gnu-emacs@gnu.org; Thu, 20 Aug 2009 15:47:35 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n7KJkpLX004437; Thu, 20 Aug 2009 12:47:32 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id n7KJctIQ002500; Thu, 20 Aug 2009 12:38:55 -0700 Resent-Date: Thu, 20 Aug 2009 12:38:55 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Juri Linkov Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Thu, 20 Aug 2009 19:38:54 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 4136 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 4136-submit@emacsbugs.donarmstrong.com id=B4136.12505444965568 (code B ref 4136); Thu, 20 Aug 2009 19:38:54 +0000 Original-Received: (at 4136) by emacsbugs.donarmstrong.com; 17 Aug 2009 21:28:16 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from mx2.starman.ee (smtp-out2.starman.ee [85.253.0.4]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n7HLSEAP005565 for <4136@emacsbugs.donarmstrong.com>; Mon, 17 Aug 2009 14:28:15 -0700 X-Virus-Scanned: by Amavisd-New at mx2.starman.ee Original-Received: from mail.starman.ee (82.131.53.255.cable.starman.ee [82.131.53.255]) by mx2.starman.ee (Postfix) with ESMTP id D09B83F406C; Tue, 18 Aug 2009 00:28:07 +0300 (EEST) In-Reply-To: <19080.51949.798286.416193@winooski.ccs.neu.edu> (Eli Barzilay's message of "Sun, 16 Aug 2009 23:13:49 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Thu, 20 Aug 2009 15:47:40 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:30324 Archived-At: >> `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/