Function: c-collect-line-comments
c-collect-line-comments is a byte-compiled function defined in
cc-engine.el.gz.
Signature
(c-collect-line-comments RANGE)
Documentation
If the argument is a cons of two buffer positions (such as returned by
c-literal-limits), and that range contains a C++ style line comment,
then an extended range is returned that contains all adjacent line
comments (i.e. all comments that starts in the same column with no
empty lines or non-whitespace characters between them). Otherwise the
argument is returned.
Note that this function might do hidden buffer changes. See the comment at the start of cc-engine.el for more info.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
(defun c-collect-line-comments (range)
"If the argument is a cons of two buffer positions (such as returned by
`c-literal-limits'), and that range contains a C++ style line comment,
then an extended range is returned that contains all adjacent line
comments (i.e. all comments that starts in the same column with no
empty lines or non-whitespace characters between them). Otherwise the
argument is returned.
Note that this function might do hidden buffer changes. See the
comment at the start of cc-engine.el for more info."
(save-excursion
(condition-case nil
(if (and (consp range) (progn
(goto-char (car range))
(looking-at c-line-comment-starter)))
(let ((col (current-column))
(beg (point))
(bopl (c-point 'bopl))
(end (cdr range)))
;; Got to take care in the backward direction to handle
;; comments which are preceded by code.
(while (and (c-backward-single-comment)
(>= (point) bopl)
(looking-at c-line-comment-starter)
(= col (current-column)))
(setq beg (point)
bopl (c-point 'bopl)))
(goto-char end)
(while (and (progn (skip-chars-forward " \t")
(looking-at c-line-comment-starter))
(= col (current-column))
(prog1 (zerop (forward-line 1))
(setq end (point)))))
(cons beg end))
range)
(error range))))