From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#15478: cc-mode does not obey electric-indent-mode Date: Sat, 5 Oct 2013 16:50:34 +0000 Message-ID: <20131005165034.GA2943@acm.acm> References: <20130928201147.GC11317@acm.acm> <20130929091017.GA3161@acm.acm> <20131002200737.GA3895@acm.acm> <20131003105600.GB3211@acm.acm> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1380991997 356 80.91.229.3 (5 Oct 2013 16:53:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 5 Oct 2013 16:53:17 +0000 (UTC) Cc: 15478@debbugs.gnu.org To: Josh Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Oct 05 18:53:20 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1VSV6V-0000yj-SX for geb-bug-gnu-emacs@m.gmane.org; Sat, 05 Oct 2013 18:53:20 +0200 Original-Received: from localhost ([::1]:52441 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VSV6V-0008Ag-IG for geb-bug-gnu-emacs@m.gmane.org; Sat, 05 Oct 2013 12:53:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46786) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VSV6L-0008AS-KG for bug-gnu-emacs@gnu.org; Sat, 05 Oct 2013 12:53:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VSV6F-0006Vs-4s for bug-gnu-emacs@gnu.org; Sat, 05 Oct 2013 12:53:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:47934) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VSV6F-0006Vn-1D for bug-gnu-emacs@gnu.org; Sat, 05 Oct 2013 12:53:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VSV6E-00081j-GV for bug-gnu-emacs@gnu.org; Sat, 05 Oct 2013 12:53:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 05 Oct 2013 16:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15478 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 15478-submit@debbugs.gnu.org id=B15478.138099194730806 (code B ref 15478); Sat, 05 Oct 2013 16:53:02 +0000 Original-Received: (at 15478) by debbugs.gnu.org; 5 Oct 2013 16:52:27 +0000 Original-Received: from localhost ([127.0.0.1]:56225 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VSV5f-00080m-3C for submit@debbugs.gnu.org; Sat, 05 Oct 2013 12:52:27 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:24291 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VSV5a-00080Z-VE for 15478@debbugs.gnu.org; Sat, 05 Oct 2013 12:52:24 -0400 Original-Received: (qmail 13412 invoked by uid 3782); 5 Oct 2013 16:52:21 -0000 Original-Received: from acm.muc.de (pD9518573.dip0.t-ipconnect.de [217.81.133.115]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 05 Oct 2013 18:52:20 +0200 Original-Received: (qmail 2992 invoked by uid 1000); 5 Oct 2013 16:50:34 -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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:78939 Archived-At: Hi, Josh. On Fri, Oct 04, 2013 at 02:21:22PM -0700, Josh wrote: > On Thu, Oct 3, 2013 at 7:32 AM, Stefan Monnier > wrote: > > > What I'm suggesting is some sort of hook so that > > > electric-indent-mode (and electric-layout-mode, too, I suppose) > > > invokes the "electric engine" in CC Mode rather than trying to do > > > the electric indentation itself. > > Sounds OK. > Unless I'm misunderstanding, the indentation hook you're describing > seems very close to `electric-indent-functions': I'd say it's moderately close rather than very close. At the moment CC Mode does its own electric indentation entirely, and I'd like things to stay that way, so as to minimise incompatibility between versions, to avoid breaking existing users' setups and so on. > electric-indent-functions is a variable defined in `electric.el'. > Its value is nil > This variable may be risky if used as a file-local variable. > Documentation: > Special hook run to decide whether to auto-indent. > Each function is called with one argument (the inserted char), with > point right after that char, and it should return t to cause > indentation, > `no-indent' to prevent indentation or nil to let other functions decide. > Is there a reason why CC Mode couldn't supply a function here that > would perform appropriate indentation and then return `no-indent' to > stop traversal of electric-indent-functions? It would be a lot of work to rearrange things, and it might leave the Emacs 24.4 version incompatible with other CC Mode versions. > Delegation of newline insertion decisions is similarly already supported > via `electric-layout-rules': > electric-layout-rules > electric-layout-rules is a variable defined in `electric.el'. > Its value is nil > Documentation: > List of rules saying where to automatically insert newlines. > Each rule has the form (CHAR . WHERE) where CHAR is the char > that was just inserted and WHERE specifies where to insert newlines > and can be: nil, `before', `after', `around', or a function of no > arguments that returns one of those symbols. > If either or both of these delegation mechanisms are insufficient to > satisfy CC Mode's requirements, it would be interesting to hear how they > fall short. CC Mode already does electric actions by other means, and users setups depend on these. I don't want to break these existing setups. Integrating CC Mode's ways with these new mechanisms is a challenge. > Although I agree with your earlier point that major modes are best > suited to make decisions about /how/ to perform electric behavior for > their specific domains, which also seems to be borne out by the existing > delegation support, I've seen no justification for a major mode deciding > to disregard (!) my configuration of /whether/ to perform it at all. Currently, that configuration is done by setting `c-electric-flag', either in your .emacs or by C-c C-l. `electric-indent-mode' is the new kid on the block. Concrete suggestions for integrating `c-electric-flag' and `electric-indent-mode' haven't been copious up till now. I've one or two ideas myself, but it's not trivial. > I read the electric-*-mode docstrings describing the exact behavior in > question and I disabled it. That should be the end of the story. Yes. But there's a difference between you disabling it and merely using the default value. Since the current default is already nil, it's not clear what you mean by "disabling" it. Perhaps there need to be three values here, 'default, t and nil. It's also still up for discussion how you {en,dis}able electric-indent-mode buffer locally, which is a sensible thing to want to do. > Josh -- Alan Mackenzie (Nuremberg, Germany).