Function: markdown-enter-key
markdown-enter-key is an interactive and byte-compiled function
defined in markdown-mode.el.
Signature
(markdown-enter-key)
Documentation
Handle RET depending on the context.
If the point is at a table, move to the next row. Otherwise,
indent according to value of markdown-indent-on-enter.
When it is nil, simply call newline. Otherwise, indent the next line
following RET using markdown-indent-line. Furthermore, when it
is set to 'indent-and-new-item and the point is in a list item,
start a new item with the same indentation. If the point is in an
empty list item, remove it (so that pressing RET twice when in a
list simply adds a blank line).
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/markdown-mode-20260321.143/markdown-mode.el
(defun markdown-enter-key () ;FIXME: Partly obsoleted by electric-indent
"Handle RET depending on the context.
If the point is at a table, move to the next row. Otherwise,
indent according to value of `markdown-indent-on-enter'.
When it is nil, simply call `newline'. Otherwise, indent the next line
following RET using `markdown-indent-line'. Furthermore, when it
is set to \\='indent-and-new-item and the point is in a list item,
start a new item with the same indentation. If the point is in an
empty list item, remove it (so that pressing RET twice when in a
list simply adds a blank line)."
(interactive)
(cond
;; Table
((markdown-table-at-point-p)
(call-interactively #'markdown-table-next-row))
;; Indent non-table text
(markdown-indent-on-enter
(let (bounds)
(if (and (memq markdown-indent-on-enter '(indent-and-new-item))
(not (markdown-code-block-at-point-p))
(setq bounds (markdown-cur-list-item-bounds)))
(let ((beg (cl-first bounds))
(end (cl-second bounds))
(nonlist-indent (cl-fourth bounds))
(checkbox (cl-sixth bounds)))
;; Point is in a list item
(if (= (- end beg) (+ nonlist-indent (length checkbox)))
;; Delete blank list
(progn
(delete-region beg end)
(newline)
(markdown-indent-line))
(call-interactively #'markdown-insert-list-item)))
;; Point is not in a list
(newline)
(markdown-indent-line))))
;; Insert a raw newline
(t (newline))))