0

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))?

0

1 Answer 1

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.

1
  • 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
    Commented Aug 29, 2018 at 11:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.