aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Stjernholm2002-05-25 16:18:59 +0000
committerMartin Stjernholm2002-05-25 16:18:59 +0000
commit3ce79cf5550fd9d616039dfe79ad8b07624f9a5a (patch)
tree30350738a6d3c782cd884444cf11775a4eb6bcdc
parent3433002d78e9f8976a8cb71b2c2051669f1fe48c (diff)
downloademacs-3ce79cf5550fd9d616039dfe79ad8b07624f9a5a.tar.gz
emacs-3ce79cf5550fd9d616039dfe79ad8b07624f9a5a.zip
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
else-if compounds.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/progmodes/cc-engine.el89
2 files changed, 55 insertions, 39 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 5533796882b..97e775e9867 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12002-05-25 Martin Stjernholm <bug-cc-mode@gnu.org>
2
3 * progmodes/cc-engine.el (c-add-stmt-syntax): Fixed some cases
4 of wrong anchoring, e.g. for else-if compounds.
5
12002-05-25 Miles Bader <miles@gnu.org> 62002-05-25 Miles Bader <miles@gnu.org>
2 7
3 * menu-bar.el (menu-bar-showhide-fringe-menu-customize-left) 8 * menu-bar.el (menu-bar-showhide-fringe-menu-customize-left)
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index fd5340f190d..045556de180 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -2333,24 +2333,14 @@ Keywords are recognized and not considered identifiers."
2333 (setq savepos (point) 2333 (setq savepos (point)
2334 step-type step-tmp)) 2334 step-type step-tmp))
2335 2335
2336 ;; Skip over any comments that stands between the statement and 2336 (catch 'done
2337 ;; boi. If stop-at-boi-only is nil and we're not at boi after
2338 ;; this, then we're done.
2339 (while (and (/= (setq savepos (point)) boi)
2340 (c-forward-comment -1))
2341 (setq at-comment t
2342 boi (c-point 'boi)))
2343 (goto-char savepos)
2344
2345 (when (or stop-at-boi-only
2346 (= (point) boi))
2347 (catch 'done
2348 ;; Loop if we have to back out of the containing block. 2337 ;; Loop if we have to back out of the containing block.
2349 (while 2338 (while
2350 (progn 2339 (progn
2351 ;; Loop if we have to back up another statement. 2340 ;; Loop if we have to back up another statement.
2352 (while 2341 (while
2353 (progn 2342 (progn
2343
2354 ;; Always start by skipping over any comments that 2344 ;; Always start by skipping over any comments that
2355 ;; stands between the statement and boi. 2345 ;; stands between the statement and boi.
2356 (while (and (/= (setq savepos (point)) boi) 2346 (while (and (/= (setq savepos (point)) boi)
@@ -2358,26 +2348,47 @@ Keywords are recognized and not considered identifiers."
2358 (setq at-comment t 2348 (setq at-comment t
2359 boi (c-point 'boi))) 2349 boi (c-point 'boi)))
2360 (goto-char savepos) 2350 (goto-char savepos)
2361 (and (or at-comment 2351
2362 (eq step-type 'label) 2352 (and
2363 (/= savepos boi)) 2353 (or at-comment
2364 (progn 2354 (eq step-type 'label)
2365 ;; Current position not good enough; skip 2355 (/= savepos boi))
2366 ;; backward another statement. 2356
2367 (setq stop-at-boi-only t 2357 (progn
2368 step-type (c-beginning-of-statement-1 2358 ;; Current position might not be good enough;
2369 containing-sexp)) 2359 ;; skip backward another statement.
2370 ;; Record this a substatement if we skipped 2360 (setq step-type (c-beginning-of-statement-1
2371 ;; up one level, but not if we're still on 2361 containing-sexp))
2372 ;; the same line. This so e.g. a sequence 2362
2373 ;; of "else if" clauses won't indent deeper 2363 (if (and (not stop-at-boi-only)
2374 ;; and deeper. 2364 (/= savepos boi)
2375 (when (and (eq step-type 'up) 2365 (memq step-type '(up previous)))
2376 (< (point) boi)) 2366 ;; If stop-at-boi-only is nil, we shouldn't
2377 (setcdr syms-tail (list 'substatement)) 2367 ;; back up over previous or containing
2378 (setq syms-tail (cdr syms-tail))) 2368 ;; statements to try to reach boi, so go
2379 (setq boi (c-point 'boi)) 2369 ;; back to the last position and exit.
2380 (/= (point) savepos)))) 2370 (progn
2371 (goto-char savepos)
2372 nil)
2373 (if (and (not stop-at-boi-only)
2374 (memq step-type '(up previous beginning)))
2375 ;; If we've moved into another statement
2376 ;; then we should no longer try to stop
2377 ;; after boi.
2378 (setq stop-at-boi-only t))
2379
2380 ;; Record this a substatement if we skipped up
2381 ;; one level, but not if we're still on the
2382 ;; same line. This so e.g. a sequence of "else
2383 ;; if" clauses won't indent deeper and deeper.
2384 (when (and (eq step-type 'up)
2385 (< (point) boi))
2386 (setcdr syms-tail (list 'substatement))
2387 (setq syms-tail (cdr syms-tail)))
2388
2389 (setq boi (c-point 'boi))
2390 (/= (point) savepos)))))
2391
2381 (setq savepos (point) 2392 (setq savepos (point)
2382 at-comment nil)) 2393 at-comment nil))
2383 (setq at-comment nil) 2394 (setq at-comment nil)
@@ -2389,10 +2400,8 @@ Keywords are recognized and not considered identifiers."
2389 paren-state) 2400 paren-state)
2390 containing-sexp (c-most-enclosing-brace paren-state)) 2401 containing-sexp (c-most-enclosing-brace paren-state))
2391 2402
2392 (when (and (prog1 2403
2393 (eq prev-paren ?{) 2404 (when (eq (setq prev-paren (char-after)) ?\()
2394 (setq prev-paren (char-after)))
2395 (eq prev-paren ?\())
2396 (c-backward-syntactic-ws containing-sexp) 2405 (c-backward-syntactic-ws containing-sexp)
2397 (when (c-on-identifier) 2406 (when (c-on-identifier)
2398 ;; Arrived at a function arglist start. Exit with 2407 ;; Arrived at a function arglist start. Exit with
@@ -2433,9 +2442,11 @@ Keywords are recognized and not considered identifiers."
2433 ;; we're at now is found to be good enough in 2442 ;; we're at now is found to be good enough in
2434 ;; the loop above. 2443 ;; the loop above.
2435 (setq step-type nil)) 2444 (setq step-type nil))
2436 (setq stop-at-boi-only t 2445 (if (and (not stop-at-boi-only)
2437 boi (c-point 'boi))))) 2446 (memq step-type '(up previous beginning)))
2438 )))) 2447 (setq stop-at-boi-only t))
2448 (setq boi (c-point 'boi)))))
2449 )))
2439 2450
2440 (while syms 2451 (while syms
2441 (c-add-syntax (car syms) (point)) 2452 (c-add-syntax (car syms) (point))