2

I'm having an annoying problem with the indentation of lists when editing documents in rst-mode. This happens in Emacs 24 (even when starting with -q), but not in Emacs 23.

For example, if my document is (where | indicates the cursor position)

* List Item|

and I then enter RET + "* Bla" + RET, I am getting this:

* List Item
  * Bla
  |

and after another "* Foo" + RET, I am getting this:

* List Item
  * Bla
* Foo
|

Surprisingly enough, I could not find any bug reports related to this. Is there anything wrong with my system? What is happening here?

In Emacs 23 the final output is as expected:

* List Item
* Bla
* Foo

1 Answer 1

4

The effect you are seeing are, most likely, caused by electric-indent-mode, a new mode which is active by default in Emacs 24.

(I said "most likely" since I'm not seeing the same indentation as you describe. In my system, running Emacs 24.5, the line after a bullet is always indented.)

Anyway, to disable this for rst-mode, you can place the following in your init file:

(defun my-rst-mode-hook ()
  (electric-indent-local-mode -1))
(add-hook 'rst-mode-hook #'my-rst-mode-hook)

To disable this for all modes, you can use:

(electric-indent-mode -1)

Note that this minor mode does not follow the normal minor mode naming convention of using xyz-mode and zxy-global-mode. Instead, electric-indent-local-mode is the buffer local mode and electric-indent-mode is the global mode.

2
  • I'm impressed. How did you figure that out, if you could not even reproduce it?
    – Nikratio
    Jul 18, 2015 at 2:09
  • 1
    I guess because I've seen electric-indent-mode misbehave in other major modes, and the symptoms were very similar. Also, the fact that I've been using Emacs since the mid eighties might have contributed. Jul 18, 2015 at 6:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.