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, 28 Oct 2012 11:36:10 +0000 Message-ID: <20121028113610.GA3339@acm.acm> References: <87ipbqpkb7.fsf@maru.md5i.com> <20120908211451.GA22477@acm.acm> <20121007105951.GA3194@acm.acm> <20121010200025.GA3449@acm.acm> <20121014170650.GA3766@acm.acm> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1351424571 6387 80.91.229.3 (28 Oct 2012 11:42:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 28 Oct 2012 11:42:51 +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 28 12:42:59 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 1TSRGa-0007Z1-Pm for geb-bug-gnu-emacs@m.gmane.org; Sun, 28 Oct 2012 12:42:57 +0100 Original-Received: from localhost ([::1]:42469 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TSRGS-0002QR-QO for geb-bug-gnu-emacs@m.gmane.org; Sun, 28 Oct 2012 07:42:48 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:55516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TSRGQ-0002QA-2Q for bug-gnu-emacs@gnu.org; Sun, 28 Oct 2012 07:42:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TSRGO-0000c4-VL for bug-gnu-emacs@gnu.org; Sun, 28 Oct 2012 07:42:46 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:54324) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TSRGN-0000bs-3A; Sun, 28 Oct 2012 07:42:43 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TSRIc-0002yu-Et; Sun, 28 Oct 2012 07:45: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, 28 Oct 2012 11:45: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.135142465711396 (code B ref 11749); Sun, 28 Oct 2012 11:45:02 +0000 Original-Received: (at 11749) by debbugs.gnu.org; 28 Oct 2012 11:44:17 +0000 Original-Received: from localhost ([127.0.0.1]:36342 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TSRHt-0002xl-5a for submit@debbugs.gnu.org; Sun, 28 Oct 2012 07:44:17 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:37013 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TSRHq-0002xZ-60 for 11749@debbugs.gnu.org; Sun, 28 Oct 2012 07:44:15 -0400 Original-Received: (qmail 44672 invoked by uid 3782); 28 Oct 2012 11:41:50 -0000 Original-Received: from acm.muc.de (pD9556261.dip.t-dialin.net [217.85.98.97]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 28 Oct 2012 12:41:48 +0100 Original-Received: (qmail 3421 invoked by uid 1000); 28 Oct 2012 11:36:10 -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:66127 Archived-At: Hello again, Michael. On Thu, Oct 25, 2012 at 09:41:11AM -0400, Michael Welsh Duggan wrote: > A new recipe. This is a strange one. I hope it works for you as well. > emacs -Q > M-x tool-bar-mode > resize the frame to be height 56 (according to the window manager) > Load the included file > M-x c-toggle-parse-state-debug > C-s FIXME C-s > Move cursor to the "o" on the next line (1175). > Type: > PyTYPE( > C-f > ) > I get errors at the first open paren, and the close paren. Resizing the > fame is important! I think it's due to caching that happens during font > locking. Thanks for this one. The cause was the cache invalidation function being called from after-change-functions. The newly inserted parens were fouling up the invalidation algorithm. :-( The solution is to call that function from before-change-functions instead. The changes are currently as follows. Would you try out the patch as usual, please, and let me know how it goes. diff -r ac6584d14c06 cc-engine.el --- a/cc-engine.el Sun Sep 09 11:15:13 2012 +0000 +++ b/cc-engine.el Sun Oct 28 11:31:48 2012 +0000 @@ -2560,8 +2560,11 @@ start-point cache-pos))) ;; Might we be better off starting from the top level, two defuns back, - ;; instead? - (when (> how-far c-state-cache-too-far) + ;; instead? This heuristic no longer works well in C++, where + ;; declarations inside namespace brace blocks are frequently placed at + ;; column zero. + (when (and (not (c-major-mode-is 'c++-mode)) + (> how-far c-state-cache-too-far)) (setq BOD-pos (c-get-fallback-scan-pos here)) ; somewhat EXPENSIVE!!! (if (< (- here BOD-pos) how-far) (setq strategy 'BOD @@ -2648,17 +2651,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 +3359,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 +3384,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 +3428,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") diff -r ac6584d14c06 cc-mode.el --- a/cc-mode.el Sun Sep 09 11:15:13 2012 +0000 +++ b/cc-mode.el Sun Oct 28 11:31:48 2012 +0000 @@ -1058,7 +1058,10 @@ (mapc (lambda (fn) (funcall fn beg end)) c-get-state-before-change-functions)) - ))))) + ))) + ;; The following must be done here rather than in `c-after-change' because + ;; newly inserted parens would foul up the invalidation algorithm. + (c-invalidate-state-cache beg))) (defvar c-in-after-change-fontification nil) (make-variable-buffer-local 'c-in-after-change-fontification) @@ -1108,7 +1111,7 @@ (c-trim-found-types beg end old-len) ; maybe we don't need all of these. (c-invalidate-sws-region-after beg end) - (c-invalidate-state-cache beg) + ;; (c-invalidate-state-cache beg) ; moved to `c-before-change'. (c-invalidate-find-decl-cache beg) (when c-recognize-<>-arglists > > -- > Michael Welsh Duggan > (mwd@cert.org) -- Alan Mackenzie (Nuremberg, Germany).