bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#11749: Acknowledgement (24.1; C-mode indentation gives wrong-type-ar


From: Alan Mackenzie
Subject: bug#11749: Acknowledgement (24.1; C-mode indentation gives wrong-type-argument error.)
Date: Mon, 7 Jan 2013 12:09:52 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

Happy New Year, Michael!

On Sun, Dec 09, 2012 at 10:35:42PM -0500, Michael Welsh Duggan wrote:
> Here's another case.  

> emacs -Q rwrec.h
> M-x c-toggle-parse-state-debug
> C-v {about 24-27 times}

> This is with current bzr.  
> 111170 rgm@gnu.org-20121210020042-arkhaf5eej6ujgtn

> rwrec.h is attached.

Thanks.  I think the following patch should have sorted out this one.  It
is based on the cc-engine.el in the emacs-24 branch in savannah.  Could
you try it out as usual, please.



=== modified file 'lisp/progmodes/cc-engine.el'
*** lisp/progmodes/cc-engine.el 2012-12-11 19:06:57 +0000
--- lisp/progmodes/cc-engine.el 2013-01-06 21:52:00 +0000
***************
*** 2464,2471 ****
--- 2464,2475 ----
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;; Variables which keep track of preprocessor constructs.
+ (defvar c-state-old-cpp-beg-marker)
+ (make-variable-buffer-local 'c-state-old-cpp-beg-marker)
  (defvar c-state-old-cpp-beg nil)
  (make-variable-buffer-local 'c-state-old-cpp-beg)
+ (defvar c-state-old-cpp-end-marker)
+ (make-variable-buffer-local 'c-state-old-cpp-end-marker)
  (defvar c-state-old-cpp-end nil)
  (make-variable-buffer-local 'c-state-old-cpp-end)
  ;; These are the limits of the macro containing point at the previous call of
***************
*** 2653,2665 ****
    ;; reduce the time wasted in repeated fruitless searches in brace deserts.
    (save-excursion
      (save-restriction
!       (let ((bra from) ce             ; Positions of "{" and "}".
!           new-cons
!           (cache-pos (c-state-cache-top-lparen)) ; might be nil.
!           (macro-start-or-from
!            (progn (goto-char from)
!                   (c-beginning-of-macro)
!                   (point))))
        (or upper-lim (setq upper-lim from))
  
        ;; If we're essentially repeating a fruitless search, just give up.
--- 2657,2678 ----
    ;; reduce the time wasted in repeated fruitless searches in brace deserts.
    (save-excursion
      (save-restriction
! 
!       (let* (new-cons
!            (cache-pos (c-state-cache-top-lparen)) ; might be nil.
!            (macro-start-or-from
!             (progn (goto-char from)
!                    (c-beginning-of-macro)
!                    (point)))
!            (bra                       ; Position of "{".
!             ;; Don't start scanning in the middle of a CPP construct unless
!             ;; it contains HERE - these constructs, in Emacs, are "commented
!             ;; out" with category properties.
!             (if (eq (c-get-char-property macro-start-or-from 'category)
!                       'c-cpp-delimiter)
!                   macro-start-or-from
!                 from))
!            ce)                        ; Position of "}"
        (or upper-lim (setq upper-lim from))
  
        ;; If we're essentially repeating a fruitless search, just give up.
***************
*** 2899,2905 ****
--- 2912,2920 ----
                  (point-max)
                (min (point-max) c-state-old-cpp-beg)))
        (while (and c-state-cache (>= (c-state-cache-top-lparen) upper-lim))
+         (setq scan-back-pos (car-safe (car c-state-cache)))
          (setq c-state-cache (cdr c-state-cache)))
+ 
        ;; If `upper-lim' is inside the last recorded brace pair, remove its
        ;; RBrace and indicate we'll need to search backwards for a previous
        ;; brace pair.
***************
*** 3324,3329 ****
--- 3339,3351 ----
       (c-with-cpps-commented-out
        (c-invalidate-state-cache-1 here)))))
  
+ (defmacro c-state-maybe-marker (place marker)
+   ;; If PLACE is non-nil, return a marker marking it, otherwise nil.
+   ;; We (re)use MARKER.
+   `(and ,place
+       (or ,marker (setq ,marker (make-marker)))
+       (set-marker ,marker ,place)))
+ 
  (defun c-parse-state ()
    ;; This is a wrapper over `c-parse-state-1'.  See that function for a
    ;; description of the functionality and return value.
***************
*** 3350,3358 ****
              (c-parse-state-1))
           (c-with-cpps-commented-out
            (c-parse-state-1))))
!       (setq c-state-old-cpp-beg (and here-cpp-beg (copy-marker here-cpp-beg 
t))
!           c-state-old-cpp-end (and here-cpp-end (copy-marker here-cpp-end t)))
!       )))
  
  ;; Debug tool to catch cache inconsistencies.  This is called from
  ;; 000tests.el.
--- 3372,3381 ----
              (c-parse-state-1))
           (c-with-cpps-commented-out
            (c-parse-state-1))))
!       (setq c-state-old-cpp-beg
!           (c-state-maybe-marker here-cpp-beg c-state-old-cpp-beg-marker)
!           c-state-old-cpp-end
!           (c-state-maybe-marker here-cpp-end c-state-old-cpp-end-marker)))))
  
  ;; Debug tool to catch cache inconsistencies.  This is called from
  ;; 000tests.el.



> -- 
> Michael Welsh Duggan
> (md5i@md5i.com)

-- 
Alan Mackenzie (Nuremberg, Germany).





reply via email to

[Prev in Thread] Current Thread [Next in Thread]