polymode / poly-rst

Polymode for ReStructured Text
7 stars 3 forks source link

Open new line after head moves point back to the beginning of head #5

Open wyuenho opened 3 years ago

wyuenho commented 3 years ago

Reproduction:

  1. visit a new buffer called ~/test.rst
  2. type .. code-block:: python
  3. RET
  4. See point now jumped back to the beginning of the head, instead of at the beginning of the new line.

Expectation:

poly-rst-mode should allow me to open a new line after the head without moving my point. It should treat the newline as part of the head because reStructuredText requires 3 newlines and an indentation to the column of the beginning of the directive (i.e. before the c of code-block) to go into code block parsing state.

In essence, in a restructured text file:


Lorum Ipsum

.. code-block: python

   print("hello")
   print("world")

Lorum Ipsum

I expect the string .. code-block: python\n\n\n to be the head, and poly-rst-mode should under no circumstances be interfering with how the host mode indents when I'm still typing the head.

Why is polymode overriding the host mode's indent-line-function and indent-region-function anyway?

vspinu commented 3 years ago

This is new. For me poly-rst-mode is unusuable in emacs 28. Both indentaion and fontlock were ok when I first wrote it.

Why is polymode overriding the host mode's indent-line-function and indent-region-function anyway?

Not really overwriting, but rather protecting and calling the original in a narrowed buffer. Host modes don't understand indentation of inner modes.

wyuenho commented 3 years ago

I'm on emacs 27