From 6515b3de9794e86c4ef8eb27ec161ee054a09df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Schmelzer?= Date: Tue, 12 Mar 2019 22:03:54 +0100 Subject: [PATCH] add indentation for ref-groups --- plantuml-mode.el | 4 ++- test/plantuml-indentation-sequence-test.el | 30 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/plantuml-mode.el b/plantuml-mode.el index d0d31c9..3335c18 100644 --- a/plantuml-mode.el +++ b/plantuml-mode.el @@ -358,6 +358,7 @@ Two variants for groups: keyword is either followed by whitespace and some text or it is followed by line end.") (defvar plantuml-indent-regexp-activate-start "^\s*activate\s+.+$") (defvar plantuml-indent-regexp-box-start "^\s*box\s+.+$") + (defvar plantuml-indent-regexp-ref-start "^\s*ref\s+over\s+\\w+\s*$") (defvar plantuml-indent-regexp-title-start "^\s*title$") (defvar plantuml-indent-regexp-header-start "^\s*\\(?:\\(?:center\\|left\\|right\\)\s+header\\|header\\)$") (defvar plantuml-indent-regexp-footer-start "^\s*\\(?:\\(?:center\\|left\\|right\\)\s+footer\\|footer\\)$") @@ -368,12 +369,13 @@ or it is followed by line end.") plantuml-indent-regexp-group-start plantuml-indent-regexp-activate-start plantuml-indent-regexp-box-start + plantuml-indent-regexp-ref-start plantuml-indent-regexp-title-start plantuml-indent-regexp-header-start plantuml-indent-regexp-footer-start plantuml-indent-regexp-legend-start plantuml-indent-regexp-if-start)) - (defvar plantuml-indent-regexp-end "^\s*\\(?:endif\\|else\s*.*\\|end\\|end\s+note\\|end\s+box\\|}\\|deactivate\s+.+\\|end\s+title\\|endheader\\|endfooter\\|endlegend\\)$") + (defvar plantuml-indent-regexp-end "^\s*\\(?:}\\|endif\\|else\s*.*\\|end\\|end\s+note\\|end\s+box\\|end\s+ref\\|deactivate\s+.+\\|end\s+title\\|endheader\\|endfooter\\|endlegend\\)$") (setq plantuml-font-lock-keywords `( (,plantuml-types-regexp . font-lock-type-face) diff --git a/test/plantuml-indentation-sequence-test.el b/test/plantuml-indentation-sequence-test.el index c669c02..839a97c 100644 --- a/test/plantuml-indentation-sequence-test.el +++ b/test/plantuml-indentation-sequence-test.el @@ -27,6 +27,36 @@ box \"Device with USB connector\" end box " )) +(ert-deftest platuml-test-block-indentation/sequence/ref () + "Test correct indentation of a ref block" + (plantuml-test-indent-block + " +participant Alice +actor Bob + +ref over Alice, Bob : init + +Alice -> Bob : hello + +ref over Bob +This can be on +several lines +end ref +" + " +participant Alice +actor Bob + +ref over Alice, Bob : init + +Alice -> Bob : hello + +ref over Bob + This can be on + several lines +end ref +" )) + (ert-deftest plantuml-test-block-indentation/sequence/alt-end () "Test correct indentation of an alt-end block.