From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: joaotavora@gmail.com (=?iso-8859-1?Q?Jo=E3o_T=E1vora?=) Newsgroups: gmane.emacs.devel Subject: Re: electric-pair-mode as a minor mode? Date: Fri, 27 Mar 2015 11:18:48 +0000 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1427455167 21188 80.91.229.3 (27 Mar 2015 11:19:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 27 Mar 2015 11:19:27 +0000 (UTC) Cc: Yuri D'Elia , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Mar 27 12:19:11 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 1YbSI1-0004dw-UE for ged-emacs-devel@m.gmane.org; Fri, 27 Mar 2015 12:19:02 +0100 Original-Received: from localhost ([::1]:49579 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbSI1-0003kM-AM for ged-emacs-devel@m.gmane.org; Fri, 27 Mar 2015 07:19:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbSHx-0003kH-QM for emacs-devel@gnu.org; Fri, 27 Mar 2015 07:18:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YbSHt-0006SN-P4 for emacs-devel@gnu.org; Fri, 27 Mar 2015 07:18:57 -0400 Original-Received: from mail-wi0-x233.google.com ([2a00:1450:400c:c05::233]:36216) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbSHt-0006SI-Ii for emacs-devel@gnu.org; Fri, 27 Mar 2015 07:18:53 -0400 Original-Received: by wibg7 with SMTP id g7so22332658wib.1 for ; Fri, 27 Mar 2015 04:18:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type:content-transfer-encoding; bh=PmrT8T2MuFpwfPB9wrKO58kEmH5T68+ugjszAKNhX8E=; b=ymtqeaXZOy+KKffLSqdkuZrPnmvy2MJ1LH0mx43BosFBFWtC+NiyWXFet9dBIPeMAg 68RuU4QdnWP+gV5+XZODyggPg/ieJO/0ikGLgRi3/FWymDngrmpWoOUtZwvUSPyBknNN G5WMbqW96sjyszuSG3YgswRiIgI5dNNWvJNaOKA8QWvpeIq5I/INSFVBgxdNc640zu+K kihG5CmZJ7jCkjlGFfDVnE6DLGd5WraaufTvKNxYwUZEWjHh4aL9g3RoJG+KoEI5DpkK Cy+b/B/Zk4L/2DGvV0E6oIzWbCNGK5HdqmmkcY+c8XZwziJ5qhs9t6sfYS3UJdff7SnP aUoA== X-Received: by 10.194.80.193 with SMTP id t1mr37796550wjx.8.1427455132410; Fri, 27 Mar 2015 04:18:52 -0700 (PDT) Original-Received: from GONDOMAR.yourcompany.com (53.236.108.93.rev.vodafone.pt. [93.108.236.53]) by mx.google.com with ESMTPSA id m9sm2961840wiz.24.2015.03.27.04.18.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Mar 2015 04:18:51 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Thu, 26 Mar 2015 22:18:33 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (windows-nt) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::233 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:184374 Archived-At: Hi Stefan and Yuri, Stefan Monnier writes: >> I'd like to disable electric-pair-mode in certain buffers. >> Probably the most important example is the minibuffer. > [ I'm curious to know more about those isearch and minibuffer cases > because I haven't bumped into them. Not that it makes any difference > to the following. ] I also don't see it. I though that, rightfully so, the syntax in isearch-mode is tweaked so that parens don't match there. This is probably the case in most minibuffers (though one still has to deal with the `electric-pair-pairs' overrider, but not isearch, where most keys are mapped to `isearch-printing-char' and not `self-insert'. And this is why they are pair-free. > (electric-pair-mode 1) > (setq-default electric-pair-mode nil) > > (add-hook 'foo-mode-hook > (lambda () (setq-local electric-pair-mode t))) I would do it like this. Though I didn't test much, it looks less hacky to me: (electric-pair-mode 1) =20=20=20=20 (add-hook 'foo-mode-hook (lambda () (setq-local electric-pair-pairs nil) (setq-local electric-pair-text-pairs nil) (setq-local electric-pair-inhibit-predicate #'identity))) So electric-pair-mode is still active (you still get autoskipping if the syntax determines it), but autopairing is inhibited. Is this still annoying? But making electric-pair-local-mode also sounds good to me. >> When editing regular text, as opposed to code, I also occasionally >> switch it off because I find it distracting. > I'm pretty sure that can be done fairly easily, by fixing a few > concrete cases. Can you name some? `electric-pair-pairs' and `electric-pair-text-pairs' which mean "always always pair these" are the "eager" cases, in my opinion. At least `electric-pair-pairs' could be made to default to nil, and probably `electric-pair-text-pairs' too. The snippet above becomes simpler. If I recall correctly, `electric-pair-pairs' was kept for backward compatibility with the original implementation of `electric-pair-mode' that didn't deduce its behaviour from the mode's syntax. Jo=E3o