diff options
| author | Craig Jennings <c@cjennings.net> | 2026-07-11 14:58:30 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-07-11 14:58:30 -0500 |
| commit | 734172047b05a7dd4d75c86f8aae66c5ae807de0 (patch) | |
| tree | 42e45d81b636e26234f6f9c4e99f275d39037a51 /tests/test-custom-text-enclose-indent.el | |
| parent | 016f322de184b09d79cb1d7db522a0aaa6c00a9f (diff) | |
| download | dotemacs-734172047b05a7dd4d75c86f8aae66c5ae807de0.tar.gz dotemacs-734172047b05a7dd4d75c86f8aae66c5ae807de0.zip | |
fix(custom-text-enclose): decouple indent count from the tabs choice
cj/indent-lines-in-region-or-buffer used "p\nP", so both COUNT and USE-TABS came from the one prefix argument: no prefix gave count 1 (the docstring's "4" was wrong) with spaces, and any numeric prefix that set the count also forced tabs. Indenting several spaces was unreachable interactively. The prefix argument is now the count (defaulting to 4), and tabs-vs-spaces follows the buffer's indent-tabs-mode. cj/dedent-lines-in-region-or-buffer had the same wrong "default 4" and now defaults its count to 4 too. Added interactive-path tests, since the internals were already covered.
Diffstat (limited to 'tests/test-custom-text-enclose-indent.el')
| -rw-r--r-- | tests/test-custom-text-enclose-indent.el | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test-custom-text-enclose-indent.el b/tests/test-custom-text-enclose-indent.el index e9042d35..f37d1800 100644 --- a/tests/test-custom-text-enclose-indent.el +++ b/tests/test-custom-text-enclose-indent.el @@ -43,6 +43,35 @@ Returns the transformed string." Returns the transformed string." (cj/--dedent-lines text count)) +;;; Interactive default resolution (the prefix-arg decoupling fix) + +(ert-deftest test-indent-lines-interactive-no-prefix-is-four-spaces () + "Interactive: no prefix indents by 4, spaces when `indent-tabs-mode' is nil. +The old \"p\\nP\" spec defaulted count to 1 and forced tabs on any prefix." + (with-temp-buffer + (setq-local indent-tabs-mode nil) + (insert "line") + (let ((current-prefix-arg nil)) + (call-interactively #'cj/indent-lines-in-region-or-buffer)) + (should (string= " line" (buffer-string))))) + +(ert-deftest test-indent-lines-interactive-follows-indent-tabs-mode () + "Interactive: tabs-vs-spaces follows `indent-tabs-mode', not the prefix arg." + (with-temp-buffer + (setq-local indent-tabs-mode t) + (insert "line") + (let ((current-prefix-arg nil)) + (call-interactively #'cj/indent-lines-in-region-or-buffer)) + (should (string= "\t\t\t\tline" (buffer-string))))) + +(ert-deftest test-dedent-lines-interactive-no-prefix-is-four () + "Interactive: no prefix removes up to 4 leading whitespace characters." + (with-temp-buffer + (insert " line") ; eight leading spaces + (let ((current-prefix-arg nil)) + (call-interactively #'cj/dedent-lines-in-region-or-buffer)) + (should (string= " line" (buffer-string))))) + ;;; Indent Tests - Normal Cases with Spaces (ert-deftest test-indent-single-line-4-spaces () |
