diff --git a/notes/test_names.org b/notes/test_names.org index cf2bc18..d9e4f54 100644 --- a/notes/test_names.org +++ b/notes/test_names.org @@ -3,3 +3,4 @@ The autogen tests are the tests automatically generated to compare the output of - No prefix :: The test is run with the default settings (The upstream Emacs Org-mode determines the default settings) - la :: Short for "list alphabetic". Enables alphabetic plain lists. +- t# :: Sets the tab-width to # (as in t4 sets the tab-width to 4). diff --git a/org_mode_samples/greater_element/plain_list/tab_width_indentation_level.org b/org_mode_samples/greater_element/plain_list/tab_width_indentation_level.org new file mode 100644 index 0000000..2dbe900 --- /dev/null +++ b/org_mode_samples/greater_element/plain_list/tab_width_indentation_level.org @@ -0,0 +1,5 @@ +# "lorem" is prefixed by a tab instead of spaces, so the editor's tab-width value determines whether lorem is a sibling of baz (tab-width 8), a sibling of bar (tab-width < 8), or a child of baz (tab-width > 8). +1. foo + 1. bar + 1. baz + 1. lorem diff --git a/src/compare/parse.rs b/src/compare/parse.rs index 37cf4e1..0a35077 100644 --- a/src/compare/parse.rs +++ b/src/compare/parse.rs @@ -7,10 +7,12 @@ use crate::GlobalSettings; /// /// Currently only org-list-allow-alphabetical is supported. fn global_settings_elisp(global_settings: &GlobalSettings) -> String { + // This string concatenation is wildly inefficient but its only called in tests 🤷. let mut ret = "".to_owned(); if global_settings.list_allow_alphabetical { ret += "(setq org-list-allow-alphabetical t)\n" } + ret += format!("(setq-default tab-width {})", global_settings.tab_width).as_str(); ret } diff --git a/tests/test_template b/tests/test_template index dd1b569..1376ed3 100644 --- a/tests/test_template +++ b/tests/test_template @@ -1,3 +1,5 @@ +// TODO: Investigate writing a proc macro to make specifying these permutations easier. + {expect_fail} #[test] fn autogen_{name}() -> Result<(), Box> {{ @@ -20,3 +22,31 @@ fn autogen_la_{name}() -> Result<(), Box> {{ organic::compare::run_anonymous_compare_with_settings(org_contents.as_str(), &global_settings)?; Ok(()) }} + +{expect_fail} +#[test] +fn autogen_t1_{name}() -> Result<(), Box> {{ + let org_path = "{path}"; + let org_contents = std::fs::read_to_string(org_path).expect("Read org file."); + let global_settings = {{ + let mut global_settings = organic::GlobalSettings::default(); + global_settings.tab_width = 1; + global_settings + }}; + organic::compare::run_anonymous_compare_with_settings(org_contents.as_str(), &global_settings)?; + Ok(()) +}} + +{expect_fail} +#[test] +fn autogen_t16_{name}() -> Result<(), Box> {{ + let org_path = "{path}"; + let org_contents = std::fs::read_to_string(org_path).expect("Read org file."); + let global_settings = {{ + let mut global_settings = organic::GlobalSettings::default(); + global_settings.tab_width = 16; + global_settings + }}; + organic::compare::run_anonymous_compare_with_settings(org_contents.as_str(), &global_settings)?; + Ok(()) +}}