Function: c-inside-bracelist-p

c-inside-bracelist-p is a byte-compiled function defined in cc-engine.el.gz.

Signature

(c-inside-bracelist-p CONTAINING-SEXP PAREN-STATE ACCEPT-IN-PAREN)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
(defun c-inside-bracelist-p (containing-sexp paren-state accept-in-paren)
  ;; return the buffer position of the beginning of the brace list statement
  ;; if CONTAINING-SEXP is inside a brace list, otherwise return nil.
  ;;
  ;; CONTAINING-SEXP is the buffer pos of the innermost containing paren.  NO
  ;; IT ISN'T!!!  [This function is badly designed, and probably needs
  ;; reformulating without its first argument, and the critical position being
  ;; at point.]
  ;;
  ;; PAREN-STATE is the remainder of the state of enclosing braces.
  ;; ACCEPT-IN-PAREN is non-nil iff we will accept as a brace list a brace
  ;; directly enclosed in a parenthesis.
  ;;
  ;; The "brace list" here is recognized solely by its context, not by
  ;; its contents.
  ;;
  ;; N.B.: This algorithm can potentially get confused by cpp macros
  ;; placed in inconvenient locations.  It's a trade-off we make for
  ;; speed.
  ;;
  ;; This function might do hidden buffer changes.
  (or
   ;; This will pick up brace list declarations.
   (save-excursion
     (goto-char containing-sexp)
     (and (c-backward-over-enum-header)
	  (point)))
   ;; this will pick up array/aggregate init lists, even if they are nested.
   (save-excursion
     (let ((bufpos t)
	    next-containing)
       (while (and (eq bufpos t)
		   containing-sexp)
	 (when paren-state
	   (setq next-containing (c-pull-open-brace paren-state)))

	 (goto-char containing-sexp)
	 (if (c-looking-at-inexpr-block next-containing next-containing)
	     ;; We're in an in-expression block of some kind.  Do not
	     ;; check nesting.  We deliberately set the limit to the
	     ;; containing sexp, so that c-looking-at-inexpr-block
	     ;; doesn't check for an identifier before it.
	     (setq bufpos nil)
	   (if (not (eq (char-after) ?{))
	       (setq bufpos nil)
	     (when (eq (setq bufpos (c-looking-at-or-maybe-in-bracelist
					  next-containing next-containing))
		       t)
	       (setq containing-sexp next-containing
		     next-containing nil)))))
       (and (consp bufpos)
	    (or accept-in-paren (not (eq (cdr bufpos) 'in-paren)))
	    (car bufpos))))))