Subject: bug#7595: Infinite loop in cc-mode, or the coming of autumn

From: Daniel Colascione <[email-masked]>
Date: Sun, 06 Mar 2011 21:15:01 -0800

On 3/6/2011 9:00 PM, Chong Yidong wrote:
>> we will shall see if we just have to bite the bullet and continue
>> pretesting.  But if it does not trigger for realistic usage, I prefer
>> to leave matters as they are for 23.3---i.e. swapping one rare infloop
>> in 23.2 (Bug#7595) for a different one in 23.3 (the above).
> On reflection, it's probably better to revert the original fix for 7595,
> and go back to the (problematic) prior behavior.  As for the patch you
> proposed, it doesn't look obvious and safe enough to include at this
> late stage.

That's probably the safest course for now.  The original patch adds a 
fair amount of logic, and I'm not entirely convinced myself it's the 
right thing.

This simple workaround fixes the immediate issue raised in bug 7595:

=== modified file 'lisp/progmodes/cc-cmds.el'
--- lisp/progmodes/cc-cmds.el   2010-10-31 11:54:02 +0000
+++ lisp/progmodes/cc-cmds.el   2010-12-09 00:18:26 +0000
@@ -2616,6 +2616,11 @@
               (setq count 0)
               nil)

+             ((looking-at "^\\s-*#\\s-*$")
+              (setq count 0)
+              (end-of-line)
+              nil)
+
              (range                     ; point is within a literal.
               (cond
                ;; sentence-flag is null => skip the entire literal.