GNU bug report logs - #15596
Let's improve the default workings of electric-indent-mode.

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Alan Mackenzie <acm@HIDDEN>; dated Sat, 12 Oct 2013 14:57:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 15596 <at> debbugs.gnu.org:


Received: (at 15596) by debbugs.gnu.org; 14 Oct 2013 02:16:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Oct 13 22:16:27 2013
Received: from localhost ([127.0.0.1]:47105 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1VVXhr-0001LN-5G
	for submit <at> debbugs.gnu.org; Sun, 13 Oct 2013 22:16:27 -0400
Received: from ironport2-out.teksavvy.com ([206.248.154.182]:25047)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <monnier@HIDDEN>) id 1VVXho-0001L9-98
 for 15596 <at> debbugs.gnu.org; Sun, 13 Oct 2013 22:16:24 -0400
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: Av4EABK/CFFMCqNl/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLDiYSFBgNJIgeBsEtkQoDpHqBXoMT
X-IPAS-Result: Av4EABK/CFFMCqNl/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLDiYSFBgNJIgeBsEtkQoDpHqBXoMT
X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="35427328"
Received: from 76-10-163-101.dsl.teksavvy.com (HELO pastel.home)
 ([76.10.163.101])
 by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA;
 13 Oct 2013 22:12:18 -0400
Received: by pastel.home (Postfix, from userid 20848)
 id 1775A60646; Sun, 13 Oct 2013 22:16:18 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
Subject: Re: bug#15596: Let's improve the default workings of
 electric-indent-mode.
Message-ID: <jwvppr8pq0x.fsf-monnier+emacsbugs@HIDDEN>
References: <524CDA92.1030107@HIDDEN>
 <jwveh83gfr7.fsf-monnier+emacsbugs@HIDDEN>
 <20131003094543.GA3211@HIDDEN>
 <mailman.3425.1380913522.10748.bug-gnu-emacs@HIDDEN>
 <l2pgv6$dnl$1@HIDDEN>
 <jwvbo339qey.fsf-monnier+emacsbugs@HIDDEN> <83zjqn5cri.fsf@HIDDEN>
 <jwvppril4fv.fsf-monnier+emacsbugs@HIDDEN>
 <20131012145415.GA3987@HIDDEN>
 <jwv61t2sbjc.fsf-monnier+emacsbugs@HIDDEN>
 <20131013123659.GB2621@HIDDEN>
Date: Sun, 13 Oct 2013 22:16:18 -0400
In-Reply-To: <20131013123659.GB2621@HIDDEN> (Alan Mackenzie's message of
 "Sun, 13 Oct 2013 12:36:59 +0000")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.3 (/)
X-Debbugs-Envelope-To: 15596
Cc: 15596 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.3 (/)

> These are surely bad ideas.  `electric-indent-mode' is a global mode, so
> creating buffer local copies of it will lead to confusion.

It's not meant for purely interactive use (and indeed it requires Elisp
coding), and for programmatic uses there's no reason why it should 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.

Presumably the user who added the buffer-local binding knows what it does.

> If it toggles the local binding, it is no longer a global mode.

Indeed, that would be a bug.

> 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.

I'm not sure I understand what we're talking about, then:
when you wrote "make `electric-indent-mode' t by default" I understood
it to mean that the default behavior of Emacs in most modes should be to
auto-indent.

> As I reported in emacs-devel, I had trouble in Text Mode with e-i-m.

Maybe we should make text-mode disable electric-indent-mode by default?

> 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.

In practice, it's already the case for those modes, AFAIK (tho not by
setting e-i-inhibit, because that feature existed before e-i-inhibit).

> How about having e-i-inhibit t by default, but setting it to nil in
> `prog-mode'?

I could consider that.  But if we can do without it, that would be
preferable, since many programming modes don't derive from prog-mode
(yet), and several non-programming modes support indentation
(e.g. latex-mode, change-log-mode).


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#15596; Package emacs. Full text available.

Message received at 15596 <at> debbugs.gnu.org:


Received: (at 15596) by debbugs.gnu.org; 13 Oct 2013 12:39:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Oct 13 08:39:03 2013
Received: from localhost ([127.0.0.1]:45517 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1VVKwo-0004Id-DN
	for submit <at> debbugs.gnu.org; Sun, 13 Oct 2013 08:39:02 -0400
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 <acm@HIDDEN>) id 1VVKwj-0004I8-UU
 for 15596 <at> debbugs.gnu.org; Sun, 13 Oct 2013 08:38:59 -0400
Received: (qmail 73196 invoked by uid 3782); 13 Oct 2013 12:38:56 -0000
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
Received: (qmail 3626 invoked by uid 1000); 13 Oct 2013 12:36:59 -0000
Date: Sun, 13 Oct 2013 12:36:59 +0000
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#15596: Let's improve the default workings of
 electric-indent-mode.
Message-ID: <20131013123659.GB2621@HIDDEN>
References: <524CDA92.1030107@HIDDEN>
 <jwveh83gfr7.fsf-monnier+emacsbugs@HIDDEN>
 <20131003094543.GA3211@HIDDEN>
 <mailman.3425.1380913522.10748.bug-gnu-emacs@HIDDEN>
 <l2pgv6$dnl$1@HIDDEN>
 <jwvbo339qey.fsf-monnier+emacsbugs@HIDDEN>
 <83zjqn5cri.fsf@HIDDEN>
 <jwvppril4fv.fsf-monnier+emacsbugs@HIDDEN>
 <20131012145415.GA3987@HIDDEN>
 <jwv61t2sbjc.fsf-monnier+emacsbugs@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <jwv61t2sbjc.fsf-monnier+emacsbugs@HIDDEN>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Delivery-Agent: TMDA/1.1.12 (Macallan)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: -1.2 (-)
X-Debbugs-Envelope-To: 15596
Cc: 15596 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.2 (-)

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).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#15596; Package emacs. Full text available.

Message received at 15596 <at> debbugs.gnu.org:


Received: (at 15596) by debbugs.gnu.org; 12 Oct 2013 16:35:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 12 12:35:51 2013
Received: from localhost ([127.0.0.1]:44539 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1VV2AQ-0005FV-CS
	for submit <at> debbugs.gnu.org; Sat, 12 Oct 2013 12:35:50 -0400
Received: from ironport2-out.teksavvy.com ([206.248.154.182]:64967)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <monnier@HIDDEN>) id 1VV2AN-0005FK-Kg
 for 15596 <at> debbugs.gnu.org; Sat, 12 Oct 2013 12:35:48 -0400
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: Av4EABK/CFFMCreE/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLDiYSFBgNJIgeBsEtkQoDpHqBXoMT
X-IPAS-Result: Av4EABK/CFFMCreE/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLDiYSFBgNJIgeBsEtkQoDpHqBXoMT
X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="35349546"
Received: from 76-10-183-132.dsl.teksavvy.com (HELO pastel.home)
 ([76.10.183.132])
 by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA;
 12 Oct 2013 12:31:51 -0400
Received: by pastel.home (Postfix, from userid 20848)
 id 54D906049A; Sat, 12 Oct 2013 12:35:46 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
Subject: Re: bug#15596: Let's improve the default workings of
 electric-indent-mode.
Message-ID: <jwv61t2sbjc.fsf-monnier+emacsbugs@HIDDEN>
References: <20131002200737.GA3895@HIDDEN>
 <jwvtxgzjlbv.fsf-monnier+emacsbugs@HIDDEN>
 <524CDA92.1030107@HIDDEN>
 <jwveh83gfr7.fsf-monnier+emacsbugs@HIDDEN>
 <20131003094543.GA3211@HIDDEN>
 <mailman.3425.1380913522.10748.bug-gnu-emacs@HIDDEN>
 <l2pgv6$dnl$1@HIDDEN>
 <jwvbo339qey.fsf-monnier+emacsbugs@HIDDEN> <83zjqn5cri.fsf@HIDDEN>
 <jwvppril4fv.fsf-monnier+emacsbugs@HIDDEN>
 <20131012145415.GA3987@HIDDEN>
Date: Sat, 12 Oct 2013 12:35:46 -0400
In-Reply-To: <20131012145415.GA3987@HIDDEN> (Alan Mackenzie's message of
 "Sat, 12 Oct 2013 14:54:15 +0000")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.3 (/)
X-Debbugs-Envelope-To: 15596
Cc: 15596 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.3 (/)

> 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.

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).
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.

> new buffer local variables `electric-indent-enabled-function' and

The buffer-local value of electric-indent-mode is already used for
that purpose (and there's also the new electric-indent-inhibit which
I recently added, which prevents reindentation, while still doing
automatic indentation for new lines.


        Stefan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#15596; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 12 Oct 2013 14:56:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 12 10:56:39 2013
Received: from localhost ([127.0.0.1]:44436 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1VV0cQ-0002rV-UU
	for submit <at> debbugs.gnu.org; Sat, 12 Oct 2013 10:56:39 -0400
Received: from eggs.gnu.org ([208.118.235.92]:60687)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <acm@HIDDEN>) id 1VV0cO-0002rK-Ph
 for submit <at> debbugs.gnu.org; Sat, 12 Oct 2013 10:56:37 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <acm@HIDDEN>) id 1VV0cF-0003jE-2b
 for submit <at> debbugs.gnu.org; Sat, 12 Oct 2013 10:56:36 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled
 version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:39068)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <acm@HIDDEN>)
 id 1VV0cE-0003j9-VH
 for submit <at> debbugs.gnu.org; Sat, 12 Oct 2013 10:56:26 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:34147)
 by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <acm@HIDDEN>)
 id 1VV0c7-0005tK-HZ
 for bug-gnu-emacs@HIDDEN; Sat, 12 Oct 2013 10:56:26 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <acm@HIDDEN>) id 1VV0bw-0003g8-MO
 for bug-gnu-emacs@HIDDEN; Sat, 12 Oct 2013 10:56:19 -0400
Received: from colin.muc.de ([193.149.48.1]:30950 helo=mail.muc.de)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <acm@HIDDEN>)
 id 1VV0bw-0003fw-D3
 for bug-gnu-emacs@HIDDEN; Sat, 12 Oct 2013 10:56:08 -0400
Received: (qmail 87941 invoked by uid 3782); 12 Oct 2013 14:56:06 -0000
Received: from acm.muc.de (pD95197FD.dip0.t-ipconnect.de [217.81.151.253]) by
 colin.muc.de (tmda-ofmipd) with ESMTP;
 Sat, 12 Oct 2013 16:56:05 +0200
Received: (qmail 4061 invoked by uid 1000); 12 Oct 2013 14:54:15 -0000
Date: Sat, 12 Oct 2013 14:54:15 +0000
To: bug-gnu-emacs@HIDDEN
Subject: Let's improve the default workings of electric-indent-mode.
Message-ID: <20131012145415.GA3987@HIDDEN>
References: <20131002200737.GA3895@HIDDEN>
 <jwvtxgzjlbv.fsf-monnier+emacsbugs@HIDDEN>
 <524CDA92.1030107@HIDDEN>
 <jwveh83gfr7.fsf-monnier+emacsbugs@HIDDEN>
 <20131003094543.GA3211@HIDDEN>
 <mailman.3425.1380913522.10748.bug-gnu-emacs@HIDDEN>
 <l2pgv6$dnl$1@HIDDEN>
 <jwvbo339qey.fsf-monnier+emacsbugs@HIDDEN>
 <83zjqn5cri.fsf@HIDDEN>
 <jwvppril4fv.fsf-monnier+emacsbugs@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <jwvppril4fv.fsf-monnier+emacsbugs@HIDDEN>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Delivery-Agent: TMDA/1.1.12 (Macallan)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-detected-operating-system: by eggs.gnu.org: FreeBSD 8.x
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.3 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.3 (----)

Hi, Stefan.

On Sun, Oct 06, 2013 at 01:01:31PM -0400, Stefan Monnier wrote:
> Hey, guys.  What are you waiting for on the bug-report requesting to
> change the default of electric-indent-mode?
> Really!

I think the default behaviour of electric-indent-mode can and should be
improved.

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).

We need a method of {en,dis}abling e-i-m for both modes and for indiviual
buffers.  We probably don't want to change the definition of the variable
`electric-indent-mode'.

So, make `electric-indent-mode' t by default, yet have it tempered by the
new buffer local variables `electric-indent-enabled-function' and
`electric-indent-enabled-flag', both defaulting to nil, which work in the
canonical Emacs fashion.  These variables will be intended mainly for
mode maintainers, yet will be available to knowledgeable users for
configuration/toggling.  When `e-i-m' is t and one of these new variables
returns/is t, then electric indentation will take place.

With this scheme, users can globally disable e-i-m by toggling
electric-indent-mode, as at present.  They can enable it in all buffers
in which it makes sense by toggling it again.  They can enable it in
other buffers by setting `electric-indent-enabled-flag' in those buffers.

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).




Acknowledgement sent to Alan Mackenzie <acm@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#15596; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.