- ;; We used to use (start-of-paragraph-text), but this can
- ;; prevent sentence-end from matching if it is anchored at
- ;; BOL and the paragraph starts indented.
- (par-beg (save-excursion (backward-paragraph) (point))))
- (if (and (re-search-backward sentence-end par-beg t)
- (or (< (match-end 0) pos)
- (re-search-backward sentence-end par-beg t)))
- (goto-char (match-end 0))
- (goto-char par-beg)))
+ par-beg par-text-beg)
+ (save-excursion
+ (start-of-paragraph-text)
+ ;; Start of real text in the paragraph.
+ ;; We move back to here if we don't see a sentence-end.
+ (setq par-text-beg (point))
+ ;; Start of the first line of the paragraph.
+ ;; We use this as the search limit
+ ;; to allow sentence-end to match if it is anchored at
+ ;; BOL and the paragraph starts indented.
+ (beginning-of-line)
+ (setq par-beg (point)))
+ (if (and (re-search-backward sentence-end par-beg t)
+ (or (< (match-end 0) pos)
+ (re-search-backward sentence-end par-beg t)))
+ (goto-char (match-end 0))
+ (goto-char par-text-beg)))