Function: c-backward-single-comment
c-backward-single-comment is a byte-compiled function defined in
cc-engine.el.gz.
Signature
(c-backward-single-comment)
Documentation
Move backward past whitespace and the closest preceding comment, if any.
Return t if a comment was found, nil otherwise. In either case, the point is moved past the preceding whitespace. Line continuations, i.e. a backslashes followed by line breaks, are treated as whitespace. The line breaks that end line comments are considered to be the comment enders, so the point cannot be at the end of the same line to move over a line comment.
This function does not do any hidden buffer changes.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
(defun c-backward-single-comment ()
"Move backward past whitespace and the closest preceding comment, if any.
Return t if a comment was found, nil otherwise. In either case, the
point is moved past the preceding whitespace. Line continuations,
i.e. a backslashes followed by line breaks, are treated as whitespace.
The line breaks that end line comments are considered to be the
comment enders, so the point cannot be at the end of the same line to
move over a line comment.
This function does not do any hidden buffer changes."
(let ((start (point)))
;; When we got newline terminated comments, forward-comment in all
;; supported emacsen so far will stop at eol of each line not
;; ending with a comment when moving backwards. This corrects for
;; that, and at the same time handles line continuations.
(while (progn
(skip-chars-backward " \t\n\r\f\v")
(and (looking-at "[\n\r]")
(eq (char-before) ?\\)))
(backward-char))
(if (bobp)
;; Some emacsen (e.g. Emacs 19.34) return t when moving
;; backwards at bob.
nil
;; Leave point after the closest following newline if we've
;; backed up over any above, since forward-comment won't move
;; backward over a line comment if point is at the end of the
;; same line.
(re-search-forward "\\=\\s *[\n\r]" start t)
(if (if (c-forward-comment-minus-1)
(if (eolp)
;; If forward-comment above succeeded and we're at eol
;; then the newline we moved over above didn't end a
;; line comment, so we give it another go.
(c-forward-comment-minus-1)
t))
;; Emacs <= 20 and XEmacs move back over the closer of a
;; block comment that lacks an opener.
(if (looking-at "\\*/")
(progn (forward-char 2) nil)
t)))))