Function: comment-search-backward
comment-search-backward is a byte-compiled function defined in
newcomment.el.gz.
Signature
(comment-search-backward &optional LIMIT NOERROR)
Documentation
Find a comment start between LIMIT and point.
Moves point to inside the comment and returns the position of the comment-starter. If no comment is found, moves point to LIMIT and raises an error or returns nil if NOERROR is non-nil.
Ensure that comment-normalize-vars has been called before you use this.
Source Code
;; Defined in /usr/src/emacs/lisp/newcomment.el.gz
(defun comment-search-backward (&optional limit noerror)
"Find a comment start between LIMIT and point.
Moves point to inside the comment and returns the position of the
comment-starter. If no comment is found, moves point to LIMIT
and raises an error or returns nil if NOERROR is non-nil.
Ensure that `comment-normalize-vars' has been called before you use this."
;; FIXME: If a comment-start appears inside a comment, we may erroneously
;; stop there. This can be rather bad in general, but since
;; comment-search-backward is only used to find the comment-column (in
;; comment-set-column) and to find the comment-start string (via
;; comment-beginning) in indent-new-comment-line, it should be harmless.
(if (not (re-search-backward comment-start-skip limit 'move))
(unless noerror (error "No comment"))
(beginning-of-line)
(let* ((end (match-end 0))
(cs (comment-search-forward end t))
(pt (point)))
(if (not cs)
(progn (beginning-of-line)
(comment-search-backward limit noerror))
(while (progn (goto-char cs)
(comment-forward)
(and (< (point) end)
(setq cs (comment-search-forward end t))))
(setq pt (point)))
(goto-char pt)
cs))))