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 /modules | |
| 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 'modules')
| -rw-r--r-- | modules/custom-text-enclose.el | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/modules/custom-text-enclose.el b/modules/custom-text-enclose.el index 4d72347d..12d2deaf 100644 --- a/modules/custom-text-enclose.el +++ b/modules/custom-text-enclose.el @@ -180,9 +180,14 @@ Returns the indented text without modifying the buffer." (defun cj/indent-lines-in-region-or-buffer (count use-tabs) "Indent each line in region or buffer by COUNT characters. -COUNT is the number of characters to indent (default 4). -USE-TABS when non-nil (prefix argument) uses tabs instead of spaces." - (interactive "p\nP") +COUNT is the numeric prefix argument, defaulting to 4 with no prefix. +USE-TABS non-nil indents with tabs instead of spaces; interactively it +follows the buffer's `indent-tabs-mode', so the prefix argument is free to +mean the count. Call it from Lisp with an explicit USE-TABS to override." + (interactive (list (if current-prefix-arg + (prefix-numeric-value current-prefix-arg) + 4) + indent-tabs-mode)) (let* ((bounds (cj/--region-or-buffer-bounds)) (start-pos (car bounds)) (end-pos (cdr bounds)) @@ -224,9 +229,11 @@ Returns the dedented text without modifying the buffer." (defun cj/dedent-lines-in-region-or-buffer (count) "Remove up to COUNT leading whitespace characters from each line. -COUNT is the number of characters to remove (default 4). +COUNT is the numeric prefix argument, defaulting to 4 with no prefix. Works on region if active, otherwise entire buffer." - (interactive "p") + (interactive (list (if current-prefix-arg + (prefix-numeric-value current-prefix-arg) + 4))) (let* ((bounds (cj/--region-or-buffer-bounds)) (start-pos (car bounds)) (end-pos (cdr bounds)) |
