From: Alan Mackenzie Date: Tue, 11 Dec 2012 19:06:57 +0000 (+0000) Subject: Make CC Mode not hang when _some_ lines end in CRLF. Bug #11841. X-Git-Tag: emacs-24.2.91~17 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=14b8c3d926ef813f621f95b0dcd059192d3d898c;p=emacs.git Make CC Mode not hang when _some_ lines end in CRLF. Bug #11841. cc-engine.el (c-backward-comments): Add code to work around `forward-comment' not recognizing ^M as whitespace. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c77cc286c76..fb75b3678c7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2012-12-11 Alan Mackenzie + + Make CC Mode not hang when _some_ lines end in CRLF. Bug #11841. + * progmodes/cc-engine.el (c-backward-comments): Add code to work + around `forward-comment' not recognizing ^M as whitespace. + 2012-12-11 Fabián Ezequiel Gallina * progmodes/python.el (python-skeleton-class) diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 10355451480..f7248e2d2d3 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -1452,8 +1452,21 @@ comment at the start of cc-engine.el for more info." ;; 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.