Function: c-invalidate-state-cache-1

c-invalidate-state-cache-1 is a byte-compiled function defined in cc-engine.el.gz.

Signature

(c-invalidate-state-cache-1 HERE)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Debugging routines to dump `c-state-cache' in a "replayable" form.
;; (defmacro c-sc-de (elt)              ; "c-state-cache-dump-element"
;;   `(format ,(concat "(setq " (symbol-name elt) " %s)    ") ,elt))
;; (defmacro c-sc-qde (elt)		; "c-state-cache-quote-dump-element"
;;   `(format ,(concat "(setq " (symbol-name elt) " '%s)    ") ,elt))
;; (defun c-state-dump ()
;;   ;; For debugging.
;;   ;(message
;;   (concat
;;    (c-sc-qde c-state-cache)
;;    (c-sc-de c-state-cache-good-pos)
;;    (c-sc-qde c-state-nonlit-pos-cache)
;;    (c-sc-de c-state-nonlit-pos-cache-limit)
;;    (c-sc-qde c-state-brace-pair-desert)
;;    (c-sc-de c-state-point-min)
;;    (c-sc-de c-state-point-min-lit-type)
;;    (c-sc-de c-state-point-min-lit-start)
;;    (c-sc-de c-state-min-scan-pos)
;;    (c-sc-de c-state-old-cpp-beg)
;;    (c-sc-de c-state-old-cpp-end)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun c-invalidate-state-cache-1 (here)
  ;; Invalidate all info on `c-state-cache' that applies to the buffer at HERE
  ;; or higher and set `c-state-cache-good-pos' and
  ;; `c-state-cache-invalid-pos' accordingly.  The cache is left in a
  ;; consistent state.
  ;;
  ;; This is much like `c-whack-state-after', but it never changes a paren
  ;; pair element into an open paren element.  Doing that would mean that the
  ;; new open paren wouldn't have the required preceding paren pair element.
  ;;
  ;; This function is called from c-before-change.

  ;; The caches of non-literals:
  ;; Note that we use "<=" for the possibility of the second char of a two-char
  ;; comment opener being typed; this would invalidate any cache position at
  ;; HERE.
  (if (<= here c-state-nonlit-pos-cache-limit)
      (setq c-state-nonlit-pos-cache-limit (1- here)))

  (cond
   ;; `c-state-cache':
   ;; Case 1: if `here' is in a literal containing point-min, everything
   ;; becomes (or is already) nil.
   ((or (null c-state-cache-good-pos)
	(< here (c-state-get-min-scan-pos)))
    (setq c-state-cache nil
	  c-state-cache-good-pos nil
	  c-state-cache-invalid-pos (c-state-get-min-scan-pos)
	  c-state-min-scan-pos nil))

   ;; Case 2: `here' is below `c-state-cache-good-pos', so we need to amend
   ;; the entire `c-state-cache' data.
   ((< here c-state-cache-good-pos)
    (let* ((res (c-remove-stale-state-cache-backwards here))
	   (good-pos (car res))
	   (scan-backward-pos (cadr res))
	   (scan-forward-p (car (cddr res))))
      (if scan-backward-pos
	  (c-append-lower-brace-pair-to-state-cache scan-backward-pos here))
      (setq c-state-cache-good-pos
	    (if scan-forward-p
		(c-append-to-state-cache good-pos here)
	      good-pos)
	    c-state-cache-invalid-pos
	    (or c-state-cache-good-pos (c-state-get-min-scan-pos))))))

  ;; The brace-pair desert marker:
  (when (car c-state-brace-pair-desert)
    (if (< here (car c-state-brace-pair-desert))
	(setq c-state-brace-pair-desert nil)
      (if (< here (cdr c-state-brace-pair-desert))
	  (setcdr c-state-brace-pair-desert here)))))