Function: c-brace-stack-at

c-brace-stack-at is a byte-compiled function defined in cc-engine.el.gz.

Signature

(c-brace-stack-at HERE)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
(defun c-brace-stack-at (here)
  ;; Given a buffer position HERE, Return the value of the brace stack there.
  (save-excursion
    (save-restriction
      (widen)
      (let ((c c-bs-cache)
	    (can-use-prev (<= c-bs-prev-pos c-bs-cache-limit))
	    elt stack pos npos high-elt)
	;; Trim the cache to take account of buffer changes.
	(while (and c
		    (> (caar c) c-bs-cache-limit))
	  (setq c (cdr c)))
	(setq c-bs-cache c)

	(while (and c
		    (> (caar c) here))
	  (setq high-elt (car c))
	  (setq c (cdr c)))
	(setq pos (or (and c (caar c))
		      (point-min)))

	(setq elt (if c
		      (car c)
		    (cons (point-min)
			  (cons nil (list 1)))))
	(when (not high-elt)
	  (setq stack (cdr elt))
	  (while
	      ;; Add an element to `c-bs-cache' each iteration.
	      (<= (setq npos (+ pos c-bs-interval)) here)
	    (setq elt (c-update-brace-stack stack pos npos))
	    (setq npos (car elt))
	    (setq stack (cdr elt))
	    (unless (eq npos (point-max)) ; NPOS could be in a literal at EOB.
	      (setq c-bs-cache (cons elt c-bs-cache)))
	    (setq pos npos)))

	(if (> pos c-bs-cache-limit)
	    (setq c-bs-cache-limit pos))

	;; Can we just use the previous value?
	(if (and can-use-prev
		 (<= c-bs-prev-pos here)
		 (> c-bs-prev-pos (car elt)))
	    (setq pos c-bs-prev-pos
		  stack c-bs-prev-stack)
	  (setq pos (car elt)
		stack (cdr elt)))
	(if (> here c-bs-cache-limit)
	    (setq c-bs-cache-limit here))
	(setq elt (c-update-brace-stack stack pos here)
	      c-bs-prev-pos (car elt)
	      c-bs-prev-stack (cdr elt))))))