From a3979a664304006afa0761884ae0927d269c698c Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Tue, 1 Aug 2023 10:38:45 +0200 Subject: [PATCH] Add `M-x align` support to conf-toml-mode * lisp/align.el (align-rules-list): Add rule for conf-toml-mode. * test/lisp/align-resources/conf-toml-mode.erts: New file. * test/lisp/align-tests.el (align-toml): New test. --- lisp/align.el | 9 +++- test/lisp/align-resources/conf-toml-mode.erts | 45 +++++++++++++++++++ test/lisp/align-tests.el | 5 +++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 test/lisp/align-resources/conf-toml-mode.erts diff --git a/lisp/align.el b/lisp/align.el index 79a75dcec79..2e667ca4749 100644 --- a/lisp/align.el +++ b/lisp/align.el @@ -568,7 +568,14 @@ The possible settings for `align-region-separate' are: (css-declaration (regexp . "^\\s-*\\(?:\\w-?\\)+:\\(\\s-*\\).*;") (group . (1)) - (modes . '(css-mode html-mode)))) + (modes . '(css-mode html-mode))) + + (toml-assignment + (regexp . ,(rx (group (zero-or-more (syntax whitespace))) + "=" + (group (zero-or-more (syntax whitespace))))) + (group . (1 2)) + (modes . '(conf-toml-mode)))) "A list describing all of the available alignment rules. The format is: diff --git a/test/lisp/align-resources/conf-toml-mode.erts b/test/lisp/align-resources/conf-toml-mode.erts new file mode 100644 index 00000000000..d1fcbd58708 --- /dev/null +++ b/test/lisp/align-resources/conf-toml-mode.erts @@ -0,0 +1,45 @@ +Name: align key-value pairs + +=-= +[foo] +foo1=10 +foo22=20 + +[bar] +bar333="example.org" +bar4444 = "zzz" +=-= +[foo] +foo1 = 10 +foo22 = 20 + +[bar] +bar333 = "example.org" +bar4444 = "zzz" +=-=-= + +Name: align list values + +=-= +[foo] +a = 1 +some_list = [ + true, + false, +] +some_other_list = [ + 1, + 2, +] +=-= +[foo] +a = 1 +some_list = [ + true, + false, +] +some_other_list = [ + 1, + 2, +] +=-=-= diff --git a/test/lisp/align-tests.el b/test/lisp/align-tests.el index 5f9580fabf0..9f94bcb611f 100644 --- a/test/lisp/align-tests.el +++ b/test/lisp/align-tests.el @@ -38,6 +38,11 @@ (ert-test-erts-file (ert-resource-file "java-mode.erts") (test-align-transform-fun #'java-mode))) +(ert-deftest align-toml () + (let ((indent-tabs-mode nil)) + (ert-test-erts-file (ert-resource-file "conf-toml-mode.erts") + (test-align-transform-fun #'conf-toml-mode)))) + (provide 'align-tests) ;;; align-tests.el ends here -- 2.39.2