# HG changeset patch # User Richard M. Stallman # Date 796290626 0 # Node ID 291aaa280603ad8e8d8bc44e6df6b61e0e8f32a7 # Parent 53e4f014e31c629337f3e2ba6041a278a8e4f571 (calculate-c++-indent): Copy colon-line-end code from calculate-c-indent. diff -r 53e4f014e31c -r 291aaa280603 lisp/progmodes/cplus-md.el --- 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