Function: tcl-hairy-scan-for-comment
tcl-hairy-scan-for-comment is a byte-compiled function defined in
tcl.el.gz.
Signature
(tcl-hairy-scan-for-comment STATE END ALWAYS-STOP)
Documentation
Determine if point is in a comment.
Returns a list of the form (FLAG . STATE). STATE can be used
as input to future invocations. FLAG is nil if not in comment,
t otherwise. If in comment, leaves point at beginning of comment.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/tcl.el.gz
(defun tcl-hairy-scan-for-comment (state end always-stop)
"Determine if point is in a comment.
Returns a list of the form `(FLAG . STATE)'. STATE can be used
as input to future invocations. FLAG is nil if not in comment,
t otherwise. If in comment, leaves point at beginning of comment."
(let ((bol (save-excursion
(goto-char end)
(line-beginning-position)))
real-comment
last-cstart)
(while (and (not last-cstart) (< (point) end))
(setq real-comment nil) ;In case we've looped around and it is set.
(setq state (parse-partial-sexp (point) end nil nil state t))
(if (nth 4 state)
(progn
;; If ALWAYS-STOP is set, stop even if we don't have a
;; real comment, or if the comment isn't on the same line
;; as the end.
(if always-stop (setq last-cstart (point)))
;; If we have a real comment, then set the comment
;; starting point if we are on the same line as the ending
;; location.
(setq real-comment (tcl-real-comment-p))
(if real-comment
(progn
(and (> (point) bol) (setq last-cstart (point)))
;; NOTE Emacs 19 has a misfeature whereby calling
;; parse-partial-sexp with COMMENTSTOP set and with
;; an initial list that says point is in a comment
;; will cause an immediate return. So we must skip
;; over the comment ourselves.
(beginning-of-line 2)))
;; Frob the state to make it look like we aren't in a
;; comment.
(setcar (nthcdr 4 state) nil))))
(and last-cstart
(goto-char last-cstart))
(cons real-comment state)))