jrblevin / markdown-mode

Emacs Markdown Mode
http://jblevins.org/projects/markdown-mode/
GNU General Public License v3.0
897 stars 163 forks source link

indent all lines of multi-line lists (like in org-mode's org-indent-mode) ? #330

Open 517qf opened 6 years ago

517qf commented 6 years ago

I use visual-line-mode to wrap text at the border of my window.

At the moment multi-line lists look like this

1. asdf asdf asdf asdf
asdf asdf asdf 
2. asdf asdf asdf asdf
asdf asdf asdf

but I want it to look like this

1. asdf asdf asdf asdf
   asdf asdf asdf 
2. asdf asdf asdf asdf
   asdf asdf asdf

Is this possible with this package? I (bought&)searched the book for the word indent but didn't find a solution, searching the issues here for indent or google in general didn't help either.

I'm intested in what org-indent-mode does in org-mode (the mode for the other popular lightweight markup language). org-indent-mode is primarily advertised to indent the text of nested headings (see here) but also works on lists. btw: In markdown-mode can I indent all the text of nested headings?

I tried with emacs 25.1.1 on linux in a new profile with a minimal init.el that only contains the code to use melpa. I used melpa to download markdown-mode (version github 20180124.138) and counsel/swiper/ivy.

jrblevin commented 6 years ago

I'm going to file this as a feature request. Currently, if you want to actually fill the list items, markdown-mode will indeed fill with hanging indentation as in your second example above. However, if you want to keep long lines in the text but have the lines display wrapped, with hanging indentation, this is unfortunately not something markdown-mode does right now.

I didn't know org-indent-mode did this. Looking at the code, there is quite a bit of machinery involved to make this work in the background, but for markdown-mode maybe we'd only need to add the wrap-prefix property to list items (say, only when markup hiding is on).

jrblevin commented 6 years ago

In searching for how to implement this, I found a minor mode that does what you want, even with variable pitch fonts: adaptive-wrap-vp. The example screenshots are even with markdown-mode!

517qf commented 6 years ago

Thank you very much for your answer (and your great packages in general (like deft)).

Somehow I must have missed adaptve-wrap. This isn't as perfect as org-indent-mode but it works and this makes the structure much clearer for me. Maybe you could point to this package in the readme and your book?

Did I also miss something about indenting nested headings and their contents (like in org-indent-mode)? If there is functionality for this could you also include this in the readme/book.

jrblevin commented 6 years ago

There is currently no functionality for indenting the contents of sections. The only related thing I can think of is that you can put the hash marks in the left margin with markdown-marginalize-headers, but that's sort of the opposite of what you'd like.

cyrus-and commented 5 years ago

This is somewhat related, I'm using adaptive-wrap with visual-line-mode but I'd like to also wrap headings nicely, for example:

#### Foo bar | <-- buffer boundary
     baz     |

instead of:

#### Foo bar | <-- buffer boundary
baz          |

@jrblevin how can I achieve that?

AFAIK it doesn't happen for the same reason why (and rightly so) M-q doesn't work on headings and the following are the variables that control this behavior:

https://github.com/jrblevin/markdown-mode/blob/f3c54e34cc5228001af36a5301883325319f21d4/markdown-mode.el#L9551-L9553

But I could use some help in changing them, even if it breaks M-q on headings, I don't care.

Or maybe there's a better way to do that...