I would like to have a double nested list in Makrdown Fill mode. For this I write in my markdown file

* item 1
  * item 1.1:
    * item 1.1.1
    * item 1.1.2

Now I would like to add an * item 1.2: which should be aligned with * item 1.1:. However, emacs allows me, using tab, just the two positions, either:

* item 1
  * item 1.1:
    * item 1.1.1
    * item 1.1.2
    * item 1.2

or

* item 1
  * item 1.1:
    * item 1.1.1
    * item 1.1.2
* item 1.2

I would need to use spaces, but that doesn't make sense in my opinion. Why is emacs not allowing me to align them properly, i.e. leave the right indentation out?

  • Emacs can do better, but by default markdown-mode doesn't. It uses the function indent-relative, which provides very simplistic indentation. Basically, it looks at the previous line and offers you any plausible tab stops it sees there. It doesn't consider any further context or language-specific details. Which means you're left to manually indent * item 1.2 in your example. To fix this will require providing markdown-mode with a more intelligent indentation function, or borrowing something from another mode. you can contact the maintainers directly: github.com/jrblevin/markdown-mode – Tyler Jul 12 '17 at 18:41
  • 1
    @Tyler markdown-mode no longer uses indent-relative, but rather a customizable indentation function (markdown-indent-line, by default) which calculates indentation in context. I do see that indent-relative is mentioned in a docstring, so apologies for that. It's out of date and I'll update it. – Jason Blevins Jul 12 '17 at 23:48
  • @user8 The issue is that your list is ambiguous: different processors give three different answers. Markdown.pl sees only two list levels, because it specifies that nested lists should be indented by four spaces. For lists markdown-mode follows Markdown.pl, so if you indent lists by four spaces, or if you let markdown-mode handle the indentation for you (with C-u or C-u C-u prefixes) from the start, then it will work out as expected. – Jason Blevins Jul 12 '17 at 23:51

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.