summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2012-12-11 19:06:57 +0000
committerAlan Mackenzie <acm@muc.de>2012-12-11 19:06:57 +0000
commit14b8c3d926ef813f621f95b0dcd059192d3d898c (patch)
tree5d7ae93d96cf43cbc3cd6887afbe7483bc7bc838
parentda187191154105389c8b6c8e538e34f3d22c588d (diff)
downloademacs-14b8c3d926ef813f621f95b0dcd059192d3d898c.tar.gz
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.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/progmodes/cc-engine.el17
2 files changed, 21 insertions, 2 deletions
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 <acm@muc.de>
+
+ 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 <fgallina@cuca>
* 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.