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#11749: Acknowledgement (24.1; C-mode indentation gives wrong-type-argument error.) Date: Sun, 7 Oct 2012 10:59:51 +0000 Message-ID: <20121007105951.GA3194@acm.acm> References: <503D4B11.6000501@cua.dk> <20120902211620.GA3824@acm.acm> <50447C94.2040402@cua.dk> <20120905204821.GA3620@acm.acm> <87ipbqpkb7.fsf@maru.md5i.com> <20120908211451.GA22477@acm.acm> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1349607953 12054 80.91.229.3 (7 Oct 2012 11:05:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 7 Oct 2012 11:05:53 +0000 (UTC) Cc: "11749@debbugs.gnu.org" <11749@debbugs.gnu.org>, Kim Storm To: Michael Welsh Duggan Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 07 13:05:58 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TKogE-00013k-Mb for geb-bug-gnu-emacs@m.gmane.org; Sun, 07 Oct 2012 13:05:54 +0200 Original-Received: from localhost ([::1]:46536 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TKog8-0002hw-OY for geb-bug-gnu-emacs@m.gmane.org; Sun, 07 Oct 2012 07:05:48 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:42701) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TKog5-0002hc-4U for bug-gnu-emacs@gnu.org; Sun, 07 Oct 2012 07:05:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TKog3-0006al-Cd for bug-gnu-emacs@gnu.org; Sun, 07 Oct 2012 07:05:45 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:48905) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TKog0-0006X3-WF; Sun, 07 Oct 2012 07:05:41 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TKogM-0005eG-4T; Sun, 07 Oct 2012 07:06: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: Sun, 07 Oct 2012 11:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11749 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 11749-submit@debbugs.gnu.org id=B11749.134960792921673 (code B ref 11749); Sun, 07 Oct 2012 11:06:02 +0000 Original-Received: (at 11749) by debbugs.gnu.org; 7 Oct 2012 11:05:29 +0000 Original-Received: from localhost ([127.0.0.1]:59156 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TKofn-0005dV-M9 for submit@debbugs.gnu.org; Sun, 07 Oct 2012 07:05:28 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:54916 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TKofj-0005dL-Tp for 11749@debbugs.gnu.org; Sun, 07 Oct 2012 07:05:25 -0400 Original-Received: (qmail 13004 invoked by uid 3782); 7 Oct 2012 11:05:01 -0000 Original-Received: from acm.muc.de (pD951BAF1.dip.t-dialin.net [217.81.186.241]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 07 Oct 2012 13:04:59 +0200 Original-Received: (qmail 3258 invoked by uid 1000); 7 Oct 2012 10:59:51 -0000 Content-Disposition: inline In-Reply-To: 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.13 Precedence: list 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:65324 Archived-At: Hi, Michael. On Fri, Sep 21, 2012 at 01:47:15PM -0400, Michael Welsh Duggan wrote: > Michael Welsh Duggan writes: > > Michael Welsh Duggan writes: > >>>> There is generally no way to re-create it, so I've stopped reporting > >>>> these. I wish there were some way to record all actions in c-mode > >>>> buffers such that they could be saved and re-played when this type of > >>>> problem happens. If there were some sort of debug flag I could turn > >>>> on, I would turn it on by default and hopefully be able to catch some > >>>> useful information. > >>> M-x c-toggle-parse-state-debug > >>> (or (c-toggle-parse-state-debug 1) in your .emacs). Warning: variable > >>> `c-debug-parse-state' is not buffer local. I wrote this on 19th October > >>> last year to help sort out the bug you reported a little earlier. :-) > >>> It works by calculating c-parse-state twice for each call - The first > >>> time normally, then again with the internal state bound to "newly > >>> initialised". If the the two results differ, they are printed to > >>> *Messages*, together with the saved previous state. If this does > >>> trigger, please note any recent buffer changes. It may make editing > >>> intolerably slow. > >> I will turn this on. > I turned this on, and inserted a (ding) where cc-mode outputs an > inconsistency message. I can barely stand to edit code now, due to > what seem to be almost every key press causing a beep. Have you made > any progress here, or do you need more data? I have found the bug which is causing (most of) these dings, though I don't think it is the one which caused Kim's original bug. Could you try out the patch below, please. (I have also enhanced/corrected the debugging routines a bit, too.) diff -r ac6584d14c06 cc-engine.el --- a/cc-engine.el Sun Sep 09 11:15:13 2012 +0000 +++ b/cc-engine.el Sun Oct 07 10:54:51 2012 +0000 @@ -2648,17 +2648,19 @@ ;; If we're essentially repeating a fruitless search, just give up. (unless (and c-state-brace-pair-desert (eq cache-pos (car c-state-brace-pair-desert)) + (> from (car c-state-brace-pair-desert)) (<= from (cdr c-state-brace-pair-desert))) - ;; DESERT-LIM. Only search what we absolutely need to, + ;; DESERT-LIM. Avoid repeated searching through the cached desert. (let ((desert-lim (and c-state-brace-pair-desert (eq cache-pos (car c-state-brace-pair-desert)) + (>= from (cdr c-state-brace-pair-desert)) (cdr c-state-brace-pair-desert))) ;; CACHE-LIM. This limit will be necessary when an opening ;; paren at `cache-pos' has just had its matching close paren - ;; inserted. `cache-pos' continues to be a search bound, even - ;; though the algorithm below would skip over the new paren - ;; pair. + ;; inserted into the buffer. `cache-pos' continues to be a + ;; search bound, even though the algorithm below would skip + ;; over the new paren pair. (cache-lim (and cache-pos (< cache-pos from) cache-pos))) (narrow-to-region (cond @@ -3354,13 +3356,19 @@ (fset 'c-real-parse-state (symbol-function 'c-parse-state))) (cc-bytecomp-defun c-real-parse-state) +(defvar c-parse-state-point nil) (defvar c-parse-state-state nil) (make-variable-buffer-local 'c-parse-state-state) (defun c-record-parse-state-state () + (setq c-parse-state-point (point)) (setq c-parse-state-state (mapcar (lambda (arg) - (cons arg (symbol-value arg))) + (let ((val (symbol-value arg))) + (cons arg + (if (consp val) + (copy-tree val) + val)))) '(c-state-cache c-state-cache-good-pos c-state-nonlit-pos-cache @@ -3373,7 +3381,8 @@ c-state-point-min-lit-start c-state-min-scan-pos c-state-old-cpp-beg - c-state-old-cpp-end)))) + c-state-old-cpp-end + c-parse-state-point)))) (defun c-replay-parse-state-state () (message (concat "(setq " @@ -3416,7 +3425,8 @@ (message "Old state:") (c-replay-parse-state-state)) (c-record-parse-state-state) - res1)) + res2 ; res1 correct a cascading series of errors ASAP + )) (defun c-toggle-parse-state-debug (&optional arg) (interactive "P") > -- > Michael Welsh Duggan > (mwd@cert.org) -- Alan Mackenzie (Nuremberg, Germany).