Function: c-state-cache-lower-good-pos
c-state-cache-lower-good-pos is a byte-compiled function defined in
cc-engine.el.gz.
Signature
(c-state-cache-lower-good-pos HERE POS STATE)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
(defun c-state-cache-lower-good-pos (here pos state)
;; Return a good pos (in the sense of `c-state-cache-good-pos') at the
;; lowest[*] position between POS and HERE which is syntactically equivalent
;; to HERE. This position may be HERE itself. POS is before HERE in the
;; buffer.
;; [*] We don't actually always determine this exact position, since this
;; would require a disproportionate amount of work, given that this function
;; deals only with a corner condition, and POS and HERE are typically on
;; adjacent lines. We actually return either POS, when POS is a good
;; position, HERE otherwise. Exceptionally, when POS is in a comment, but
;; HERE not, we can return the position of the end of the comment.
(let (s)
(save-excursion
(goto-char pos)
(when (nth 8 state) ; POS in a comment or string. Move out of it.
(setq s (parse-partial-sexp pos here nil nil state 'syntax-table))
(when (< (point) here)
(setq pos (point)
state s)))
(if (eq (point) here) ; HERE is in the same literal as POS
pos
(setq s (parse-partial-sexp pos here (1+ (car state)) nil state nil))
(cond
((> (car s) (car state)) ; Moved into a paren between POS and HERE
here)
((not (eq (nth 6 s) (car state))) ; Moved out of a paren between POS
; and HERE
here)
(t pos))))))