Hello again, Michael. On Tue, May 03, 2022 at 18:10:36 +0000, Alan Mackenzie wrote: > On Mon, May 02, 2022 at 15:30:09 -0400, Michael Welsh Duggan wrote: > > Package: cc-mode > > From emacs -Q: > > C-x C-f /tmp/foo.cpp RET > > M-x c-toggle-parse-state-debug RET > > "{} > > After typing the close brace, I get the following: > > c-parse-state inconsistency at 3: using cache: (2), from scratch: nil. POINT-MIN: 1 > > Old state: > > (setq c-state-cache '(2) c-state-cache-good-pos 1 c-state-nonlit-pos-cache nil c-state-nonlit-pos-cache-limit 0 c-state-brace-pair-desert nil 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 3) > > I have not noticed any indentation errors due to this, but any cache > > inconsistency might lead to errors down the line, hence this report. > Many thanks for the bug report. > This time it is not the cache mechanism itself which is at fault. > Instead, it is the first character ", which since it is unbalanced by > another ", has had its syntax is temporarily "commented out" by giving > it a syntax-table property of "punctuation". The parse-state cache was > generated whilst in this state, but used when it no longer was, hence > the inconsistency. > There are somewhere between 10 and 20 occurrences of c-parse-state in > the source code which will need to be "protected" against this fault. I > hope to be able to finish this work in the next two or three days, when > I'll get back to you again. There were actually 32 such occurrences, and they have generated a rather large patch which I am taking the liberty of just sending to you. The vast bulk of this patch is just putting (c-with-string-fences ....) around these functions, reindenting them. I've attached the patch as a separate file because it is so big. It should apply cleanly to the CC Mode in the Emacs savannah master version. Would you please apply it and try it out a bit, and let me know how well it works. Thanks! > > Emacs : GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0) > > of 2022-04-09 > > Package: CC Mode 5.35.1 (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) > > -- > > Michael Welsh Duggan > > (md5i@md5i.com) -- Alan Mackenzie (Nuremberg, Germany).