Mercurial > emacs
comparison lisp/progmodes/delphi.el @ 109401:f0baf5788e14
(delphi-previous-indent-of): Indent case blocks within record
declarations (i.e. variant parts) correctly.
author | Simon South <ssouth@member.fsf.org> |
---|---|
date | Wed, 14 Jul 2010 23:12:37 -0400 |
parents | c232035b5f44 |
children | b47e85affa59 |
comparison
equal
deleted
inserted
replaced
109400:c232035b5f44 | 109401:f0baf5788e14 |
---|---|
887 ;; Skip over nested blocks. | 887 ;; Skip over nested blocks. |
888 ((delphi-is token-kind delphi-end-block-statements) | 888 ((delphi-is token-kind delphi-end-block-statements) |
889 (setq token (delphi-block-start token))) | 889 (setq token (delphi-block-start token))) |
890 | 890 |
891 ;; Regular block start found. | 891 ;; Regular block start found. |
892 ((delphi-is token-kind delphi-block-statements) (throw 'done token)) | 892 ((delphi-is token-kind delphi-block-statements) |
893 (throw 'done | |
894 ;; As a special case, when a "case" block appears | |
895 ;; within a record declaration (to denote a variant | |
896 ;; part), the record declaration should be considered | |
897 ;; the enclosing block. | |
898 (if (eq 'case token-kind) | |
899 (let ((enclosing-token | |
900 (delphi-block-start token | |
901 'stop-on-class))) | |
902 (if | |
903 (eq 'record | |
904 (delphi-token-kind enclosing-token)) | |
905 (if stop-on-class | |
906 enclosing-token | |
907 (delphi-previous-token enclosing-token)) | |
908 token)) | |
909 token))) | |
893 | 910 |
894 ;; A class/record start also begins a block. | 911 ;; A class/record start also begins a block. |
895 ((delphi-composite-type-start token last-token) | 912 ((delphi-composite-type-start token last-token) |
896 (throw 'done (if stop-on-class last-token token))) | 913 (throw 'done (if stop-on-class last-token token))) |
897 ) | 914 ) |
1057 ;; Returns the indentation of the previous statement of the token. | 1074 ;; Returns the indentation of the previous statement of the token. |
1058 (let ((token (delphi-previous-token from-token)) | 1075 (let ((token (delphi-previous-token from-token)) |
1059 (token-kind nil) | 1076 (token-kind nil) |
1060 (from-kind (delphi-token-kind from-token)) | 1077 (from-kind (delphi-token-kind from-token)) |
1061 (last-colon nil) | 1078 (last-colon nil) |
1079 (last-of nil) | |
1062 (last-token nil)) | 1080 (last-token nil)) |
1063 (catch 'done | 1081 (catch 'done |
1064 (while token | 1082 (while token |
1065 (setq token-kind (delphi-token-kind token)) | 1083 (setq token-kind (delphi-token-kind token)) |
1066 (cond | 1084 (cond |
1100 (throw 'done (delphi-stmt-line-indent-of last-token 0))) | 1118 (throw 'done (delphi-stmt-line-indent-of last-token 0))) |
1101 | 1119 |
1102 ;; Ignore whitespace. | 1120 ;; Ignore whitespace. |
1103 ((delphi-is token-kind delphi-whitespace)) | 1121 ((delphi-is token-kind delphi-whitespace)) |
1104 | 1122 |
1105 ;; Remember any ':' we encounter, since that affects how we indent to | 1123 ;; Remember any "of" we encounter, since that affects how we |
1106 ;; a case statement. | 1124 ;; indent to a case statement within a record declaration |
1107 ((eq 'colon token-kind) (setq last-colon token)) | 1125 ;; (i.e. a variant part). |
1126 ((eq 'of token-kind) | |
1127 (setq last-of token)) | |
1128 | |
1129 ;; Remember any ':' we encounter (until we reach an "of"), | |
1130 ;; since that affects how we indent to case statements in | |
1131 ;; general. | |
1132 ((eq 'colon token-kind) | |
1133 (unless last-of (setq last-colon token))) | |
1108 | 1134 |
1109 ;; A case statement delimits a previous statement. We indent labels | 1135 ;; A case statement delimits a previous statement. We indent labels |
1110 ;; specially. | 1136 ;; specially. |
1111 ((eq 'case token-kind) | 1137 ((eq 'case token-kind) |
1112 (throw 'done | 1138 (throw 'done |