Subject: bug#16770: Erroneous interaction between electric-indent-mode and electric-indent-local-mode

From: Stefan Monnier <[email-masked]>
Date: Tue, 18 Feb 2014 13:26:56 -0500

> 1. Start emacs -Q.
> 2. Visit, successively, two random buffers foo and bar.
> 3. In buffer foo, do M-x electric-indent-local-mode.
> 4. In buffer bar, do M-x electric-indent-mode.

> Both buffers now have e-i-mode disabled.

> 5. Still in buffer bar, do M-x electric-indent-mode.

> This, being a global mode, should enable e-i-mode in all buffers.  But
> in buffer foo, electric-indent-mode remains disabled.  This is a bug.

Actually, upon further consideration, I don't think this one is a bug.
The behavior you want would make sense, but the current one also
makes sense.  At step 3 the user specifically requested to disable
electric-indent in `foo' so changing the global setting should not
affect it.

So the real problem is that electric-indent-local-mode is not consistent
in this regard (it sometimes remembers a local setting even if it's
equal to the global setting, and sometimes treats a local setting equal
to the global setting as meaning "obey the global setting").

Worse:

   (electric-indent-mode -1)
   (electric-indent-local-mode 1)
   (electric-indent-mode 1)
   (electric-indent-mode -1)

leaves us with a buffer where electric-indent-mode is locally t but
there is no electric indentation.

        Stefan