What's the simplest way to check whether a given point value p
is at the beginning of some line or not? Is there anything simpler than (save-excursion (goto-char p) (= p (point-at-bol)))
or (member (char-before p) '(nil \n))
?
Asked
Active
Viewed 99 times
1 Answers
2
You can also use the function bolp
:
bolp
is a built-in function in `../editfns.c'.
(bolp)
Return
t
if point is at the beginning of a line.This function does not change global state, including the match data.
Usually you get a buffer position via (point)
, thus simply issuing (bolp)
will be enough. If the point has been moved, use goto-char
in advance.

xuchunyang
- 14,302
- 1
- 18
- 39
-
This only slightly simpler than `point-at-bol` since you still have to use `save-excursion` if you don't want to move point. `char-before` still seems simplest. – Lassi Aug 29 '18 at 11:50