From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#9560: An exact recipe Date: Thu, 20 Oct 2011 11:42:29 +0000 Message-ID: <20111020114229.GA3617@acm.acm> References: <87zkh54o3x.fsf@maru.md5i.com> <20111019101617.GA2445@acm.acm> <87zkgx2iye.fsf@maru.md5i.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1319111296 3829 80.91.229.12 (20 Oct 2011 11:48:16 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 20 Oct 2011 11:48:16 +0000 (UTC) Cc: 9560@debbugs.gnu.org To: Michael Welsh Duggan Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 20 13:48:11 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RGr6Y-00056q-8W for geb-bug-gnu-emacs@m.gmane.org; Thu, 20 Oct 2011 13:48:10 +0200 Original-Received: from localhost ([::1]:49175 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGr6W-0005xp-Jl for geb-bug-gnu-emacs@m.gmane.org; Thu, 20 Oct 2011 07:48:08 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:52333) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGr6S-0005xO-JU for bug-gnu-emacs@gnu.org; Thu, 20 Oct 2011 07:48:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RGr6Q-00079v-9U for bug-gnu-emacs@gnu.org; Thu, 20 Oct 2011 07:48:04 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:48436) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGr6I-00078X-Jr; Thu, 20 Oct 2011 07:47:54 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1RGr7O-0000Pl-64; Thu, 20 Oct 2011 07:49:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Thu, 20 Oct 2011 11:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9560 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 9560-submit@debbugs.gnu.org id=B9560.13191113051549 (code B ref 9560); Thu, 20 Oct 2011 11:49:02 +0000 Original-Received: (at 9560) by debbugs.gnu.org; 20 Oct 2011 11:48:25 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RGr6n-0000Ow-4D for submit@debbugs.gnu.org; Thu, 20 Oct 2011 07:48:25 -0400 Original-Received: from colin.muc.de ([193.149.48.1] helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RGr6j-0000On-Ty for 9560@debbugs.gnu.org; Thu, 20 Oct 2011 07:48:23 -0400 Original-Received: (qmail 96835 invoked by uid 3782); 20 Oct 2011 11:47:12 -0000 Original-Received: from acm.muc.de (pD951B906.dip.t-dialin.net [217.81.185.6]) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 20 Oct 2011 13:47:10 +0200 Original-Received: (qmail 3657 invoked by uid 1000); 20 Oct 2011 11:42:29 -0000 Content-Disposition: inline In-Reply-To: <87zkgx2iye.fsf@maru.md5i.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 20 Oct 2011 07:49:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:52916 Archived-At: Hi, Michael. On Wed, Oct 19, 2011 at 09:45:45AM -0400, Michael Welsh Duggan wrote: > Alan Mackenzie writes: > Okay, I've done some experimenting, and unfortunately, I have been > unable to recreate this problem using this recipe using emacs -Q -nw. > I've only encountered it using an X window. That still perplexes me. I've got a fix, but the problem should have appeared on a tty and a -nw too. > In this environment, I was able to recreate the problem consistently. > I was able to replace the initial "3*C-v 7*C-n" in the macro with > "100*C-n C-l" and this allowed it to work with larger frame sizes. > Don't ask me why the C-l is necessary, as I do not know. > >> When you have solved this bug, please let me know if the solution has a > >> reasonable chance of having solved the other problem that I have not > >> been able to recreate reliably, which is getting "topmost-intro indent > >> 0" instead of "statement indent 4" when in the middle of editing a > >> function. If these have little chance of being connected, I'll do my > >> best to try to create that scenario again (no promises). I think there's a good chance of that bug being fixed by the following patch (no promises ;-). The bug was a bit of carelessness on my part. I'd done (unless (and T1 T2 T3) ...) , and in the body tested (and T1 (not T3)) , which is rubbish, since that says nothing about the state of T2. T2 being the wrong way round was what caused the bug to show up. Anyhow, here's the patch. Only the first chunk is for the bug; the rest of it is the superior instrumentation. Let me know how this goes! *** orig/cc-engine.el 2011-10-19 19:16:01.000000000 +0000 --- cc-engine.el 2011-10-20 11:22:15.000000000 +0000 *************** *** 2485,2491 **** (<= 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))) (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 --- 2485,2491 ---- (<= from (cdr c-state-brace-pair-desert))) ;; Only search what we absolutely need to: (if (and 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 *************** *** 3169,3174 **** --- 3169,3204 ---- (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 () + (let ((outstring "(setq ")) + (mapc + (lambda (arg) + (setq outstring + (concat outstring + (format " %s %s%s" + (car arg) (if (atom (cdr arg)) "" "'") (cdr arg))))) + c-parse-state-state) + (setq outstring (concat outstring ")")) + (message outstring))) + (defun c-debug-parse-state () (let ((here (point)) (res1 (c-real-parse-state)) res2) (let ((c-state-cache nil) *************** *** 3187,3201 **** ;; 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)))) res1)) (defun c-toggle-parse-state-debug (&optional arg) --- 3217,3237 ---- ;; 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))) ! (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) > -- > Michael Welsh Duggan > (md5i@md5i.com) -- Alan Mackenzie (Nuremberg, Germany).