]> git.eshelyaron.com Git - emacs.git/commitdiff
(calculate-c++-indent): Copy colon-line-end code from calculate-c-indent.
authorRichard M. Stallman <rms@gnu.org>
Mon, 27 Mar 1995 07:50:26 +0000 (07:50 +0000)
committerRichard M. Stallman <rms@gnu.org>
Mon, 27 Mar 1995 07:50:26 +0000 (07:50 +0000)
lisp/progmodes/cplus-md.el

index 65ab5967a9be17d411e2cf15fea4d26e9197cb55..3d1173959c061791c146544b7bc2592a8c6781ca 100644 (file)
@@ -529,26 +529,37 @@ Returns nil if line starts inside a string, t if in a comment."
                 ;; 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