Function: c-at-toplevel-p

c-at-toplevel-p is a byte-compiled function defined in cc-engine.el.gz.

Signature

(c-at-toplevel-p)

Documentation

Return a determination as to whether point is "at the top level".

Informally, "at the top level" is anywhere where you can write a function.

More precisely, being at the top-level means that point is either outside any enclosing block (such as a function definition), or directly inside a class, namespace or other block that contains another declaration level.

If point is not at the top-level (e.g. it is inside a method definition), then nil is returned. Otherwise, if point is at a top-level not enclosed within a class definition, t is returned. Otherwise, a 2-vector is returned where the zeroth element is the buffer position of the start of the class declaration, and the first element is the buffer position of the enclosing class's opening brace.

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-at-toplevel-p ()
  "Return a determination as to whether point is \"at the top level\".
Informally, \"at the top level\" is anywhere where you can write
a function.

More precisely, being at the top-level means that point is either
outside any enclosing block (such as a function definition), or
directly inside a class, namespace or other block that contains
another declaration level.

If point is not at the top-level (e.g. it is inside a method
definition), then nil is returned.  Otherwise, if point is at a
top-level not enclosed within a class definition, t is returned.
Otherwise, a 2-vector is returned where the zeroth element is the
buffer position of the start of the class declaration, and the first
element is the buffer position of the enclosing class's opening
brace.

Note that this function might do hidden buffer changes.  See the
comment at the start of cc-engine.el for more info."
  ;; Note to maintainers: this function consumes a great mass of CPU cycles.
  ;; Its use should thus be minimized as far as possible.
  ;; Consider instead using `c-bs-at-toplevel-p'.
  (let ((paren-state (c-parse-state)))
    (or (not (c-most-enclosing-brace paren-state))
	(c-search-uplist-for-classkey paren-state))))