diff options
| author | Simon South | 2010-07-14 23:12:37 -0400 |
|---|---|---|
| committer | Simon South | 2010-07-14 23:12:37 -0400 |
| commit | 2c6a779afec9c223e3735d8f37dca5bbe8877f92 (patch) | |
| tree | 5e0cf8a1ede0315144de8c2744c819f06f1445c6 | |
| parent | a11b38eea2c4a15ecdaa29dcb66161e9d1143c05 (diff) | |
| download | emacs-2c6a779afec9c223e3735d8f37dca5bbe8877f92.tar.gz emacs-2c6a779afec9c223e3735d8f37dca5bbe8877f92.zip | |
(delphi-previous-indent-of): Indent case blocks within record
declarations (i.e. variant parts) correctly.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/progmodes/delphi.el | 34 |
2 files changed, 35 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 32fa19c26a9..54b7937c859 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2010-07-15 Simon South <ssouth@localhost.localdomain> | ||
| 2 | |||
| 3 | * progmodes/delphi.el (delphi-previous-indent-of): Indent case | ||
| 4 | blocks within record declarations (i.e. variant parts) correctly. | ||
| 5 | |||
| 1 | 2010-07-15 Simon South <ssouth@member.fsf.org> | 6 | 2010-07-15 Simon South <ssouth@member.fsf.org> |
| 2 | 7 | ||
| 3 | * progmodes/delphi.el (delphi-token-at): Give newlines precedence | 8 | * progmodes/delphi.el (delphi-token-at): Give newlines precedence |
diff --git a/lisp/progmodes/delphi.el b/lisp/progmodes/delphi.el index 03f74a42fd7..2558456bc07 100644 --- a/lisp/progmodes/delphi.el +++ b/lisp/progmodes/delphi.el | |||
| @@ -889,7 +889,24 @@ non-delphi buffer. Set to nil in a delphi buffer. To override, just do: | |||
| 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) |
| @@ -1059,6 +1076,7 @@ non-delphi buffer. Set to nil in a delphi buffer. To override, just do: | |||
| 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 |
| @@ -1102,9 +1120,17 @@ non-delphi buffer. Set to nil in a delphi buffer. To override, just do: | |||
| 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. |