diff options
author | Alan Mackenzie <acm@muc.de> | 2011-10-22 10:17:25 +0000 |
---|---|---|
committer | Alan Mackenzie <acm@muc.de> | 2011-10-22 10:17:25 +0000 |
commit | cd5495ffbac3a11db329f5ea41d154a55edf17d0 (patch) | |
tree | 77bd7b9384cd2bde102c617de5a0908e25aad6cc /lisp/progmodes/cc-engine.el | |
parent | 42ee24ed38db25d3b2c78c612f48a969e2be5a64 (diff) | |
download | emacs-cd5495ffbac3a11db329f5ea41d154a55edf17d0.tar.gz emacs-cd5495ffbac3a11db329f5ea41d154a55edf17d0.tar.bz2 emacs-cd5495ffbac3a11db329f5ea41d154a55edf17d0.zip |
Fix bug #9560, sporadic wrong indentation; improve instrumentation of
c-parse-state.
cc-engine.el (c-append-lower-brace-pair-to-state-cache): correct faulty
logical expression.
(c-parse-state-state, c-record-parse-state-state):
(c-replay-parse-state-state): New defvar/defuns.
(c-debug-parse-state): Use new functions.
Diffstat (limited to 'lisp/progmodes/cc-engine.el')
-rw-r--r-- | lisp/progmodes/cc-engine.el | 53 |
1 files changed, 43 insertions, 10 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index a1cbdc16560..b2c548847c3 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -2456,7 +2456,7 @@ comment at the start of cc-engine.el for more info." (<= from (cdr c-state-brace-pair-desert))) ;; Only search what we absolutely need to: (if (and c-state-brace-pair-desert - (> from (cdr c-state-brace-pair-desert))) + (eq cache-pos (car c-state-brace-pair-desert))) (narrow-to-region (cdr c-state-brace-pair-desert) (point-max))) ;; In the next pair of nested loops, the inner one moves back past a @@ -3127,6 +3127,33 @@ comment at the start of cc-engine.el for more info." (unless (fboundp 'c-real-parse-state) (fset 'c-real-parse-state (symbol-function 'c-parse-state))) (cc-bytecomp-defun c-real-parse-state) + +(defvar c-parse-state-state nil) +(defun c-record-parse-state-state () + (setq c-parse-state-state + (mapcar + (lambda (arg) + (cons arg (symbol-value arg))) + '(c-state-cache + c-state-cache-good-pos + c-state-nonlit-pos-cache + c-state-nonlit-pos-cache-limit + c-state-brace-pair-desert + c-state-point-min + c-state-point-min-lit-type + c-state-point-min-lit-start + c-state-min-scan-pos + c-state-old-cpp-beg + c-state-old-cpp-end)))) +(defun c-replay-parse-state-state () + (message + (concat "(setq " + (mapconcat + (lambda (arg) + (format "%s %s%s" (car arg) (if (atom (cdr arg)) "" "'") (cdr arg))) + c-parse-state-state " ") + ")"))) + (defun c-debug-parse-state () (let ((here (point)) (res1 (c-real-parse-state)) res2) (let ((c-state-cache nil) @@ -3145,15 +3172,21 @@ comment at the start of cc-engine.el for more info." ;; The cache can actually go further back due to the ad-hoc way ;; the first paren is found, so try to whack off a bit of its ;; start before complaining. - (save-excursion - (goto-char (or (c-least-enclosing-brace res2) (point))) - (c-beginning-of-defun-1) - (while (not (or (bobp) (eq (char-after) ?{))) - (c-beginning-of-defun-1)) - (unless (equal (c-whack-state-before (point) res1) res2) - (message (concat "c-parse-state inconsistency at %s: " - "using cache: %s, from scratch: %s") - here res1 res2)))) + ;; (save-excursion + ;; (goto-char (or (c-least-enclosing-brace res2) (point))) + ;; (c-beginning-of-defun-1) + ;; (while (not (or (bobp) (eq (char-after) ?{))) + ;; (c-beginning-of-defun-1)) + ;; (unless (equal (c-whack-state-before (point) res1) res2) + ;; (message (concat "c-parse-state inconsistency at %s: " + ;; "using cache: %s, from scratch: %s") + ;; here res1 res2))) + (message (concat "c-parse-state inconsistency at %s: " + "using cache: %s, from scratch: %s") + here res1 res2) + (message "Old state:") + (c-replay-parse-state-state)) + (c-record-parse-state-state) res1)) (defun c-toggle-parse-state-debug (&optional arg) |