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

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.

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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