Function: markdown-beginning-of-line

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

Signature

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

Documentation

Go to the beginning of the current visible line.

If this is a headline, and markdown-special-ctrl-a/e is not nil or symbol reversed, on the first attempt move to where the headline text hashes, and only move to beginning of line when the cursor is already before the hashes of the text of the headline.

If markdown-special-ctrl-a/e is symbol reversed then go to the hashes of the text 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
;;; Movement ==================================================================

;; This function was originally derived from `org-beginning-of-line' from org.el.
(defun markdown-beginning-of-line (&optional n)
  "Go to the beginning of the current visible line.

If this is a headline, and `markdown-special-ctrl-a/e' is not nil
or symbol `reversed', on the first attempt move to where the
headline text hashes, and only move to beginning of line when the
cursor is already before the hashes of the text of the headline.

If `markdown-special-ctrl-a/e' is symbol `reversed' then go to
the hashes of the text 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-a . ,_) C-a) (_ 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)
      ;; `move-beginning-of-line' may leave point after invisible
      ;; characters if line starts with such of these (e.g., with
      ;; a link at column 0).  Really move to the beginning of the
      ;; current visible line.
      (forward-line 0))
    (cond
     ;; No special behavior.  Point is already at the beginning of
     ;; a line, logical or visual.
     ((not special))
     ;; `beginning-of-visual-line' left point before logical beginning
     ;; of line: point is at the beginning of a visual line.  Bail
     ;; out.
     ((and visual-line-mode (not (bolp))))
     ((looking-at markdown-regex-header-atx)
      ;; At a header, special position is before the title.
      (let ((refpos (match-beginning 2))
            (bol (point)))
        (if (eq special 'reversed)
            (when (and (= origin bol) (eq last-command this-command))
              (goto-char refpos))
          (when (or (> origin refpos) (<= origin bol))
            (goto-char refpos)))
        ;; 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))))
     ((looking-at markdown-regex-list)
      ;; At a list item, special position is after the list marker or checkbox.
      (let ((refpos (or (match-end 4) (match-end 3))))
        (if (eq special 'reversed)
            (when (and (= (point) origin) (eq last-command this-command))
              (goto-char refpos))
          (when (or (> origin refpos) (<= origin (line-beginning-position)))
          (goto-char refpos)))))
     ;; No special case, already at beginning of line.
     (t nil))))