From: Simon South Date: Thu, 15 Jul 2010 03:12:37 +0000 (-0400) Subject: (delphi-previous-indent-of): Indent case blocks within record X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~438^2~51^2~46^2 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2c6a779afec9c223e3735d8f37dca5bbe8877f92;p=emacs.git (delphi-previous-indent-of): Indent case blocks within record declarations (i.e. variant parts) correctly. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 32fa19c26a9..54b7937c859 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2010-07-15 Simon South + + * progmodes/delphi.el (delphi-previous-indent-of): Indent case + blocks within record declarations (i.e. variant parts) correctly. + 2010-07-15 Simon South * 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: (setq token (delphi-block-start token))) ;; Regular block start found. - ((delphi-is token-kind delphi-block-statements) (throw 'done token)) + ((delphi-is token-kind delphi-block-statements) + (throw 'done + ;; As a special case, when a "case" block appears + ;; within a record declaration (to denote a variant + ;; part), the record declaration should be considered + ;; the enclosing block. + (if (eq 'case token-kind) + (let ((enclosing-token + (delphi-block-start token + 'stop-on-class))) + (if + (eq 'record + (delphi-token-kind enclosing-token)) + (if stop-on-class + enclosing-token + (delphi-previous-token enclosing-token)) + token)) + token))) ;; A class/record start also begins a block. ((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: (token-kind nil) (from-kind (delphi-token-kind from-token)) (last-colon nil) + (last-of nil) (last-token nil)) (catch 'done (while token @@ -1102,9 +1120,17 @@ non-delphi buffer. Set to nil in a delphi buffer. To override, just do: ;; Ignore whitespace. ((delphi-is token-kind delphi-whitespace)) - ;; Remember any ':' we encounter, since that affects how we indent to - ;; a case statement. - ((eq 'colon token-kind) (setq last-colon token)) + ;; Remember any "of" we encounter, since that affects how we + ;; indent to a case statement within a record declaration + ;; (i.e. a variant part). + ((eq 'of token-kind) + (setq last-of token)) + + ;; Remember any ':' we encounter (until we reach an "of"), + ;; since that affects how we indent to case statements in + ;; general. + ((eq 'colon token-kind) + (unless last-of (setq last-colon token))) ;; A case statement delimits a previous statement. We indent labels ;; specially.