GNU bug report logs - #11749
24.1; C-mode indentation gives wrong-type-argument error.

Previous Next

Packages: emacs, cc-mode;

Reported by: storm <at> cua.dk (Kim F. Storm)

Date: Tue, 19 Jun 2012 20:50:02 UTC

Severity: normal

Merged with 9957, 13385

Found in versions 24.0.90, 24.1

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 11749 in the body.
You can then email your comments to 11749 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#11749; Package emacs. (Tue, 19 Jun 2012 20:50:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to storm <at> cua.dk (Kim F. Storm):
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 19 Jun 2012 20:50:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: storm <at> cua.dk (Kim F. Storm)
To: bug-gnu-emacs <at> gnu.org
Subject: 24.1; C-mode indentation gives wrong-type-argument error.
Date: Tue, 19 Jun 2012 22:45:32 +0200
Every now and then, while editing some C files, indentation fails
with a wrong-type-argument number-or-marker-p error.

I have seen it happen when yanking text - but also just typing code
and all of a sudden it fails to indent after a {.

Here is the last incident:





Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Thu, 21 Jun 2012 07:22:02 GMT) Full text and rfc822 format available.

Message #8 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: storm <at> cua.dk (Kim F. Storm)
Cc: 11749 <at> debbugs.gnu.org
Subject: Re: bug#11749: 24.1;
	C-mode indentation gives wrong-type-argument error.
Date: Thu, 21 Jun 2012 03:17:43 -0400
Kim F. Storm wrote:

> Here is the last incident:

At this point, the report ended... :)
Could you (re)send the details?
Does they resemble http://debbugs.gnu.org/9957 ?




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Thu, 21 Jun 2012 09:39:01 GMT) Full text and rfc822 format available.

Message #11 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Kim Storm <storm <at> cua.dk>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 11749 <at> debbugs.gnu.org
Subject: Re: bug#11749: 24.1; C-mode indentation gives wrong-type-argument
	error.
Date: Thu, 21 Jun 2012 11:34:25 +0200
On 06/21/2012 09:17 AM, Glenn Morris wrote:
> Kim F. Storm wrote:
>
>> Here is the last incident:
> At this point, the report ended... :)
> Could you (re)send the details?
> Does they resemble http://debbugs.gnu.org/9957 ?
>
I no longer have the original message - but yes, from what I remeber, it 
resembles that other bug.
It was also related to indentation.  I'll send another backtrace next 
time it happens.

About the truncated mail:

I remember that while sending the mail, emacs barfed that there were NUL 
characters (or similar) in the message
and what I would like to do about it.  I hit the "d" option (delete 
non-printable characters and send the messsage).
Seems it removed a lot more than just non-printable characters (or is 
has a rather stupid interpretation of "non-printing").

Also the message log contains only the truncated message.

Still that's a different issue.

Kim







Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Tue, 28 Aug 2012 16:18:02 GMT) Full text and rfc822 format available.

Message #14 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: storm <at> cua.dk (Kim F. Storm)
To: 11749 <at> debbugs.gnu.org
Subject: 24.2; wrong-type-argument
Date: Tue, 28 Aug 2012 12:17:55 -0400
Tried 24.2 RC2 - and once again I hit this annoying indentation bug i c mode:


In GNU Emacs 24.2.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.10)
 of 2012-08-24 on kfs-lx2
Windowing system distributor `The X.Org Foundation', version 11.0.11104000
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: en_DK.utf8
  value of $LC_NUMERIC: en_DK.utf8
  value of $LC_TIME: en_DK.utf8
  value of $LANG: en_US.utf8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Debugger

Minor modes in effect:
  diff-auto-refine-mode: t
  shell-dirtrack-mode: t
  display-time-mode: t
  cua-mode: t
  ido-everywhere: t
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> <right> <right> <S-right> <S-right> 
o b j C-z <left> <left> <S-right> <S-right> <S-right> 
o b j M-v <right> <right> <right> <right> <right> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> <right> <right> <right> <left> <left> 
<delete> <delete> <delete> x t r M-v <backspace> <backspace> 
<backspace> <backspace> x x ½ <end> <down> <up> <up> 
<up> <up> <up> <up> <left> <C-left> <C-left> <left> 
1 <down> <left> 1 <down> <left> 1 <down> <left> <M-backspace> 
<C-right> 1 <C-right> <C-right> <up> <up> <C-left> 
M-d a c t <down> <left> <left> <left> M-d o b j <down> 
<backspace> <backspace> <backspace> x t r <right> <S-end> 
<S-left> <delete> <up> <up> <up> <C-left> <C-left> 
<C-left> <C-left> <C-left> <C-left> <C-return> <down> 
<down> <down> <right> <right> <right> <right> <right> 
<right> <left> <delete> <right> <right> <right> <right> 
<right> <delete> <down> <delete> <down> <delete> <down> 
<delete> <down> <down> <left> <S-end> <S-left> <delete> 
( x d o m SPC | SPC x a c t SPC ' <backspace> | SPC 
a x <backspace> o b j <backspace> <backspace> <backspace> 
<backspace> x o b j SPC | SPC x x t r ) SPC & S-SPC 
0 x 8 0 <home> <right> <right> <right> <right> <right> 
<right> <right> <right> <right> ( ! <end> ) <down> 
<down> <down> <left> SPC & & S-SPC <up> <up> <up> <C-left> 
<C-left> <C-left> <C-left> <C-right> <right> <right> 
<S-end> C-c <timeout> <down> <down> <down> <left> C-v 
<C-left> <right> <right> <delete> 1 <backspace> <right> 
1 <C-left> <C-left> <C-left> <C-left> <left> <left> 
<left> M-d <end> <backspace> <backspace> ) <up> <S-down> 
<S-down> <S-down> <S-down> <S-down> <S-down> C-c <timeout> 


Recent messages:
Mark set
Undo!
Mark set [4 times]
Auto-saving...done
Mark set [3 times]
Undo!
Mark set
Auto-saving...done
Mark set
Entering debugger...

Load-path shadows:
/home/kfs/emacs/common/emacs/user/kfs/nero hides /home/kfs/emacs/common/emacs/lisp/nero
/home/kfs/emacs/common/emacs/lisp/mwheel hides /home/kfs/Downloads/emacs-24.2/lisp/mwheel
/home/kfs/emacs/common/emacs/lisp/misc hides /home/kfs/Downloads/emacs-24.2/lisp/misc
/home/kfs/emacs/common/emacs/user/kfs/vcursor hides /home/kfs/Downloads/emacs-24.2/lisp/vcursor
/home/kfs/emacs/common/emacs/lisp/avoid hides /home/kfs/Downloads/emacs-24.2/lisp/avoid
/home/kfs/emacs/common/emacs/lisp/printing hides /home/kfs/Downloads/emacs-24.2/lisp/printing
/home/kfs/emacs/common/emacs/lisp/pong hides /home/kfs/Downloads/emacs-24.2/lisp/play/pong
/home/kfs/emacs/common/emacs/lisp/smtpmail hides /home/kfs/Downloads/emacs-24.2/lisp/mail/smtpmail

Features:
(shadow emacsbug message mml mml-sec mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mail-utils debug perl-mode make-mode conf-mode
jka-compr woman man skeleton tramp-cache tramp-sh tramp tramp-compat
auth-source eieio assoc gnus-util mm-util mail-prsvr password-cache
format-spec advice help-fns advice-preload tramp-loaddefs sh-script
executable help-mode view vc-annotate log-view vc-rcs js byte-opt
bytecomp byte-compile cconv macroexp json thingatpt newcomment
log-edit add-log diff-mode vc ediff-merg ediff-diff ediff-wind
ediff-help ediff-util ediff-mult ediff-init ediff vc-dispatcher
sgml-mode cua-gmrk cc-mode cc-fonts cc-guess cc-menus cc-cmds
find-dired grep-x grep compile pcmpl-unix shell pcomplete dabbrev
tabify cua-rect rect misearch multi-isearch parse-time vc-cvs pcvs
pcvs-parse pcvs-info pcvs-defs easy-mmode pcvs-util ewoc dired imenu
cgi-mode derived windmove kmacro paren keypad time cua-base cus-start
cus-load telnet mailcrypt rfc822 comint ansi-color ring easymenu make
begendol ido server cc-styles cc-align cc-engine cc-vars cc-defs
regexp-opt disp-table match aux-fct common printing ps-print ps-def
lpr time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win
x-dnd tool-bar dnd fontset image fringe lisp-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer
loaddefs button faces cus-face files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
dynamic-setting system-font-setting font-render-setting move-toolbar
gtk x-toolkit x multi-tty emacs)


-- 
Kim F. Storm  <storm <at> cua.dk>      http://www.cua.dk





Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Tue, 28 Aug 2012 22:52:01 GMT) Full text and rfc822 format available.

Message #17 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Kim Storm <storm <at> cua.dk>
To: 11749 <at> debbugs.gnu.org
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Wed, 29 Aug 2012 00:49:53 +0200
M-x report-emacs-bug obviously refuses to include any useful information 
-- so I send it through my Thunderbird client... this time.

Tried 24.2 RC2 - and once again I hit this annoying indentation bug i c 
mode:

Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p 
(5457 . 5720))
  c-guess-basic-syntax()
  c-indent-line()
  indent-according-to-mode()
  c-electric-paren(nil)
  call-interactively(c-electric-paren nil nil)

The offsets corresponds to a preceding { ... } block.

The code I was working on is the following (sorry, I cannot show more 
than that):

      if (!((xdom | xact | xobj | xxtr) & 0x80))
    continue;

      if (domains && !alldom && !((xdom | xobj | xxtr) & 0x01))
    {


I get a lot of errors -- making 24.2 impossible to work with for my C code.

Here are some more backtraces:

Debugger entered--Lisp error: (error "Invalid search bound (wrong side 
of point)")
  re-search-backward("^[     ]*:[     ]*\\(.\\)?" 5920 t)
  c-lineup-gcc-asm-reg((arglist-cont-nonempty . 5920))
  c-evaluate-offset(c-lineup-gcc-asm-reg (arglist-cont-nonempty 5920 
5950) arglist-cont-nonempty)
  c-evaluate-offset((c-lineup-gcc-asm-reg c-lineup-arglist) 
(arglist-cont-nonempty 5920 5950) arglist-cont-nonempty)
  c-calc-offset((arglist-cont-nonempty 5920 5950))
  c-get-syntactic-indentation(((arglist-cont-nonempty 5920 5950)))
  c-indent-line()
  indent-according-to-mode()
  c-electric-paren(nil)
  call-interactively(c-electric-paren nil nil)


Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p 
(5874 . 5881))
  c-guess-basic-syntax()
  c-indent-line()
  indent-according-to-mode()
  c-electric-paren(nil)
  call-interactively(c-electric-paren nil nil)

The last one came when I inserted the final ; in the last line of the 
following snippet:

static void add_hash_ext(idhash_t **hp, id_t *idtab, int n)
{

 }


  static idhash_t *lookup_ext(idhash_t **hp, );


Yes, there are syntax errors in that code -- but indentation should be 
able to
handle that without signalling errors all the time.



I have seen similar problems in 24.1 - but not in 23.4 that I usually
use (for this very reason).


If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
For information about debugging Emacs, please read the file
/home/kfs/Downloads/emacs-24.2/etc/DEBUG.


In GNU Emacs 24.2.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.10)
 of 2012-08-24 on kfs-lx2
Windowing system distributor `The X.Org Foundation', version 11.0.11104000
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: en_DK.utf8
  value of $LC_NUMERIC: en_DK.utf8
  value of $LC_TIME: en_DK.utf8
  value of $LANG: en_US.utf8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Debugger

Minor modes in effect:
  diff-auto-refine-mode: t
  shell-dirtrack-mode: t
  display-time-mode: t
  cua-mode: t
  ido-everywhere: t
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<right> <right> <right> <right> <right> <right> <right>
<right> <right> <right> <right> <S-right> <S-right>
o b j C-z <left> <left> <S-right> <S-right> <S-right>
o b j M-v <right> <right> <right> <right> <right> <right>
<right> <right> <right> <right> <right> <right> <right>
<right> <right> <right> <right> <right> <left> <left>
<delete> <delete> <delete> x t r M-v <backspace> <backspace>
<backspace> <backspace> x x ½ <end> <down> <up> <up>
<up> <up> <up> <up> <left> <C-left> <C-left> <left>
1 <down> <left> 1 <down> <left> 1 <down> <left> <M-backspace>
<C-right> 1 <C-right> <C-right> <up> <up> <C-left>
M-d a c t <down> <left> <left> <left> M-d o b j <down>
<backspace> <backspace> <backspace> x t r <right> <S-end>
<S-left> <delete> <up> <up> <up> <C-left> <C-left>
<C-left> <C-left> <C-left> <C-left> <C-return> <down>
<down> <down> <right> <right> <right> <right> <right>
<right> <left> <delete> <right> <right> <right> <right>
<right> <delete> <down> <delete> <down> <delete> <down>
<delete> <down> <down> <left> <S-end> <S-left> <delete>
( x d o m SPC | SPC x a c t SPC ' <backspace> | SPC
a x <backspace> o b j <backspace> <backspace> <backspace>
<backspace> x o b j SPC | SPC x x t r ) SPC & S-SPC
0 x 8 0 <home> <right> <right> <right> <right> <right>
<right> <right> <right> <right> ( ! <end> ) <down>
<down> <down> <left> SPC & & S-SPC <up> <up> <up> <C-left>
<C-left> <C-left> <C-left> <C-right> <right> <right>
<S-end> C-c <timeout> <down> <down> <down> <left> C-v
<C-left> <right> <right> <delete> 1 <backspace> <right>
1 <C-left> <C-left> <C-left> <C-left> <left> <left>
<left> M-d <end> <backspace> <backspace> ) <up> <S-down>
<S-down> <S-down> <S-down> <S-down> <S-down> C-c <timeout>


Recent messages:
Mark set
Undo!
Mark set [4 times]
Auto-saving...done
Mark set [3 times]
Undo!
Mark set
Auto-saving...done
Mark set
Entering debugger...

Load-path shadows:
/home/kfs/emacs/common/emacs/user/kfs/nero hides 
/home/kfs/emacs/common/emacs/lisp/nero
/home/kfs/emacs/common/emacs/lisp/mwheel hides 
/home/kfs/Downloads/emacs-24.2/lisp/mwheel
/home/kfs/emacs/common/emacs/lisp/misc hides 
/home/kfs/Downloads/emacs-24.2/lisp/misc
/home/kfs/emacs/common/emacs/user/kfs/vcursor hides 
/home/kfs/Downloads/emacs-24.2/lisp/vcursor
/home/kfs/emacs/common/emacs/lisp/avoid hides 
/home/kfs/Downloads/emacs-24.2/lisp/avoid
/home/kfs/emacs/common/emacs/lisp/printing hides 
/home/kfs/Downloads/emacs-24.2/lisp/printing
/home/kfs/emacs/common/emacs/lisp/pong hides 
/home/kfs/Downloads/emacs-24.2/lisp/play/pong
/home/kfs/emacs/common/emacs/lisp/smtpmail hides 
/home/kfs/Downloads/emacs-24.2/lisp/mail/smtpmail

Features:
(shadow emacsbug message mml mml-sec mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mail-utils debug perl-mode make-mode conf-mode
jka-compr woman man skeleton tramp-cache tramp-sh tramp tramp-compat
auth-source eieio assoc gnus-util mm-util mail-prsvr password-cache
format-spec advice help-fns advice-preload tramp-loaddefs sh-script
executable help-mode view vc-annotate log-view vc-rcs js byte-opt
bytecomp byte-compile cconv macroexp json thingatpt newcomment
log-edit add-log diff-mode vc ediff-merg ediff-diff ediff-wind
ediff-help ediff-util ediff-mult ediff-init ediff vc-dispatcher
sgml-mode cua-gmrk cc-mode cc-fonts cc-guess cc-menus cc-cmds
find-dired grep-x grep compile pcmpl-unix shell pcomplete dabbrev
tabify cua-rect rect misearch multi-isearch parse-time vc-cvs pcvs
pcvs-parse pcvs-info pcvs-defs easy-mmode pcvs-util ewoc dired imenu
cgi-mode derived windmove kmacro paren keypad time cua-base cus-start
cus-load telnet mailcrypt rfc822 comint ansi-color ring easymenu make
begendol ido server cc-styles cc-align cc-engine cc-vars cc-defs
regexp-opt disp-table match aux-fct common printing ps-print ps-def
lpr time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win
x-dnd tool-bar dnd fontset image fringe lisp-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer
loaddefs button faces cus-face files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
dynamic-setting system-font-setting font-render-setting move-toolbar
gtk x-toolkit x multi-tty emacs)






Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Fri, 31 Aug 2012 11:04:01 GMT) Full text and rfc822 format available.

Message #20 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Kim Storm <storm <at> cua.dk>
Cc: 11749 <at> debbugs.gnu.org
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Fri, 31 Aug 2012 14:01:47 +0300
> Date: Wed, 29 Aug 2012 00:49:53 +0200
> From: Kim Storm <storm <at> cua.dk>
> 
> M-x report-emacs-bug obviously refuses to include any useful information 

How does it refuse to do that?  Any error messages, or some other
hints?




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Fri, 31 Aug 2012 12:39:01 GMT) Full text and rfc822 format available.

Message #23 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Kim Storm <storm <at> cua.dk>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 11749 <at> debbugs.gnu.org
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Fri, 31 Aug 2012 14:37:23 +0200
On 2012-08-31 13:01, Eli Zaretskii wrote:
>> Date: Wed, 29 Aug 2012 00:49:53 +0200
>> From: Kim Storm<storm <at> cua.dk>
>>
>> M-x report-emacs-bug obviously refuses to include any useful information
> How does it refuse to do that?  Any error messages, or some other
> hints?
>
No, it sent the message, but the text I had pasted into the mail buffer 
had vanished
when I checked in debbugs. So fortunately I had saved a copy of the message
(based on previous experience *) so I could send it again.

*) The first time I sent that bug report emacs had removed the entire 
body (at that
time I was asked something about problems with the character set or 
something,
and I guess I said "go ahead").

Still the original problem makes 24.1 and 24.2 absolutely useless for me.
It works fine for some time -- and then suddenly it barfs about 
indentation all the time.
I know I should start from -Q etc. - but I need to get some work done ...

I really wonder why I'm the only one seeing this -- can my C style 
really be that different :-)

BTW - 23.4 has quite some display problems with Debian / Gnome - it 
leaves highlight artifacts
and missing screen updates when scrolling and when killing and inserting 
text
 ... those problems are still present in 24.2 ... and maybe they've 
gotten worse.

I remember having seen some bug reports about it, so I haven't bothered
reporting them -- but it happens "all the time".

Kim







Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Sun, 02 Sep 2012 21:23:02 GMT) Full text and rfc822 format available.

Message #26 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Kim Storm <storm <at> cua.dk>
Cc: 11749 <at> debbugs.gnu.org
Subject: Re: bug#11749: Acknowledgement (24.1; C-mode indentation gives
	wrong-type-argument error.)
Date: Sun, 2 Sep 2012 21:16:20 +0000
Hello, Kim.

On Wed, Aug 29, 2012 at 12:49:53AM +0200, Kim Storm wrote:
> M-x report-emacs-bug obviously refuses to include any useful information 
> -- so I send it through my Thunderbird client... this time.

> Tried 24.2 RC2 - and once again I hit this annoying indentation bug i c 
> mode:

> Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p 
> (5457 . 5720))
>    c-guess-basic-syntax()
>    c-indent-line()
>    indent-according-to-mode()
>    c-electric-paren(nil)
>    call-interactively(c-electric-paren nil nil)

> The offsets corresponds to a preceding { ... } block.

Yes.  It looks like the "state cache" (a cache of certain brace, paren
and bracket positions) has got corrupted.  This is difficult to make
repeatable, and is very dependent upon the exact navigation taken around
the C buffer.

> The code I was working on is the following (sorry, I cannot show more 
> than that):

>        if (!((xdom | xact | xobj | xxtr) & 0x80))
>      continue;

>        if (domains && !alldom && !((xdom | xobj | xxtr) & 0x01))
>      {


> I get a lot of errors -- making 24.2 impossible to work with for my C code.

> Here are some more backtraces:

> Debugger entered--Lisp error: (error "Invalid search bound (wrong side 
> of point)")
>    re-search-backward("^[     ]*:[     ]*\\(.\\)?" 5920 t)
>    c-lineup-gcc-asm-reg((arglist-cont-nonempty . 5920))
>    c-evaluate-offset(c-lineup-gcc-asm-reg (arglist-cont-nonempty 5920 
> 5950) arglist-cont-nonempty)
>    c-evaluate-offset((c-lineup-gcc-asm-reg c-lineup-arglist) 
> (arglist-cont-nonempty 5920 5950) arglist-cont-nonempty)
>    c-calc-offset((arglist-cont-nonempty 5920 5950))
>    c-get-syntactic-indentation(((arglist-cont-nonempty 5920 5950)))
>    c-indent-line()
>    indent-according-to-mode()
>    c-electric-paren(nil)
>    call-interactively(c-electric-paren nil nil)

That looks a bit like bug #10941, but isn't it.  It could be something
quite easy inside `c-lineup-gcc-asm-reg' (which I've not seen being used
before).  Is this an easily repeatable bug?  Any chance of a recipe?
Would you also dump your CC Mode configuration (C-c C-b) please.

> Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p 
> (5874 . 5881))
>    c-guess-basic-syntax()
>    c-indent-line()
>    indent-according-to-mode()
>    c-electric-paren(nil)
>    call-interactively(c-electric-paren nil nil)

> The last one came when I inserted the final ; in the last line of the 
> following snippet:

> static void add_hash_ext(idhash_t **hp, id_t *idtab, int n)
> {

>   }


>    static idhash_t *lookup_ext(idhash_t **hp, );

I've not been able to reproduce it in that limited context.  It looks
like another bug in the state cache, and they're bastards.

> Yes, there are syntax errors in that code -- but indentation should be 
> able to
> handle that without signalling errors all the time.

Yes.

> I have seen similar problems in 24.1 - but not in 23.4 that I usually
> use (for this very reason).

Might you have something unusual in your CC Mode config?

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Mon, 03 Sep 2012 09:49:01 GMT) Full text and rfc822 format available.

Message #29 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Kim Storm <storm <at> cua.dk>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 11749 <at> debbugs.gnu.org
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Mon, 03 Sep 2012 11:47:00 +0200
On 2012-09-02 23:16, Alan Mackenzie wrote:
> Yes. It looks like the "state cache" (a cache of certain brace, paren 
> and bracket positions) has got corrupted.
> This is difficult to make repeatable, and is very dependent upon the 
> exact navigation taken around the C buffer.
Well - my navigation triggers that bug a lot.


>> Debugger entered--Lisp error: (error "Invalid search bound (wrong side
>> of point)")
>>     re-search-backward("^[     ]*:[     ]*\\(.\\)?" 5920 t)
>>     c-lineup-gcc-asm-reg((arglist-cont-nonempty . 5920))
>>     c-evaluate-offset(c-lineup-gcc-asm-reg (arglist-cont-nonempty 5920
>> 5950) arglist-cont-nonempty)
>>     c-evaluate-offset((c-lineup-gcc-asm-reg c-lineup-arglist)
>> (arglist-cont-nonempty 5920 5950) arglist-cont-nonempty)
>>     c-calc-offset((arglist-cont-nonempty 5920 5950))
>>     c-get-syntactic-indentation(((arglist-cont-nonempty 5920 5950)))
>>     c-indent-line()
>>     indent-according-to-mode()
>>     c-electric-paren(nil)
>>     call-interactively(c-electric-paren nil nil)
> That looks a bit like bug #10941, but isn't it.  It could be something
> quite easy inside `c-lineup-gcc-asm-reg' (which I've not seen being used
> before).  Is this an easily repeatable bug?  Any chance of a recipe?
> Would you also dump your CC Mode configuration (C-c C-b) please.
I think I only saw this once - the other bug already happened, and I 
just started typing some random code snippets, and this bug happened.
>
>> Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p
>> (5874 . 5881))
>>     c-guess-basic-syntax()
>>     c-indent-line()
>>     indent-according-to-mode()
>>     c-electric-paren(nil)
>>     call-interactively(c-electric-paren nil nil)
>
> I've not been able to reproduce it in that limited context.  It looks
> like another bug in the state cache, and they're bastards.
Any way of clearing the cache?
>
> Might you have something unusual in your CC Mode config?
I have this:

(modify-syntax-entry ?_ "w" c-mode-syntax-table)

But otherwise, I don't seem to have any customizations ... only an 
awkward programming style :-)


_Subject: CC Mode 5.32.3 (C/l); emacs bug 11749

_ X-Reporter-Void-Vars-Found: auto-fill-mode (setq
c-basic-offset 2
c-comment-only-line-offset '(0 . 0)
c-indent-comment-alist '((anchored-comment column . 0) (end-block space 
. 1) (cpp-end-block space . 2))
c-indent-comments-syntactically-p nil
c-block-comment-prefix ""
c-comment-prefix-regexp '((pike-mode . "//+!?\\|\\**") (awk-mode . "#+") 
(other . "//+\\|\\**"))
c-doc-comment-style '((java-mode . javadoc) (pike-mode . autodoc) 
(c-mode . gtkdoc))
c-cleanup-list '(scope-operator)
c-hanging-braces-alist '((substatement-open before after) 
(arglist-cont-nonempty))
c-hanging-colons-alist nil
c-hanging-semi&comma-criteria '(c-semi&comma-inside-parenlist)
c-backslash-column 48
c-backslash-max-column 72
c-special-indent-hook '(c-gnu-impose-minimum)
c-label-minimum-indentation 1
c-offsets-alist '((inexpr-class . +)
(inexpr-statement . +)
(lambda-intro-cont . +)
(inlambda . c-lineup-inexpr-block)
(template-args-cont c-lineup-template-args +)
(incomposition . +)
(inmodule . +)
(innamespace . +)
(inextern-lang . +)
(composition-close . 0)
(module-close . 0)
(namespace-close . 0)
(extern-lang-close . 0)
(composition-open . 0)
(module-open . 0)
(namespace-open . 0)
(extern-lang-open . 0)
(objc-method-call-cont c-lineup-ObjC-method-call-colons 
c-lineup-ObjC-method-call +)
(objc-method-args-cont . c-lineup-ObjC-method-args)
(objc-method-intro . [0])
(friend . 0)
(cpp-define-intro c-lineup-cpp-define +)
(cpp-macro-cont . +)
(cpp-macro . [0])
(inclass . +)
(stream-op . c-lineup-streamop)
(arglist-cont-nonempty c-lineup-gcc-asm-reg c-lineup-arglist)
(arglist-cont c-lineup-gcc-asm-reg 0)
(comment-intro c-lineup-knr-region-comment c-lineup-comment)
(catch-clause . 0)
(else-clause . 0)
(do-while-closure . 0)
(access-label . -)
(case-label . 0)
(substatement . +)
(statement-case-intro . +)
(statement . 0)
(brace-entry-open . 0)
(brace-list-entry . 0)
(brace-list-intro . +)
(brace-list-close . 0)
(block-close . 0)
(block-open . 0)
(inher-cont . c-lineup-multi-inher)
(inher-intro . +)
(member-init-cont . c-lineup-multi-inher)
(member-init-intro . +)
(annotation-var-cont . +)
(annotation-top-cont . 0)
(topmost-intro . 0)
(knr-argdecl . 0)
(func-decl-cont . +)
(inline-close . 0)
(class-close . 0)
(class-open . 0)
(defun-block-intro . +)
(defun-close . 0)
(defun-open . 0)
(c . c-lineup-C-comments)
(string . c-lineup-dont-change)
(topmost-intro-cont first c-lineup-topmost-intro-cont 
c-lineup-gnu-DEFUN-intro-cont)
(brace-list-open . +)
(inline-open . 0)
(arglist-close . c-lineup-arglist)
(arglist-intro . c-lineup-arglist-intro-after-paren)
(statement-cont . +)
(statement-case-open . +)
(label . 0)
(substatement-label . 0)
(substatement-open . +)
(knr-argdecl-intro . 5)
(statement-block-intro . +)
)
c-buffer-is-cc-mode 'c-mode
c-tab-always-indent t
c-syntactic-indentation t
c-syntactic-indentation-in-macros t
c-ignore-auto-fill '(string cpp code)
c-auto-align-backslashes t
c-backspace-function 'backward-delete-char-untabify
c-delete-function 'delete-char
c-electric-pound-behavior nil
c-default-style '((java-mode . "java") (awk-mode . "awk") (other . "gnu"))
c-enable-xemacs-performance-kludge-p nil
c-old-style-variable-behavior nil
defun-prompt-regexp nil
tab-width 8
comment-column 32
parse-sexp-ignore-comments t
parse-sexp-lookup-properties t
auto-fill-function nil
comment-multi-line t
comment-start-skip "\\(//+\\|/\\*+\\)\\s *"
fill-prefix nil
fill-column 70
paragraph-start "[ ]*\\(//+\\|\\**\\)[ ]*$\\|^\f"
adaptive-fill-mode t
adaptive-fill-regexp "[ ]*\\(//+\\|\\**\\)[ ]*\\([ 
]*\\([-–!|#%;>*·•‣⁃◦]+[ ]*\\)*\\)"
)

Emacs : GNU Emacs 24.2.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.10)
of 2012-08-24 on kfs-lx2
Package: CC Mode 5.32.3 (C/l)
Buffer Style: gnu
c-emacs-features: (pps-extended-state col-0-paren posix-char-classes 
gen-string-delim gen-comment-delim syntax-properties 1-bit)

current state:
==============





Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Mon, 03 Sep 2012 13:59:01 GMT) Full text and rfc822 format available.

Message #32 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Kim Storm <storm <at> cua.dk>
Cc: Alan Mackenzie <acm <at> muc.de>, 11749 <at> debbugs.gnu.org
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Mon, 03 Sep 2012 09:56:25 -0400
> I have this:
> (modify-syntax-entry ?_ "w" c-mode-syntax-table)

I don't know if it's the culprit, or if Alan considers this is a broken
config, but at least for the major modes I maintain, I consider this as
a broken config.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Mon, 03 Sep 2012 14:23:02 GMT) Full text and rfc822 format available.

Message #35 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Kim Storm <storm <at> cua.dk>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Alan Mackenzie <acm <at> muc.de>, 11749 <at> debbugs.gnu.org
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Mon, 03 Sep 2012 16:20:41 +0200
On 2012-09-03 15:56, Stefan Monnier wrote:
>> I have this:
>> (modify-syntax-entry ?_ "w" c-mode-syntax-table)
> I don't know if it's the culprit, or if Alan considers this is a broken
> config, but at least for the major modes I maintain, I consider this as
> a broken config.
>
Still, it never caused any problems in emacs 23.

Kim




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Mon, 03 Sep 2012 18:55:01 GMT) Full text and rfc822 format available.

Message #38 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Kim Storm <storm <at> cua.dk>
Cc: Alan Mackenzie <acm <at> muc.de>, 11749 <at> debbugs.gnu.org
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Mon, 03 Sep 2012 14:52:21 -0400
>>> I have this:
>>> (modify-syntax-entry ?_ "w" c-mode-syntax-table)
>> I don't know if it's the culprit, or if Alan considers this is a broken
>> config, but at least for the major modes I maintain, I consider this as
>> a broken config.
> Still, it never caused any problems in Emacs 23.

A broken config is not guaranteed to trigger problems ;-)
In any case, I do not know if it's the culprit (or even if Alan
considers it to be broken).  Still, I comment you try to remove it, to
see if it helps, and if it does, try to find some other way to get the
same result (e.g. using forward-symbol instead of forward-word).


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Wed, 05 Sep 2012 15:54:03 GMT) Full text and rfc822 format available.

Message #41 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Denis Zalevskiy <denis.zalevskiy <at> jollamobile.com>
To: 11749 <at> debbugs.gnu.org
Subject: I also have this issue
Date: Wed, 05 Sep 2012 16:11:34 +0300
In GNU Emacs 24.1.1 (x86_64-redhat-linux-gnu, GTK+ Version 2.24.11)
 of 2012-08-13 on buildvm-11.phx2.fedoraproject.org

*Messages*
...
c-inside-bracelist-p: Wrong type argument: number-or-marker-p, (4212 . 4415)
...

it occurs sometimes. 

I think it has some relation to bug 4590. At least, symptoms are the same and 
4590 is reproducible on my debian installation with the same version of emacs.

In c++ I can use C-c C-s to see all the code now is topmost-intro (like in bug 
4590), here it just end up in error message pointed above.





Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Wed, 05 Sep 2012 20:54:01 GMT) Full text and rfc822 format available.

Message #44 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Kim Storm <storm <at> cua.dk>
Cc: 11749 <at> debbugs.gnu.org
Subject: Re: bug#11749: Acknowledgement (24.1; C-mode indentation gives
	wrong-type-argument error.)
Date: Wed, 5 Sep 2012 20:48:21 +0000
Hello, Kim.

On Mon, Sep 03, 2012 at 11:47:00AM +0200, Kim Storm wrote:
> On 2012-09-02 23:16, Alan Mackenzie wrote:
> > Yes. It looks like the "state cache" (a cache of certain brace, paren 
> > and bracket positions) has got corrupted.
> > This is difficult to make repeatable, and is very dependent upon the 
> > exact navigation taken around the C buffer.
> Well - my navigation triggers that bug a lot.

It's strange that it doesn't seem to be happening much to other people.

[ .... ]

> > I've not been able to reproduce it in that limited context.  It looks
> > like another bug in the state cache, and they're bastards.
> Any way of clearing the cache?

M-: c-state-cache-init.  As a workaround, you could turn that into a
command and bind it to a spare C-c C-<letter>.

> > Might you have something unusual in your CC Mode config?
> I have this:

> (modify-syntax-entry ?_ "w" c-mode-syntax-table)

That shouldn't be causing the current problem.

> But otherwise, I don't seem to have any customizations ... only an 
> awkward programming style :-)

Thanks for the config!

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Fri, 07 Sep 2012 03:47:01 GMT) Full text and rfc822 format available.

Message #47 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Michael Welsh Duggan <md5i <at> md5i.com>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 11749 <at> debbugs.gnu.org, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Thu, 06 Sep 2012 23:45:48 -0400
Alan Mackenzie <acm <at> muc.de> writes:

> Hello, Kim.
>
> On Mon, Sep 03, 2012 at 11:47:00AM +0200, Kim Storm wrote:
>> On 2012-09-02 23:16, Alan Mackenzie wrote:
>> > Yes. It looks like the "state cache" (a cache of certain brace, paren 
>> > and bracket positions) has got corrupted.
>> > This is difficult to make repeatable, and is very dependent upon the 
>> > exact navigation taken around the C buffer.
>> Well - my navigation triggers that bug a lot.
>
> It's strange that it doesn't seem to be happening much to other people.

It happens to me irregularly.  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.

-- 
Michael Welsh Duggan
(md5i <at> md5i.com)




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Fri, 07 Sep 2012 14:54:02 GMT) Full text and rfc822 format available.

Message #50 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Michael Welsh Duggan <md5i <at> md5i.com>
Cc: Alan Mackenzie <acm <at> muc.de>, 11749 <at> debbugs.gnu.org,
	Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Fri, 07 Sep 2012 10:53:38 -0400
>>> > Yes. It looks like the "state cache" (a cache of certain brace, paren 
>>> > and bracket positions) has got corrupted.
>>> > This is difficult to make repeatable, and is very dependent upon the 
>>> > exact navigation taken around the C buffer.
>>> Well - my navigation triggers that bug a lot.
>> It's strange that it doesn't seem to be happening much to other people.
> It happens to me irregularly.  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.

If the problem happens while browsing a file (i.e. without any
intervening buffer modifications), then a trace of calls to
font-lock-default-fontify-region (but only those in the affected buffer)
might do the trick.

This said, I'm wondering why cc-mode's cache of parsing state is
so fragile.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Fri, 07 Sep 2012 16:17:02 GMT) Full text and rfc822 format available.

Message #53 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Kim Storm <storm <at> cua.dk>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: Alan Mackenzie <acm <at> muc.de>, Michael Welsh Duggan <md5i <at> md5i.com>,
	11749 <at> debbugs.gnu.org
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Fri, 07 Sep 2012 18:16:27 +0200
On 2012-09-07 16:53, Stefan Monnier wrote:
> If the problem happens while browsing a file (i.e. without any
> intervening buffer modifications), then a trace of calls to
> font-lock-default-fontify-region (but only those in the affected buffer)
> might do the trick.
I have never seen it just by browsing a C file.

When I see it, I have made "a number of changes".

Maybe changes have to include kill&yanks.

As I said, it's hard to work with 24.x due to this bug, but I'll give it 
another try
now that I know how to clear the cache.

Kim




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Sat, 08 Sep 2012 21:20:01 GMT) Full text and rfc822 format available.

Message #56 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Michael Welsh Duggan <md5i <at> md5i.com>
Cc: 11749 <at> debbugs.gnu.org, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1; C-mode indentation gives
	wrong-type-argument error.)
Date: Sat, 8 Sep 2012 21:14:51 +0000
Hello again, Michael!

On Thu, Sep 06, 2012 at 11:45:48PM -0400, Michael Welsh Duggan wrote:
> Alan Mackenzie <acm <at> muc.de> writes:

> > Hello, Kim.

> > On Mon, Sep 03, 2012 at 11:47:00AM +0200, Kim Storm wrote:
> >> On 2012-09-02 23:16, Alan Mackenzie wrote:
> >> > Yes. It looks like the "state cache" (a cache of certain brace, paren 
> >> > and bracket positions) has got corrupted.
> >> > This is difficult to make repeatable, and is very dependent upon the 
> >> > exact navigation taken around the C buffer.
> >> Well - my navigation triggers that bug a lot.

> > It's strange that it doesn't seem to be happening much to other people.

> It happens to me irregularly.

Once a week?  Once a day?  Is it associated with buffer changes, or does
it just happen?

> 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.

Kim, would you please try this out on a buffer you could actually send to
me.  Thanks!

> -- 
> Michael Welsh Duggan
> (md5i <at> md5i.com)

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Mon, 10 Sep 2012 12:20:01 GMT) Full text and rfc822 format available.

Message #59 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Michael Welsh Duggan <mwd <at> cert.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: Michael Welsh Duggan <md5i <at> md5i.com>, 11749 <at> debbugs.gnu.org,
	Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Mon, 10 Sep 2012 08:18:51 -0400
Alan Mackenzie <acm <at> muc.de> writes:

> Hello again, Michael!
>
> On Thu, Sep 06, 2012 at 11:45:48PM -0400, Michael Welsh Duggan wrote:
>> Alan Mackenzie <acm <at> muc.de> writes:
>
>> > Hello, Kim.
>
>> > On Mon, Sep 03, 2012 at 11:47:00AM +0200, Kim Storm wrote:
>> >> On 2012-09-02 23:16, Alan Mackenzie wrote:
>> >> > Yes. It looks like the "state cache" (a cache of certain brace, paren 
>> >> > and bracket positions) has got corrupted.
>> >> > This is difficult to make repeatable, and is very dependent upon the 
>> >> > exact navigation taken around the C buffer.
>> >> Well - my navigation triggers that bug a lot.
>
>> > It's strange that it doesn't seem to be happening much to other people.
>
>> It happens to me irregularly.
>
> Once a week?  Once a day?  Is it associated with buffer changes, or does
> it just happen?

It happens when I'm editing C code.  I can't say once a week/day, etc.,
because I don't edit C code every day.  Most days I don't see it at all.
When it does happen, it is either extremely ephemeral (and goes away
immediately), or happens frequently in the same file, and I have to
reload the file completely just to get back to status quo.  It's very
hard to characterize.  (It used to happen a lot more often before you
fixed this in a few places.)

>> 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.

-- 
Michael Welsh Duggan
(mwd <at> cert.org)




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Mon, 10 Sep 2012 12:50:01 GMT) Full text and rfc822 format available.

Message #62 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Michael Welsh Duggan <mwd <at> cert.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: Michael Welsh Duggan <md5i <at> md5i.com>, 11749 <at> debbugs.gnu.org,
	Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Mon, 10 Sep 2012 08:48:19 -0400
Michael Welsh Duggan <mwd <at> cert.org> 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.

And I have already hit several warnings.  I noticed nothing when
editing.  The latest one seemed to happen when I was cut/pasting code
from one place to another.  Now that I noticed the problems, I can't
recreate them.  I will modify my sources to beep at me when the messages
come up again so I notice them more immediately.

c-parse-state inconsistency at 6033: using cache: (6031 (5900 . 6025) 5819 (5689 . 5767) 5456 2847 2824), from scratch: (6031 (5900 . 6025) 5819 (5689 . 5767) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '((6644 . 6646) 2847 2824)  c-state-cache-good-pos 6646  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5602)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6033: using cache: (6031 (5900 . 6025) 5819 (5689 . 5767) 5456 2847 2824), from scratch: (6031 (5900 . 6025) 5819 (5689 . 5767) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6031 (5900 . 6025) 5819 (5689 . 5767) 5456 2847 2824)  c-state-cache-good-pos 6032  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5602)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6044: using cache: (6042 (5911 . 6036) 5830 (5700 . 5778) 5456 2847 2824), from scratch: (6042 (5911 . 6036) 5830 (5700 . 5778) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '((6655 . 6657) 2847 2824)  c-state-cache-good-pos 6657  c-state-nonlit-pos-cache '(9001 6001 3001)  c-state-nonlit-pos-cache-limit 6001  c-state-brace-pair-desert '(2847 . 5582)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6044: using cache: (6042 (5911 . 6036) 5830 (5700 . 5778) 5456 2847 2824), from scratch: (6042 (5911 . 6036) 5830 (5700 . 5778) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6042 (5911 . 6036) 5830 (5700 . 5778) 5456 2847 2824)  c-state-cache-good-pos 6043  c-state-nonlit-pos-cache '(9001 6001 3001)  c-state-nonlit-pos-cache-limit 6001  c-state-brace-pair-desert '(2847 . 5582)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
Opening nnimap server on home...done
nnimap read 0k from localhost
No more unseen articles
No more unread articles
Mark set [5 times]
Undo! [12 times]
c-parse-state inconsistency at 6294: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '((6607 . 6609) 2847 2824)  c-state-cache-good-pos 6609  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6306: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6306: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6271: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6446: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6446: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6306: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6477: using cache: (6476 6257 (5759 . 6205) 5456 2847 2824), from scratch: (6476 6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6477: using cache: (6476 6257 (5759 . 6205) 5456 2847 2824), from scratch: (6476 6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6476 6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6477: using cache: (6476 6257 (5759 . 6205) 5456 2847 2824), from scratch: (6476 6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6476 6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6477  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6506: using cache: ((6257 . 6497) 5456 2847 2824), from scratch: ((6257 . 6497) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6476 6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6477  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6506: using cache: ((6257 . 6497) 5456 2847 2824), from scratch: ((6257 . 6497) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '((6257 . 6497) 5456 2847 2824)  c-state-cache-good-pos 6497  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6214: using cache: ((5759 . 6205) 5456 2847 2824), from scratch: ((5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '((6257 . 6497) 5456 2847 2824)  c-state-cache-good-pos 6497  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6525: using cache: (6516 (6257 . 6497) 5456 2847 2824), from scratch: (6516 (6257 . 6497) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '((5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6205  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6525: using cache: (6516 (6257 . 6497) 5456 2847 2824), from scratch: (6516 (6257 . 6497) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6516 (6257 . 6497) 5456 2847 2824)  c-state-cache-good-pos 6497  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6517: using cache: (6516 (6257 . 6497) 5456 2847 2824), from scratch: (6516 (6257 . 6497) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6516 (6257 . 6497) 5456 2847 2824)  c-state-cache-good-pos 6517  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6294: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '((6607 . 6609) 2847 2824)  c-state-cache-good-pos 6609  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6294: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6294: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6306: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6306: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6271: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6294: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6294: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6259: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6306: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6306: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6271: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6259: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6259: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6259: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6306: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6306: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6271: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6446: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6446: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6306: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6477: using cache: (6476 6257 (5759 . 6205) 5456 2847 2824), from scratch: (6476 6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6477: using cache: (6476 6257 (5759 . 6205) 5456 2847 2824), from scratch: (6476 6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6476 6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6477: using cache: (6476 6257 (5759 . 6205) 5456 2847 2824), from scratch: (6476 6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6476 6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6477  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6506: using cache: ((6257 . 6497) 5456 2847 2824), from scratch: ((6257 . 6497) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6476 6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6477  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6506: using cache: ((6257 . 6497) 5456 2847 2824), from scratch: ((6257 . 6497) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '((6257 . 6497) 5456 2847 2824)  c-state-cache-good-pos 6497  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6214: using cache: ((5759 . 6205) 5456 2847 2824), from scratch: ((5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '((6257 . 6497) 5456 2847 2824)  c-state-cache-good-pos 6497  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6525: using cache: (6516 (6257 . 6497) 5456 2847 2824), from scratch: (6516 (6257 . 6497) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '((5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6205  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6525: using cache: (6516 (6257 . 6497) 5456 2847 2824), from scratch: (6516 (6257 . 6497) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6516 (6257 . 6497) 5456 2847 2824)  c-state-cache-good-pos 6497  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6517: using cache: (6516 (6257 . 6497) 5456 2847 2824), from scratch: (6516 (6257 . 6497) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6516 (6257 . 6497) 5456 2847 2824)  c-state-cache-good-pos 6517  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6259: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '((6607 . 6609) 2847 2824)  c-state-cache-good-pos 6676  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 6259: using cache: (6257 (5759 . 6205) 5456 2847 2824), from scratch: (6257 (5759 . 6205) 5456 (5210 . 5330) 2847 2824)
Old state:
(setq c-state-cache '(6257 (5759 . 6205) 5456 2847 2824)  c-state-cache-good-pos 6258  c-state-nonlit-pos-cache '(9010 6010 3001)  c-state-nonlit-pos-cache-limit 6010  c-state-brace-pair-desert '(2847 . 5546)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)


-- 
Michael Welsh Duggan
(mwd <at> cert.org)




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Mon, 10 Sep 2012 13:12:02 GMT) Full text and rfc822 format available.

Message #65 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Michael Welsh Duggan <mwd <at> cert.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: Michael Welsh Duggan <md5i <at> md5i.com>, 11749 <at> debbugs.gnu.org,
	Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Mon, 10 Sep 2012 09:10:27 -0400
[Message part 1 (text/plain, inline)]
Michael Welsh Duggan <mwd <at> cert.org> 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.  :-)
>
> I will turn this on.

Okay, I have something repeatable.  This is with an older checkout
("109494 dmantipov <at> yandex.ru-20120807112841-k0pyiinoxi2llcmu"), so I'm
updating my sources to see if this holds in the current bzr.  In the
meantime, here's a recipe that works in the above version.

1) emacs -Q
2) C-x C-f <attached-file>
3) M-x c-toggle-parse-state-debug RET
4) C-v until you get a state inconsistency message (10 times for me)

c-parse-state inconsistency at 9942: using cache: (9866 9516 5134 5090), from scratch: (9866 9516 (7654 . 9439) 5134 5090)
Old state:
(setq c-state-cache '(9516 5134 5090)  c-state-cache-good-pos 10231  c-state-nonlit-pos-cache '(15063 12049 9049 6049 3049)  c-state-nonlit-pos-cache-limit 15063  c-state-brace-pair-desert '(9516 . 9818)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)
c-parse-state inconsistency at 9942: using cache: (9866 9516 5134 5090), from scratch: (9866 9516 (7654 . 9439) 5134 5090)
Old state:
(setq c-state-cache '(9866 9516 5134 5090)  c-state-cache-good-pos 9867  c-state-nonlit-pos-cache '(15063 12049 9049 6049 3049)  c-state-nonlit-pos-cache-limit 15063  c-state-brace-pair-desert '(9516 . 9818)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil)

[conn_memory.lzz (text/plain, attachment)]
[Message part 3 (text/plain, inline)]
-- 
Michael Welsh Duggan
(mwd <at> cert.org)

Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Mon, 10 Sep 2012 13:23:01 GMT) Full text and rfc822 format available.

Message #68 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Michael Welsh Duggan <mwd <at> cert.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: Michael Welsh Duggan <md5i <at> md5i.com>,
	"11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Mon, 10 Sep 2012 09:22:11 -0400
Michael Welsh Duggan <mwd <at> cert.org> writes:

> Michael Welsh Duggan <mwd <at> cert.org> writes:
>
> Okay, I have something repeatable.  This is with an older checkout
> ("109494 dmantipov <at> yandex.ru-20120807112841-k0pyiinoxi2llcmu"), so I'm
> updating my sources to see if this holds in the current bzr.  

It indeed works in bzr version "109966
rgm <at> gnu.org-20120910101811-dxrpeq7h0vulwpr4", to which I have just
updated.

-- 
Michael Welsh Duggan
(mwd <at> cert.org)




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Mon, 10 Sep 2012 18:26:01 GMT) Full text and rfc822 format available.

Message #71 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Michael Welsh Duggan <mwd <at> cert.org>
To: Alan Mackenzie <acm <at> muc.de>, Michael Welsh Duggan <mwd <at> cert.org>
Cc: Michael Welsh Duggan <md5i <at> md5i.com>,
	"11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Mon, 10 Sep 2012 14:25:00 -0400
Michael Welsh Duggan <mwd <at> cert.org> writes:

> Michael Welsh Duggan <mwd <at> cert.org> writes:
>
>> Michael Welsh Duggan <mwd <at> cert.org> writes:
>>
>> Okay, I have something repeatable.  This is with an older checkout
>> ("109494 dmantipov <at> yandex.ru-20120807112841-k0pyiinoxi2llcmu"), so I'm
>> updating my sources to see if this holds in the current bzr.  
>
> It indeed works in bzr version "109966
> rgm <at> gnu.org-20120910101811-dxrpeq7h0vulwpr4", to which I have just
> updated.

And by works, I mean the recipe works, and the warning is triggered.

-- 
Michael Welsh Duggan
(mwd <at> cert.org)




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Fri, 21 Sep 2012 17:50:02 GMT) Full text and rfc822 format available.

Message #74 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Michael Welsh Duggan <mwd <at> cert.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: Michael Welsh Duggan <md5i <at> md5i.com>,
	"11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Fri, 21 Sep 2012 13:47:15 -0400
Michael Welsh Duggan <mwd <at> cert.org> writes:

> Michael Welsh Duggan <mwd <at> cert.org> 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?

-- 
Michael Welsh Duggan
(mwd <at> cert.org)




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Sun, 07 Oct 2012 11:06:02 GMT) Full text and rfc822 format available.

Message #77 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Michael Welsh Duggan <mwd <at> cert.org>
Cc: Michael Welsh Duggan <md5i <at> md5i.com>,
	"11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1; C-mode indentation gives
	wrong-type-argument error.)
Date: Sun, 7 Oct 2012 10:59:51 +0000
Hi, Michael.

On Fri, Sep 21, 2012 at 01:47:15PM -0400, Michael Welsh Duggan wrote:
> Michael Welsh Duggan <mwd <at> cert.org> writes:

> > Michael Welsh Duggan <mwd <at> cert.org> 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 <at> cert.org)

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Tue, 09 Oct 2012 14:06:02 GMT) Full text and rfc822 format available.

Message #80 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Michael Welsh Duggan <mwd <at> cert.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: Michael Welsh Duggan <md5i <at> md5i.com>,
	"11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Tue, 09 Oct 2012 10:05:07 -0400
[Message part 1 (text/plain, inline)]
Alan Mackenzie <acm <at> muc.de> writes:

> Hi, Michael.
>
> On Fri, Sep 21, 2012 at 01:47:15PM -0400, Michael Welsh Duggan wrote:
>> Michael Welsh Duggan <mwd <at> cert.org> writes:
>
>> > Michael Welsh Duggan <mwd <at> cert.org> 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.)

Still doesn't seem to help much here.  I have attached a file which
reliably causes a cache failure.  I have attached the smallest file of
the set of files I am working on that causes this particular problem.
Load the attached file and toggle on parse state debugging.  Then scroll
to the bottom of the file.  (Use C-v multiple times, or just M->.)  One
reason I have attached this file is that it only triggers the warning
message once.  Most of my larger files cause this to happen quite a lot.

[mod_fan_in.lzz (text/plain, attachment)]
[Message part 3 (text/plain, inline)]
-- 
Michael Welsh Duggan
(mwd <at> cert.org)

Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Wed, 10 Oct 2012 20:07:02 GMT) Full text and rfc822 format available.

Message #83 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Michael Welsh Duggan <mwd <at> cert.org>
Cc: Michael Welsh Duggan <md5i <at> md5i.com>,
	"11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1; C-mode indentation gives
	wrong-type-argument error.)
Date: Wed, 10 Oct 2012 20:00:25 +0000
Hi, Michael,

On Tue, Oct 09, 2012 at 10:05:07AM -0400, Michael Welsh Duggan wrote:
> Alan Mackenzie <acm <at> muc.de> writes:

[ .... ]

> >> >>> M-x c-toggle-parse-state-debug

> >> >>> 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.)

> Still doesn't seem to help much here.  I have attached a file which
> reliably causes a cache failure.  I have attached the smallest file of
> the set of files I am working on that causes this particular problem.
> Load the attached file and toggle on parse state debugging.  Then scroll
> to the bottom of the file.  (Use C-v multiple times, or just M->.)  One
> reason I have attached this file is that it only triggers the warning
> message once.  Most of my larger files cause this to happen quite a lot.

What is happening in this file is another bug, arising from historical
assumptions which are no longer valid.

The "from scratch" calculation notes that the starting scanning position
would be a long way (>5000) back, hence it tries going back to the second
"beginning-of-defun" to get a top-level starting point.  This
"beginning-of-defun" is a pure "brace in column zero" test.

This doesn't work in C++ when constructs inside a namespace have braces
at column zero, something I believe has become very common in recent
years.  Namespaces didn't exist in C++ when c-parse-state was originally
written.

Obviously this optimisation is no longer valid.  I wouldn't be surprised
if it has caused quite a bit of buggy behaviour.  I'll need to think it
over for a few days to decide what to do.

Again, thanks for taking so much trouble in submitting these bug
reports.


> -- 
> Michael Welsh Duggan
> (mwd <at> cert.org)

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Sun, 14 Oct 2012 17:14:01 GMT) Full text and rfc822 format available.

Message #86 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Michael Welsh Duggan <mwd <at> cert.org>
Cc: "11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1; C-mode indentation gives
	wrong-type-argument error.)
Date: Sun, 14 Oct 2012 17:06:50 +0000
Hi, Michael,

On Wed, Oct 10, 2012 at 08:00:25PM +0000, Alan Mackenzie wrote:
> On Tue, Oct 09, 2012 at 10:05:07AM -0400, Michael Welsh Duggan wrote:
> > Alan Mackenzie <acm <at> muc.de> writes:

[ .... ]

> > > 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.)

> > Still doesn't seem to help much here.  I have attached a file which
> > reliably causes a cache failure.  I have attached the smallest file of
> > the set of files I am working on that causes this particular problem.
> > Load the attached file and toggle on parse state debugging.  Then scroll
> > to the bottom of the file.  (Use C-v multiple times, or just M->.)  One
> > reason I have attached this file is that it only triggers the warning
> > message once.  Most of my larger files cause this to happen quite a lot.

> What is happening in this file is another bug, arising from historical
> assumptions which are no longer valid.

> The "from scratch" calculation notes that the starting scanning position
> would be a long way (>5000) back, hence it tries going back to the second
> "beginning-of-defun" to get a top-level starting point.  This
> "beginning-of-defun" is a pure "brace in column zero" test.

> This doesn't work in C++ when constructs inside a namespace have braces
> at column zero, something I believe has become very common in recent
> years.  Namespaces didn't exist in C++ when c-parse-state was originally
> written.

> Obviously this optimisation is no longer valid.  I wouldn't be surprised
> if it has caused quite a bit of buggy behaviour.  I'll need to think it
> over for a few days to decide what to do.

The only reasonable thing to do is to disable the heuristic for C++ Mode.
This is what the patch below now does.  Could you try it out as usual,
please.  Thanks!




diff -r ac6584d14c06 cc-engine.el
--- a/cc-engine.el	Sun Sep 09 11:15:13 2012 +0000
+++ b/cc-engine.el	Sun Oct 14 17:02:08 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")


> > -- 
> > Michael Welsh Duggan
> > (mwd <at> cert.org)

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Tue, 23 Oct 2012 16:16:01 GMT) Full text and rfc822 format available.

Message #89 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Michael Welsh Duggan <mwd <at> cert.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: "11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Tue, 23 Oct 2012 12:13:50 -0400
Alan Mackenzie <acm <at> muc.de> writes:

> Hi, Michael,
>
> On Wed, Oct 10, 2012 at 08:00:25PM +0000, Alan Mackenzie wrote:
>> On Tue, Oct 09, 2012 at 10:05:07AM -0400, Michael Welsh Duggan wrote:
>> > Alan Mackenzie <acm <at> muc.de> writes:
>
> [ .... ]
>
>> > > 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.)
>
>> > Still doesn't seem to help much here.  I have attached a file which
>> > reliably causes a cache failure.  I have attached the smallest file of
>> > the set of files I am working on that causes this particular problem.
>> > Load the attached file and toggle on parse state debugging.  Then scroll
>> > to the bottom of the file.  (Use C-v multiple times, or just M->.)  One
>> > reason I have attached this file is that it only triggers the warning
>> > message once.  Most of my larger files cause this to happen quite a lot.
>
>> What is happening in this file is another bug, arising from historical
>> assumptions which are no longer valid.
>
>> The "from scratch" calculation notes that the starting scanning position
>> would be a long way (>5000) back, hence it tries going back to the second
>> "beginning-of-defun" to get a top-level starting point.  This
>> "beginning-of-defun" is a pure "brace in column zero" test.
>
>> This doesn't work in C++ when constructs inside a namespace have braces
>> at column zero, something I believe has become very common in recent
>> years.  Namespaces didn't exist in C++ when c-parse-state was originally
>> written.
>
>> Obviously this optimisation is no longer valid.  I wouldn't be surprised
>> if it has caused quite a bit of buggy behaviour.  I'll need to think it
>> over for a few days to decide what to do.
>
> The only reasonable thing to do is to disable the heuristic for C++ Mode.
> This is what the patch below now does.  Could you try it out as usual,
> please.  Thanks!

Better, but doesn't solve all problems.  I'll see if I can't find
something reproducible for you.

-- 
Michael Welsh Duggan
(mwd <at> cert.org)




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Thu, 25 Oct 2012 13:44:02 GMT) Full text and rfc822 format available.

Message #92 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Michael Welsh Duggan <mwd <at> cert.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: "11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Thu, 25 Oct 2012 09:41:11 -0400
[Message part 1 (text/plain, inline)]
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. 

[pysilk.c (text/plain, attachment)]
[Message part 3 (text/plain, inline)]
-- 
Michael Welsh Duggan
(mwd <at> cert.org)

Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Sun, 28 Oct 2012 11:45:02 GMT) Full text and rfc822 format available.

Message #95 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Michael Welsh Duggan <mwd <at> cert.org>
Cc: "11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1; C-mode indentation gives
	wrong-type-argument error.)
Date: Sun, 28 Oct 2012 11:36:10 +0000
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 <at> cert.org)

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Sun, 04 Nov 2012 03:47:02 GMT) Full text and rfc822 format available.

Message #98 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> gnu.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 11749 <at> debbugs.gnu.org, Michael Welsh Duggan <mwd <at> cert.org>,
	Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Sun, 04 Nov 2012 11:43:26 +0800
Alan Mackenzie <acm <at> muc.de> writes:

> 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.

Hi Alan,

When you are ready to commit this, please commit to the emacs-24 branch
(as opposed to the trunk).  I think this should be fixed for Emacs 24.3.
Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Sun, 04 Nov 2012 20:49:01 GMT) Full text and rfc822 format available.

Message #101 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Kim Storm <storm <at> cua.dk>, Michael Welsh Duggan <mwd <at> cert.org>
Cc: "11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>
Subject: Re: bug#11749: Acknowledgement (24.1; C-mode indentation gives
	wrong-type-argument error.)
Date: Sun, 4 Nov 2012 20:39:12 +0000
Kim,

could you please try out this patch on your C++ files, and let me know
if the main problem has been resolved.

Michael,

there was a rather crass bug in last week's patch.  Sorry.  It's fixed
now, below.  M-x c-toggle-parse-state-debug has been enhanced to display
messages when the state-cache is intrinsically invalid.  It also now
gives a message when you {en,dis}able it.  Would you try out this patch
now, please.

Thanks to you both!

On Sun, Oct 28, 2012 at 11:36:10AM +0000, Alan Mackenzie wrote:

> 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.



diff -r ac6584d14c06 cc-engine.el
--- a/cc-engine.el	Sun Sep 09 11:15:13 2012 +0000
+++ b/cc-engine.el	Sun Nov 04 20:24:06 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,20 @@
 	;; 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))
+		     (or (null (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 +3360,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 +3385,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 "
@@ -3383,6 +3396,16 @@
      c-parse-state-state "  ")
     ")")))
 
+(defun c-debug-parse-state-double-cons (state)
+  (let (state-car conses-not-ok)
+    (while state
+      (setq state-car (car state)
+	    state (cdr state))
+      (if (and (consp state-car)
+	       (consp (car state)))
+	  (setq conses-not-ok t)))
+    conses-not-ok))
+
 (defun c-debug-parse-state ()
   (let ((here (point)) (res1 (c-real-parse-state)) res2)
     (let ((c-state-cache nil)
@@ -3415,8 +3438,16 @@
 	       here res1 res2)
       (message "Old state:")
       (c-replay-parse-state-state))
+
+    (when (c-debug-parse-state-double-cons res1)
+      (message "c-parse-state INVALIDITY at %s: %s"
+	       here res1)
+      (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")
@@ -3424,7 +3455,9 @@
   (fset 'c-parse-state (symbol-function (if c-debug-parse-state
 					    'c-debug-parse-state
 					  'c-real-parse-state)))
-  (c-keep-region-active))
+  (c-keep-region-active)
+  (message "c-debug-parse-state %sabled"
+	   (if c-debug-parse-state "en" "dis")))
 (when c-debug-parse-state
   (c-toggle-parse-state-debug 1))
 
diff -r ac6584d14c06 cc-mode.el
--- a/cc-mode.el	Sun Sep 09 11:15:13 2012 +0000
+++ b/cc-mode.el	Sun Nov 04 20:24:06 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 <at> cert.org)

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Sun, 04 Nov 2012 20:52:01 GMT) Full text and rfc822 format available.

Message #104 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Chong Yidong <cyd <at> gnu.org>
Cc: 11749 <at> debbugs.gnu.org, Michael Welsh Duggan <mwd <at> cert.org>,
	Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1; C-mode indentation gives
	wrong-type-argument error.)
Date: Sun, 4 Nov 2012 20:42:29 +0000
Hi, Yidong,

On Sun, Nov 04, 2012 at 11:43:26AM +0800, Chong Yidong wrote:
> Alan Mackenzie <acm <at> muc.de> writes:

> Hi Alan,

> When you are ready to commit this, please commit to the emacs-24 branch
> (as opposed to the trunk).  I think this should be fixed for Emacs 24.3.
> Thanks.

Will do!  I agree it should be fixed for 24.3, as it has become a rather
"popular" bug out in the wild.  :-(  I'm hoping I'm close to a fix, now.

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Sun, 04 Nov 2012 21:08:02 GMT) Full text and rfc822 format available.

Message #107 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Kim Storm <storm <at> cua.dk>
To: Alan Mackenzie <acm <at> muc.de>
Cc: "11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>,
	Michael Welsh Duggan <mwd <at> cert.org>
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Sun, 04 Nov 2012 22:04:36 +0100
On 2012-11-04 21:39, Alan Mackenzie wrote:
> Kim,
>
> could you please try out this patch on your C++ files, and let me know
> if the main problem has been resolved.
>
> Michael,
Hi Michael and Alan

Sorry for the silence on this bug - I've worked on some other projects 
where the
bug has only shown up once or twice, so I couldn't really do any useful 
testing.

Also, my files are all C and not C++, so I didn't think the fixes you 
discussed would
be relevant for me.

In any case, I will install the patch and see what happens.

Kim





Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Wed, 14 Nov 2012 16:54:01 GMT) Full text and rfc822 format available.

Message #110 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Michael Welsh Duggan <mwd <at> cert.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: "11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Wed, 14 Nov 2012 11:52:41 -0500
[Message part 1 (text/plain, inline)]
Alan Mackenzie <acm <at> muc.de> writes:

> there was a rather crass bug in last week's patch.  Sorry.  It's fixed
> now, below.  M-x c-toggle-parse-state-debug has been enhanced to display
> messages when the state-cache is intrinsically invalid.  It also now
> gives a message when you {en,dis}able it.  Would you try out this patch
> now, please.

Sorry it has taken me so long to respond.  I was working in non-C-based
languages for a while.  today I started working in C again, and ran into
issues like this:

Error during redisplay: (jit-lock-function 3411) signaled (wrong-type-argument number-or-marker-p nil)
c-parse-state inconsistency at 3599: using cache: nil, from scratch: ((3409 . 3599))
Old state:
(setq c-state-cache '((3409 . 3599))  c-state-cache-good-pos 3599  c-state-nonlit-pos-cache '(6307 3307)  c-state-nonlit-pos-cache-limit 3592  c-state-semi-nonlit-pos-cache '(3307)  c-state-semi-nonlit-pos-cache-limit 3592  c-state-brace-pair-desert '(nil . 3396)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil  c-parse-state-point 3600)

I have finally managed to come up with a recipe for this one.  I am
using "110803 rgm <at> gnu.org-20121105111732-ilq2sbfo09xg9i9z" with your
patches.

emacs -Q rwfileinfo.c
M-x c-toggle-parse-state-debug
C-x 4 b *Messages* RET
C-s enum RET
C-M-f C-p C-e ,

Error occurs after the comma (should be on line 197).

[rwfileinfo.c (text/plain, attachment)]
[Message part 3 (text/plain, inline)]
-- 
Michael Welsh Duggan
(mwd <at> cert.org)

Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Wed, 21 Nov 2012 21:06:01 GMT) Full text and rfc822 format available.

Message #113 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Chong Yidong <cyd <at> gnu.org>
Cc: 11749 <at> debbugs.gnu.org, Michael Welsh Duggan <mwd <at> cert.org>,
	Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1; C-mode indentation gives
	wrong-type-argument error.)
Date: Wed, 21 Nov 2012 20:58:12 +0000
Hello, Yidong.

On Sun, Nov 04, 2012 at 11:43:26AM +0800, Chong Yidong wrote:
> Alan Mackenzie <acm <at> muc.de> writes:

> > 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.

> Hi Alan,

> When you are ready to commit this, please commit to the emacs-24 branch
> (as opposed to the trunk).  I think this should be fixed for Emacs 24.3.
> Thanks.

I've just committed the current state of the bug fixes to Emacs-24 in
anticipation of the coming pretest.  (I also bumped CC Mode's version
number.)  Can I assume that you or Stefan will copy the changes to the
trunk?

There is, however, at least one outstanding bug, as reported by Michael
on 2012-11-14.  I'm trying to track this one down, but at the moment I
can't reproduce it.

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Wed, 21 Nov 2012 21:42:02 GMT) Full text and rfc822 format available.

Message #116 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Michael Welsh Duggan <mwd <at> cert.org>
Cc: "11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1; C-mode indentation gives
	wrong-type-argument error.)
Date: Wed, 21 Nov 2012 21:33:40 +0000
Hi, Michael.

On Wed, Nov 14, 2012 at 11:52:41AM -0500, Michael Welsh Duggan wrote:

> ... Today I started working in C again, and ran into issues like this:

> Error during redisplay: (jit-lock-function 3411) signaled (wrong-type-argument number-or-marker-p nil)
> c-parse-state inconsistency at 3599: using cache: nil, from scratch: ((3409 . 3599))
> Old state:
> (setq c-state-cache '((3409 . 3599))  c-state-cache-good-pos 3599  c-state-nonlit-pos-cache '(6307 3307)  c-state-nonlit-pos-cache-limit 3592  c-state-semi-nonlit-pos-cache '(3307)  c-state-semi-nonlit-pos-cache-limit 3592  c-state-brace-pair-desert '(nil . 3396)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil  c-parse-state-point 3600)

> I have finally managed to come up with a recipe for this one.  I am
> using "110803 rgm <at> gnu.org-20121105111732-ilq2sbfo09xg9i9z" with your
> patches.

> emacs -Q rwfileinfo.c
> M-x c-toggle-parse-state-debug
> C-x 4 b *Messages* RET

I assumed a C-x o here.  ;-)

> C-s enum RET
> C-M-f C-p C-e ,

> Error occurs after the comma (should be on line 197).

I find myself on L96.  I can't reproduce this error, neither on a tty or
in X windows.  I tried repeating the C-M-f, so that the C-p C-e brought
point to just after "RWINFO_PROPERTY_COUNT" and typing a comma there.
That still didn't signal an error.

I've just committed the current state of the fixes to the Emacs-24 branch
at savannah, for the pretest next weekend.

Thanks again for all the input.

> -- 
> Michael Welsh Duggan
> (mwd <at> cert.org)

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Thu, 22 Nov 2012 14:54:02 GMT) Full text and rfc822 format available.

Message #119 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Alan Mackenzie <acm <at> muc.de>
Cc: Chong Yidong <cyd <at> gnu.org>, Michael Welsh Duggan <mwd <at> cert.org>,
	11749 <at> debbugs.gnu.org, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Thu, 22 Nov 2012 09:52:24 -0500
> I've just committed the current state of the bug fixes to Emacs-24 in
> anticipation of the coming pretest.  (I also bumped CC Mode's version
> number.)

Thanks.

> Can I assume that you or Stefan will copy the changes to the trunk?

Could also be someone else, but yes you can assume it will happen within
a few days.  Except we call it "merge" rather than "copy" ;-)

> There is, however, at least one outstanding bug, as reported by Michael
> on 2012-11-14.  I'm trying to track this one down, but at the moment I
> can't reproduce it.

I wish you luck,


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Mon, 26 Nov 2012 13:28:01 GMT) Full text and rfc822 format available.

Message #122 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Michael Welsh Duggan <mwd <at> cert.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: "11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Mon, 26 Nov 2012 08:25:33 -0500
[Message part 1 (text/plain, inline)]
Alan Mackenzie <acm <at> muc.de> writes:

> Hi, Michael.
>
> On Wed, Nov 14, 2012 at 11:52:41AM -0500, Michael Welsh Duggan wrote:
>
>> ... Today I started working in C again, and ran into issues like this:
>
>> Error during redisplay: (jit-lock-function 3411) signaled
>> (wrong-type-argument number-or-marker-p nil)
>> c-parse-state inconsistency at 3599: using cache: nil, from scratch:
>> ((3409 . 3599))
>> Old state:
>> (setq c-state-cache '((3409 . 3599)) c-state-cache-good-pos 3599
>> c-state-nonlit-pos-cache '(6307 3307) c-state-nonlit-pos-cache-limit
>> 3592 c-state-semi-nonlit-pos-cache '(3307)
>> c-state-semi-nonlit-pos-cache-limit 3592 c-state-brace-pair-desert
>> (nil . 3396) c-state-point-min 1 c-state-point-min-lit-type nil
>> c-state-point-min-lit-start nil c-state-min-scan-pos 1
>> c-state-old-cpp-beg nil c-state-old-cpp-end nil c-parse-state-point
>> 3600)
>
>> I have finally managed to come up with a recipe for this one.  I am
>> using "110803 rgm <at> gnu.org-20121105111732-ilq2sbfo09xg9i9z" with your
>> patches.
>
>> emacs -Q rwfileinfo.c
>> M-x c-toggle-parse-state-debug
>> C-x 4 b *Messages* RET
>
> I assumed a C-x o here.  ;-)
>
>> C-s enum RET
>> C-M-f C-p C-e ,
>
>> Error occurs after the comma (should be on line 197).
>
> I find myself on L96.  I can't reproduce this error, neither on a tty or
> in X windows.  I tried repeating the C-M-f, so that the C-p C-e brought
> point to just after "RWINFO_PROPERTY_COUNT" and typing a comma there.
> That still didn't signal an error.

I'm sorry.  I realized that I attached the wrong file.  And the line
number should have been 97, not 197.  Unfortunately, I cannot reliably
trigger the problem using the above recipe using a recent Emacs trunk
check-out.  Even more unfortunately, I have still encountered the
problem (but have been unable to recreate it).  All in all, though, I
think your changes have been beneficial.  I'll try to isolate an example
over the next few days.

[rwsiteinfo.c (text/plain, attachment)]
[Message part 3 (text/plain, inline)]
-- 
Michael Welsh Duggan
(mwd <at> cert.org)

Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Mon, 10 Dec 2012 03:37:01 GMT) Full text and rfc822 format available.

Message #125 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Michael Welsh Duggan <mwd <at> md5i.com>
To: Michael Welsh Duggan <mwd <at> cert.org>
Cc: Alan Mackenzie <acm <at> muc.de>,
	"11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Sun, 09 Dec 2012 22:35:42 -0500
[Message part 1 (text/plain, inline)]
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 <at> gnu.org-20121210020042-arkhaf5eej6ujgtn

rwrec.h is attached.

[rwrec.h (text/x-chdr, attachment)]
[Message part 3 (text/plain, inline)]
-- 
Michael Welsh Duggan
(md5i <at> md5i.com)

Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Mon, 07 Jan 2013 12:18:02 GMT) Full text and rfc822 format available.

Message #128 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Michael Welsh Duggan <mwd <at> md5i.com>
Cc: "11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>,
	Michael Welsh Duggan <mwd <at> cert.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1; C-mode indentation gives
	wrong-type-argument error.)
Date: Mon, 7 Jan 2013 12:09:52 +0000
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 <at> 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 <at> md5i.com)

-- 
Alan Mackenzie (Nuremberg, Germany).




Merged 9957 11749 13385. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 08 Jan 2013 17:18:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Tue, 08 Jan 2013 19:12:01 GMT) Full text and rfc822 format available.

Message #133 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: Michael Welsh Duggan <mwd <at> md5i.com>,
	"11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>,
	Michael Welsh Duggan <mwd <at> cert.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Tue, 08 Jan 2013 14:10:58 -0500
If you'd like to see this in the next pretest, please install this in
emacs-24 as soon as possible.

FWIW, here is some sanity checking from someone who knows nothing about
cc-mode (other than the terror that it brings). Just ignore any of these
comments if they are obviously wrong.

Alan Mackenzie wrote:

> + (defvar c-state-old-cpp-beg-marker)

I guess you wanted to give that an actual value, ie

(defvar c-state-old-cpp-beg-marker nil)

> + (defvar c-state-old-cpp-end-marker)

Likewise.

> + (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)))
> + 
[...]
> !       (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)))))

Looks like the marker insertion type has changed?




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Wed, 09 Jan 2013 22:22:02 GMT) Full text and rfc822 format available.

Message #136 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Glenn Morris <rgm <at> gnu.org>
Cc: Michael Welsh Duggan <mwd <at> md5i.com>,
	"11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>,
	Michael Welsh Duggan <mwd <at> cert.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1; C-mode indentation gives
	wrong-type-argument error.)
Date: Wed, 9 Jan 2013 22:13:44 +0000
Hi, Glenn.

On Tue, Jan 08, 2013 at 02:10:58PM -0500, Glenn Morris wrote:

> If you'd like to see this in the next pretest, please install this in
> emacs-24 as soon as possible.

DONE.  I'll be looking forward to the new pretest ?tomorrow.

> FWIW, here is some sanity checking from someone who knows nothing about
> cc-mode (other than the terror that it brings). Just ignore any of these
> comments if they are obviously wrong.

> Alan Mackenzie wrote:

> > + (defvar c-state-old-cpp-beg-marker)

> I guess you wanted to give that an actual value, ie

> (defvar c-state-old-cpp-beg-marker nil)

Sugar!  I must stop being caught out by this.  That construct merely
interns a symbol, leaving its value unbound.  Thanks very much for
catching this.

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Thu, 17 Jan 2013 16:28:01 GMT) Full text and rfc822 format available.

Message #139 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Michael Welsh Duggan <mwd <at> cert.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: "11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Thu, 17 Jan 2013 11:27:04 -0500
Alan Mackenzie <acm <at> muc.de> writes:

> 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 <at> 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.

This fixes this case, indeed.  Unfortunately, here's another.

emacs -Q rwtransfer.c
  M-x c-toggle-parse-state-debug
  M->
Then type M-v until the parse failure happens.  For me it happens at 
32% point in the file.  Please not that this particular problem only
happens when paging through the file in reverse order.

c-parse-state inconsistency at 15885: using cache: (15636 15181 (13849 . 15141)), from scratch: (15636 (15303 . 15493) 15181 (13849 . 15141))
Old state:
(setq c-state-cache '(16334 16271 16248 (16059 . 16193) 15181 (13849 . 15141))  c-state-cache-good-pos 16335  c-state-nonlit-pos-cache '(48473 45473 42473 39473 36473 33473 30473 27378 24378 21260 18015 15015 12015 9015 6015 3015)  c-state-nonlit-pos-cache-limit 48473  c-state-semi-nonlit-pos-cache '(48323 45323 42323 39323 36323 33260 30260 27260 24260 21260 18001 15001 12001 9001 6001 3001)  c-state-semi-nonlit-pos-cache-limit 48323  c-state-brace-pair-desert '(15181 . 17388)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil  c-parse-state-point 16335)
c-parse-state inconsistency at 15885: using cache: (15636 15181 (13849 . 15141)), from scratch: (15636 (15303 . 15493) 15181 (13849 . 15141))

-- 
Michael Welsh Duggan
(mwd <at> cert.org)




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Thu, 17 Jan 2013 16:29:02 GMT) Full text and rfc822 format available.

Message #142 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Michael Welsh Duggan <mwd <at> cert.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: "11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Thu, 17 Jan 2013 11:28:01 -0500
[Message part 1 (text/plain, inline)]
And here's the file I was supposed to include:

[rwtransfer.c (text/plain, attachment)]
[Message part 3 (text/plain, inline)]
-- 
Michael Welsh Duggan
(mwd <at> cert.org)

Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Wed, 23 Jan 2013 14:25:02 GMT) Full text and rfc822 format available.

Message #145 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Michael Welsh Duggan <mwd <at> cert.org>
Cc: "11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1; C-mode indentation gives
	wrong-type-argument error.)
Date: Wed, 23 Jan 2013 14:16:45 +0000
Hi, Michael.

On Thu, Jan 17, 2013 at 11:27:04AM -0500, Michael Welsh Duggan wrote:
> Alan Mackenzie <acm <at> muc.de> writes:

> [This] fixes this case, indeed.  Unfortunately, here's another.

> emacs -Q rwtransfer.c
>   M-x c-toggle-parse-state-debug
>   M->
> Then type M-v until the parse failure happens.  For me it happens at 
> 32% point in the file.  Please not that this particular problem only
> happens when paging through the file in reverse order.

> c-parse-state inconsistency at 15885: using cache: (15636 15181 (13849 . 15141)), from scratch: (15636 (15303 . 15493) 15181 (13849 . 15141))
> Old state:
> (setq c-state-cache '(16334 16271 16248 (16059 . 16193) 15181 (13849 . 15141))  c-state-cache-good-pos 16335  c-state-nonlit-pos-cache '(48473 45473 42473 39473 36473 33473 30473 27378 24378 21260 18015 15015 12015 9015 6015 3015)  c-state-nonlit-pos-cache-limit 48473  c-state-semi-nonlit-pos-cache '(48323 45323 42323 39323 36323 33260 30260 27260 24260 21260 18001 15001 12001 9001 6001 3001)  c-state-semi-nonlit-pos-cache-limit 48323  c-state-brace-pair-desert '(15181 . 17388)  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil  c-parse-state-point 16335)
> c-parse-state inconsistency at 15885: using cache: (15636 15181 (13849 . 15141)), from scratch: (15636 (15303 . 15493) 15181 (13849 . 15141))

I think the following patch should fix that glitch.  I've also taken the
opportunity to simplify things a little (part of the global state was
being passed needlessly as a parameter) and to rename some variables for
more consistency.

Would you try this out and confirm it works, as usual, please.

However, this isn't the end of the story - 

(i) Start your test case in rwtransfer.c, and M-v until the top of the
  file.  (This shouldn't display any inconsistency messages)
(ii) M-x goto-char <ret> 20001 <ret>.  This should go to EOL 671, just
  after a "}".
(iii) Type <space> }.  (Two characters)
(iv) C-v, possibly twice.

This displays a message something like:
    c-parse-state inconsistency at 21070: using cache: ((20458 . 20935)),
    from scratch: ((20838 . 20877))
, together with a state dump.

This bug isn't a new one, but I've just come across it.  I'll be working
on it in the meantime.

Here's the patch, based on the savannah emacs-24 branch (which should be
identical to the trunk):



=== modified file 'lisp/progmodes/cc-engine.el'
*** lisp/progmodes/cc-engine.el	2013-01-09 21:33:00 +0000
--- lisp/progmodes/cc-engine.el	2013-01-23 13:36:33 +0000
***************
*** 2545,2558 ****
    ;;
    ;; The return value is a list, one of the following:
    ;;
!   ;; o - ('forward CACHE-POS START-POINT) - scan forward from START-POINT,
!   ;;                                        which is not less than CACHE-POS.
!   ;; o - ('backward CACHE-POS nil) - scan backwards (from HERE).
!   ;; o - ('BOD nil START-POINT) - scan forwards from START-POINT, which is at the
    ;;   top level.
!   ;; o - ('IN-LIT nil nil) - point is inside the literal containing point-min.
!   ;; , where CACHE-POS is the highest position recorded in `c-state-cache' at
!   ;; or below HERE.
    (let ((cache-pos (c-get-cache-scan-pos here))	; highest position below HERE in cache (or 1)
  	BOD-pos		    ; position of 2nd BOD before HERE.
  	strategy	    ; 'forward, 'backward, 'BOD, or 'IN-LIT.
--- 2545,2556 ----
    ;;
    ;; The return value is a list, one of the following:
    ;;
!   ;; o - ('forward START-POINT) - scan forward from START-POINT,
!   ;;	 which is not less than the highest position in `c-state-cache' below here.
!   ;; o - ('backward nil) - scan backwards (from HERE).
!   ;; o - ('BOD START-POINT) - scan forwards from START-POINT, which is at the
    ;;   top level.
!   ;; o - ('IN-LIT nil) - point is inside the literal containing point-min.
    (let ((cache-pos (c-get-cache-scan-pos here))	; highest position below HERE in cache (or 1)
  	BOD-pos		    ; position of 2nd BOD before HERE.
  	strategy	    ; 'forward, 'backward, 'BOD, or 'IN-LIT.
***************
*** 2590,2596 ****
  
      (list
       strategy
-      (and (memq strategy '(forward backward)) cache-pos)
       (and (memq strategy '(forward BOD)) start-point))))
  
  
--- 2588,2593 ----
***************
*** 2657,2663 ****
    ;; 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)
--- 2654,2661 ----
    ;; reduce the time wasted in repeated fruitless searches in brace deserts.
    (save-excursion
      (save-restriction
!       (let* ((here (point-max))
! 	     new-cons
  	     (cache-pos (c-state-cache-top-lparen)) ; might be nil.
  	     (macro-start-or-from
  	      (progn (goto-char from)
***************
*** 2692,2697 ****
--- 2690,2696 ----
  		;; search bound, even though the algorithm below would skip
  		;; over the new paren pair.
  		(cache-lim (and cache-pos (< cache-pos from) cache-pos)))
+ 	    (widen)
  	    (narrow-to-region
  		(cond
  		 ((and desert-lim cache-lim)
***************
*** 2711,2726 ****
  		  (while
  		      (and (setq ce (scan-lists bra -1 -1)) ; back past )/]/}; might signal
  			   (setq bra (scan-lists ce -1 1)) ; back past (/[/{; might signal
! 			   (or (> ce upper-lim)
! 			       (not (eq (char-after bra) ?\{))
! 			       (and (goto-char bra)
! 				    (c-beginning-of-macro)
! 				    (< (point) macro-start-or-from))))))
  		(and ce (< ce bra)))
  	    (setq bra ce))	; If we just backed over an unbalanced closing
  					; brace, ignore it.
  
! 	  (if (and ce (< bra ce) (eq (char-after bra) ?\{))
  	      ;; We've found the desired brace-pair.
  	      (progn
  		(setq new-cons (cons bra (1+ ce)))
--- 2710,2727 ----
  		  (while
  		      (and (setq ce (scan-lists bra -1 -1)) ; back past )/]/}; might signal
  			   (setq bra (scan-lists ce -1 1)) ; back past (/[/{; might signal
! 			   (or (> bra here) ;(> ce here)
! 			       (and
! 				(< ce here)
! 				(or (not (eq (char-after bra) ?\{))
! 				    (and (goto-char bra)
! 					 (c-beginning-of-macro)
! 					 (< (point) macro-start-or-from))))))))
  		(and ce (< ce bra)))
  	    (setq bra ce))	; If we just backed over an unbalanced closing
  					; brace, ignore it.
  
! 	  (if (and ce (< ce here) (< bra ce) (eq (char-after bra) ?\{))
  	      ;; We've found the desired brace-pair.
  	      (progn
  		(setq new-cons (cons bra (1+ ce)))
***************
*** 2734,2740 ****
  		 (t (setq c-state-cache (cons new-cons c-state-cache)))))
  
  	    ;; We haven't found a brace pair.  Record this in the cache.
! 	    (setq c-state-brace-pair-desert (cons cache-pos from))))))))
  
  (defsubst c-state-push-any-brace-pair (bra+1 macro-start-or-here)
    ;; If BRA+1 is nil, do nothing.  Otherwise, BRA+1 is the buffer position
--- 2735,2745 ----
  		 (t (setq c-state-cache (cons new-cons c-state-cache)))))
  
  	    ;; We haven't found a brace pair.  Record this in the cache.
! 	    (setq c-state-brace-pair-desert
! 		  (cons (if (and ce (< bra ce) (> ce here)) ; {..} straddling HERE?
! 			    bra
! 			  (point-min))
! 			(min here from)))))))))
  
  (defsubst c-state-push-any-brace-pair (bra+1 macro-start-or-here)
    ;; If BRA+1 is nil, do nothing.  Otherwise, BRA+1 is the buffer position
***************
*** 2852,2870 ****
         (paren+1)
         (t from)))))
  
! (defun c-remove-stale-state-cache (good-pos pps-point)
    ;; Remove stale entries from the `c-cache-state', i.e. those which will
    ;; not be in it when it is amended for position (point-max).
    ;; Additionally, the "outermost" open-brace entry before (point-max)
    ;; will be converted to a cons if the matching close-brace is scanned.
    ;;
!   ;; GOOD-POS is a "maximal" "safe position" - there must be no open
!   ;; parens/braces/brackets between GOOD-POS and (point-max).
    ;;
    ;; As a second thing, calculate the result of parse-partial-sexp at
!   ;; PPS-POINT, w.r.t. GOOD-POS.  The motivation here is that
    ;; `c-state-cache-good-pos' may become PPS-POINT, but the caller may need to
!   ;; adjust it to get outside a string/comment.  (Sorry about this!  The code
    ;; needs to be FAST).
    ;;
    ;; Return a list (GOOD-POS SCAN-BACK-POS PPS-STATE), where
--- 2857,2875 ----
         (paren+1)
         (t from)))))
  
! (defun c-remove-stale-state-cache (start-point pps-point)
    ;; Remove stale entries from the `c-cache-state', i.e. those which will
    ;; not be in it when it is amended for position (point-max).
    ;; Additionally, the "outermost" open-brace entry before (point-max)
    ;; will be converted to a cons if the matching close-brace is scanned.
    ;;
!   ;; START-POINT is a "maximal" "safe position" - there must be no open
!   ;; parens/braces/brackets between START-POINT and (point-max).
    ;;
    ;; As a second thing, calculate the result of parse-partial-sexp at
!   ;; PPS-POINT, w.r.t. START-POINT.  The motivation here is that
    ;; `c-state-cache-good-pos' may become PPS-POINT, but the caller may need to
!   ;; adjust it to get outside a string/comment.	 (Sorry about this!  The code
    ;; needs to be FAST).
    ;;
    ;; Return a list (GOOD-POS SCAN-BACK-POS PPS-STATE), where
***************
*** 2872,2878 ****
    ;;   to be good (we aim for this to be as high as possible);
    ;; o - SCAN-BACK-POS, if not nil, indicates there may be a brace pair
    ;;   preceding POS which needs to be recorded in `c-state-cache'.  It is a
!   ;;   position to scan backwards from.
    ;; o - PPS-STATE is the parse-partial-sexp state at PPS-POINT.
    (save-restriction
      (narrow-to-region 1 (point-max))
--- 2877,2885 ----
    ;;   to be good (we aim for this to be as high as possible);
    ;; o - SCAN-BACK-POS, if not nil, indicates there may be a brace pair
    ;;   preceding POS which needs to be recorded in `c-state-cache'.  It is a
!   ;;   position to scan backwards from.  It is the position of the "{" of the
!   ;;   last element to be removed from `c-state-cache', when that elt is a
!   ;;   cons, otherwise nil.
    ;; o - PPS-STATE is the parse-partial-sexp state at PPS-POINT.
    (save-restriction
      (narrow-to-region 1 (point-max))
***************
*** 2882,2902 ****
  		(goto-char (point-max))
  		(and (c-beginning-of-macro)
  		     (point))))
! 	     (good-pos-actual-macro-start ; Start of macro containing good-pos
! 					; or nil
! 	      (and (< good-pos (point-max))
  		   (save-excursion
! 		     (goto-char good-pos)
  		     (and (c-beginning-of-macro)
  			  (point)))))
! 	     (good-pos-actual-macro-end	; End of this macro, (maybe
  					; (point-max)), or nil.
! 	      (and good-pos-actual-macro-start
  		   (save-excursion
! 		     (goto-char good-pos-actual-macro-start)
  		     (c-end-of-macro)
  		     (point))))
! 	     pps-state 			; Will be 9 or 10 elements long.
  	     pos
  	     upper-lim	   ; ,beyond which `c-state-cache' entries are removed
  	     scan-back-pos
--- 2889,2909 ----
  		(goto-char (point-max))
  		(and (c-beginning-of-macro)
  		     (point))))
! 	     (start-point-actual-macro-start ; Start of macro containing
! 					     ; start-point or nil
! 	      (and (< start-point (point-max))
  		   (save-excursion
! 		     (goto-char start-point)
  		     (and (c-beginning-of-macro)
  			  (point)))))
! 	     (start-point-actual-macro-end ; End of this macro, (maybe
  					; (point-max)), or nil.
! 	      (and start-point-actual-macro-start
  		   (save-excursion
! 		     (goto-char start-point-actual-macro-start)
  		     (c-end-of-macro)
  		     (point))))
! 	     pps-state			; Will be 9 or 10 elements long.
  	     pos
  	     upper-lim	   ; ,beyond which `c-state-cache' entries are removed
  	     scan-back-pos
***************
*** 2926,2940 ****
  	;; The next loop jumps forward out of a nested level of parens each
  	;; time round; the corresponding elements in `c-state-cache' are
  	;; removed.  `pos' is just after the brace-pair or the open paren at
! 	;; (car c-state-cache).  There can be no open parens/braces/brackets
! 	;; between `good-pos'/`good-pos-actual-macro-start' and (point-max),
  	;; due to the interface spec to this function.
! 	(setq pos (if (and good-pos-actual-macro-end
! 			   (not (eq good-pos-actual-macro-start
  				    in-macro-start)))
! 		      (1+ good-pos-actual-macro-end) ; get outside the macro as
  					; marked by a `category' text property.
! 		    good-pos))
  	(goto-char pos)
  	(while (and c-state-cache
  		    (< (point) (point-max)))
--- 2933,2947 ----
  	;; The next loop jumps forward out of a nested level of parens each
  	;; time round; the corresponding elements in `c-state-cache' are
  	;; removed.  `pos' is just after the brace-pair or the open paren at
! 	;; (car c-state-cache).	 There can be no open parens/braces/brackets
! 	;; between `start-point'/`start-point-actual-macro-start' and (point-max),
  	;; due to the interface spec to this function.
! 	(setq pos (if (and start-point-actual-macro-end
! 			   (not (eq start-point-actual-macro-start
  				    in-macro-start)))
! 		      (1+ start-point-actual-macro-end) ; get outside the macro as
  					; marked by a `category' text property.
! 		    start-point))
  	(goto-char pos)
  	(while (and c-state-cache
  		    (< (point) (point-max)))
***************
*** 2993,3006 ****
  
  	(list pos scan-back-pos pps-state)))))
  
! (defun c-remove-stale-state-cache-backwards (here cache-pos)
    ;; Strip stale elements of `c-state-cache' by moving backwards through the
    ;; buffer, and inform the caller of the scenario detected.
    ;;
    ;; HERE is the position we're setting `c-state-cache' for.
!   ;; CACHE-POS is just after the latest recorded position in `c-state-cache'
!   ;;   before HERE, or a position at or near point-min which isn't in a
!   ;;   literal.
    ;;
    ;; This function must only be called only when (> `c-state-cache-good-pos'
    ;; HERE).  Usually the gap between CACHE-POS and HERE is large.  It is thus
--- 3000,3013 ----
  
  	(list pos scan-back-pos pps-state)))))
  
! (defun c-remove-stale-state-cache-backwards (here)
    ;; Strip stale elements of `c-state-cache' by moving backwards through the
    ;; buffer, and inform the caller of the scenario detected.
    ;;
    ;; HERE is the position we're setting `c-state-cache' for.
!   ;; CACHE-POS (a locally bound variable) is just after the latest recorded
!   ;;   position in `c-state-cache' before HERE, or a position at or near
!   ;;   point-min which isn't in a literal.
    ;;
    ;; This function must only be called only when (> `c-state-cache-good-pos'
    ;; HERE).  Usually the gap between CACHE-POS and HERE is large.  It is thus
***************
*** 3023,3032 ****
    ;; The comments in this defun use "paren" to mean parenthesis or square
    ;; bracket (as contrasted with a brace), and "(" and ")" likewise.
    ;;
!   ;;    .   {..} (..) (..)  ( .. {   }  ) (...)    ( ....          .  ..)
!   ;;    |                   |       |   |     |                    |
!   ;;    CP                  E      here D     C                   good
!   (let ((pos c-state-cache-good-pos)
  	pa ren	       ; positions of "(" and ")"
  	dropped-cons ; whether the last element dropped from `c-state-cache'
  		     ; was a cons (representing a brace-pair)
--- 3030,3040 ----
    ;; The comments in this defun use "paren" to mean parenthesis or square
    ;; bracket (as contrasted with a brace), and "(" and ")" likewise.
    ;;
!   ;;	.   {..} (..) (..)  ( .. {   }	) (...)	   ( ....	   .  ..)
!   ;;	|		    |	    |	|     |			   |
!   ;;	CP		    E	   here D     C			  good
!   (let ((cache-pos (c-get-cache-scan-pos here))	; highest position below HERE in cache (or 1)
! 	(pos c-state-cache-good-pos)
  	pa ren	       ; positions of "(" and ")"
  	dropped-cons ; whether the last element dropped from `c-state-cache'
  		     ; was a cons (representing a brace-pair)
***************
*** 3263,3269 ****
  	 cache-pos	     ; highest position below HERE already existing in
  			     ; cache (or 1).
  	 good-pos
! 	 start-point
  	 bopl-state
  	 res
  	 scan-backward-pos scan-forward-p) ; used for 'backward.
--- 3271,3278 ----
  	 cache-pos	     ; highest position below HERE already existing in
  			     ; cache (or 1).
  	 good-pos
! 	 start-point ; (when scanning forward) a place below HERE where there
! 		     ; are no open parens/braces between it and HERE.
  	 bopl-state
  	 res
  	 scan-backward-pos scan-forward-p) ; used for 'backward.
***************
*** 3274,3281 ****
      ;; Strategy?
      (setq res (c-parse-state-get-strategy here c-state-cache-good-pos)
  	  strategy (car res)
! 	  cache-pos (cadr res)
! 	  start-point (nth 2 res))
  
      (when (eq strategy 'BOD)
        (setq c-state-cache nil
--- 3283,3289 ----
      ;; Strategy?
      (setq res (c-parse-state-get-strategy here c-state-cache-good-pos)
  	  strategy (car res)
! 	  start-point (cadr res))
  
      (when (eq strategy 'BOD)
        (setq c-state-cache nil
***************
*** 3302,3308 ****
  		good-pos)))
  
         ((eq strategy 'backward)
! 	(setq res (c-remove-stale-state-cache-backwards here cache-pos)
  	      good-pos (car res)
  	      scan-backward-pos (cadr res)
  	      scan-forward-p (car (cddr res)))
--- 3310,3316 ----
  		good-pos)))
  
         ((eq strategy 'backward)
! 	(setq res (c-remove-stale-state-cache-backwards here)
  	      good-pos (car res)
  	      scan-backward-pos (cadr res)
  	      scan-forward-p (car (cddr res)))



> -- 
> Michael Welsh Duggan
> (mwd <at> cert.org)

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Wed, 23 Jan 2013 15:42:02 GMT) Full text and rfc822 format available.

Message #148 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Michael Welsh Duggan <mwd <at> cert.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: "11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Wed, 23 Jan 2013 10:39:34 -0500
Alan Mackenzie <acm <at> muc.de> writes:

> Hi, Michael.
>
> On Thu, Jan 17, 2013 at 11:27:04AM -0500, Michael Welsh Duggan wrote:
>> Alan Mackenzie <acm <at> muc.de> writes:
>
>> [This] fixes this case, indeed.  Unfortunately, here's another.
>

[...]

> I think the following patch should fix that glitch.  I've also taken the
> opportunity to simplify things a little (part of the global state was
> being passed needlessly as a parameter) and to rename some variables for
> more consistency.
>
> Would you try this out and confirm it works, as usual, please.

I can confirm that this fixes this particular problem.

> However, this isn't the end of the story - 
>
> (i) Start your test case in rwtransfer.c, and M-v until the top of the
>   file.  (This shouldn't display any inconsistency messages)
> (ii) M-x goto-char <ret> 20001 <ret>.  This should go to EOL 671, just
>   after a "}".
> (iii) Type <space> }.  (Two characters)
> (iv) C-v, possibly twice.
>
> This displays a message something like:
>     c-parse-state inconsistency at 21070: using cache: ((20458 . 20935)),
>     from scratch: ((20838 . 20877))
> , together with a state dump.
>
> This bug isn't a new one, but I've just come across it.  I'll be working
> on it in the meantime.

Oh, good.  I haven't reported any "type stuff" errors I have been
getting because they are harder to reproduce.  (Unless it is triggered
the first time you've typed in the buffer, it's hard to replicate the
exact scenario.)  I usually wait until you've fixed the last thing I
sent in before attempting to report another, just in case the thing you
are fixing is related.

-- 
Michael Welsh Duggan
(mwd <at> cert.org)




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Tue, 29 Jan 2013 11:46:02 GMT) Full text and rfc822 format available.

Message #151 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Michael Welsh Duggan <mwd <at> cert.org>
Cc: "11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1; C-mode indentation gives
	wrong-type-argument error.)
Date: Tue, 29 Jan 2013 11:37:37 +0000
Hi, Michael.

On Wed, Jan 23, 2013 at 10:39:34AM -0500, Michael Welsh Duggan wrote:
> Alan Mackenzie <acm <at> muc.de> writes:

> > However, this isn't the end of the story - 

> > (i) Start your test case in rwtransfer.c, and M-v until the top of the
> >   file.  (This shouldn't display any inconsistency messages)
> > (ii) M-x goto-char <ret> 20001 <ret>.  This should go to EOL 671, just
> >   after a "}".
> > (iii) Type <space> }.  (Two characters)
> > (iv) C-v, possibly twice.

> > This displays a message something like:
> >     c-parse-state inconsistency at 21070: using cache: ((20458 . 20935)),
> >     from scratch: ((20838 . 20877))
> > , together with a state dump.

> > This bug isn't a new one, but I've just come across it.  I'll be working
> > on it in the meantime.

> Oh, good.  I haven't reported any "type stuff" errors I have been
> getting because they are harder to reproduce.  (Unless it is triggered
> the first time you've typed in the buffer, it's hard to replicate the
> exact scenario.)  I usually wait until you've fixed the last thing I
> sent in before attempting to report another, just in case the thing you
> are fixing is related.

OK, I think I've fixed that above bug.  I've also done a moderate amount
of refactoring to simplify things for the next bug, if any.

I've removed the scanning strategy "start at the 2nd previous column-0
beginning-of-defun", because it was returning false results, even in C
Mode.  I'd already disabled it for C++ Mode (because hackers frequently
put things inside namespaces at column 0).  One consequence is that
running with `c-toggle-parse-state-debug' is somewhat slower.  Sorry for
that.

Could you try this new version, please.  The patch is based on the
emacs-24 branch of the savannah bzr repository.  This should be identical
to the trunk.



=== modified file 'lisp/progmodes/cc-engine.el'
*** lisp/progmodes/cc-engine.el	2013-01-23 18:58:11 +0000
--- lisp/progmodes/cc-engine.el	2013-01-29 11:03:35 +0000
***************
*** 2477,2496 ****
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;; Defuns which analyze the buffer, yet don't change `c-state-cache'.
- (defun c-get-fallback-scan-pos (here)
-   ;; Return a start position for building `c-state-cache' from
-   ;; scratch.  This will be at the top level, 2 defuns back.
-   (save-excursion
-     ;; Go back 2 bods, but ignore any bogus positions returned by
-     ;; beginning-of-defun (i.e. open paren in column zero).
-     (goto-char here)
-     (let ((cnt 2))
-       (while (not (or (bobp) (zerop cnt)))
- 	(c-beginning-of-defun-1)	; Pure elisp BOD.
- 	(if (eq (char-after) ?\{)
- 	    (setq cnt (1- cnt)))))
-     (point)))
- 
  (defun c-state-balance-parens-backwards (here- here+ top)
    ;; Return the position of the opening paren/brace/bracket before HERE- which
    ;; matches the outermost close p/b/b between HERE+ and TOP.  Except when
--- 2477,2482 ----
***************
*** 2548,2594 ****
    ;; o - ('forward START-POINT) - scan forward from START-POINT,
    ;;	 which is not less than the highest position in `c-state-cache' below here.
    ;; o - ('backward nil) - scan backwards (from HERE).
-   ;; o - ('BOD START-POINT) - scan forwards from START-POINT, which is at the
-   ;;   top level.
    ;; o - ('IN-LIT nil) - point is inside the literal containing point-min.
    (let ((cache-pos (c-get-cache-scan-pos here))	; highest position below HERE in cache (or 1)
! 	BOD-pos		    ; position of 2nd BOD before HERE.
! 	strategy	    ; 'forward, 'backward, 'BOD, or 'IN-LIT.
! 	start-point
! 	how-far)			; putative scanning distance.
      (setq good-pos (or good-pos (c-state-get-min-scan-pos)))
      (cond
       ((< here (c-state-get-min-scan-pos))
!       (setq strategy 'IN-LIT
! 	    start-point nil
! 	    cache-pos nil
! 	    how-far 0))
       ((<= good-pos here)
        (setq strategy 'forward
! 	    start-point (max good-pos cache-pos)
! 	    how-far (- here start-point)))
       ((< (- good-pos here) (- here cache-pos)) ; FIXME!!! ; apply some sort of weighting.
!       (setq strategy 'backward
! 	    how-far (- good-pos here)))
       (t
        (setq strategy 'forward
! 	      how-far (- here cache-pos)
! 	      start-point cache-pos)))
! 
!     ;; Might we be better off starting from the top level, two defuns back,
!     ;; 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
! 		start-point BOD-pos)))
! 
!     (list
!      strategy
!      (and (memq strategy '(forward BOD)) start-point))))
  
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
--- 2534,2556 ----
    ;; o - ('forward START-POINT) - scan forward from START-POINT,
    ;;	 which is not less than the highest position in `c-state-cache' below here.
    ;; o - ('backward nil) - scan backwards (from HERE).
    ;; o - ('IN-LIT nil) - point is inside the literal containing point-min.
    (let ((cache-pos (c-get-cache-scan-pos here))	; highest position below HERE in cache (or 1)
! 	strategy	    ; 'forward, 'backward, or 'IN-LIT.
! 	start-point)
      (setq good-pos (or good-pos (c-state-get-min-scan-pos)))
      (cond
       ((< here (c-state-get-min-scan-pos))
!       (setq strategy 'IN-LIT))
       ((<= good-pos here)
        (setq strategy 'forward
! 	    start-point (max good-pos cache-pos)))
       ((< (- good-pos here) (- here cache-pos)) ; FIXME!!! ; apply some sort of weighting.
!       (setq strategy 'backward))
       (t
        (setq strategy 'forward
! 	    start-point cache-pos)))
!     (list strategy (and (eq strategy 'forward) start-point))))
  
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
***************
*** 2630,2636 ****
  
    (setq c-state-point-min (point-min)))
  
! (defun c-append-lower-brace-pair-to-state-cache (from &optional upper-lim)
    ;; If there is a brace pair preceding FROM in the buffer, at the same level
    ;; of nesting (not necessarily immediately preceding), push a cons onto
    ;; `c-state-cache' to represent it.  FROM must not be inside a literal.  If
--- 2592,2598 ----
  
    (setq c-state-point-min (point-min)))
  
! (defun c-append-lower-brace-pair-to-state-cache (from here &optional upper-lim)
    ;; If there is a brace pair preceding FROM in the buffer, at the same level
    ;; of nesting (not necessarily immediately preceding), push a cons onto
    ;; `c-state-cache' to represent it.  FROM must not be inside a literal.  If
***************
*** 2654,2661 ****
    ;; reduce the time wasted in repeated fruitless searches in brace deserts.
    (save-excursion
      (save-restriction
!       (let* ((here (point-max))
! 	     new-cons
  	     (cache-pos (c-state-cache-top-lparen)) ; might be nil.
  	     (macro-start-or-from
  	      (progn (goto-char from)
--- 2616,2622 ----
    ;; 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)
***************
*** 2690,2696 ****
  		;; search bound, even though the algorithm below would skip
  		;; over the new paren pair.
  		(cache-lim (and cache-pos (< cache-pos from) cache-pos)))
- 	    (widen)
  	    (narrow-to-region
  		(cond
  		 ((and desert-lim cache-lim)
--- 2651,2656 ----
***************
*** 2698,2704 ****
  		 (desert-lim)
  		 (cache-lim)
  		 ((point-min)))
! 		(point-max)))
  
  	  ;; In the next pair of nested loops, the inner one moves back past a
  	  ;; pair of (mis-)matching parens or brackets; the outer one moves
--- 2658,2666 ----
  		 (desert-lim)
  		 (cache-lim)
  		 ((point-min)))
! 		;; The top limit is EOB to ensure that `bra' is inside the
! 		;; accessible part of the buffer at the next scan operation.
! 		(1+ (buffer-size))))
  
  	  ;; In the next pair of nested loops, the inner one moves back past a
  	  ;; pair of (mis-)matching parens or brackets; the outer one moves
***************
*** 2765,2789 ****
  		      (if (consp (car c-state-cache))
  			  (cdr c-state-cache)
  			c-state-cache)))
! 	;; N.B.  This defsubst codes one method for the simple, normal case,
  	;; and a more sophisticated, slower way for the general case.  Don't
  	;; eliminate this defsubst - it's a speed optimization.
! 	(c-append-lower-brace-pair-to-state-cache (1- bra+1)))))
  
! (defun c-append-to-state-cache (from)
!   ;; Scan the buffer from FROM to (point-max), adding elements into
!   ;; `c-state-cache' for braces etc.  Return a candidate for
!   ;; `c-state-cache-good-pos'.
    ;;
    ;; FROM must be after the latest brace/paren/bracket in `c-state-cache', if
    ;; any.  Typically, it is immediately after it.  It must not be inside a
    ;; literal.
!   (let ((here-bol (c-point 'bol (point-max)))
  	(macro-start-or-here
! 	 (save-excursion (goto-char (point-max))
  			 (if (c-beginning-of-macro)
  			     (point)
! 			   (point-max))))
  	pa+1		      ; pos just after an opening PAren (or brace).
  	(ren+1 from)	      ; usually a pos just after an closing paREN etc.
  			      ; Is actually the pos. to scan for a (/{/[ from,
--- 2727,2750 ----
  		      (if (consp (car c-state-cache))
  			  (cdr c-state-cache)
  			c-state-cache)))
! 	;; N.B.	 This defsubst codes one method for the simple, normal case,
  	;; and a more sophisticated, slower way for the general case.  Don't
  	;; eliminate this defsubst - it's a speed optimization.
! 	(c-append-lower-brace-pair-to-state-cache (1- bra+1) (point-max)))))
  
! (defun c-append-to-state-cache (from here)
!   ;; Scan the buffer from FROM to HERE, adding elements into `c-state-cache'
!   ;; for braces etc.  Return a candidate for `c-state-cache-good-pos'.
    ;;
    ;; FROM must be after the latest brace/paren/bracket in `c-state-cache', if
    ;; any.  Typically, it is immediately after it.  It must not be inside a
    ;; literal.
!   (let ((here-bol (c-point 'bol here))
  	(macro-start-or-here
! 	 (save-excursion (goto-char here)
  			 (if (c-beginning-of-macro)
  			     (point)
! 			   here)))
  	pa+1		      ; pos just after an opening PAren (or brace).
  	(ren+1 from)	      ; usually a pos just after an closing paREN etc.
  			      ; Is actually the pos. to scan for a (/{/[ from,
***************
*** 2796,2870 ****
  	mstart)		      ; start of a macro.
  
      (save-excursion
!       ;; Each time round the following loop, we enter a successively deeper
!       ;; level of brace/paren nesting.  (Except sometimes we "continue at
!       ;; the existing level".)  `pa+1' is a pos inside an opening
!       ;; brace/paren/bracket, usually just after it.
!       (while
! 	  (progn
! 	    ;; Each time round the next loop moves forward over an opening then
! 	    ;; a closing brace/bracket/paren.  This loop is white hot, so it
! 	    ;; plays ugly tricks to go fast.  DON'T PUT ANYTHING INTO THIS
! 	    ;; LOOP WHICH ISN'T ABSOLUTELY NECESSARY!!!  It terminates when a
! 	    ;; call of `scan-lists' signals an error, which happens when there
! 	    ;; are no more b/b/p's to scan.
! 	    (c-safe
! 	      (while t
! 		(setq pa+1 (scan-lists ren+1 1 -1) ; Into (/{/[; might signal
! 		      paren+1s (cons pa+1 paren+1s))
! 		(setq ren+1 (scan-lists pa+1 1 1)) ; Out of )/}/]; might signal
! 		(if (and (eq (char-before pa+1) ?{)) ; Check for a macro later.
! 		    (setq bra+1 pa+1))
! 		(setcar paren+1s ren+1)))
  
! 	    (if (and pa+1 (> pa+1 ren+1))
! 		;; We've just entered a deeper nesting level.
! 		(progn
! 		  ;; Insert the brace pair (if present) and the single open
! 		  ;; paren/brace/bracket into `c-state-cache' It cannot be
! 		  ;; inside a macro, except one around point, because of what
! 		  ;; `c-neutralize-syntax-in-CPP' has done.
! 		  (c-state-push-any-brace-pair bra+1 macro-start-or-here)
! 		  ;; Insert the opening brace/bracket/paren position.
! 		  (setq c-state-cache (cons (1- pa+1) c-state-cache))
! 		  ;; Clear admin stuff for the next more nested part of the scan.
! 		  (setq ren+1 pa+1  pa+1 nil  bra+1 nil  bra+1s nil)
! 		  t)			; Carry on the loop
! 
! 	      ;; All open p/b/b's at this nesting level, if any, have probably
! 	      ;; been closed by matching/mismatching ones.  We're probably
! 	      ;; finished - we just need to check for having found an
! 	      ;; unmatched )/}/], which we ignore.  Such a )/}/] can't be in a
! 	      ;; macro, due the action of `c-neutralize-syntax-in-CPP'.
! 	      (c-safe (setq ren+1 (scan-lists ren+1 1 1)))))) ; acts as loop control.
! 
!       ;; Record the final, innermost, brace-pair if there is one.
!       (c-state-push-any-brace-pair bra+1 macro-start-or-here)
! 
!       ;; Determine a good pos
!       (while (and (setq paren+1 (car paren+1s))
! 		  (> (if (> paren+1 macro-start-or-here)
! 			 paren+1
! 		       (goto-char paren+1)
! 		       (setq mstart (and (c-beginning-of-macro)
! 					 (point)))
! 		       (or mstart paren+1))
! 		     here-bol))
! 	(setq paren+1s (cdr paren+1s)))
!       (cond
!        ((and paren+1 mstart)
! 	(min paren+1 mstart))
!        (paren+1)
!        (t from)))))
  
! (defun c-remove-stale-state-cache (start-point pps-point)
    ;; Remove stale entries from the `c-cache-state', i.e. those which will
!   ;; not be in it when it is amended for position (point-max).
!   ;; Additionally, the "outermost" open-brace entry before (point-max)
!   ;; will be converted to a cons if the matching close-brace is scanned.
    ;;
    ;; START-POINT is a "maximal" "safe position" - there must be no open
!   ;; parens/braces/brackets between START-POINT and (point-max).
    ;;
    ;; As a second thing, calculate the result of parse-partial-sexp at
    ;; PPS-POINT, w.r.t. START-POINT.  The motivation here is that
--- 2757,2833 ----
  	mstart)		      ; start of a macro.
  
      (save-excursion
!       (save-restriction
! 	(narrow-to-region (point-min) here)
! 	;; Each time round the following loop, we enter a successively deeper
! 	;; level of brace/paren nesting.  (Except sometimes we "continue at
! 	;; the existing level".)  `pa+1' is a pos inside an opening
! 	;; brace/paren/bracket, usually just after it.
! 	(while
! 	    (progn
! 	      ;; Each time round the next loop moves forward over an opening then
! 	      ;; a closing brace/bracket/paren.  This loop is white hot, so it
! 	      ;; plays ugly tricks to go fast.  DON'T PUT ANYTHING INTO THIS
! 	      ;; LOOP WHICH ISN'T ABSOLUTELY NECESSARY!!!  It terminates when a
! 	      ;; call of `scan-lists' signals an error, which happens when there
! 	      ;; are no more b/b/p's to scan.
! 	      (c-safe
! 		(while t
! 		  (setq pa+1 (scan-lists ren+1 1 -1) ; Into (/{/[; might signal
! 			paren+1s (cons pa+1 paren+1s))
! 		  (setq ren+1 (scan-lists pa+1 1 1)) ; Out of )/}/]; might signal
! 		  (if (and (eq (char-before pa+1) ?{)) ; Check for a macro later.
! 		      (setq bra+1 pa+1))
! 		  (setcar paren+1s ren+1)))
  
! 	      (if (and pa+1 (> pa+1 ren+1))
! 		  ;; We've just entered a deeper nesting level.
! 		  (progn
! 		    ;; Insert the brace pair (if present) and the single open
! 		    ;; paren/brace/bracket into `c-state-cache' It cannot be
! 		    ;; inside a macro, except one around point, because of what
! 		    ;; `c-neutralize-syntax-in-CPP' has done.
! 		    (c-state-push-any-brace-pair bra+1 macro-start-or-here)
! 		    ;; Insert the opening brace/bracket/paren position.
! 		    (setq c-state-cache (cons (1- pa+1) c-state-cache))
! 		    ;; Clear admin stuff for the next more nested part of the scan.
! 		    (setq ren+1 pa+1  pa+1 nil  bra+1 nil  bra+1s nil)
! 		    t)			; Carry on the loop
! 
! 		;; All open p/b/b's at this nesting level, if any, have probably
! 		;; been closed by matching/mismatching ones.  We're probably
! 		;; finished - we just need to check for having found an
! 		;; unmatched )/}/], which we ignore.  Such a )/}/] can't be in a
! 		;; macro, due the action of `c-neutralize-syntax-in-CPP'.
! 		(c-safe (setq ren+1 (scan-lists ren+1 1 1)))))) ; acts as loop control.
! 
! 	;; Record the final, innermost, brace-pair if there is one.
! 	(c-state-push-any-brace-pair bra+1 macro-start-or-here)
! 
! 	;; Determine a good pos
! 	(while (and (setq paren+1 (car paren+1s))
! 		    (> (if (> paren+1 macro-start-or-here)
! 			   paren+1
! 			 (goto-char paren+1)
! 			 (setq mstart (and (c-beginning-of-macro)
! 					   (point)))
! 			 (or mstart paren+1))
! 		       here-bol))
! 	  (setq paren+1s (cdr paren+1s)))
! 	(cond
! 	 ((and paren+1 mstart)
! 	  (min paren+1 mstart))
! 	 (paren+1)
! 	 (t from))))))
  
! (defun c-remove-stale-state-cache (start-point here pps-point)
    ;; Remove stale entries from the `c-cache-state', i.e. those which will
!   ;; not be in it when it is amended for position HERE.  Additionally, the
!   ;; "outermost" open-brace entry before HERE will be converted to a cons if
!   ;; the matching close-brace is scanned.
    ;;
    ;; START-POINT is a "maximal" "safe position" - there must be no open
!   ;; parens/braces/brackets between START-POINT and HERE.
    ;;
    ;; As a second thing, calculate the result of parse-partial-sexp at
    ;; PPS-POINT, w.r.t. START-POINT.  The motivation here is that
***************
*** 2881,2903 ****
    ;;   last element to be removed from `c-state-cache', when that elt is a
    ;;   cons, otherwise nil.
    ;; o - PPS-STATE is the parse-partial-sexp state at PPS-POINT.
!   (save-restriction
!     (narrow-to-region 1 (point-max))
!     (save-excursion
!       (let* ((in-macro-start   ; start of macro containing (point-max) or nil.
  	      (save-excursion
! 		(goto-char (point-max))
  		(and (c-beginning-of-macro)
  		     (point))))
  	     (start-point-actual-macro-start ; Start of macro containing
  					     ; start-point or nil
! 	      (and (< start-point (point-max))
  		   (save-excursion
  		     (goto-char start-point)
  		     (and (c-beginning-of-macro)
  			  (point)))))
  	     (start-point-actual-macro-end ; End of this macro, (maybe
! 					; (point-max)), or nil.
  	      (and start-point-actual-macro-start
  		   (save-excursion
  		     (goto-char start-point-actual-macro-start)
--- 2844,2866 ----
    ;;   last element to be removed from `c-state-cache', when that elt is a
    ;;   cons, otherwise nil.
    ;; o - PPS-STATE is the parse-partial-sexp state at PPS-POINT.
!   (save-excursion
!     (save-restriction
!       (narrow-to-region 1 (point-max))
!       (let* ((in-macro-start   ; start of macro containing HERE or nil.
  	      (save-excursion
! 		(goto-char here)
  		(and (c-beginning-of-macro)
  		     (point))))
  	     (start-point-actual-macro-start ; Start of macro containing
  					     ; start-point or nil
! 	      (and (< start-point here)
  		   (save-excursion
  		     (goto-char start-point)
  		     (and (c-beginning-of-macro)
  			  (point)))))
  	     (start-point-actual-macro-end ; End of this macro, (maybe
! 					; HERE), or nil.
  	      (and start-point-actual-macro-start
  		   (save-excursion
  		     (goto-char start-point-actual-macro-start)
***************
*** 2909,2922 ****
  	     scan-back-pos
  	     pair-beg pps-point-state target-depth)
  
! 	;; Remove entries beyond (point-max).  Also remove any entries inside
! 	;; a macro, unless (point-max) is in the same macro.
  	(setq upper-lim
  	      (if (or (null c-state-old-cpp-beg)
! 		      (and (> (point-max) c-state-old-cpp-beg)
! 			   (< (point-max) c-state-old-cpp-end)))
! 		  (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)))
--- 2872,2885 ----
  	     scan-back-pos
  	     pair-beg pps-point-state target-depth)
  
! 	;; Remove entries beyond HERE.  Also remove any entries inside
! 	;; a macro, unless HERE is in the same macro.
  	(setq upper-lim
  	      (if (or (null c-state-old-cpp-beg)
! 		      (and (> here c-state-old-cpp-beg)
! 			   (< here c-state-old-cpp-end)))
! 		  here
! 		(min here 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)))
***************
*** 2934,2940 ****
  	;; time round; the corresponding elements in `c-state-cache' are
  	;; removed.  `pos' is just after the brace-pair or the open paren at
  	;; (car c-state-cache).	 There can be no open parens/braces/brackets
! 	;; between `start-point'/`start-point-actual-macro-start' and (point-max),
  	;; due to the interface spec to this function.
  	(setq pos (if (and start-point-actual-macro-end
  			   (not (eq start-point-actual-macro-start
--- 2897,2903 ----
  	;; time round; the corresponding elements in `c-state-cache' are
  	;; removed.  `pos' is just after the brace-pair or the open paren at
  	;; (car c-state-cache).	 There can be no open parens/braces/brackets
! 	;; between `start-point'/`start-point-actual-macro-start' and HERE,
  	;; due to the interface spec to this function.
  	(setq pos (if (and start-point-actual-macro-end
  			   (not (eq start-point-actual-macro-start
***************
*** 2944,2950 ****
  		    start-point))
  	(goto-char pos)
  	(while (and c-state-cache
! 		    (< (point) (point-max)))
  	  (cond
  	   ((null pps-state)		; first time through
  	    (setq target-depth -1))
--- 2907,2915 ----
  		    start-point))
  	(goto-char pos)
  	(while (and c-state-cache
! 		    (or (numberp (car c-state-cache)) ; Have we a { at all? 
! 			(cdr c-state-cache))
! 		    (< (point) here))
  	  (cond
  	   ((null pps-state)		; first time through
  	    (setq target-depth -1))
***************
*** 2956,2962 ****
  	  ;; Scan!
  	  (setq pps-state
  		(parse-partial-sexp
! 		 (point) (if (< (point) pps-point) pps-point (point-max))
  		 target-depth
  		 nil pps-state))
  
--- 2921,2927 ----
  	  ;; Scan!
  	  (setq pps-state
  		(parse-partial-sexp
! 		 (point) (if (< (point) pps-point) pps-point here)
  		 target-depth
  		 nil pps-state))
  
***************
*** 3209,3215 ****
        ;; Do we need to add in an earlier brace pair, having lopped one off?
        (if (and dropped-cons
  	       (< too-high-pa (+ here c-state-cache-too-far)))
! 	  (c-append-lower-brace-pair-to-state-cache too-high-pa here-bol))
        (setq c-state-cache-good-pos (or (c-state-cache-after-top-paren)
  				       (c-state-get-min-scan-pos)))))
  
--- 3174,3180 ----
        ;; Do we need to add in an earlier brace pair, having lopped one off?
        (if (and dropped-cons
  	       (< too-high-pa (+ here c-state-cache-too-far)))
! 	  (c-append-lower-brace-pair-to-state-cache too-high-pa here here-bol))
        (setq c-state-cache-good-pos (or (c-state-cache-after-top-paren)
  				       (c-state-get-min-scan-pos)))))
  
***************
*** 3285,3331 ****
  	  strategy (car res)
  	  start-point (cadr res))
  
-     (when (eq strategy 'BOD)
-       (setq c-state-cache nil
- 	    c-state-cache-good-pos start-point))
- 
      ;; SCAN!
!     (save-restriction
!       (cond
!        ((memq strategy '(forward BOD))
! 	(narrow-to-region (point-min) here)
! 	(setq res (c-remove-stale-state-cache start-point here-bopl))
! 	(setq cache-pos (car res)
! 	      scan-backward-pos (cadr res)
! 	      bopl-state (car (cddr res))) ; will be nil if (< here-bopl
  					; start-point)
! 	(if scan-backward-pos
! 	    (c-append-lower-brace-pair-to-state-cache scan-backward-pos))
! 	(setq good-pos
! 	      (c-append-to-state-cache cache-pos))
! 	(setq c-state-cache-good-pos
! 	      (if (and bopl-state
! 		       (< good-pos (- here c-state-cache-too-far)))
! 		  (c-state-cache-non-literal-place here-bopl bopl-state)
! 		good-pos)))
! 
!        ((eq strategy 'backward)
! 	(setq res (c-remove-stale-state-cache-backwards here)
! 	      good-pos (car res)
! 	      scan-backward-pos (cadr res)
! 	      scan-forward-p (car (cddr res)))
! 	(if scan-backward-pos
! 	    (c-append-lower-brace-pair-to-state-cache
! 	     scan-backward-pos))
! 	(setq c-state-cache-good-pos
! 	      (if scan-forward-p
! 		  (progn (narrow-to-region (point-min) here)
! 			 (c-append-to-state-cache good-pos))
! 		good-pos)))
  
!        (t ; (eq strategy 'IN-LIT)
! 	(setq c-state-cache nil
! 	      c-state-cache-good-pos nil)))))
  
    c-state-cache)
  
--- 3250,3288 ----
  	  strategy (car res)
  	  start-point (cadr res))
  
      ;; SCAN!
!     (cond
!      ((eq strategy 'forward)
!       (setq res (c-remove-stale-state-cache start-point here here-bopl))
!       (setq cache-pos (car res)
! 	    scan-backward-pos (cadr res)
! 	    bopl-state (car (cddr res))) ; will be nil if (< here-bopl
  					; start-point)
!       (if scan-backward-pos
! 	  (c-append-lower-brace-pair-to-state-cache scan-backward-pos here))
!       (setq good-pos
! 	    (c-append-to-state-cache cache-pos here))
!       (setq c-state-cache-good-pos
! 	    (if (and bopl-state
! 		     (< good-pos (- here c-state-cache-too-far)))
! 		(c-state-cache-non-literal-place here-bopl bopl-state)
! 	      good-pos)))
! 
!      ((eq strategy 'backward)
!       (setq res (c-remove-stale-state-cache-backwards here)
! 	    good-pos (car res)
! 	    scan-backward-pos (cadr res)
! 	    scan-forward-p (car (cddr res)))
!       (if scan-backward-pos
! 	  (c-append-lower-brace-pair-to-state-cache scan-backward-pos here))
!       (setq c-state-cache-good-pos
! 	    (if scan-forward-p
! 		(c-append-to-state-cache good-pos here)
! 	      good-pos)))
  
!      (t					; (eq strategy 'IN-LIT)
!       (setq c-state-cache nil
! 	    c-state-cache-good-pos nil))))
  
    c-state-cache)
  
***************
*** 8559,8566 ****
     ))
  
  (defun c-looking-at-special-brace-list (&optional lim)
!   ;; If we're looking at the start of a pike-style list, ie `({ })',
!   ;; `([ ])', `(< >)' etc, a cons of a cons of its starting and ending
    ;; positions and its entry in c-special-brace-lists is returned, nil
    ;; otherwise.  The ending position is nil if the list is still open.
    ;; LIM is the limit for forward search.  The point may either be at
--- 8516,8523 ----
     ))
  
  (defun c-looking-at-special-brace-list (&optional lim)
!   ;; If we're looking at the start of a pike-style list, ie `({ })',
!   ;; `([ ])', `(< >)' etc, a cons of a cons of its starting and ending
    ;; positions and its entry in c-special-brace-lists is returned, nil
    ;; otherwise.  The ending position is nil if the list is still open.
    ;; LIM is the limit for forward search.  The point may either be at


> -- 
> Michael Welsh Duggan
> (mwd <at> cert.org)

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Fri, 01 Feb 2013 22:20:02 GMT) Full text and rfc822 format available.

Message #154 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Michael Welsh Duggan <mwd <at> cert.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: "11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Fri, 01 Feb 2013 17:18:44 -0500
Alan Mackenzie <acm <at> muc.de> writes:

> Hi, Michael.

I've been running with this for a few days, and have yet to run into a
problem.  I'll let you know when/if I do in the future.


> On Wed, Jan 23, 2013 at 10:39:34AM -0500, Michael Welsh Duggan wrote:
>> Alan Mackenzie <acm <at> muc.de> writes:
>
>> > However, this isn't the end of the story - 
>
>> > (i) Start your test case in rwtransfer.c, and M-v until the top of the
>> >   file.  (This shouldn't display any inconsistency messages)
>> > (ii) M-x goto-char <ret> 20001 <ret>.  This should go to EOL 671, just
>> >   after a "}".
>> > (iii) Type <space> }.  (Two characters)
>> > (iv) C-v, possibly twice.
>
>> > This displays a message something like:
>> >     c-parse-state inconsistency at 21070: using cache: ((20458 . 20935)),
>> >     from scratch: ((20838 . 20877))
>> > , together with a state dump.
>
>> > This bug isn't a new one, but I've just come across it.  I'll be working
>> > on it in the meantime.
>
>> Oh, good.  I haven't reported any "type stuff" errors I have been
>> getting because they are harder to reproduce.  (Unless it is triggered
>> the first time you've typed in the buffer, it's hard to replicate the
>> exact scenario.)  I usually wait until you've fixed the last thing I
>> sent in before attempting to report another, just in case the thing you
>> are fixing is related.
>
> OK, I think I've fixed that above bug.  I've also done a moderate amount
> of refactoring to simplify things for the next bug, if any.
>
> I've removed the scanning strategy "start at the 2nd previous column-0
> beginning-of-defun", because it was returning false results, even in C
> Mode.  I'd already disabled it for C++ Mode (because hackers frequently
> put things inside namespaces at column 0).  One consequence is that
> running with `c-toggle-parse-state-debug' is somewhat slower.  Sorry for
> that.
>
> Could you try this new version, please.  The patch is based on the
> emacs-24 branch of the savannah bzr repository.  This should be identical
> to the trunk.
>
>
>
> === modified file 'lisp/progmodes/cc-engine.el'
> *** lisp/progmodes/cc-engine.el	2013-01-23 18:58:11 +0000
> --- lisp/progmodes/cc-engine.el	2013-01-29 11:03:35 +0000
> ***************
> *** 2477,2496 ****
>   
>   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>   ;; Defuns which analyze the buffer, yet don't change `c-state-cache'.
> - (defun c-get-fallback-scan-pos (here)
> -   ;; Return a start position for building `c-state-cache' from
> -   ;; scratch.  This will be at the top level, 2 defuns back.
> -   (save-excursion
> -     ;; Go back 2 bods, but ignore any bogus positions returned by
> -     ;; beginning-of-defun (i.e. open paren in column zero).
> -     (goto-char here)
> -     (let ((cnt 2))
> -       (while (not (or (bobp) (zerop cnt)))
> - 	(c-beginning-of-defun-1)	; Pure elisp BOD.
> - 	(if (eq (char-after) ?\{)
> - 	    (setq cnt (1- cnt)))))
> -     (point)))
> - 
>   (defun c-state-balance-parens-backwards (here- here+ top)
>     ;; Return the position of the opening paren/brace/bracket before HERE- which
>     ;; matches the outermost close p/b/b between HERE+ and TOP.  Except when
> --- 2477,2482 ----
> ***************
> *** 2548,2594 ****
>     ;; o - ('forward START-POINT) - scan forward from START-POINT,
>     ;;	 which is not less than the highest position in `c-state-cache' below here.
>     ;; o - ('backward nil) - scan backwards (from HERE).
> -   ;; o - ('BOD START-POINT) - scan forwards from START-POINT, which is at the
> -   ;;   top level.
>     ;; o - ('IN-LIT nil) - point is inside the literal containing point-min.
>     (let ((cache-pos (c-get-cache-scan-pos here))	; highest position below HERE in cache (or 1)
> ! 	BOD-pos		    ; position of 2nd BOD before HERE.
> ! 	strategy	    ; 'forward, 'backward, 'BOD, or 'IN-LIT.
> ! 	start-point
> ! 	how-far)			; putative scanning distance.
>       (setq good-pos (or good-pos (c-state-get-min-scan-pos)))
>       (cond
>        ((< here (c-state-get-min-scan-pos))
> !       (setq strategy 'IN-LIT
> ! 	    start-point nil
> ! 	    cache-pos nil
> ! 	    how-far 0))
>        ((<= good-pos here)
>         (setq strategy 'forward
> ! 	    start-point (max good-pos cache-pos)
> ! 	    how-far (- here start-point)))
>        ((< (- good-pos here) (- here cache-pos)) ; FIXME!!! ; apply some sort of weighting.
> !       (setq strategy 'backward
> ! 	    how-far (- good-pos here)))
>        (t
>         (setq strategy 'forward
> ! 	      how-far (- here cache-pos)
> ! 	      start-point cache-pos)))
> ! 
> !     ;; Might we be better off starting from the top level, two defuns back,
> !     ;; 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
> ! 		start-point BOD-pos)))
> ! 
> !     (list
> !      strategy
> !      (and (memq strategy '(forward BOD)) start-point))))
>   
>   
>   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> --- 2534,2556 ----
>     ;; o - ('forward START-POINT) - scan forward from START-POINT,
>     ;;	 which is not less than the highest position in `c-state-cache' below here.
>     ;; o - ('backward nil) - scan backwards (from HERE).
>     ;; o - ('IN-LIT nil) - point is inside the literal containing point-min.
>     (let ((cache-pos (c-get-cache-scan-pos here))	; highest position below HERE in cache (or 1)
> ! 	strategy	    ; 'forward, 'backward, or 'IN-LIT.
> ! 	start-point)
>       (setq good-pos (or good-pos (c-state-get-min-scan-pos)))
>       (cond
>        ((< here (c-state-get-min-scan-pos))
> !       (setq strategy 'IN-LIT))
>        ((<= good-pos here)
>         (setq strategy 'forward
> ! 	    start-point (max good-pos cache-pos)))
>        ((< (- good-pos here) (- here cache-pos)) ; FIXME!!! ; apply some sort of weighting.
> !       (setq strategy 'backward))
>        (t
>         (setq strategy 'forward
> ! 	    start-point cache-pos)))
> !     (list strategy (and (eq strategy 'forward) start-point))))
>   
>   
>   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ***************
> *** 2630,2636 ****
>   
>     (setq c-state-point-min (point-min)))
>   
> ! (defun c-append-lower-brace-pair-to-state-cache (from &optional upper-lim)
>     ;; If there is a brace pair preceding FROM in the buffer, at the same level
>     ;; of nesting (not necessarily immediately preceding), push a cons onto
>     ;; `c-state-cache' to represent it.  FROM must not be inside a literal.  If
> --- 2592,2598 ----
>   
>     (setq c-state-point-min (point-min)))
>   
> ! (defun c-append-lower-brace-pair-to-state-cache (from here &optional upper-lim)
>     ;; If there is a brace pair preceding FROM in the buffer, at the same level
>     ;; of nesting (not necessarily immediately preceding), push a cons onto
>     ;; `c-state-cache' to represent it.  FROM must not be inside a literal.  If
> ***************
> *** 2654,2661 ****
>     ;; reduce the time wasted in repeated fruitless searches in brace deserts.
>     (save-excursion
>       (save-restriction
> !       (let* ((here (point-max))
> ! 	     new-cons
>   	     (cache-pos (c-state-cache-top-lparen)) ; might be nil.
>   	     (macro-start-or-from
>   	      (progn (goto-char from)
> --- 2616,2622 ----
>     ;; 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)
> ***************
> *** 2690,2696 ****
>   		;; search bound, even though the algorithm below would skip
>   		;; over the new paren pair.
>   		(cache-lim (and cache-pos (< cache-pos from) cache-pos)))
> - 	    (widen)
>   	    (narrow-to-region
>   		(cond
>   		 ((and desert-lim cache-lim)
> --- 2651,2656 ----
> ***************
> *** 2698,2704 ****
>   		 (desert-lim)
>   		 (cache-lim)
>   		 ((point-min)))
> ! 		(point-max)))
>   
>   	  ;; In the next pair of nested loops, the inner one moves back past a
>   	  ;; pair of (mis-)matching parens or brackets; the outer one moves
> --- 2658,2666 ----
>   		 (desert-lim)
>   		 (cache-lim)
>   		 ((point-min)))
> ! 		;; The top limit is EOB to ensure that `bra' is inside the
> ! 		;; accessible part of the buffer at the next scan operation.
> ! 		(1+ (buffer-size))))
>   
>   	  ;; In the next pair of nested loops, the inner one moves back past a
>   	  ;; pair of (mis-)matching parens or brackets; the outer one moves
> ***************
> *** 2765,2789 ****
>   		      (if (consp (car c-state-cache))
>   			  (cdr c-state-cache)
>   			c-state-cache)))
> ! 	;; N.B.  This defsubst codes one method for the simple, normal case,
>   	;; and a more sophisticated, slower way for the general case.  Don't
>   	;; eliminate this defsubst - it's a speed optimization.
> ! 	(c-append-lower-brace-pair-to-state-cache (1- bra+1)))))
>   
> ! (defun c-append-to-state-cache (from)
> !   ;; Scan the buffer from FROM to (point-max), adding elements into
> !   ;; `c-state-cache' for braces etc.  Return a candidate for
> !   ;; `c-state-cache-good-pos'.
>     ;;
>     ;; FROM must be after the latest brace/paren/bracket in `c-state-cache', if
>     ;; any.  Typically, it is immediately after it.  It must not be inside a
>     ;; literal.
> !   (let ((here-bol (c-point 'bol (point-max)))
>   	(macro-start-or-here
> ! 	 (save-excursion (goto-char (point-max))
>   			 (if (c-beginning-of-macro)
>   			     (point)
> ! 			   (point-max))))
>   	pa+1		      ; pos just after an opening PAren (or brace).
>   	(ren+1 from)	      ; usually a pos just after an closing paREN etc.
>   			      ; Is actually the pos. to scan for a (/{/[ from,
> --- 2727,2750 ----
>   		      (if (consp (car c-state-cache))
>   			  (cdr c-state-cache)
>   			c-state-cache)))
> ! 	;; N.B.	 This defsubst codes one method for the simple, normal case,
>   	;; and a more sophisticated, slower way for the general case.  Don't
>   	;; eliminate this defsubst - it's a speed optimization.
> ! 	(c-append-lower-brace-pair-to-state-cache (1- bra+1) (point-max)))))
>   
> ! (defun c-append-to-state-cache (from here)
> !   ;; Scan the buffer from FROM to HERE, adding elements into `c-state-cache'
> !   ;; for braces etc.  Return a candidate for `c-state-cache-good-pos'.
>     ;;
>     ;; FROM must be after the latest brace/paren/bracket in `c-state-cache', if
>     ;; any.  Typically, it is immediately after it.  It must not be inside a
>     ;; literal.
> !   (let ((here-bol (c-point 'bol here))
>   	(macro-start-or-here
> ! 	 (save-excursion (goto-char here)
>   			 (if (c-beginning-of-macro)
>   			     (point)
> ! 			   here)))
>   	pa+1		      ; pos just after an opening PAren (or brace).
>   	(ren+1 from)	      ; usually a pos just after an closing paREN etc.
>   			      ; Is actually the pos. to scan for a (/{/[ from,
> ***************
> *** 2796,2870 ****
>   	mstart)		      ; start of a macro.
>   
>       (save-excursion
> !       ;; Each time round the following loop, we enter a successively deeper
> !       ;; level of brace/paren nesting.  (Except sometimes we "continue at
> !       ;; the existing level".)  `pa+1' is a pos inside an opening
> !       ;; brace/paren/bracket, usually just after it.
> !       (while
> ! 	  (progn
> ! 	    ;; Each time round the next loop moves forward over an opening then
> ! 	    ;; a closing brace/bracket/paren.  This loop is white hot, so it
> ! 	    ;; plays ugly tricks to go fast.  DON'T PUT ANYTHING INTO THIS
> ! 	    ;; LOOP WHICH ISN'T ABSOLUTELY NECESSARY!!!  It terminates when a
> ! 	    ;; call of `scan-lists' signals an error, which happens when there
> ! 	    ;; are no more b/b/p's to scan.
> ! 	    (c-safe
> ! 	      (while t
> ! 		(setq pa+1 (scan-lists ren+1 1 -1) ; Into (/{/[; might signal
> ! 		      paren+1s (cons pa+1 paren+1s))
> ! 		(setq ren+1 (scan-lists pa+1 1 1)) ; Out of )/}/]; might signal
> ! 		(if (and (eq (char-before pa+1) ?{)) ; Check for a macro later.
> ! 		    (setq bra+1 pa+1))
> ! 		(setcar paren+1s ren+1)))
>   
> ! 	    (if (and pa+1 (> pa+1 ren+1))
> ! 		;; We've just entered a deeper nesting level.
> ! 		(progn
> ! 		  ;; Insert the brace pair (if present) and the single open
> ! 		  ;; paren/brace/bracket into `c-state-cache' It cannot be
> ! 		  ;; inside a macro, except one around point, because of what
> ! 		  ;; `c-neutralize-syntax-in-CPP' has done.
> ! 		  (c-state-push-any-brace-pair bra+1 macro-start-or-here)
> ! 		  ;; Insert the opening brace/bracket/paren position.
> ! 		  (setq c-state-cache (cons (1- pa+1) c-state-cache))
> ! 		  ;; Clear admin stuff for the next more nested part of the scan.
> ! 		  (setq ren+1 pa+1  pa+1 nil  bra+1 nil  bra+1s nil)
> ! 		  t)			; Carry on the loop
> ! 
> ! 	      ;; All open p/b/b's at this nesting level, if any, have probably
> ! 	      ;; been closed by matching/mismatching ones.  We're probably
> ! 	      ;; finished - we just need to check for having found an
> ! 	      ;; unmatched )/}/], which we ignore.  Such a )/}/] can't be in a
> ! 	      ;; macro, due the action of `c-neutralize-syntax-in-CPP'.
> ! 	      (c-safe (setq ren+1 (scan-lists ren+1 1 1)))))) ; acts as loop control.
> ! 
> !       ;; Record the final, innermost, brace-pair if there is one.
> !       (c-state-push-any-brace-pair bra+1 macro-start-or-here)
> ! 
> !       ;; Determine a good pos
> !       (while (and (setq paren+1 (car paren+1s))
> ! 		  (> (if (> paren+1 macro-start-or-here)
> ! 			 paren+1
> ! 		       (goto-char paren+1)
> ! 		       (setq mstart (and (c-beginning-of-macro)
> ! 					 (point)))
> ! 		       (or mstart paren+1))
> ! 		     here-bol))
> ! 	(setq paren+1s (cdr paren+1s)))
> !       (cond
> !        ((and paren+1 mstart)
> ! 	(min paren+1 mstart))
> !        (paren+1)
> !        (t from)))))
>   
> ! (defun c-remove-stale-state-cache (start-point pps-point)
>     ;; Remove stale entries from the `c-cache-state', i.e. those which will
> !   ;; not be in it when it is amended for position (point-max).
> !   ;; Additionally, the "outermost" open-brace entry before (point-max)
> !   ;; will be converted to a cons if the matching close-brace is scanned.
>     ;;
>     ;; START-POINT is a "maximal" "safe position" - there must be no open
> !   ;; parens/braces/brackets between START-POINT and (point-max).
>     ;;
>     ;; As a second thing, calculate the result of parse-partial-sexp at
>     ;; PPS-POINT, w.r.t. START-POINT.  The motivation here is that
> --- 2757,2833 ----
>   	mstart)		      ; start of a macro.
>   
>       (save-excursion
> !       (save-restriction
> ! 	(narrow-to-region (point-min) here)
> ! 	;; Each time round the following loop, we enter a successively deeper
> ! 	;; level of brace/paren nesting.  (Except sometimes we "continue at
> ! 	;; the existing level".)  `pa+1' is a pos inside an opening
> ! 	;; brace/paren/bracket, usually just after it.
> ! 	(while
> ! 	    (progn
> ! 	      ;; Each time round the next loop moves forward over an opening then
> ! 	      ;; a closing brace/bracket/paren.  This loop is white hot, so it
> ! 	      ;; plays ugly tricks to go fast.  DON'T PUT ANYTHING INTO THIS
> ! 	      ;; LOOP WHICH ISN'T ABSOLUTELY NECESSARY!!!  It terminates when a
> ! 	      ;; call of `scan-lists' signals an error, which happens when there
> ! 	      ;; are no more b/b/p's to scan.
> ! 	      (c-safe
> ! 		(while t
> ! 		  (setq pa+1 (scan-lists ren+1 1 -1) ; Into (/{/[; might signal
> ! 			paren+1s (cons pa+1 paren+1s))
> ! 		  (setq ren+1 (scan-lists pa+1 1 1)) ; Out of )/}/]; might signal
> ! 		  (if (and (eq (char-before pa+1) ?{)) ; Check for a macro later.
> ! 		      (setq bra+1 pa+1))
> ! 		  (setcar paren+1s ren+1)))
>   
> ! 	      (if (and pa+1 (> pa+1 ren+1))
> ! 		  ;; We've just entered a deeper nesting level.
> ! 		  (progn
> ! 		    ;; Insert the brace pair (if present) and the single open
> ! 		    ;; paren/brace/bracket into `c-state-cache' It cannot be
> ! 		    ;; inside a macro, except one around point, because of what
> ! 		    ;; `c-neutralize-syntax-in-CPP' has done.
> ! 		    (c-state-push-any-brace-pair bra+1 macro-start-or-here)
> ! 		    ;; Insert the opening brace/bracket/paren position.
> ! 		    (setq c-state-cache (cons (1- pa+1) c-state-cache))
> ! 		    ;; Clear admin stuff for the next more nested part of the scan.
> ! 		    (setq ren+1 pa+1  pa+1 nil  bra+1 nil  bra+1s nil)
> ! 		    t)			; Carry on the loop
> ! 
> ! 		;; All open p/b/b's at this nesting level, if any, have probably
> ! 		;; been closed by matching/mismatching ones.  We're probably
> ! 		;; finished - we just need to check for having found an
> ! 		;; unmatched )/}/], which we ignore.  Such a )/}/] can't be in a
> ! 		;; macro, due the action of `c-neutralize-syntax-in-CPP'.
> ! 		(c-safe (setq ren+1 (scan-lists ren+1 1 1)))))) ; acts as loop control.
> ! 
> ! 	;; Record the final, innermost, brace-pair if there is one.
> ! 	(c-state-push-any-brace-pair bra+1 macro-start-or-here)
> ! 
> ! 	;; Determine a good pos
> ! 	(while (and (setq paren+1 (car paren+1s))
> ! 		    (> (if (> paren+1 macro-start-or-here)
> ! 			   paren+1
> ! 			 (goto-char paren+1)
> ! 			 (setq mstart (and (c-beginning-of-macro)
> ! 					   (point)))
> ! 			 (or mstart paren+1))
> ! 		       here-bol))
> ! 	  (setq paren+1s (cdr paren+1s)))
> ! 	(cond
> ! 	 ((and paren+1 mstart)
> ! 	  (min paren+1 mstart))
> ! 	 (paren+1)
> ! 	 (t from))))))
>   
> ! (defun c-remove-stale-state-cache (start-point here pps-point)
>     ;; Remove stale entries from the `c-cache-state', i.e. those which will
> !   ;; not be in it when it is amended for position HERE.  Additionally, the
> !   ;; "outermost" open-brace entry before HERE will be converted to a cons if
> !   ;; the matching close-brace is scanned.
>     ;;
>     ;; START-POINT is a "maximal" "safe position" - there must be no open
> !   ;; parens/braces/brackets between START-POINT and HERE.
>     ;;
>     ;; As a second thing, calculate the result of parse-partial-sexp at
>     ;; PPS-POINT, w.r.t. START-POINT.  The motivation here is that
> ***************
> *** 2881,2903 ****
>     ;;   last element to be removed from `c-state-cache', when that elt is a
>     ;;   cons, otherwise nil.
>     ;; o - PPS-STATE is the parse-partial-sexp state at PPS-POINT.
> !   (save-restriction
> !     (narrow-to-region 1 (point-max))
> !     (save-excursion
> !       (let* ((in-macro-start   ; start of macro containing (point-max) or nil.
>   	      (save-excursion
> ! 		(goto-char (point-max))
>   		(and (c-beginning-of-macro)
>   		     (point))))
>   	     (start-point-actual-macro-start ; Start of macro containing
>   					     ; start-point or nil
> ! 	      (and (< start-point (point-max))
>   		   (save-excursion
>   		     (goto-char start-point)
>   		     (and (c-beginning-of-macro)
>   			  (point)))))
>   	     (start-point-actual-macro-end ; End of this macro, (maybe
> ! 					; (point-max)), or nil.
>   	      (and start-point-actual-macro-start
>   		   (save-excursion
>   		     (goto-char start-point-actual-macro-start)
> --- 2844,2866 ----
>     ;;   last element to be removed from `c-state-cache', when that elt is a
>     ;;   cons, otherwise nil.
>     ;; o - PPS-STATE is the parse-partial-sexp state at PPS-POINT.
> !   (save-excursion
> !     (save-restriction
> !       (narrow-to-region 1 (point-max))
> !       (let* ((in-macro-start   ; start of macro containing HERE or nil.
>   	      (save-excursion
> ! 		(goto-char here)
>   		(and (c-beginning-of-macro)
>   		     (point))))
>   	     (start-point-actual-macro-start ; Start of macro containing
>   					     ; start-point or nil
> ! 	      (and (< start-point here)
>   		   (save-excursion
>   		     (goto-char start-point)
>   		     (and (c-beginning-of-macro)
>   			  (point)))))
>   	     (start-point-actual-macro-end ; End of this macro, (maybe
> ! 					; HERE), or nil.
>   	      (and start-point-actual-macro-start
>   		   (save-excursion
>   		     (goto-char start-point-actual-macro-start)
> ***************
> *** 2909,2922 ****
>   	     scan-back-pos
>   	     pair-beg pps-point-state target-depth)
>   
> ! 	;; Remove entries beyond (point-max).  Also remove any entries inside
> ! 	;; a macro, unless (point-max) is in the same macro.
>   	(setq upper-lim
>   	      (if (or (null c-state-old-cpp-beg)
> ! 		      (and (> (point-max) c-state-old-cpp-beg)
> ! 			   (< (point-max) c-state-old-cpp-end)))
> ! 		  (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)))
> --- 2872,2885 ----
>   	     scan-back-pos
>   	     pair-beg pps-point-state target-depth)
>   
> ! 	;; Remove entries beyond HERE.  Also remove any entries inside
> ! 	;; a macro, unless HERE is in the same macro.
>   	(setq upper-lim
>   	      (if (or (null c-state-old-cpp-beg)
> ! 		      (and (> here c-state-old-cpp-beg)
> ! 			   (< here c-state-old-cpp-end)))
> ! 		  here
> ! 		(min here 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)))
> ***************
> *** 2934,2940 ****
>   	;; time round; the corresponding elements in `c-state-cache' are
>   	;; removed.  `pos' is just after the brace-pair or the open paren at
>   	;; (car c-state-cache).	 There can be no open parens/braces/brackets
> ! 	;; between `start-point'/`start-point-actual-macro-start' and (point-max),
>   	;; due to the interface spec to this function.
>   	(setq pos (if (and start-point-actual-macro-end
>   			   (not (eq start-point-actual-macro-start
> --- 2897,2903 ----
>   	;; time round; the corresponding elements in `c-state-cache' are
>   	;; removed.  `pos' is just after the brace-pair or the open paren at
>   	;; (car c-state-cache).	 There can be no open parens/braces/brackets
> ! 	;; between `start-point'/`start-point-actual-macro-start' and HERE,
>   	;; due to the interface spec to this function.
>   	(setq pos (if (and start-point-actual-macro-end
>   			   (not (eq start-point-actual-macro-start
> ***************
> *** 2944,2950 ****
>   		    start-point))
>   	(goto-char pos)
>   	(while (and c-state-cache
> ! 		    (< (point) (point-max)))
>   	  (cond
>   	   ((null pps-state)		; first time through
>   	    (setq target-depth -1))
> --- 2907,2915 ----
>   		    start-point))
>   	(goto-char pos)
>   	(while (and c-state-cache
> ! 		    (or (numberp (car c-state-cache)) ; Have we a { at all? 
> ! 			(cdr c-state-cache))
> ! 		    (< (point) here))
>   	  (cond
>   	   ((null pps-state)		; first time through
>   	    (setq target-depth -1))
> ***************
> *** 2956,2962 ****
>   	  ;; Scan!
>   	  (setq pps-state
>   		(parse-partial-sexp
> ! 		 (point) (if (< (point) pps-point) pps-point (point-max))
>   		 target-depth
>   		 nil pps-state))
>   
> --- 2921,2927 ----
>   	  ;; Scan!
>   	  (setq pps-state
>   		(parse-partial-sexp
> ! 		 (point) (if (< (point) pps-point) pps-point here)
>   		 target-depth
>   		 nil pps-state))
>   
> ***************
> *** 3209,3215 ****
>         ;; Do we need to add in an earlier brace pair, having lopped one off?
>         (if (and dropped-cons
>   	       (< too-high-pa (+ here c-state-cache-too-far)))
> ! 	  (c-append-lower-brace-pair-to-state-cache too-high-pa here-bol))
>         (setq c-state-cache-good-pos (or (c-state-cache-after-top-paren)
>   				       (c-state-get-min-scan-pos)))))
>   
> --- 3174,3180 ----
>         ;; Do we need to add in an earlier brace pair, having lopped one off?
>         (if (and dropped-cons
>   	       (< too-high-pa (+ here c-state-cache-too-far)))
> ! 	  (c-append-lower-brace-pair-to-state-cache too-high-pa here here-bol))
>         (setq c-state-cache-good-pos (or (c-state-cache-after-top-paren)
>   				       (c-state-get-min-scan-pos)))))
>   
> ***************
> *** 3285,3331 ****
>   	  strategy (car res)
>   	  start-point (cadr res))
>   
> -     (when (eq strategy 'BOD)
> -       (setq c-state-cache nil
> - 	    c-state-cache-good-pos start-point))
> - 
>       ;; SCAN!
> !     (save-restriction
> !       (cond
> !        ((memq strategy '(forward BOD))
> ! 	(narrow-to-region (point-min) here)
> ! 	(setq res (c-remove-stale-state-cache start-point here-bopl))
> ! 	(setq cache-pos (car res)
> ! 	      scan-backward-pos (cadr res)
> ! 	      bopl-state (car (cddr res))) ; will be nil if (< here-bopl
>   					; start-point)
> ! 	(if scan-backward-pos
> ! 	    (c-append-lower-brace-pair-to-state-cache scan-backward-pos))
> ! 	(setq good-pos
> ! 	      (c-append-to-state-cache cache-pos))
> ! 	(setq c-state-cache-good-pos
> ! 	      (if (and bopl-state
> ! 		       (< good-pos (- here c-state-cache-too-far)))
> ! 		  (c-state-cache-non-literal-place here-bopl bopl-state)
> ! 		good-pos)))
> ! 
> !        ((eq strategy 'backward)
> ! 	(setq res (c-remove-stale-state-cache-backwards here)
> ! 	      good-pos (car res)
> ! 	      scan-backward-pos (cadr res)
> ! 	      scan-forward-p (car (cddr res)))
> ! 	(if scan-backward-pos
> ! 	    (c-append-lower-brace-pair-to-state-cache
> ! 	     scan-backward-pos))
> ! 	(setq c-state-cache-good-pos
> ! 	      (if scan-forward-p
> ! 		  (progn (narrow-to-region (point-min) here)
> ! 			 (c-append-to-state-cache good-pos))
> ! 		good-pos)))
>   
> !        (t ; (eq strategy 'IN-LIT)
> ! 	(setq c-state-cache nil
> ! 	      c-state-cache-good-pos nil)))))
>   
>     c-state-cache)
>   
> --- 3250,3288 ----
>   	  strategy (car res)
>   	  start-point (cadr res))
>   
>       ;; SCAN!
> !     (cond
> !      ((eq strategy 'forward)
> !       (setq res (c-remove-stale-state-cache start-point here here-bopl))
> !       (setq cache-pos (car res)
> ! 	    scan-backward-pos (cadr res)
> ! 	    bopl-state (car (cddr res))) ; will be nil if (< here-bopl
>   					; start-point)
> !       (if scan-backward-pos
> ! 	  (c-append-lower-brace-pair-to-state-cache scan-backward-pos here))
> !       (setq good-pos
> ! 	    (c-append-to-state-cache cache-pos here))
> !       (setq c-state-cache-good-pos
> ! 	    (if (and bopl-state
> ! 		     (< good-pos (- here c-state-cache-too-far)))
> ! 		(c-state-cache-non-literal-place here-bopl bopl-state)
> ! 	      good-pos)))
> ! 
> !      ((eq strategy 'backward)
> !       (setq res (c-remove-stale-state-cache-backwards here)
> ! 	    good-pos (car res)
> ! 	    scan-backward-pos (cadr res)
> ! 	    scan-forward-p (car (cddr res)))
> !       (if scan-backward-pos
> ! 	  (c-append-lower-brace-pair-to-state-cache scan-backward-pos here))
> !       (setq c-state-cache-good-pos
> ! 	    (if scan-forward-p
> ! 		(c-append-to-state-cache good-pos here)
> ! 	      good-pos)))
>   
> !      (t					; (eq strategy 'IN-LIT)
> !       (setq c-state-cache nil
> ! 	    c-state-cache-good-pos nil))))
>   
>     c-state-cache)
>   
> ***************
> *** 8559,8566 ****
>      ))
>   
>   (defun c-looking-at-special-brace-list (&optional lim)
> !   ;; If we're looking at the start of a pike-style list, ie `({ })',
> !   ;; `([ ])', `(< >)' etc, a cons of a cons of its starting and ending
>     ;; positions and its entry in c-special-brace-lists is returned, nil
>     ;; otherwise.  The ending position is nil if the list is still open.
>     ;; LIM is the limit for forward search.  The point may either be at
> --- 8516,8523 ----
>      ))
>   
>   (defun c-looking-at-special-brace-list (&optional lim)
> !   ;; If we're looking at the start of a pike-style list, ie `({ })',
> !   ;; `([ ])', `(< >)' etc, a cons of a cons of its starting and ending
>     ;; positions and its entry in c-special-brace-lists is returned, nil
>     ;; otherwise.  The ending position is nil if the list is still open.
>     ;; LIM is the limit for forward search.  The point may either be at
>
>
>> -- 
>> Michael Welsh Duggan
>> (mwd <at> cert.org)

-- 
Michael Welsh Duggan
(mwd <at> cert.org)




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Fri, 01 Feb 2013 23:52:02 GMT) Full text and rfc822 format available.

Message #157 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Kim Storm <storm <at> cua.dk>
To: Michael Welsh Duggan <mwd <at> cert.org>
Cc: Alan Mackenzie <acm <at> muc.de>,
	"11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>
Subject: Re: bug#11749: Acknowledgement (24.1;
	C-mode indentation gives wrong-type-argument error.)
Date: Sat, 02 Feb 2013 00:50:39 +0100
On 2013-02-01 23:18, Michael Welsh Duggan wrote:
> Alan Mackenzie <acm <at> muc.de> writes:
>
>> Hi, Michael.
> I've been running with this for a few days, and have yet to run into a
> problem.  I'll let you know when/if I do in the future.
>
>
Hi Alan

I have been running with the 24.2.91 pretest since it came out - and I 
have not run
into the problems I originally reported with the wrong-type-argument 
error in plain C sources.

So I assume that problem have been fixed  - or Murphy will tell me 
otherwise in 5 mintes :-).

Thank you
Kim




Reply sent to Alan Mackenzie <acm <at> muc.de>:
You have taken responsibility. (Sat, 02 Feb 2013 18:45:02 GMT) Full text and rfc822 format available.

Notification sent to storm <at> cua.dk (Kim F. Storm):
bug acknowledged by developer. (Sat, 02 Feb 2013 18:45:02 GMT) Full text and rfc822 format available.

Message #162 received at 11749-done <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: 11749-done <at> debbugs.gnu.org
Subject: Re: 24.1; C-mode indentation gives wrong-type-argument error.
Date: Sat, 2 Feb 2013 18:37:09 +0000
Bug fixed.




Reply sent to Alan Mackenzie <acm <at> muc.de>:
You have taken responsibility. (Sat, 02 Feb 2013 18:45:03 GMT) Full text and rfc822 format available.

Notification sent to Michael Welsh Duggan <md5i <at> md5i.com>:
bug acknowledged by developer. (Sat, 02 Feb 2013 18:45:03 GMT) Full text and rfc822 format available.

Reply sent to Alan Mackenzie <acm <at> muc.de>:
You have taken responsibility. (Sat, 02 Feb 2013 18:45:04 GMT) Full text and rfc822 format available.

Notification sent to Julian Stecklina <jsteckli <at> os.inf.tu-dresden.de>:
bug acknowledged by developer. (Sat, 02 Feb 2013 18:45:04 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11749; Package emacs,cc-mode. (Sat, 02 Feb 2013 19:44:01 GMT) Full text and rfc822 format available.

Message #175 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Kim Storm <storm <at> cua.dk>, Michael Welsh Duggan <mwd <at> cert.org>
Cc: "11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>
Subject: Re: bug#11749: Acknowledgement (24.1; C-mode indentation gives
	wrong-type-argument error.)
Date: Sat, 2 Feb 2013 19:35:56 +0000
Hi, Kim and Michael,

On Sat, Feb 02, 2013 at 12:50:39AM +0100, Kim Storm wrote:
> On 2013-02-01 23:18, Michael Welsh Duggan wrote:

> > I've been running with this for a few days, and have yet to run into a
> > problem.  I'll let you know when/if I do in the future.

It made my weekend, reading that.  :-)  Many thanks for all the testing
work.

> Hi Alan

> I have been running with the 24.2.91 pretest since it came out - and I 
> have not run
> into the problems I originally reported with the wrong-type-argument 
> error in plain C sources.

> So I assume that problem have been fixed  - or Murphy will tell me 
> otherwise in 5 minutes :-).

No, Murphy will wait until just after 24.3 has been released.  ;-(

Anyhow, I've closed bug#11749 as fixed.  Here's hoping that piece of CC
Mode code now has a modicum of stability about it.

> Thank you

Appreciated!

> Kim

-- 
Alan Mackenzie (Nuremberg, Germany).




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 04 Mar 2013 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 106 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.