From 56d668c54ed0ee2c85101fca48f83f6f47f9d1b4 Mon Sep 17 00:00:00 2001 From: Carlo Sciolla Date: Tue, 8 Jan 2019 22:47:51 +0100 Subject: [PATCH] Added extra keywords to the indentation block start regex Keywords added: - `folder` - `frame` - `cloud` Fixes #78 --- plantuml-mode.el | 2 +- test/plantuml-indentation-test.el | 36 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/plantuml-mode.el b/plantuml-mode.el index 8dab349..138c5d0 100644 --- a/plantuml-mode.el +++ b/plantuml-mode.el @@ -341,7 +341,7 @@ Uses prefix (as PREFIX) to choose where to display it: (defvar plantuml-keywords-regexp (concat "^\\s *" (regexp-opt plantuml-keywords 'words) "\\|\\(<\\|<|\\|\\*\\|o\\)\\(\\.+\\|-+\\)\\|\\(\\.+\\|-+\\)\\(>\\||>\\|\\*\\|o\\)\\|\\.\\{2,\\}\\|-\\{2,\\}")) (defvar plantuml-builtins-regexp (regexp-opt plantuml-builtins 'words)) (defvar plantuml-preprocessors-regexp (concat "^\\s *" (regexp-opt plantuml-preprocessors 'words))) - (defvar plantuml-indent-regexp-start "^[ \t]*\\(\\(?:.*\\)?\s*\\(?:[<>.*a-z-|]+\\)?\s*\\(?:\\[[a-zA-Z]+\\]\\)?\s+if\s+.*\\|loop\s+.*\\|group\s+.*\\|par\s*$\\|opt\s+.*\\|alt\s+.*\\|else\\|note\s+over\\|note\sas\s.*\\|note\s+\\(\\(?:\\(?:buttom\\|left\\|right\\|top\\)\\)\\)\\(?:\s+of\\)?\\|\\(?:class\\|enum\\|package\\|database\\)\s+.*{\\|activate\s+.+\\)") + (defvar plantuml-indent-regexp-start "^[ \t]*\\(\\(?:.*\\)?\s*\\(?:[<>.*a-z-|]+\\)?\s*\\(?:\\[[a-zA-Z]+\\]\\)?\s+if\s+.*\\|loop\s+.*\\|group\s+.*\\|par\s*$\\|opt\s+.*\\|alt\s+.*\\|else\\|note\s+over\\|note\sas\s.*\\|note\s+\\(\\(?:\\(?:button\\|left\\|right\\|top\\)\\)\\)\\(?:\s+of\\)?\\|\\(?:class\\|enum\\|package\\|database\\|frame\\|cloud\\|folder\\)\s+.*{\\|activate\s+.+\\)") (defvar plantuml-indent-regexp-end "^[ \t]*\\(endif\\|else\\|end\\|end\s+note\\|.*}\\|deactivate\s+.+\\)") (setq plantuml-font-lock-keywords diff --git a/test/plantuml-indentation-test.el b/test/plantuml-indentation-test.el index 464199d..3860f2f 100644 --- a/test/plantuml-indentation-test.el +++ b/test/plantuml-indentation-test.el @@ -306,6 +306,42 @@ package APackage { } ")) +(ert-deftest plantuml-test-block-indentation/various-keywords () + "Test correct indentation of a package block." + (plantuml-test-indent-block + " +cloud \"mycloud\" { +[Cloud] +} +" + " +cloud \"mycloud\" { + [Cloud] +} +") + (plantuml-test-indent-block + " +folder \"myfolder\" { +[Folder] +} +" + " +folder \"myfolder\" { + [Folder] +} +") + (plantuml-test-indent-block + " +frame \"myframe\" { +[Frame] +} +" + " +frame \"myframe\" { + [Frame] +} +")) + (ert-deftest plantuml-test-block-indentation/package-database-nested () "Test correct indentation of two nested blocks, a package and a database. Note: currently the inner database is not indented."