Function: line-beginning-position

line-beginning-position is a function defined in editfns.c.

Signature

(line-beginning-position &optional N)

Documentation

Return the character position of the first character on the current line.

With optional argument N, scan forward N - 1 lines first. If the scan reaches the end of the buffer, return that position.

This function ignores text display directionality; it returns the position of the first character in logical order, i.e. the smallest character position on the logical line. See vertical-motion for movement by screen lines.

This function constrains the returned position to the current field unless that position would be on a different line from the original, unconstrained result. If N is nil or 1, and a front-sticky field starts at point, the scan stops as soon as it starts. To ignore field boundaries, bind inhibit-field-text-motion to t.

This function does not move point.

Other relevant functions are documented in the buffer group.

Probably introduced at or before Emacs version 20.4.

Shortdoc

;; buffer
(line-beginning-position)
    => 131

Aliases

mh-line-beginning-position hashcash-point-at-bol (obsolete since 28.1) point-at-bol

Source Code

// Defined in /usr/src/emacs/src/editfns.c
{
  ptrdiff_t charpos, bytepos, count;

  if (NILP (n))
    count = 0;
  else if (FIXNUMP (n))
    count = clip_to_bounds (-BUF_BYTES_MAX, XFIXNUM (n) - 1, BUF_BYTES_MAX);
  else
    {
      CHECK_INTEGER (n);
      count = NILP (Fnatnump (n)) ? -BUF_BYTES_MAX : BUF_BYTES_MAX;
    }

  scan_newline_from_point (count, &charpos, &bytepos);

  /* Return END constrained to the current input field.  */
  return Fconstrain_to_field (make_fixnum (charpos), make_fixnum (PT),
			      count != 0 ? Qt : Qnil,
			      Qt, Qnil);
}