- ;; CASE 1: The top of the cache is a brace pair which now encloses `here'.
- ;; As good-pos, return the address. of the "{".
- (if (and (consp (car c-state-cache))
- (> (cdar c-state-cache) here))
- ;; Since we've no knowledge of what's inside these braces, we have no
- ;; alternative but to direct the caller to scan the buffer from the
- ;; opening brace.
- (progn
- (setq pos (caar c-state-cache))
- (setcar c-state-cache pos)
- (list (1+ pos) pos t)) ; return value. We've just converted a brace
- ; pair entry into a { entry, so the caller
- ; needs to search for a brace pair before the
- ; {.
-
- ;; ;; `here' might be inside a literal. Check for this.
- (setq lit (c-state-literal-at here)
- here-lit-start (or (car lit) here)
- here-lit-end (or (cdr lit) here))
-
- ;; `here' might be nested inside any depth of parens (or brackets but
- ;; not braces). Scan backwards to find the outermost such opening
- ;; paren, if there is one. This will be the scan position to return.
- (save-restriction
- (narrow-to-region cache-pos (point-max))
- (setq pos (c-state-balance-parens-backwards here-lit-end pos)))
-
- (if (< pos here-lit-start)
- ;; CASE 2: Address of outermost ( or [ which now encloses `here',
- ;; but didn't enclose the (previous) `c-state-cache-good-pos'. If
- ;; there is a brace pair preceding this, it will already be in
- ;; `c-state-cache', unless there was a brace pair after it,
- ;; i.e. there'll only be one to scan for if we've just deleted one.
- (list pos (and dropped-cons pos) t) ; Return value.
-
- ;; `here' isn't enclosed in a (previously unrecorded) bracket/paren.
- ;; Further forward scanning isn't needed, but we still need to find a
- ;; GOOD-POS. Step out of all enclosing "("s on HERE's line.
+ (cond
+ ((and (consp (car c-state-cache))
+ (> (cdar c-state-cache) here))
+ ;; CASE 1: The top of the cache is a brace pair which now encloses
+ ;; `here'. As good-pos, return the address. of the "{". Since we've no
+ ;; knowledge of what's inside these braces, we have no alternative but
+ ;; to direct the caller to scan the buffer from the opening brace.
+ (setq pos (caar c-state-cache))
+ (setcar c-state-cache pos)
+ (list (1+ pos) pos t)) ; return value. We've just converted a brace pair
+ ; entry into a { entry, so the caller needs to
+ ; search for a brace pair before the {.
+
+ ;; `here' might be inside a literal. Check for this.
+ ((progn
+ (setq lit (c-state-literal-at here)
+ here-lit-start (or (car lit) here)
+ here-lit-end (or (cdr lit) here))
+ ;; Has `here' just "newly entered" a macro?
+ (save-excursion
+ (goto-char here-lit-start)
+ (if (and (c-beginning-of-macro)
+ (or (null c-state-old-cpp-beg)
+ (not (= (point) c-state-old-cpp-beg))))
+ (progn
+ (setq here- (point))
+ (c-end-of-macro)
+ (setq here+ (point)))
+ (setq here- here-lit-start
+ here+ here-lit-end)))
+
+ ;; `here' might be nested inside any depth of parens (or brackets but
+ ;; not braces). Scan backwards to find the outermost such opening
+ ;; paren, if there is one. This will be the scan position to return.
+ (save-restriction
+ (narrow-to-region cache-pos (point-max))
+ (setq pos (c-state-balance-parens-backwards here- here+ pos)))
+ nil)) ; for the cond
+
+ ((< pos here-lit-start)
+ ;; CASE 2: Address of outermost ( or [ which now encloses `here', but
+ ;; didn't enclose the (previous) `c-state-cache-good-pos'. If there is
+ ;; a brace pair preceding this, it will already be in `c-state-cache',
+ ;; unless there was a brace pair after it, i.e. there'll only be one to
+ ;; scan for if we've just deleted one.
+ (list pos (and dropped-cons pos) t)) ; Return value.
+
+ ;; `here' isn't enclosed in a (previously unrecorded) bracket/paren.
+ ;; Further forward scanning isn't needed, but we still need to find a
+ ;; GOOD-POS. Step out of all enclosing "("s on HERE's line.
+ ((progn