794 |
(setq indent (save-excursion |
(setq indent (save-excursion |
795 |
(c-backward-to-start-of-do) |
(c-backward-to-start-of-do) |
796 |
(current-indentation)))) |
(current-indentation)))) |
797 |
((= (following-char) ?}) |
((= (following-char) ?\}) |
798 |
(setq indent (- indent c-indent-level))) |
(setq indent (- indent c-indent-level))) |
799 |
((= (following-char) ?{) |
((= (following-char) ?\{) |
800 |
(setq indent (+ indent c-brace-offset)))))) |
(setq indent (+ indent c-brace-offset)))))) |
801 |
(skip-chars-forward " \t") |
(skip-chars-forward " \t") |
802 |
(setq shift-amt (- indent (current-column))) |
(setq shift-amt (- indent (current-column))) |
839 |
;; in which case this line is the first argument decl. |
;; in which case this line is the first argument decl. |
840 |
(goto-char indent-point) |
(goto-char indent-point) |
841 |
(skip-chars-forward " \t") |
(skip-chars-forward " \t") |
842 |
(if (= (following-char) ?{) |
(if (= (following-char) ?\{) |
843 |
0 ; Unless it starts a function body |
0 ; Unless it starts a function body |
844 |
(c-backward-to-noncomment (or parse-start (point-min))) |
(c-backward-to-noncomment (or parse-start (point-min))) |
845 |
;; Look at previous line that's at column 0 |
;; Look at previous line that's at column 0 |
907 |
;; (= (current-indentation) 0)) |
;; (= (current-indentation) 0)) |
908 |
;; 0 c-continued-statement-offset)) |
;; 0 c-continued-statement-offset)) |
909 |
|
|
910 |
((/= (char-after containing-sexp) ?{) |
((/= (char-after containing-sexp) ?\{) |
911 |
;; line is expression, not statement: |
;; line is expression, not statement: |
912 |
;; indent to just after the surrounding open. |
;; indent to just after the surrounding open. |
913 |
(goto-char (1+ containing-sexp)) |
(goto-char (1+ containing-sexp)) |
958 |
(save-excursion |
(save-excursion |
959 |
(goto-char indent-point) |
(goto-char indent-point) |
960 |
(skip-chars-forward " \t") |
(skip-chars-forward " \t") |
961 |
(not (= (following-char) ?})))) |
(not (= (following-char) ?\})))) |
962 |
;; This line is continuation of preceding line's statement; |
;; This line is continuation of preceding line's statement; |
963 |
;; indent c-continued-statement-offset more than the |
;; indent c-continued-statement-offset more than the |
964 |
;; previous line of the statement. |
;; previous line of the statement. |
967 |
(+ c-continued-statement-offset (current-column) |
(+ c-continued-statement-offset (current-column) |
968 |
(if (save-excursion (goto-char indent-point) |
(if (save-excursion (goto-char indent-point) |
969 |
(skip-chars-forward " \t") |
(skip-chars-forward " \t") |
970 |
(eq (following-char) ?{)) |
(eq (following-char) ?\{)) |
971 |
c-continued-brace-offset 0))) |
c-continued-brace-offset 0))) |
972 |
;; This line starts a new statement. |
;; This line starts a new statement. |
973 |
;; Position following last unclosed open. |
;; Position following last unclosed open. |
1124 |
;; is a close brace.) |
;; is a close brace.) |
1125 |
(if (save-excursion |
(if (save-excursion |
1126 |
(forward-sexp 1) |
(forward-sexp 1) |
1127 |
(or (and (not first) (= (preceding-char) ?})) |
(or (and (not first) (= (preceding-char) ?\})) |
1128 |
(search-forward ";" next-start t |
(search-forward ";" next-start t |
1129 |
(if (and first |
(if (and first |
1130 |
(/= (preceding-char) ?})) |
(/= (preceding-char) ?\})) |
1131 |
2 1)))) |
2 1)))) |
1132 |
(setq done 'fail) |
(setq done 'fail) |
1133 |
(setq first nil) |
(setq first nil) |
1345 |
;; Yes. |
;; Yes. |
1346 |
;; Compute the standard indent for this level. |
;; Compute the standard indent for this level. |
1347 |
(let (val) |
(let (val) |
1348 |
(if (= (char-after (car contain-stack)) ?{) |
(if (= (char-after (car contain-stack)) ?\{) |
1349 |
(save-excursion |
(save-excursion |
1350 |
(goto-char (car contain-stack)) |
(goto-char (car contain-stack)) |
1351 |
(setq val (calculate-c-indent-after-brace))) |
(setq val (calculate-c-indent-after-brace))) |
1361 |
;; Adjust indent of this individual line |
;; Adjust indent of this individual line |
1362 |
;; based on its predecessor. |
;; based on its predecessor. |
1363 |
;; Handle continuation lines, if, else, while, and so on. |
;; Handle continuation lines, if, else, while, and so on. |
1364 |
(if (/= (char-after (car contain-stack)) ?{) |
(if (/= (char-after (car contain-stack)) ?\{) |
1365 |
(setq this-indent (car indent-stack)) |
(setq this-indent (car indent-stack)) |
1366 |
;; Line is at statement level. |
;; Line is at statement level. |
1367 |
;; Is it a new statement? Is it an else? |
;; Is it a new statement? Is it an else? |
1370 |
(setq this-point (point)) |
(setq this-point (point)) |
1371 |
(setq at-else (and (looking-at "else\\b") |
(setq at-else (and (looking-at "else\\b") |
1372 |
(not (looking-at "else\\s_")))) |
(not (looking-at "else\\s_")))) |
1373 |
(setq at-brace (= (following-char) ?{)) |
(setq at-brace (= (following-char) ?\{)) |
1374 |
(setq at-while (and (looking-at "while\\b") |
(setq at-while (and (looking-at "while\\b") |
1375 |
(not (looking-at "while\\s_")))) |
(not (looking-at "while\\s_")))) |
1376 |
(if (= (following-char) ?}) |
(if (= (following-char) ?\}) |
1377 |
(setq this-indent (car indent-stack)) |
(setq this-indent (car indent-stack)) |
1378 |
(c-backward-to-noncomment opoint) |
(c-backward-to-noncomment opoint) |
1379 |
(if (not (memq (preceding-char) '(0 ?\, ?\; ?} ?: ?{))) |
(if (not (memq (preceding-char) '(0 ?\, ?\; ?\} ?: ?\{))) |
1380 |
;; Preceding line did not end in comma or semi; |
;; Preceding line did not end in comma or semi; |
1381 |
;; indent this line c-continued-statement-offset |
;; indent this line c-continued-statement-offset |
1382 |
;; more than previous. |
;; more than previous. |
1403 |
(forward-sexp 1) |
(forward-sexp 1) |
1404 |
(looking-at ":")))) |
(looking-at ":")))) |
1405 |
(setq this-indent (max 1 (+ this-indent c-label-offset)))) |
(setq this-indent (max 1 (+ this-indent c-label-offset)))) |
1406 |
(if (= (following-char) ?}) |
(if (= (following-char) ?\}) |
1407 |
(setq this-indent (- this-indent c-indent-level))) |
(setq this-indent (- this-indent c-indent-level))) |
1408 |
(if (= (following-char) ?{) |
(if (= (following-char) ?\{) |
1409 |
;; Don't move an open-brace in column 0. |
;; Don't move an open-brace in column 0. |
1410 |
;; This is good when constructs such as |
;; This is good when constructs such as |
1411 |
;; `extern "C" {' surround a function definition |
;; `extern "C" {' surround a function definition |
1437 |
(parse-partial-sexp beg (point) |
(parse-partial-sexp beg (point) |
1438 |
nil nil state))) |
nil nil state))) |
1439 |
(and (not (nth 3 new-state)) (not (nth 5 new-state)))) |
(and (not (nth 3 new-state)) (not (nth 5 new-state)))) |
1440 |
(indent-for-comment))))))))))))) |
(indent-for-comment))))))))))) |
1441 |
|
|
1442 |
;; Look at all comment-start strings in the current line after point. |
;; Look at all comment-start strings in the current line after point. |
1443 |
;; Return t if one of them starts a real comment. |
;; Return t if one of them starts a real comment. |