Alan Mackenzie avatar Alan Mackenzie committed e5984b8

Make CC Mode not hang when _some_ lines end in CRLF.
cc-engine.el (c-backward-comments): Add code to work around
`forward-comment' not recognizing ^M as whitespace.

Comments (0)

Files changed (1)

 	    ;; 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.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.