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#15596: Let's improve the default workings of electric-indent-mode. Date: Sun, 13 Oct 2013 12:36:59 +0000 Message-ID: <20131013123659.GB2621@acm.acm> References: <524CDA92.1030107@dancol.org> <20131003094543.GA3211@acm.acm> <83zjqn5cri.fsf@gnu.org> <20131012145415.GA3987@acm.acm> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1381668019 32628 80.91.229.3 (13 Oct 2013 12:40:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 13 Oct 2013 12:40:19 +0000 (UTC) Cc: 15596@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 13 14:40:22 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 1VVKy5-0000YE-S9 for geb-bug-gnu-emacs@m.gmane.org; Sun, 13 Oct 2013 14:40:22 +0200 Original-Received: from localhost ([::1]:33053 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVKy5-0005Tm-4Z for geb-bug-gnu-emacs@m.gmane.org; Sun, 13 Oct 2013 08:40:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54030) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVKxv-0005TL-5F for bug-gnu-emacs@gnu.org; Sun, 13 Oct 2013 08:40:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VVKxn-0006qF-Ql for bug-gnu-emacs@gnu.org; Sun, 13 Oct 2013 08:40:11 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:59732) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVKxn-0006p3-OA for bug-gnu-emacs@gnu.org; Sun, 13 Oct 2013 08:40:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VVKxm-0004KK-Jp for bug-gnu-emacs@gnu.org; Sun, 13 Oct 2013 08:40: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: Sun, 13 Oct 2013 12:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15596 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 15596-submit@debbugs.gnu.org id=B15596.138166794316535 (code B ref 15596); Sun, 13 Oct 2013 12:40:02 +0000 Original-Received: (at 15596) by debbugs.gnu.org; 13 Oct 2013 12:39:03 +0000 Original-Received: from localhost ([127.0.0.1]:45517 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VVKwo-0004Id-DN for submit@debbugs.gnu.org; Sun, 13 Oct 2013 08:39:02 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:32644 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VVKwj-0004I8-UU for 15596@debbugs.gnu.org; Sun, 13 Oct 2013 08:38:59 -0400 Original-Received: (qmail 73196 invoked by uid 3782); 13 Oct 2013 12:38:56 -0000 Original-Received: from acm.muc.de (p5492C747.dip0.t-ipconnect.de [84.146.199.71]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 13 Oct 2013 14:38:55 +0200 Original-Received: (qmail 3626 invoked by uid 1000); 13 Oct 2013 12:36:59 -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:79224 Archived-At: Hello, Stefan. On Sat, Oct 12, 2013 at 12:35:46PM -0400, Stefan Monnier wrote: > > At the moment, it is (rather crudely) just nil or t, globally for all > > modes and all buffers. This is unsatisfactory, as it makes it difficult > > to {en,dis}able e-i-m for a single mode, and for a single buffer. An > > example of when you might want to do the latter is thus: one has an > > isolated file.c (or section therewithin) whose indentation style does not > > conform to project norms, and one does not wish to reindent the file > > wholesale. Electric indentation makes editing such a file inconvenient, > > hence the need for the ability readily to switch it off (currently > > available in CC Mode with C-c C-l). > Currently it's easyish for the user to do > (add-hook 'blabla-hook > (lambda () (setq-local electric-indent-mode nil))) > Or to set electric-indent-mode to nil in the file variables. These are surely bad ideas. `electric-indent-mode' is a global mode, so creating buffer local copies of it will lead to confusion. What does M-x electric-indent-mode do when there's a buffer local value of e-i-m? If it toggles the global binding, it will appear not to have worked in the current buffer. If it toggles the local binding, it is no longer a global mode. This is why I suggested extra variables to handle locality (see below). > But we could provide an electric-indent-local-mode, yes. Patch welcome. > > So, make `electric-indent-mode' t by default, yet have it tempered by the > Have any one of you tried to use Emacs with this setting? I'm not > fundamentally opposed to changing the default setting, but just as was > the case for font-lock-mode, transient-mark-mode, etc... we need to be > sure it actually works well enough in "all" cases (except those cases > where the user just doesn't like the feature and will disable it > globally). I think I was a bit unclear. I meant have the _variable_ e-i-m set to t by default, but have the electricity disabled by default by the new buffer local variable `electric-indent-enabled-flag'. But the new variable `electric-indent-inhibit' can do this anyhow. > But contrary to font-lock-mode, transient-mark-mode, AFAIK not many > people have enabled this mode yet, so I'd urge you all to try it out for > a few weeks first, to see if you like it not only in modes like c-mode > but also everywhere else, and if there are cases where you find it > inconvenient, report it here, so we can see what we should do about it. As I reported in emacs-devel, I had trouble in Text Mode with e-i-m. > > new buffer local variables `electric-indent-enabled-function' and > The buffer-local value of electric-indent-mode is already used for > that purpose ..... I think this is a bad thing (see above), and such uses should be superseded by using ... > ... (and there's also the new electric-indent-inhibit which I recently > added, which prevents reindentation, while still doing automatic > indentation for new lines. Surely e-i-inhibit should be t by default. Electric indentation is useful in (?most) programming modes, but probably not very much in text modes, or things like Outline Mode. It is useful precisely where the indentation of a line is determined by that same line's contents. (That's not counting the `newline-and-indent' behaviour.) That surely happens only in programming modes, or the like. How about having e-i-inhibit t by default, but setting it to nil in `prog-mode'? > Stefan -- Alan Mackenzie (Nuremberg, Germany).