Function: c-back-over-member-initializers

c-back-over-member-initializers is a byte-compiled function defined in cc-engine.el.gz.

Signature

(c-back-over-member-initializers &optional LIMIT)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
(defun c-back-over-member-initializers (&optional limit)
  ;; Test whether we are in a C++ member initializer list, and if so, go back
  ;; to the introducing ":", returning the position of the opening paren of
  ;; the function's arglist.  Otherwise return nil, leaving point unchanged.
  ;; LIMIT, if non-nil, is a limit for the backward search.
  (save-restriction
    (let ((here (point))
	  (paren-state (c-parse-state))	; Do this outside the narrowing for
					; performance reasons.
	  pos level-plausible at-top-level res)
      (if limit (narrow-to-region limit (point)))
      ;; Assume tentatively that we're at the top level.  Try to go back to the
      ;; colon we seek.
      (setq res
	    (catch 'done
	      (setq level-plausible
		    (catch 'level
		      (c-backward-syntactic-ws limit)
		      (when (memq (char-before) '(?\) ?}))
			(when (not (c-go-list-backward))
			  (throw 'done nil))
			(c-backward-syntactic-ws limit))
		      (when (c-back-over-compound-identifier)
			(c-backward-syntactic-ws limit))
		      (c-back-over-list-of-member-inits limit)
		      (and (eq (char-before) ?:)
			   (save-excursion
			     (c-backward-token-2)
			     (not (looking-at c-:$-multichar-token-regexp)))
			   (c-just-after-func-arglist-p))))

	      (while (and (not (and level-plausible
				    (setq at-top-level (c-at-toplevel-p))))
			  (setq pos (c-pull-open-brace paren-state)) ; might be a paren.
			  (or (null limit) (>= pos limit)))
		(setq level-plausible
		      (catch 'level
			(goto-char pos)
			(c-backward-syntactic-ws limit)
			(when (not (c-back-over-compound-identifier))
			  (throw 'level nil))
			(c-backward-syntactic-ws limit)
			(c-back-over-list-of-member-inits limit)
			(and (eq (char-before) ?:)
			     (save-excursion
			       (c-backward-token-2 nil nil limit)
			       (not (looking-at c-:$-multichar-token-regexp)))
			     (c-just-after-func-arglist-p)))))

	      (and at-top-level level-plausible)))
      (or res (goto-char here))
      res)))