From unknown Sun Jun 22 22:43:52 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#14000 <14000@debbugs.gnu.org> To: bug#14000 <14000@debbugs.gnu.org> Subject: Status: 24.3.50; electric-pair-post-self-insert-function does not handle nested parentheses Reply-To: bug#14000 <14000@debbugs.gnu.org> Date: Mon, 23 Jun 2025 05:43:52 +0000 retitle 14000 24.3.50; electric-pair-post-self-insert-function does not han= dle nested parentheses reassign 14000 emacs submitter 14000 Carsten Bormann severity 14000 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 19 15:55:32 2013 Received: (at submit) by debbugs.gnu.org; 19 Mar 2013 19:55:32 +0000 Received: from localhost ([127.0.0.1]:36063 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UI2d9-0006xJ-LZ for submit@debbugs.gnu.org; Tue, 19 Mar 2013 15:55:31 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53940) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UI2d7-0006x8-CX for submit@debbugs.gnu.org; Tue, 19 Mar 2013 15:55:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UI2bR-0002sg-LM for submit@debbugs.gnu.org; Tue, 19 Mar 2013 15:53:48 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:58040) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UI2bR-0002sW-GY for submit@debbugs.gnu.org; Tue, 19 Mar 2013 15:53:45 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37016) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UI2bN-0002c3-Ng for bug-gnu-emacs@gnu.org; Tue, 19 Mar 2013 15:53:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UI0pb-0006pg-U5 for bug-gnu-emacs@gnu.org; Tue, 19 Mar 2013 14:00:22 -0400 Received: from mailhost.informatik.uni-bremen.de ([2001:638:708:30c9::12]:51414 helo=informatik.uni-bremen.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UI0pb-0006oD-HD for bug-gnu-emacs@gnu.org; Tue, 19 Mar 2013 14:00:15 -0400 X-Virus-Scanned: amavisd-new at informatik.uni-bremen.de Received: from alma.local.informatik.uni-bremen.de (maildrop.informatik.uni-bremen.de [134.102.201.19]) by informatik.uni-bremen.de (8.14.4/8.14.4) with ESMTP id r2JI01C2025406 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Tue, 19 Mar 2013 19:00:06 +0100 (CET) X-Mailer: emacs 24.3.50.1 (via feedmail 11-beta-1 I) From: Carsten Bormann To: bug-gnu-emacs@gnu.org Subject: 24.3.50; electric-pair-post-self-insert-function does not handle nested parentheses Date: Tue, 19 Mar 2013 18:59:53 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) In electric-pair-mode, I type "((" I get "(()" I should get "(())" Fix below. In GNU Emacs 24.3.50.1 (x86_64-apple-darwin, NS apple-appkit-1038.36) of 2013-03-19 on bob.porkrind.org Bzr revision: 112090 dgutov@yandex.ru-20130319050649-jie5ixrjvsavih4i Windowing system distributor `Apple', version 10.3.1187 Configured using: `configure --host=x86_64-apple-darwin --build=i686-apple-darwin --with-ns' --- electric.el 2013-03-19 18:51:05.000000000 +0100 +++ electric-fixed.el 2013-03-19 18:55:59.000000000 +0100 @@ -354,7 +354,10 @@ ;; I find it more often preferable not to pair when the ;; same char is next. (eq last-command-event (char-after)) - (eq last-command-event (char-before (1- (point)))) + (and + (eq last-command-event (char-before (1- (point)))) + (not (eq syntax ?\()) + ) ;; I also find it often preferable not to pair next to a word. (eq (char-syntax (following-char)) ?w))) (save-excursion (insert closer)))))) From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 25 22:43:59 2013 Received: (at 14000) by debbugs.gnu.org; 26 Mar 2013 02:43:59 +0000 Received: from localhost ([127.0.0.1]:45358 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UKJrj-0002Yh-02 for submit@debbugs.gnu.org; Mon, 25 Mar 2013 22:43:59 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:41649) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UKJre-0002YW-4j for 14000@debbugs.gnu.org; Mon, 25 Mar 2013 22:43:54 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EABK/CFFFxLSu/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCwsOJhIUGA0kiB4GwS2OLoJcA6R6gV6Caik X-IPAS-Result: Av8EABK/CFFFxLSu/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCwsOJhIUGA0kiB4GwS2OLoJcA6R6gV6Caik X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="5776234" Received: from 69-196-180-174.dsl.teksavvy.com (HELO pastel.home) ([69.196.180.174]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 25 Mar 2013 22:41:34 -0400 Received: by pastel.home (Postfix, from userid 20848) id 69C1967AC0; Mon, 25 Mar 2013 22:41:36 -0400 (EDT) From: Stefan Monnier To: Carsten Bormann Subject: Re: bug#14000: 24.3.50; electric-pair-post-self-insert-function does not handle nested parentheses Message-ID: References: Date: Mon, 25 Mar 2013 22:41:36 -0400 In-Reply-To: (Carsten Bormann's message of "Tue, 19 Mar 2013 18:59:53 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 14000 Cc: 14000@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -0.5 (/) > In electric-pair-mode, I type "((" > I get "(()" > I should get "(())" > Fix below. Actually, it's not a bug but a feature. There's no way to know for sure when pairing is desired and when it's not, and as an electric-pair user I prefer electric-pair to err on the conservative side. This said, it would be nice to also accommodate users with different usage patterns. If you look at the many other pairing packages, they show a whole bunch of slightly different behaviors, it would be nice to try and see how we can "merge" them. Stefan From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 26 03:29:57 2013 Received: (at 14000) by debbugs.gnu.org; 26 Mar 2013 07:29:57 +0000 Received: from localhost ([127.0.0.1]:45512 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UKOKQ-00018M-Iy for submit@debbugs.gnu.org; Tue, 26 Mar 2013 03:29:56 -0400 Received: from mailhost.informatik.uni-bremen.de ([134.102.201.18]:42849 helo=informatik.uni-bremen.de) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UKOKO-00018D-3y for 14000@debbugs.gnu.org; Tue, 26 Mar 2013 03:29:53 -0400 X-Virus-Scanned: amavisd-new at informatik.uni-bremen.de Received: from smtp-fb3.informatik.uni-bremen.de (smtp-fb3.informatik.uni-bremen.de [134.102.224.120]) by informatik.uni-bremen.de (8.14.4/8.14.4) with ESMTP id r2Q7RWup015907; Tue, 26 Mar 2013 08:27:32 +0100 (CET) Received: from [192.168.217.105] (p54893DD9.dip.t-dialin.net [84.137.61.217]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by smtp-fb3.informatik.uni-bremen.de (Postfix) with ESMTPSA id 0891C3720; Tue, 26 Mar 2013 08:27:31 +0100 (CET) Subject: Re: bug#14000: 24.3.50; electric-pair-post-self-insert-function does not handle nested parentheses Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\)) Content-Type: text/plain; charset=iso-8859-1 From: Carsten Bormann In-Reply-To: Date: Tue, 26 Mar 2013 08:27:31 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: References: To: Stefan Monnier X-Mailer: Apple Mail (2.1503) X-Spam-Score: -1.5 (-) X-Debbugs-Envelope-To: 14000 Cc: 14000@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.2 (----) On Mar 26, 2013, at 03:41, Stefan Monnier = wrote: >> In electric-pair-mode, I type "((" >> I get "(()" >> I should get "(())" >> Fix below. >=20 > Actually, it's not a bug but a feature. There's no way to know for = sure > when pairing is desired and when it's not, and as an electric-pair = user > I prefer electric-pair to err on the conservative side. OK, I maybe should have suggested adding a preference. But if you live in a world of paired parentheses (and I thought = Emacs-Lispers were!) you want to add them in pairs, always. > This said, it would be nice to also accommodate users with different > usage patterns. If you look at the many other pairing packages, they > show a whole bunch of slightly different behaviors, it would be nice = to > try and see how we can "merge" them. I haven't done the work of surveying pairing packages. I just happened to pick up electric-pair-mode from a specific package (I = forget which), and since it is a global thing, it immediately started = affecting all my buffers. It is nice enough, so I kept it on. =20 But the behavior I was fixing here is seriously jarring (as in *always* = wrong) in my usage. Gr=FC=DFe, Carsten From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 26 09:21:15 2013 Received: (at 14000) by debbugs.gnu.org; 26 Mar 2013 13:21:15 +0000 Received: from localhost ([127.0.0.1]:45856 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UKToQ-0002Ja-T1 for submit@debbugs.gnu.org; Tue, 26 Mar 2013 09:21:15 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:48417) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UKToN-0002JR-UG for 14000@debbugs.gnu.org; Tue, 26 Mar 2013 09:21:13 -0400 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r2QDIoim018472 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 26 Mar 2013 13:18:51 GMT Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r2QDInwM022468 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 26 Mar 2013 13:18:50 GMT Received: from abhmt109.oracle.com (abhmt109.oracle.com [141.146.116.61]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r2QDInO8016777; Tue, 26 Mar 2013 08:18:49 -0500 Received: from dradamslap1 (/10.159.80.48) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 26 Mar 2013 06:18:48 -0700 From: "Drew Adams" To: "'Carsten Bormann'" , "'Stefan Monnier'" References: Subject: RE: bug#14000: 24.3.50; electric-pair-post-self-insert-function does not handle nestedparentheses Date: Tue, 26 Mar 2013 06:18:43 -0700 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 In-Reply-To: Thread-Index: Ac4p83BoGJRKQUNeTEqz3n/g400GhwALfCdw X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-Source-IP: acsinet22.oracle.com [141.146.126.238] X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 14000 Cc: 14000@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.5 (-----) > But if you live in a world of paired parentheses (and I > thought Emacs-Lispers were!) Mostly, yes. > you want to add them in pairs, always. No, not at all. Some people do, but my guess would be that they are a minority. Probably most if not all who live in a world of paired parens have tried behavior such as electric pairing, but I'd guess that relatively few who tried it have stayed with it. Perhaps it's a bit like the use of the so-called "structured" editors that were pushed by some in the 1980s: they pretty much forced you to only perform actions that kept things well-formed, always - like filling out forms. Real users hated them, for the most part. What they wanted was instead the typical best-of-both-worlds behavior that Emacs offered: you can do anything at all, but you can also easily ask the editor to check text for well-formedness etc. IOW, check on-demand, not preformed or forced form. Not that electric pairing prevents you from deleting parens, so they are no longer necessarily paired (that would really be like those structured editors), but the analogy is not too off-base. Personally, I use `show-paren-mode' (and `blink-matching-paren'). But I don't program in C etc., and I suppose that the language used might make some difference wrt preference. Wrt right parens, some Lisp dialects (e.g. Franz Lisp) have allowed you to use `]' to act as a sufficient number of `)' to reach an even number (balance). For quick interactive evaluation it could sometimes be handy. E.g. (setq foo '((a) (((b (c d]. From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 26 09:34:40 2013 Received: (at 14000) by debbugs.gnu.org; 26 Mar 2013 13:34:40 +0000 Received: from localhost ([127.0.0.1]:45864 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UKU1P-0002cH-K4 for submit@debbugs.gnu.org; Tue, 26 Mar 2013 09:34:40 -0400 Received: from mailhost.informatik.uni-bremen.de ([134.102.201.18]:45592 helo=informatik.uni-bremen.de) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UKU1J-0002c5-Pm for 14000@debbugs.gnu.org; Tue, 26 Mar 2013 09:34:36 -0400 X-Virus-Scanned: amavisd-new at informatik.uni-bremen.de Received: from smtp-fb3.informatik.uni-bremen.de (smtp-fb3.informatik.uni-bremen.de [134.102.224.120]) by informatik.uni-bremen.de (8.14.4/8.14.4) with ESMTP id r2QDW6uP004547; Tue, 26 Mar 2013 14:32:07 +0100 (CET) Received: from [192.168.217.105] (p54893BDF.dip.t-dialin.net [84.137.59.223]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by smtp-fb3.informatik.uni-bremen.de (Postfix) with ESMTPSA id 9ACF83A19; Tue, 26 Mar 2013 14:32:06 +0100 (CET) Subject: Re: bug#14000: 24.3.50; electric-pair-post-self-insert-function does not handle nestedparentheses Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\)) Content-Type: text/plain; charset=iso-8859-1 From: Carsten Bormann In-Reply-To: Date: Tue, 26 Mar 2013 14:32:05 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <951A6DF7-E25B-40A1-8197-7825F508EE43@tzi.org> References: To: "Drew Adams" X-Mailer: Apple Mail (2.1503) X-Spam-Score: -1.5 (-) X-Debbugs-Envelope-To: 14000 Cc: 14000@debbugs.gnu.org, 'Stefan Monnier' X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.2 (----) On Mar 26, 2013, at 14:18, "Drew Adams" wrote: > Some people do, but my guess would be that they are a minority. Well, the majority is then going to keep electric-pair-mode off, and = will not be concerned by this bugfix? My bug report was about the behavior when it's on. Apparently then, someone already has made the decision that they want = the parentheses in pairs. Wanting them in pairs, but not when they happen to be nested touching on = the left, is hard to follow for me. But, as Stefan points out, there may indeed be people who actually want = that, hence a preference setting within electric-pair-mode may be the = right thing here. Gr=FC=DFe, Carsten From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 26 10:23:08 2013 Received: (at 14000) by debbugs.gnu.org; 26 Mar 2013 14:23:08 +0000 Received: from localhost ([127.0.0.1]:46246 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UKUmJ-0003rQ-NY for submit@debbugs.gnu.org; Tue, 26 Mar 2013 10:23:08 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:26874) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UKUmI-0003rJ-77 for 14000@debbugs.gnu.org; Tue, 26 Mar 2013 10:23:06 -0400 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r2QEKjj4000466 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 26 Mar 2013 14:20:45 GMT Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r2QEKhJN008703 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 26 Mar 2013 14:20:44 GMT Received: from abhmt114.oracle.com (abhmt114.oracle.com [141.146.116.66]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r2QEKgnI001146; Tue, 26 Mar 2013 09:20:43 -0500 Received: from dradamslap1 (/130.35.178.8) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 26 Mar 2013 07:20:42 -0700 From: "Drew Adams" To: "'Carsten Bormann'" References: <951A6DF7-E25B-40A1-8197-7825F508EE43@tzi.org> Subject: RE: bug#14000: 24.3.50; electric-pair-post-self-insert-function does not handle nestedparentheses Date: Tue, 26 Mar 2013 07:20:42 -0700 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <951A6DF7-E25B-40A1-8197-7825F508EE43@tzi.org> Thread-Index: Ac4qJlj2DsFXHczJQKeNW1K4QQ6L7gABYtkQ X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-Source-IP: ucsinet21.oracle.com [156.151.31.93] X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 14000 Cc: 14000@debbugs.gnu.org, 'Stefan Monnier' X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.5 (-----) > > Some people do, but my guess would be that they are a minority. > > Well, the majority is then going to keep electric-pair-mode > off, and will not be concerned by this bugfix? Yes, my reply was only wrt the lines I quoted - nothing about the bug itself. Mine was an OT comment on the notion that Lispers generally prefer electric pairing (I doubt it). And it's only a guess on my part wrt the majority. And it really doesn't matter whether something is majority or minority. I just wanted to respond to the assumption that if you are an Emacs Lisper then "you want to add them in pairs, always." That's too strong, IMO. > My bug report was about the behavior when it's on. > Apparently then, someone already has made the decision that > they want the parentheses in pairs. Yes. > Wanting them in pairs, but not when they happen to be nested > touching on the left, is hard to follow for me. > But, as Stefan points out, there may indeed be people who > actually want that, hence a preference setting within > electric-pair-mode may be the right thing here. A preference setting would be good, IMO. Emacs is (should be), above _all_ else, easily user-extensible and customizable. By all means, make it easy to choose, and make users aware of the easy-to-make choices. From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 26 12:51:06 2013 Received: (at 14000) by debbugs.gnu.org; 26 Mar 2013 16:51:06 +0000 Received: from localhost ([127.0.0.1]:46311 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UKX5W-0007po-7J for submit@debbugs.gnu.org; Tue, 26 Mar 2013 12:51:06 -0400 Received: from chene.dit.umontreal.ca ([132.204.246.20]:56364) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UKX5U-0007ph-14 for 14000@debbugs.gnu.org; Tue, 26 Mar 2013 12:51:04 -0400 Received: from faina.iro.umontreal.ca (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id r2QGmgS0023794; Tue, 26 Mar 2013 12:48:43 -0400 Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id D0370B40E2; Tue, 26 Mar 2013 12:48:42 -0400 (EDT) From: Stefan Monnier To: Carsten Bormann Subject: Re: bug#14000: 24.3.50; electric-pair-post-self-insert-function does not handle nested parentheses Message-ID: References: Date: Tue, 26 Mar 2013 12:48:42 -0400 In-Reply-To: (Carsten Bormann's message of "Tue, 26 Mar 2013 08:27:31 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Level: X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0.2 X-NAI-Spam-Rules: 2 Rules triggered GEN_SPAM_FEATRE=0.2, RV4529=0 X-NAI-Spam-Version: 2.3.0.9362 : core <4529> : streams <928528> : uri <1376965> X-Spam-Score: -4.8 (----) X-Debbugs-Envelope-To: 14000 Cc: 14000@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.8 (----) > ... adding a preference. Yes, that's the intention. Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 01 09:32:17 2013 Received: (at 14000-done) by debbugs.gnu.org; 1 Apr 2013 13:32:17 +0000 Received: from localhost ([127.0.0.1]:55708 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UMeqK-0003tD-Ie for submit@debbugs.gnu.org; Mon, 01 Apr 2013 09:32:13 -0400 Received: from chene.dit.umontreal.ca ([132.204.246.20]:36885) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UMepz-0003se-EL for 14000-done@debbugs.gnu.org; Mon, 01 Apr 2013 09:32:04 -0400 Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id r31DSuWa012886; Mon, 1 Apr 2013 09:28:57 -0400 Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id A2D0FAE334; Mon, 1 Apr 2013 09:28:56 -0400 (EDT) From: Stefan Monnier To: Carsten Bormann Subject: Re: bug#14000: 24.3.50; electric-pair-post-self-insert-function does not handle nested parentheses Message-ID: References: Date: Mon, 01 Apr 2013 09:28:56 -0400 In-Reply-To: (Carsten Bormann's message of "Tue, 26 Mar 2013 08:27:31 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4535=0 X-NAI-Spam-Version: 2.3.0.9362 : core <4535> : streams <931938> : uri <1381536> X-Spam-Score: -4.5 (----) X-Debbugs-Envelope-To: 14000-done Cc: 14000-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) > OK, I maybe should have suggested adding a preference. > But if you live in a world of paired parentheses (and I thought > Emacs-Lispers were!) you want to add them in pairs, always. I installed the patch below, Stefan === modified file 'lisp/electric.el' --- lisp/electric.el 2013-01-01 09:11:05 +0000 +++ lisp/electric.el 2013-04-01 13:27:16 +0000 @@ -302,6 +302,26 @@ :version "24.1" :type 'boolean) +(defcustom electric-pair-inhibit-predicate + #'electric-pair-default-inhibit + "Predicate to prevent insertion of a matching pair. +The function is called with a single char (the opening char just inserted). +If it returns non-nil, then `electric-pair-mode' will not insert a matching +closer." + :type '(choice + (const :tag "Default" electric-pair-default-inhibit) + (const :tag "Always pair" ignore) + function)) + +(defun electric-pair-default-inhibit (char) + (or + ;; I find it more often preferable not to pair when the + ;; same char is next. + (eq char (char-after)) + (eq char (char-before (1- (point)))) + ;; I also find it often preferable not to pair next to a word. + (eq (char-syntax (following-char)) ?w))) + (defun electric-pair-syntax (command-event) (and electric-pair-mode (let ((x (assq command-event electric-pair-pairs))) @@ -351,12 +371,7 @@ ;; Insert matching pair. ((not (or (not (memq syntax `(?\( ?\" ?\$))) overwrite-mode - ;; I find it more often preferable not to pair when the - ;; same char is next. - (eq last-command-event (char-after)) - (eq last-command-event (char-before (1- (point)))) - ;; I also find it often preferable not to pair next to a word. - (eq (char-syntax (following-char)) ?w))) + (funcall electric-pair-inhibit-predicate last-command-event))) (save-excursion (insert closer)))))) (defun electric-pair-will-use-region () From unknown Sun Jun 22 22:43:52 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 30 Apr 2013 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator