From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: electric-pair-mode as a minor mode? Date: Sun, 29 Mar 2015 00:01:05 -0400 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1427601684 27042 80.91.229.3 (29 Mar 2015 04:01:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 29 Mar 2015 04:01:24 +0000 (UTC) Cc: Yuri D'Elia , emacs-devel@gnu.org To: joaotavora@gmail.com (=?windows-1252?B?Sm/jbyBU4XZvcmE=?=) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 29 06:01:18 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Yc4PR-0006BX-Ft for ged-emacs-devel@m.gmane.org; Sun, 29 Mar 2015 06:01:13 +0200 Original-Received: from localhost ([::1]:55935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yc4PQ-00058g-Lo for ged-emacs-devel@m.gmane.org; Sun, 29 Mar 2015 00:01:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yc4PN-00055y-Gh for emacs-devel@gnu.org; Sun, 29 Mar 2015 00:01:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yc4PK-0001Z4-Oy for emacs-devel@gnu.org; Sun, 29 Mar 2015 00:01:09 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:45543) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yc4PK-0001Yz-Lx for emacs-devel@gnu.org; Sun, 29 Mar 2015 00:01:06 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgUFAGvvdVRBbthL/2dsb2JhbAA3gVOhb4EIgXUBAQQBDkgPFAULCzQSFBgNiDeiEYt2AjI6DAODPgODcASoOw X-IPAS-Result: AgUFAGvvdVRBbthL/2dsb2JhbAA3gVOhb4EIgXUBAQQBDkgPFAULCzQSFBgNiDeiEYt2AjI6DAODPgODcASoOw X-IronPort-AV: E=Sophos;i="5.01,1,1400040000"; d="scan'208";a="114862506" Original-Received: from 65-110-216-75.cpe.pppoe.ca (HELO pastel.home) ([65.110.216.75]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 29 Mar 2015 00:01:06 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id E51E7144D; Sun, 29 Mar 2015 00:01:05 -0400 (EDT) In-Reply-To: (=?windows-1252?Q?=22Jo=E3o_T=E1vo?= =?windows-1252?Q?ra=22's?= message of "Sat, 28 Mar 2015 21:47:20 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:184498 Archived-At: > But this is precisely the use case for the "message mode hack" earlier: Yes, you can add more hacks to try and handle a few special cases, but each one of those hacks is heuristic (i.e. will have false positives and false negatives) and they'll never cover all actual cases (they're very dependent on specific conventions used by people, which change significantly between communities). > I haven't tested, because I don't have time to learn about implementing > comment syntaxes right now (I also probably won't if you tell me it's > futile or problematic for some other reason). It might be a good idea to do it in general (i.e. not as part of electric-pair-mode but as part of message-mode for example). But it doesn't change the fact that syntax-ppss is unreliable. > assessment it should work as well as it already does for programming > modes, where `(' and `)' thingies can exist unpaired in comments and > string literals. In programming modes, there's a formal and unambiguous definition of what is correct syntax and what isn't (or at least there should be for any sane programming language), so we can hope to refine Emacs's rules until they're correct. But for natural language, there's no such perfection. > Yes, I understand, but what do you suggest? I just hope it's not > changing the default value of `electric-pair-preserve-balance', which I > personally like very much... Why don't you > > (add-hook 'text-mode-hook > (lambda () (setq-local electric-pair-preserve-balance nil))) > > in your configuration? Ah, that might do it, indeed. At least a quick experiment seems to handle the cases I mentioned so far. Stefan