Function: c-semi-get-near-cache-entry

c-semi-get-near-cache-entry is a byte-compiled function defined in cc-engine.el.gz.

Signature

(c-semi-get-near-cache-entry HERE)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
(defun c-semi-get-near-cache-entry (here)
  ;; Return the near cache entry at the highest position before HERE, if any,
  ;; or nil.  The near cache entry is of the form (POSITION . STATE), where
  ;; STATE has the form of a result of `parse-partial-sexp'.
  (let ((nc-pos-state
	 (or (assq here c-semi-lit-near-cache)
	     (let ((nc-list c-semi-lit-near-cache)
		   pos (nc-pos 0) cand-pos-state)
	       (catch 'found
		 (while nc-list
		   (setq pos (caar nc-list))
		   (when (>= here pos)
		     (cond
		      ((and (cdar nc-list)
			    (nth 8 (cdar nc-list))
			    (< here (nth 8 (cdar nc-list))))
		       (throw 'found (car nc-list)))
		      ((> pos nc-pos)
		       (setq nc-pos pos
			     cand-pos-state (car nc-list)))))
		   (setq nc-list (cdr nc-list)))
		 cand-pos-state)))))
    (when (and nc-pos-state
	       (not (eq nc-pos-state (car c-semi-lit-near-cache))))
      ;; Move the found cache entry to the front of the list.
      (setq c-semi-lit-near-cache
	    (delq nc-pos-state c-semi-lit-near-cache))
      (push nc-pos-state c-semi-lit-near-cache))
    (copy-tree nc-pos-state)))