Function: c-forward-to-nth-EOF-;-or-}
c-forward-to-nth-EOF-;-or-} is a byte-compiled function defined in
cc-cmds.el.gz.
Signature
(c-forward-to-nth-EOF-\;-or-} N WHERE)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cc-cmds.el.gz
(defun c-forward-to-nth-EOF-\;-or-} (n where)
;; Skip to the closing brace or semicolon of the Nth function after point.
;; We move to a semicolon only for things like structs which don't end at a
;; closing brace. If point is inside a function, this counts as the first.
;; Point must be outside any comment/string or macro.
;;
;; N must be strictly positive.
;; WHERE describes the position of point, one of the symbols `at-header',
;; `in-header', `in-block', `in-trailer', `at-function-end',
;; `outwith-function' as returned by c-where-wrt-brace-construct.
;;
;; If we run out of functions, leave point at EOB. Return zero on success,
;; otherwise the number of }s still to go.
;;
;; This function may do hidden buffer changes.
(cond
;; What we do to go forward over the first defun depends on where we
;; start. We go to the closing brace of that defun, even when we go
;; backwards to it (in a "struct foo {...} bar ;").
((eobp))
((eq where 'in-block)
(goto-char (c-least-enclosing-brace (c-parse-state)))
(forward-sexp)
(setq n (1- n)))
((eq where 'in-trailer)
;; The actual movement is done below.
(setq n (1- n)))
((memq where '(at-function-end outwith-function at-header in-header))
(if (eq where 'in-header)
(let ((pos (c-least-enclosing-brace (c-parse-state))))
(if pos (c-go-list-forward pos))))
(when (c-syntactic-re-search-forward "{" nil 'eob t)
(backward-char)
(forward-sexp)
(setq n (1- n))))
(t (error "c-forward-to-nth-EOF-\\;-or-}: `where' is %s" where)))
;; Each time round the loop, go forward to a "}" at the outermost level.
(while (and (> n 0) (not (eobp)))
(when (c-syntactic-re-search-forward "{" nil 'eob)
(backward-char)
(forward-sexp)
(setq n (1- n))))
(when (c-in-function-trailer-p)
(c-syntactic-re-search-forward ";" nil 'eob t))
n)