Function: org-beginning-of-line
org-beginning-of-line is an interactive and byte-compiled function
defined in org.el.gz.
Signature
(org-beginning-of-line &optional N)
Documentation
Go to the beginning of the current visible line.
If this is a headline, and org-special-ctrl-a/e is not nil or
symbol reversed, on the first attempt move to where the
headline text starts, and only move to beginning of line when the
cursor is already before the start of the text of the headline.
If org-special-ctrl-a/e is symbol reversed then go to the
start 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 /usr/src/emacs/lisp/org/org.el.gz
;;;; Functions extending outline functionality
(defun org-beginning-of-line (&optional n)
"Go to the beginning of the current visible line.
If this is a headline, and `org-special-ctrl-a/e' is not nil or
symbol `reversed', on the first attempt move to where the
headline text starts, and only move to beginning of line when the
cursor is already before the start of the text of the headline.
If `org-special-ctrl-a/e' is symbol `reversed' then go to the
start 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 org-special-ctrl-a/e
(`(,C-a . ,_) C-a) (_ org-special-ctrl-a/e)))
deactivate-mark)
;; First move to a visible line.
(if (bound-and-true-p 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 (bound-and-true-p visual-line-mode) (not (bolp))))
((let ((case-fold-search nil)) (looking-at org-complex-heading-regexp))
;; At a headline, special position is before the title, but
;; after any TODO keyword or priority cookie.
(let ((refpos (min (1+ (or (match-end 3) (match-end 2) (match-end 1)))
(line-end-position)))
(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)))))
((and (looking-at org-list-full-item-re)
(org-element-type-p
(save-match-data (org-element-at-point))
'(item plain-list)))
;; Set special position at first white space character after
;; bullet, and check-box, if any.
(let ((after-bullet
(let ((box (match-end 3)))
(cond ((not box) (match-end 1))
((eq (char-after box) ?\s) (1+ box))
(t box)))))
(if (eq special 'reversed)
(when (and (= (point) origin) (eq last-command this-command))
(goto-char after-bullet))
(when (or (> origin after-bullet) (>= (point) origin))
(goto-char after-bullet)))))
;; No special context. Point is already at beginning of line.
(t nil))))