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

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

bug#13046: 23.4; Minimal Example to freeze emacs C++ mode (nasty interac


From: John Smith
Subject: bug#13046: 23.4; Minimal Example to freeze emacs C++ mode (nasty interaction between templates & windows endline characters )
Date: Mon, 3 Dec 2012 09:54:51 +0100

Hello all,

I'm afraid my limited emacs knowledge will not allow me to test the patch. (Building fresh from source + patching the lisp => too much :) )
I trust however that it does!

Thanks for being so responsive.

Yours Sincerely,
John

On Sun, Dec 2, 2012 at 7:16 PM, Alan Mackenzie <acm@muc.de> wrote:
Hello Yidong, Vadim, John.

On Sun, Dec 02, 2012 at 10:13:47AM +0800, Chong Yidong wrote:
> John Smith <drefleladi@gmail.com> writes:

> > Using emacs -Q,just open the attached minimal example and try typing
> > "std::string" in the body of the function.
> > That should hang emacs forever (or at least it does on my up-to-date
> > ubuntu).

> I think this is a duplicate of Bug#11841.

> The patch posted in Bug#11841 does not completely fix this test case.
> Giving ^M whitespace syntax in CC mode, as Stefan suggested, seems like
> the easiest solution.  Alan, could you take another look?  It would be
> good to have this fixed in Emacs 24.3.

On Wed, Jul 25, 2012 at 11:58:22PM +0300, Vadim K wrote:
> Hello Alan,


> I've tried your patch and it worked fine for the original posted
> bad.cpp file. However I have found a variation of that file that still
> causes emacs to hang (see attached bad2.cpp).
[ Bug #11841 ]


I think the enclosed patch fixes these bugs.  Please try out the patch
and let us know if there are still any problems here.

The basic problem is that (forward-comment -1) doesn't recognise a CR
character as whitespace.  My first attempt to patch this, in July, was
only partly successful.

The specific problem was that (forward-comment -1) _sometimes_ goes back
over the LF in CRLF, sometimes not.  I've not discovered by what
criterion.



diff -r 1adcc48506f9 cc-engine.el
--- a/cc-engine.el      Sun Apr 22 09:42:29 2012 +0000
+++ b/cc-engine.el      Sun Dec 02 17:46:53 2012 +0000
@@ -1454,8 +1454,21 @@
            ;; return t when moving backwards at bob.
            (not (bobp))

-           (if (let (open-paren-in-column-0-is-defun-start)
-                 (forward-comment -1))
+           (if (let (open-paren-in-column-0-is-defun-start moved-comment)
+                 (while
+                     (and (not (setq moved-comment (forward-comment -1)))
+                     ;; Cope specifically with ^M^J here -
+                     ;; forward-comment sometimes gets stuck after ^Ms,
+                     ;; sometimes after ^M^J.
+                          (or
+                           (when (eq (char-before) ?\r)
+                             (backward-char)
+                             t)
+                           (when (and (eq (char-before) ?\n)
+                                      (eq (char-before (1- (point))) ?\r))
+                             (backward-char 2)
+                             t))))
+                 moved-comment)
                (if (looking-at "\\*/")
                    ;; Emacs <= 20 and XEmacs move back over the
                    ;; closer of a block comment that lacks an opener.



--
Alan Mackenzie (Nuremberg, Germany).


reply via email to

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