Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve list indentation after RET #179

Closed
steckerhalter opened this issue Jan 21, 2017 · 3 comments
Closed

Preserve list indentation after RET #179

steckerhalter opened this issue Jan 21, 2017 · 3 comments

Comments

@steckerhalter
Copy link

I have this code now mapped on RET in markdown-mode:

  (defun my-markdown-ret ()
    "Preserve list indentation after RET in markdown-mode."
    ;; improved version of http://emacs.stackexchange.com/a/14642
    (interactive)
    (if-let ((bounds (markdown-cur-list-item-bounds))
             (beg (car bounds))
             (end (cadr bounds))
             (indent (cadddr bounds))
             (text (buffer-substring beg end)))
        (if (= (- end beg)
               indent)
            (progn
              (kill-region beg end)
              (markdown-enter-key))
          (call-interactively #'markdown-insert-list-item))
      (markdown-enter-key)))

I think it is quite convenient... maybe you would like to integrate it in some way?

@steckerhalter
Copy link
Author

@jrblevin nice, thanks for adding this

@jrblevin
Copy link
Owner

jrblevin commented May 26, 2017

An update: I realized that this is not what you want to happen if you wrap lines yourself using RET. You might want a multi-line list item, for example. So, I added a new setting to markdown-indent-on-enter in 9e10d57: it can be nil, indent, or indent-and-new-item. You'll want it set to the latter:

(setq markdown-indent-on-enter 'indent-and-new-item)

@steckerhalter
Copy link
Author

ok thanks for the notice

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants