Function: c-beginning-of-sentence-in-comment
c-beginning-of-sentence-in-comment is a byte-compiled function defined
in cc-cmds.el.gz.
Signature
(c-beginning-of-sentence-in-comment RANGE)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cc-cmds.el.gz
(defun c-beginning-of-sentence-in-comment (range)
;; Move backwards to the "beginning of a sentence" within the comment
;; defined by RANGE, a cons of its starting and ending positions. If we
;; find a BOS, return NIL. Otherwise, move point to just before the start
;; of the comment and return T.
;;
;; The BOS is either text which follows a regexp match of sentence-end,
;; or text which is a beginning of "paragraph".
;; Comment-prefixes are treated like WS when calculating BOSes or BOPs.
;;
;; This code was adapted from GNU Emacs's forward-sentence in paragraphs.el.
;; It is not a general function, but is intended only for calling from
;; c-move-over-sentence. Not all preconditions have been explicitly stated.
;;
;; This function might do hidden buffer changes.
(save-match-data
(let ((start-point (point)))
(save-restriction
(c-narrow-to-comment-innards range) ; This may move point back.
(let* ((here (point))
last
(here-filler ; matches WS and comment-prefixes at point.
(concat "\\=\\(^[ \t]*\\(" c-current-comment-prefix "\\)"
"\\|[ \t\n\r\f]\\)*"))
(prefix-at-bol-here ; matches WS and prefix at BOL, just before point
(concat "^[ \t]*\\(" c-current-comment-prefix "\\)[ \t\n\r\f]*\\="))
;; First, find the previous paragraph start, if any.
(par-beg ; point where non-WS/non-prefix text of paragraph starts.
(save-excursion
(forward-paragraph -1) ; uses cc-mode values of
; paragraph-\(start\|separate\)
(if (> (re-search-forward here-filler nil t) here)
(goto-char here))
(when (>= (point) here)
(forward-paragraph -2)
(if (> (re-search-forward here-filler nil t) here)
(goto-char here)))
(point))))
;; Now seek successively earlier sentence ends between PAR-BEG and
;; HERE, until the "start of sentence" following it is earlier than
;; HERE, or we hit PAR-BEG. Beware of comment prefixes!
(while (and (re-search-backward (c-sentence-end) par-beg 'limit)
(setq last (point))
(goto-char (match-end 0)) ; tentative beginning of sentence
(or (>= (point) here)
(and (not (bolp)) ; Found a non-blank comment-prefix?
(save-excursion
(if (re-search-backward prefix-at-bol-here nil t)
(/= (match-beginning 1) (match-end 1)))))
(progn ; Skip the crud to find a real b-o-s.
(if (c-in-comment-line-prefix-p)
(beginning-of-line))
(re-search-forward here-filler) ; always succeeds.
(>= (point) here))))
(goto-char last))
(re-search-forward here-filler)))
(if (< (point) start-point)
nil
(goto-char (car range))
t))))