Function: markdown-end-of-line

markdown-end-of-line is an interactive and byte-compiled function defined in markdown-mode.el.

Signature

(markdown-end-of-line &optional N)

Documentation

Go to the end of the line, but before ellipsis, if any.

If this is a headline, and markdown-special-ctrl-a/e is not nil or symbol reversed, ignore closing tags on the first attempt, and only move to after the closing tags when the cursor is already beyond the end of the headline.

If markdown-special-ctrl-a/e is symbol reversed then ignore closing tags on the second attempt.

With argument N not nil or 1, move forward N - 1 lines first.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/markdown-mode-20260321.143/markdown-mode.el
;; This function was originally derived from `org-end-of-line' from org.el.
(defun markdown-end-of-line (&optional n)
  "Go to the end of the line, but before ellipsis, if any.

If this is a headline, and `markdown-special-ctrl-a/e' is not nil
or symbol `reversed', ignore closing tags on the first attempt,
and only move to after the closing tags when the cursor is
already beyond the end of the headline.

If `markdown-special-ctrl-a/e' is symbol `reversed' then ignore
closing tags on the second attempt.

With argument N not nil or 1, move forward N - 1 lines first."
  (interactive "^p")
  (let ((origin (point))
        (special (pcase markdown-special-ctrl-a/e
                   (`(,_ . ,C-e) C-e) (_ markdown-special-ctrl-a/e)))
        deactivate-mark)
    ;; First move to a visible line.
    (if visual-line-mode
        (beginning-of-visual-line n)
      (move-beginning-of-line n))
    (cond
     ;; At a headline, with closing tags.
     ((save-excursion
        (forward-line 0)
        (and (looking-at markdown-regex-header-atx) (match-end 3)))
      (let ((refpos (match-end 2))
            (visual-end (and visual-line-mode
                             (save-excursion
                               (end-of-visual-line)
                               (point)))))
        ;; If `end-of-visual-line' brings us before end of line or even closing
        ;; tags, i.e., the headline spans over multiple visual lines, move
        ;; there.
        (cond ((and visual-end
                    (< visual-end refpos)
                    (<= origin visual-end))
               (goto-char visual-end))
              ((not special) (end-of-line))
              ((eq special 'reversed)
               (if (and (= origin (line-end-position))
                        (eq this-command last-command))
                   (goto-char refpos)
                 (end-of-line)))
              (t
               (if (or (< origin refpos) (>= origin (line-end-position)))
                   (goto-char refpos)
                 (end-of-line))))
        ;; Prevent automatic cursor movement caused by the command loop.
        ;; Enable disable-point-adjustment to avoid unintended cursor repositioning.
        (when (and markdown-hide-markup
                   (equal (get-char-property (point) 'display) ""))
          (setq disable-point-adjustment t))))
     (visual-line-mode
      (let ((bol (line-beginning-position)))
        (end-of-visual-line)
        ;; If `end-of-visual-line' gets us past the ellipsis at the
        ;; end of a line, backtrack and use `end-of-line' instead.
        (when (/= bol (line-beginning-position))
          (goto-char bol)
          (end-of-line))))
     (t (end-of-line)))))