From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478. Date: Mon, 24 Mar 2014 22:40:55 +0000 Message-ID: <20140324224055.GB3825@acm.acm> References: <20140309123711.GA2615@acm.acm> <20140316223509.GD3854@acm.acm> <20140319224231.GB4783@acm.acm> <20140322131350.GA3163@acm.acm> <20140322223454.GA3562@acm.acm> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1395701093 26941 80.91.229.3 (24 Mar 2014 22:44:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 24 Mar 2014 22:44:53 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 24 23:45:01 2014 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 1WSDc4-0005HS-1A for ged-emacs-devel@m.gmane.org; Mon, 24 Mar 2014 23:45:00 +0100 Original-Received: from localhost ([::1]:38684 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSDc3-0004yy-N1 for ged-emacs-devel@m.gmane.org; Mon, 24 Mar 2014 18:44:59 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36905) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSDbs-0004kq-9o for emacs-devel@gnu.org; Mon, 24 Mar 2014 18:44:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WSDbk-0001Er-Om for emacs-devel@gnu.org; Mon, 24 Mar 2014 18:44:48 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:49986 helo=mail.muc.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSDbk-0001Eb-BW for emacs-devel@gnu.org; Mon, 24 Mar 2014 18:44:40 -0400 Original-Received: (qmail 93280 invoked by uid 3782); 24 Mar 2014 22:44:38 -0000 Original-Received: from acm.muc.de (pD951B82E.dip0.t-ipconnect.de [217.81.184.46]) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 24 Mar 2014 23:44:37 +0100 Original-Received: (qmail 4209 invoked by uid 1000); 24 Mar 2014 22:40:55 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 8.x X-Received-From: 193.149.48.1 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:170939 Archived-At: Hello, Stefan. On Sun, Mar 23, 2014 at 09:37:09PM -0400, Stefan wrote: > > The actual definition of "electricity" is found in the Emacs manual, page > Use in other packages shows that people have understood the notion of > "electric" to mean many other things beside the very restricted > semantics you point to. Yes, but as used in "electric indentation", I think the terminology, and the methodology, has been as in C Mode's definition up until very recently. > > No. To keep Elisp properly indented, you merely have to depress > > whichever key is bound to `newline-and-indent', whether that be RET, or > > C-j, or whatever. > "whichever key is bound to `newline-and-indent'" would be C-j and not > RET in all Emacsen released so far, so I see we violently agree. > > Electric indentation doesn't come into it. > Of course it does because electric-indent changes the behavior such that > RET can be (or has to be in 24.4) used instead of C-j. But you knew > that, obviously. OK, I meant "electric indentation" as defined in the manual page - "reindenting the current line". This has nothing to do with which way round C-j and RET are bound. > > You'll want electric indentation on some other character you've just > > typed. > Indeed that's also good. But I don't know of any such character we > could use globally in electric-indent-chars, so it's up to each major > mode to specify which chars to use. Yes. > > No. If electric indentation has already happened after typing the > > semicolon/comma/brace, the alignment of the subsequent comment will > > remain undisturbed. If RET puts the alignment out, you're cursing it. > Then I misunderstood and don't know what you're talking about. Can you > give a scenario? Assume that electric indentation happens on \n, and not on {. You type in a { (which is intrinsically 4 characters too indented, for some value of 4) then do M-; to insert a comment at comment-column. You fill in the comment, do C-e then RET. The ensuing electric indentation on RET puts out the alignment of the comment: if (foo) /* aligned comment */ { /* coment misaligned by e-i-m */ > >> What would be more optimal? > > A mode-dependent or buffer-local dependent setting, as well as, rather > > than instead of. > We have that: electric-indent-local-mode and electric-indent-inhibit. OK, for electric-indent-local-mode, which is gradually becoming prominent. But I though electric-indent-inhibit was a variable for major modes, not users - a mode initialisation thing, rather than a user configuration variable. > > Why can't we simply have RET bound to `newline-and-indent' and C-j > > bound to `newline' in programming modes, as discussed and, pretty much > > agreed on, in emacs-devel last autumn? > Lack of patch implementing this (supposed) simple change? Here is what I propose, and am willing to do: 1. For electric indentation: a - Restore `newline' and `newline-and-indent' to their traditional functionality, and remove `electric-newline-and-maybe-indent'. b - Simplify `electric-indent-post-self-insert-function' such that it reindents only the line on which the self-inserting character is typed. c - Reform `electric-indent-local-mode' as a first-class minor mode and `electric-indent-mode' as a global version of it. 2. For making RET indent the new line in programming modes: a - Bind RET to `newline-and-indent' and C-j to `newline' in `prog-mode-map' and possibly in certain other major mode maps (to be discussed). b - (Maybe) create a minor mode to restore RET and C-j to traditional bindings. The above will leave electric-indent-mode functioning pretty much as it currently does. What do you say? > > Incidentally, in Emacs -Q, Text Mode and Fundamental Mode have gone back > > to the unwanted state of RET doing `newline-and-indent'. Should I raise > > another bug report? > You can, but it's not a bug. It's a feature (not sure what you mean by > "back" since it's been this way ever since I enabled > electric-indent-mode by default, AFAIK). Apologies: I thought Text Mode had been restored to the traditional bindings in the last few months. > So make this bug report specific about a particular circumstance where > the behavior is undesirable, or about how hard it is to disable it. I think RMS's bug #16156, reproduced and being discussed on a parallel thread, is a good enough example, so there's not much point in me opening a new one. > Stefan -- Alan Mackenzie (Nuremberg, Germany).