changeset 11128:291aaa280603

(calculate-c++-indent): Copy colon-line-end code from calculate-c-indent.
author Richard M. Stallman <rms@gnu.org>
date Mon, 27 Mar 1995 07:50:26 +0000
parents 53e4f014e31c
children 2ce4b0aac50c
files lisp/progmodes/cplus-md.el
diffstat 1 files changed, 31 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/cplus-md.el	Sun Mar 26 21:13:57 1995 +0000
+++ b/lisp/progmodes/cplus-md.el	Mon Mar 27 07:50:26 1995 +0000
@@ -529,26 +529,37 @@
 		 ;; If no, find that first statement and indent like it.
 		 (save-excursion
 		   (forward-char 1)
-		   (while (progn (skip-chars-forward " \t\n")
-				 (looking-at
-				  (concat
-				   "#\\|/\\*\\|//"
-				   "\\|case[ \t]"
-				   "\\|[a-zA-Z0-9_$]*:[^:]"
-				   "\\|friend[ \t]")))
-		     ;; Skip over comments and labels following openbrace.
-		     (cond ((= (following-char) ?\#)
-			    (forward-line 1))
-			   ((looking-at "/\\*")
-			    (search-forward "*/" nil 'move))
-			   ((looking-at "//\\|friend[ \t]")
-			    (forward-line 1))
-			   (t
-			    (re-search-forward ":[^:]" nil 'move))))
-		      ;; The first following code counts
-		      ;; if it is before the line we want to indent.
-		      (and (< (point) indent-point)
-			   (current-column)))
+		   (let ((colon-line-end 0))
+		     (while (progn (skip-chars-forward " \t\n")
+				   (looking-at
+				    (concat
+				     "#\\|/\\*\\|//"
+				     "\\|case[ \t]"
+				     "\\|[a-zA-Z0-9_$]*:[^:]"
+				     "\\|friend[ \t]")))
+		       ;; Skip over comments and labels following openbrace.
+		       (cond ((= (following-char) ?\#)
+			      (forward-line 1))
+			     ((looking-at "/\\*")
+			      (search-forward "*/" nil 'move))
+			     ((looking-at "//\\|friend[ \t]")
+			      (forward-line 1))
+			     (t
+			      (save-excursion (end-of-line)
+					      (setq colon-line-end (point)))
+			      (search-forward ":"))))
+		     ;; The first following code counts
+		     ;; if it is before the line we want to indent.
+		     (and (< (point) indent-point)
+			  (- 
+			   (if (> colon-line-end (point))
+			       (- (current-indentation) c-label-offset)
+			     (current-column))
+			   ;; If prev stmt starts with open-brace, that
+			   ;; open brace was offset by c-brace-offset.
+			   ;; Compensate to get the column where
+			   ;; an ordinary statement would start.
+			   (if (= (following-char) ?\{) c-brace-offset 0)))))
 		 ;; If no previous statement,
 		 ;; indent it relative to line brace is on.
 		 ;; For open brace in column zero, don't let statement