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: [patch] make electric-pair-mode smarter/more useful Date: Sat, 14 Dec 2013 20:39:57 -0500 Message-ID: References: <87haalh806.fsf@gmail.com> <87d2l9wfne.fsf@yandex.ru> <87fvq49xzp.fsf@gmail.com> <87vbyuwyyc.fsf@gmail.com> <52A93B99.8040308@yandex.ru> <87r49if185.fsf@gmail.com> <52AA772D.7050503@yandex.ru> <52AC8DA6.5070403@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1387071624 2026 80.91.229.3 (15 Dec 2013 01:40:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 15 Dec 2013 01:40:24 +0000 (UTC) Cc: =?windows-1252?B?Sm/jbyBU4XZvcmE=?= , emacs-devel@gnu.org To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Dec 15 02:40:28 2013 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 1Vs0h1-0004Xu-5H for ged-emacs-devel@m.gmane.org; Sun, 15 Dec 2013 02:40:27 +0100 Original-Received: from localhost ([::1]:49124 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vs0h0-0008U2-Eh for ged-emacs-devel@m.gmane.org; Sat, 14 Dec 2013 20:40:26 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33357) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vs0gn-0008Ft-Ad for emacs-devel@gnu.org; Sat, 14 Dec 2013 20:40:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vs0gd-00061z-CL for emacs-devel@gnu.org; Sat, 14 Dec 2013 20:40:13 -0500 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:37418) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vs0gd-00060t-4w for emacs-devel@gnu.org; Sat, 14 Dec 2013 20:40:03 -0500 Original-Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.DIT.UMontreal.CA (8.14.1/8.14.1) with ESMTP id rBF1dv7e030379; Sat, 14 Dec 2013 20:39:58 -0500 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 1C6BDAE358; Sat, 14 Dec 2013 20:39:57 -0500 (EST) In-Reply-To: <52AC8DA6.5070403@yandex.ru> (Dmitry Gutov's message of "Sat, 14 Dec 2013 18:56:06 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4792=0 X-NAI-Spam-Version: 2.3.0.9362 : core <4792> : inlines <324> : streams <1090989> : uri <1624274> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.22 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:166411 Archived-At: > Yes, but if it's set via electric-layout-rules, to what value will this > variable be set in e.g. js-mode? The value which seems most useful for javascript. > If it'll include what's there currently, '((?\; . after) (?\{ . after) (?\} > . before)), then to get the desired behavior I described previously (NOT to > insert a newline after I just typed `{', or any other character), I'd have > to modify it again in js-mode-hook. If there can be various competing choices, then indeed we have a problem. The intention of electric-layout-mode is that it should more or less (tho in a naive way) insert the newlines for you if you just naively/sequentially type in the code. There might indeed be various options as to "when" to insert the newlines as well as "where". > IOW, turning on electric-layout-mode would turn on all > electric-layout-related behaviors defined for a given major mode. Are we > willing to remove electric newlines after `;', `{' and `}', by default, from > any major mode where one of those might conceivably be followed by some > character other than newline? I don't understand the question: if there are cases where electric-layout-mode would insert a newline but the user doesn't want it, indeed the user will be annoyed. I think in general there's no way to be sure this never happens, other than turning off electric-layout-mode. Same happens for the suggested electric-pair-newline-between-pairs-rule. > Speaking of cc-mode, I don't really program in C (though I'd like to > continue learning it at some point), but if I did, I'm not sure I'd > want the electric-layout-mode behavior there, but > electric-pair-newline-between-pairs-rule would be useful. { not followed by a newline are rare in C, but they do happen, indeed. E.g. for "enum"s or for immediate values of structs/arrays. So, indeed, for those cases electric-layout-mode will be annoying. For that reason electric-layout-mode is off by default, and I haven't heard anyone argue to enable it by default. >From this POV, maybe electric-pair-newline-between-pairs-rule should be made into a separate minor mode, indeed. It will reduce your use of RET much less than electric-layout-mode but it's less likely to be annoying. Less gain and less pain. Stefan