From 87ad8a11437752f3a5f7f1096328e3b9d11bba9f Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 22 Jul 2019 13:10:35 -0400 Subject: [PATCH] * lisp/progmodes/opascal.el: Allow inline `var` decl in `for` (bug#36348) (opascal-enclosing-indent-of): Ignore decls "neutered" by delimiter. --- lisp/progmodes/opascal.el | 7 +++++-- test/manual/indent/opascal.pas | 12 ++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 test/manual/indent/opascal.pas diff --git a/lisp/progmodes/opascal.el b/lisp/progmodes/opascal.el index 7d51816bf40..9bb62ced3bd 100644 --- a/lisp/progmodes/opascal.el +++ b/lisp/progmodes/opascal.el @@ -1177,8 +1177,11 @@ routine.") (throw 'done (opascal-stmt-line-indent-of (or last-token token) opascal-indent-level))) - ;; We indent relative to an enclosing declaration section. - ((opascal-is token-kind opascal-decl-sections) + ;; We indent relative to an enclosing declaration section, + ;; unless this is within the a delimited expression + ;; (bug#36348). + ((and (not expr-delimited) + (opascal-is token-kind opascal-decl-sections)) (throw 'done (opascal-indent-of (if last-token last-token token) opascal-indent-level))) diff --git a/test/manual/indent/opascal.pas b/test/manual/indent/opascal.pas new file mode 100644 index 00000000000..ac4beb3f840 --- /dev/null +++ b/test/manual/indent/opascal.pas @@ -0,0 +1,12 @@ +{ -*- opascal -*- } + +procedure Toto (); +begin + for i := 0 to 1 do + Write (str.Chars[i]); + + // bug#36348 + for var i := 0 to 1 do + Write (str.Chars[i]); + +end; -- 2.39.2