Function: c-end-of-sentence-in-comment

c-end-of-sentence-in-comment is a byte-compiled function defined in cc-cmds.el.gz.

Signature

(c-end-of-sentence-in-comment RANGE)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-cmds.el.gz
(defun c-end-of-sentence-in-comment (range)
  ;; Move forward to the "end of a sentence" within the comment defined by
  ;; RANGE, a cons of its starting and ending positions (enclosing the opening
  ;; comment delimiter and the terminating */ or newline).  If we find an EOS,
  ;; return NIL.  Otherwise, move point to just after the end of the comment
  ;; and return T.
  ;;
  ;; The EOS is just after the non-WS part of the next match of the regexp
  ;; sentence-end.  Typically, this is just after one of [.!?].  If there is
  ;; no sentence-end match following point, any WS before the end of the
  ;; comment will count as EOS, providing we're not already in it.
  ;;
  ;; 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.
  ;;
  ;; This function might do hidden buffer changes.
  (save-match-data
    (let ((start-point (point))
	  ;; (lit-type (c-literal-type range))  ; Commented out, 2005/11/23, ACM
	  )
      (save-restriction
	(c-narrow-to-comment-innards range) ; This might move point forwards.
	(let* ((here (point))
	       (par-end	; EOL position of last text in current/next paragraph.
		(save-excursion
		  ;; The cc-mode values of paragraph-\(start\|separate\), set
		  ;; in c-setup-paragraph-variables, are used in the
		  ;; following.
		  (forward-paragraph 1)
		  (if (eq (preceding-char) ?\n) (forward-char -1))
		  (when (<= (point) here) ; can happen, e.g., when HERE is at EOL.
		    (goto-char here)
		    (forward-paragraph 2)
		    (if (eq (preceding-char) ?\n) (forward-char -1)))
		  (point)))

	       last
	       (prefix-at-bol-here
		(concat "^[ \t]*\\(" c-current-comment-prefix "\\)\\=")))
	  ;; Go forward one "comment-prefix which looks like sentence-end"
	  ;; each time round the following:
	  (while (and (re-search-forward (c-sentence-end) par-end 'limit)
		      (progn
			(setq last (point))
			(skip-chars-backward " \t\n")
			(or (and (not (bolp))
				 (re-search-backward prefix-at-bol-here nil t)
				 (/= (match-beginning 1) (match-end 1)))
			    (<= (point) here))))
	    (goto-char last))

	  ;; Take special action if we're up against the end of a comment (of
	  ;; either sort): Leave point just after the last non-ws text.
	  (if (eq (point) (point-max))
	      (while (or (/= (skip-chars-backward " \t\n") 0)
			 (and (re-search-backward prefix-at-bol-here nil t)
			      (/= (match-beginning 1) (match-end 1))))))))

      (if (> (point) start-point)
	      nil
	    (goto-char (cdr range))
	    t))))