From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#4136: 23.1; delete-pair Date: Mon, 14 Sep 2020 16:08:45 +0200 Message-ID: <87r1r48n82.fsf@gnus.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> <87ocqezdfd.fsf@mail.jurta.org> <4A8A549E.20605@gmx.at> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16764"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Eli Barzilay , 4136@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 14 16:21:54 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kHpMf-0004DK-Se for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 14 Sep 2020 16:21:53 +0200 Original-Received: from localhost ([::1]:42500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kHpMe-0005kj-Po for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 14 Sep 2020 10:21:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47114) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kHpAE-0006Qv-6m for bug-gnu-emacs@gnu.org; Mon, 14 Sep 2020 10:09:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44075) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kHpAD-0007qr-Rc for bug-gnu-emacs@gnu.org; Mon, 14 Sep 2020 10:09:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kHpAD-0004y1-M3 for bug-gnu-emacs@gnu.org; Mon, 14 Sep 2020 10:09:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 14 Sep 2020 14:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 4136 X-GNU-PR-Package: emacs Original-Received: via spool by 4136-submit@debbugs.gnu.org id=B4136.160009253819081 (code B ref 4136); Mon, 14 Sep 2020 14:09:01 +0000 Original-Received: (at 4136) by debbugs.gnu.org; 14 Sep 2020 14:08:58 +0000 Original-Received: from localhost ([127.0.0.1]:55621 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kHpAA-0004xh-76 for submit@debbugs.gnu.org; Mon, 14 Sep 2020 10:08:58 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:59728) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kHpA7-0004xT-Q0 for 4136@debbugs.gnu.org; Mon, 14 Sep 2020 10:08:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Rb/RvaTLsqcXEN/zQDFz3TbECyTcMFlOx2FOtU9n2EY=; b=phJ0VspMPrxV1NWgqSHF6glE1G WJzrXqmcRCUlHZ3OgMBmd8ekfkPqqbACSjS0T6oAAYi+WdqrRSqGpm7126ommtwmsnSrPnrjrFDjP Iqiajlwt1UxuPhJsnZoS51tUV6qryDV/jjTJcsTsiZk4e+dRqy35rmNib7HCyb4lEOGA=; Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kHp9y-0002NM-Hw; Mon, 14 Sep 2020 16:08:49 +0200 X-Now-Playing: Jay Glass Dubs's _Epitaph_: "To My Benefitors" In-Reply-To: <4A8A549E.20605@gmx.at> (martin rudalics's message of "Tue, 18 Aug 2009 09:13:34 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:188052 Archived-At: martin rudalics writes: > Ne hlebom jedinnym. Why can't we be generous and provide something like > the attached? The patch no longer applied, so I've respun it for Emacs 28 (included below). The thread here ended with Martin and Juri both agreeing that this was a good idea, but it was never applied? I don't use delete-pair myself regularly, but giving it some testing now, this new version seems to work fine. Any comments? (The patch is 11 years old.) diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el index 8c18557c79..ac4ba78897 100644 --- a/lisp/emacs-lisp/lisp.el +++ b/lisp/emacs-lisp/lisp.el @@ -735,12 +735,37 @@ insert-parentheses (insert-pair arg ?\( ?\))) (defun delete-pair (&optional arg) - "Delete a pair of characters enclosing ARG sexps following point. -A negative ARG deletes a pair of characters around preceding ARG sexps." - (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))) + "Delete a pair of characters enclosing ARG sexps that follow point. +A negative ARG deletes a pair around the preceding ARG sexps instead." + (interactive "P") + (if arg + (setq arg (prefix-numeric-value arg)) + (setq arg 1)) + (if (< arg 0) + (save-excursion + (skip-chars-backward " \t") + (save-excursion + (let ((close-char (char-before))) + (forward-sexp arg) + (unless (member (list (char-after) close-char) + (mapcar (lambda (p) + (if (= (length p) 3) (cdr p) p)) + insert-pair-alist)) + (error "Not after matching pair")) + (delete-char 1))) + (delete-char -1)) + (save-excursion + (skip-chars-forward " \t") + (save-excursion + (let ((open-char (char-after))) + (forward-sexp arg) + (unless (member (list open-char (char-before)) + (mapcar (lambda (p) + (if (= (length p) 3) (cdr p) p)) + insert-pair-alist)) + (error "Not before matching pair")) + (delete-char -1))) + (delete-char 1)))) (defun raise-sexp (&optional arg) "Raise ARG sexps higher up the tree." -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no