From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#15478: cc-mode does not obey electric-indent-mode Date: Mon, 07 Oct 2013 12:14:19 -0400 Message-ID: References: <20130929091017.GA3161@acm.acm> <20131002200737.GA3895@acm.acm> <524CDA92.1030107@dancol.org> <20131003094543.GA3211@acm.acm> <20131007103041.GB3859@acm.acm> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1381162536 26880 80.91.229.3 (7 Oct 2013 16:15:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 7 Oct 2013 16:15:36 +0000 (UTC) Cc: gnu-emacs-bug@moderators.isc.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Oct 07 18:15:38 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 1VTDT6-0008Mg-G2 for geb-bug-gnu-emacs@m.gmane.org; Mon, 07 Oct 2013 18:15:36 +0200 Original-Received: from localhost ([::1]:60764 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTDT6-0005T6-1h for geb-bug-gnu-emacs@m.gmane.org; Mon, 07 Oct 2013 12:15:36 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33996) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTDSv-0005Rx-1V for bug-gnu-emacs@gnu.org; Mon, 07 Oct 2013 12:15:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTDSk-00060p-4M for bug-gnu-emacs@gnu.org; Mon, 07 Oct 2013 12:15:23 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:52294) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTDSZ-0005sM-Ej; Mon, 07 Oct 2013 12:15:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VTDSY-0004BT-PN; Mon, 07 Oct 2013 12:15:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Mon, 07 Oct 2013 16:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15478 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by submit@debbugs.gnu.org id=B.138116249416054 (code B ref -1); Mon, 07 Oct 2013 16:15:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 7 Oct 2013 16:14:54 +0000 Original-Received: from localhost ([127.0.0.1]:60587 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VTDSP-0004Ao-Qr for submit@debbugs.gnu.org; Mon, 07 Oct 2013 12:14:54 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:60268) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VTDSN-0004Ag-DD for submit@debbugs.gnu.org; Mon, 07 Oct 2013 12:14:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTDSD-0005ef-3o for submit@debbugs.gnu.org; Mon, 07 Oct 2013 12:14:50 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:57541) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTDSC-0005eP-QF for submit@debbugs.gnu.org; Mon, 07 Oct 2013 12:14:41 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTDS4-0004gu-Lq for bug-gnu-emacs@gnu.org; Mon, 07 Oct 2013 12:14:40 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTDRw-0005b0-Hu for bug-gnu-emacs@gnu.org; Mon, 07 Oct 2013 12:14:32 -0400 Original-Received: from moderators.individual.net ([130.133.4.7]:46726) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTDRw-0005at-BH for bug-gnu-emacs@gnu.org; Mon, 07 Oct 2013 12:14:24 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]) by moderators.individual.net (Exim 4.80.1) for gnu-emacs-bug@moderators.isc.org with esmtp (envelope-from ) id <1VTDRv-002Ydf-NZ>; Mon, 07 Oct 2013 18:14:23 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EABK/CFHO+K8t/2dsb2JhbAA6Cr8OF3OCHgEBBAFWGgkFCwsOJhIUGA0kiB4GwS2NFYN1A5IgklqBXoMT X-IPAS-Result: Av8EABK/CFHO+K8t/2dsb2JhbAA6Cr8OF3OCHgEBBAFWGgkFCwsOJhIUGA0kiB4GwS2NFYN1A5IgklqBXoMT X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="34936060" Original-Received: from 206-248-175-45.dsl.teksavvy.com (HELO pastel.home) ([206.248.175.45]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 07 Oct 2013 12:10:42 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 7DB7760C2E; Mon, 7 Oct 2013 12:14:19 -0400 (EDT) In-Reply-To: <20131007103041.GB3859@acm.acm> (Alan Mackenzie's message of "Mon, 7 Oct 2013 10:30:42 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). 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:78987 Archived-At: >> Emacs has never provided this feature in any mode that I know, cc-mode >> included. Some major modes (such as CC-mode) try to provide some vague >> approximation of it, using "electric keys" that trigger indentation >> "often enough" that it works more or less OK in some common cases. > :-). I think CC Mode DTRT practically 100% of the time. There haven't > been bug reports asking for the details of the electric indentation to be > improved. I can assure you it doesn't work 100%: in many circumstances you have to hit TAB (or M-C-\ or M-C-q) manually before the text's indentation reflects the modifications that took place. I don't think it's a failure of your code, tho (and electric-indent-mode fails in the exact same way). > from 1992. Somebody (RMS? Barry Warsaw?) clearly thought it very > important. I thought it's important enough to embark on electric-indent-mode (which is reasonably easy to implement, except it's hellish to get all the various authors to get back in line and start using the generic infrastructure, for the long term benefit of end users, at the cost of short term disruption and extra work). >> No they're not. And I think it's blatantly obvious, even to you. >> I understand that simply to mean that you do not want CC-mode's default >> behavior to change. > You're not wrong there. Thank you. >> The core is then: how should we make cc-mode integrate better with Emacs >> and use the generic electric-*-mode functionality instead of >> rolling its own? > How about aliasing `c-electric-mode' and `electric-indent-mode' and > making them buffer-local in CC Mode buffers? Then setting CC Mode's > value of `electric-indent-chars' to nil, for now, and in the medium > future (once e-i-m has percolated through to old versions and XEmacs) > integrating CC Mode into electric-indent-mode properly? Poor, but does satisfy the requirements. > How about introducing `global-electric-indent-mode' and redefining e-i-m > to be buffer-local? Or, alternatively, leaving e-i-m as it is and > defining `local-electric-indent-mode'? `electric-indent-local-mode' sounds good. > What about defining a property `no-electric-indentation' which could > be set on python-mode and others? I wouldn't use a property. Just a buffer-local variable `electric-indent-inhibit' which those modes can set. For Python and Haskell, this should only inhibit *re*indentation, while still calling indent-according-to-mode after inserting a newline. >> For the record: CC-mode is not the only major mode in this boat. >> I've already converted several major modes to use electric-indent-mode, >> and for some of them this also involved changing the default behavior. > Would you identify (some of) these modes, please, so I can go and have a > look. If you "grep electric-indent- **/*.el" you'll find some of them (I also changed a few external ones like sml-mode). Note that in most cases I made the change by completely side-stepping the old code (i.e. the define-key that rebinds the keys to electric versions was either removed or made conditional on something like (fboundp 'electric-indent-mode)). And those were usually simpler than what cc-mode does, with the exception maybe of octave.el where the old behavior was a bit more complex, and replaced by a mix of electric-indent-mode, electric-layout-mode. But in most of those cases, I only made a minimal effort at trying to preserve old behavior and user's customization. I've seen a few questions about "why foo-mode doesn't indent as before", and the answer "it's now controlled by electric-indent-mode" always seemed to satisfy the user. Stefan