diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-29 04:41:40 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-29 04:41:40 -0400 |
| commit | 37d53dacf0636ae299b092b54dde78c0658a51c1 (patch) | |
| tree | 6eb61c1a9220bbbf13bafc931476d87b61c5b27d | |
| parent | 256027866f9ff2cbc3b6155950f21a92b54ea307 (diff) | |
| download | dotemacs-37d53dacf0636ae299b092b54dde78c0658a51c1.tar.gz dotemacs-37d53dacf0636ae299b092b54dde78c0658a51c1.zip | |
refactor: split custom-misc.el into focused modules
custom-misc.el was an incoherent grab-bag, so anything small defaulted to landing there. I split its eight commands by concern. Three moved into new modules: custom-format (region/buffer reformat), custom-counts (word and character counts), and custom-text-transform (fraction glyphs). The other three went to existing homes: the previous-buffer toggle to custom-buffer-file, the delimiter jump to custom-line-paragraph, and the align-regexp space advice with its alignment and fill bindings to custom-whitespace.
The C-; bindings, which-key labels, and the six test files moved with their functions, and custom-misc.el is deleted. No behavior change: every command keeps its name and its C-; key.
| -rw-r--r-- | init.el | 4 | ||||
| -rw-r--r-- | modules/custom-buffer-file.el | 9 | ||||
| -rw-r--r-- | modules/custom-counts.el | 63 | ||||
| -rw-r--r-- | modules/custom-format.el | 46 | ||||
| -rw-r--r-- | modules/custom-line-paragraph.el | 31 | ||||
| -rw-r--r-- | modules/custom-misc.el | 196 | ||||
| -rw-r--r-- | modules/custom-text-transform.el | 63 | ||||
| -rw-r--r-- | modules/custom-whitespace.el | 16 | ||||
| -rw-r--r-- | tests/test-custom-counts--count-characters.el (renamed from tests/test-custom-misc-cj--count-characters.el) | 34 | ||||
| -rw-r--r-- | tests/test-custom-counts-count-characters-buffer-or-region.el (renamed from tests/test-custom-misc-cj-count-characters-buffer-or-region.el) | 32 | ||||
| -rw-r--r-- | tests/test-custom-counts-count-words.el (renamed from tests/test-custom-misc-count-words.el) | 10 | ||||
| -rw-r--r-- | tests/test-custom-format-format-region.el (renamed from tests/test-custom-misc-format-region.el) | 10 | ||||
| -rw-r--r-- | tests/test-custom-line-paragraph-jump-to-matching-paren.el (renamed from tests/test-custom-misc-jump-to-matching-paren.el) | 10 | ||||
| -rw-r--r-- | tests/test-custom-text-transform-replace-fraction-glyphs.el (renamed from tests/test-custom-misc-replace-fraction-glyphs.el) | 10 | ||||
| -rw-r--r-- | tests/test-init-module-headers.el | 4 | ||||
| -rw-r--r-- | todo.org | 4 |
16 files changed, 290 insertions, 252 deletions
@@ -36,7 +36,9 @@ (require 'custom-datetime) ;; date/timestamp insertion in various formats (require 'custom-buffer-file) ;; custom buffer and file operations and keymap (require 'custom-line-paragraph) ;; operations on lines and paragraphs -(require 'custom-misc) ;; miscellaneous functions +(require 'custom-counts) ;; word and character counts +(require 'custom-format) ;; region/buffer reformatting +(require 'custom-text-transform) ;; fraction-glyph text transforms (require 'custom-ordering) ;; ordering and sorting operations (require 'custom-text-enclose) ;; operations to append, prepend, and surround text (require 'custom-whitespace) ;; whitespace operations diff --git a/modules/custom-buffer-file.el b/modules/custom-buffer-file.el index b10ecd168..261956f37 100644 --- a/modules/custom-buffer-file.el +++ b/modules/custom-buffer-file.el @@ -574,5 +574,14 @@ Signals an error if: "C-; b <down>" "resize divider down")) +;; --- previous-buffer toggle (formerly in custom-misc.el) --- +(defun cj/switch-to-previous-buffer () + "Switch to previously open buffer. +Repeated invocations toggle between the two most recently open buffers." + (interactive) + (switch-to-buffer (other-buffer (current-buffer) 1))) + +(cj/register-command "SPC" #'cj/switch-to-previous-buffer "prev buffer") + (provide 'custom-buffer-file) ;;; custom-buffer-file.el ends here. diff --git a/modules/custom-counts.el b/modules/custom-counts.el new file mode 100644 index 000000000..792732a40 --- /dev/null +++ b/modules/custom-counts.el @@ -0,0 +1,63 @@ +;;; custom-counts.el --- Word and character counts -*- coding: utf-8; lexical-binding: t; -*- + +;;; Commentary: +;; +;; Layer: 2 (Core UX). +;; Category: L. +;; Load shape: eager. +;; Eager reason: registers its C-; # w and C-; # c command bindings at load. +;; Top-level side effects: binds the count commands under C-; # w and C-; # c. +;; Runtime requires: keybindings. +;; Direct test load: yes (requires keybindings explicitly). +;; +;; Count words or characters in the active region, or the whole buffer when no +;; region is active, and report the total in the minibuffer. Split out of the +;; former custom-misc.el grab-bag. + +;;; Code: + +(require 'keybindings) ;; provides cj/register-command + +(defun cj/--count-words (start end) + "Internal implementation: Count words between START and END. +START and END define the region to count. +Returns the word count as an integer." + (when (> start end) + (error "Invalid region: start (%d) is greater than end (%d)" start end)) + (count-words start end)) + +(defun cj/count-words-buffer-or-region () + "Count the number of words in the buffer or region. +Display the result in the minibuffer." + (interactive) + (let* ((use-region (use-region-p)) + (begin (if use-region (region-beginning) (point-min))) + (end (if use-region (region-end) (point-max))) + (area-type (if use-region "the region" "the buffer")) + (word-count (cj/--count-words begin end))) + (message "There are %d words in %s." word-count area-type))) + +(defun cj/--count-characters (start end) + "Internal implementation: Count characters between START and END. +START and END define the region to count. +Returns the character count as an integer." + (when (> start end) + (error "Invalid region: start (%d) is greater than end (%d)" start end)) + (- end start)) + +(defun cj/count-characters-buffer-or-region () + "Count the number of characters in the buffer or region. +Display the result in the minibuffer." + (interactive) + (let* ((use-region (use-region-p)) + (begin (if use-region (region-beginning) (point-min))) + (end (if use-region (region-end) (point-max))) + (area-type (if use-region "the region" "the buffer")) + (char-count (cj/--count-characters begin end))) + (message "There are %d characters in %s." char-count area-type))) + +(cj/register-command "# w" #'cj/count-words-buffer-or-region "count words") +(cj/register-command "# c" #'cj/count-characters-buffer-or-region "count characters") + +(provide 'custom-counts) +;;; custom-counts.el ends here diff --git a/modules/custom-format.el b/modules/custom-format.el new file mode 100644 index 000000000..47cd7d88d --- /dev/null +++ b/modules/custom-format.el @@ -0,0 +1,46 @@ +;;; custom-format.el --- Region and buffer reformatting -*- coding: utf-8; lexical-binding: t; -*- + +;;; Commentary: +;; +;; Layer: 2 (Core UX). +;; Category: L. +;; Load shape: eager. +;; Eager reason: registers its C-; f command binding at load. +;; Top-level side effects: binds cj/format-region-or-buffer under C-; f. +;; Runtime requires: keybindings. +;; Direct test load: yes (requires keybindings explicitly). +;; +;; Reformat the active region, or the whole buffer when no region is active: +;; untabify, reindent, and delete trailing whitespace. Split out of the +;; former custom-misc.el grab-bag. + +;;; Code: + +(require 'keybindings) ;; provides cj/register-command + +(defun cj/--format-region (start end) + "Internal implementation: Reformat text between START and END. +START and END define the region to operate on. +Replaces tabs with spaces, reindents, and deletes trailing whitespace." + (when (> start end) + (error "Invalid region: start (%d) is greater than end (%d)" start end)) + (save-excursion + (save-restriction + (narrow-to-region start end) + (untabify (point-min) (point-max)) + (indent-region (point-min) (point-max)) + (delete-trailing-whitespace (point-min) (point-max))))) + +(defun cj/format-region-or-buffer () + "Reformat the region or the entire buffer. +Replaces tabs with spaces, deletes trailing whitespace, and reindents." + (interactive) + (let ((start-pos (if (use-region-p) (region-beginning) (point-min))) + (end-pos (if (use-region-p) (region-end) (point-max)))) + (cj/--format-region start-pos end-pos) + (message "Formatted %s" (if (use-region-p) "region" "buffer")))) + +(cj/register-command "f" #'cj/format-region-or-buffer "format buffer") + +(provide 'custom-format) +;;; custom-format.el ends here diff --git a/modules/custom-line-paragraph.el b/modules/custom-line-paragraph.el index dd2999c4e..d29d4125b 100644 --- a/modules/custom-line-paragraph.el +++ b/modules/custom-line-paragraph.el @@ -166,5 +166,36 @@ If the line is empty or contains only whitespace, abort with a message." "C-; l r" "remove matching" "C-; l u" "underscore line")) +;; --- delimiter jump (formerly in custom-misc.el) --- +(defun cj/jump-to-matching-paren () + "Jump to the matching delimiter if point is on (or just after) one. +If not on a delimiter, show a message. Respects the current syntax table." + (interactive) + (let* ((ca (char-after)) + (cb (char-before)) + ;; Check if on opening paren + (open-p (and ca (eq (char-syntax ca) ?\())) + ;; Check if on or just after closing paren + (close-p (or (and ca (eq (char-syntax ca) ?\))) + (and cb (eq (char-syntax cb) ?\)))))) + (cond + ;; Jump forward from opening + (open-p + (condition-case err + (forward-sexp) + (scan-error + (message "No matching delimiter: %s" (error-message-string err))))) + ;; Jump backward from closing + (close-p + (condition-case err + (backward-sexp) + (scan-error + (message "No matching delimiter: %s" (error-message-string err))))) + ;; Not on delimiter + (t + (message "Point is not on a delimiter."))))) + +(cj/register-command ")" #'cj/jump-to-matching-paren "jump to paren") + (provide 'custom-line-paragraph) ;;; custom-line-paragraph.el ends here. diff --git a/modules/custom-misc.el b/modules/custom-misc.el deleted file mode 100644 index 7e5e4f8d6..000000000 --- a/modules/custom-misc.el +++ /dev/null @@ -1,196 +0,0 @@ -;;; custom-misc.el --- Miscellaneous utility functions -*- coding: utf-8; lexical-binding: t; -*- - -;;; Commentary: -;; -;; Layer: 2 (Core UX). -;; Category: L/C. -;; Load shape: eager. -;; Eager reason: registers its C-; command bindings and an align-regexp advice -;; at load. Currently eager by init order; a deferral candidate for Phase 3/4. -;; Top-level side effects: advises align-regexp; binds several commands directly -;; under C-; (")", "f", "A", "SPC", "|", and others). -;; Runtime requires: keybindings. -;; Direct test load: yes (requires keybindings explicitly). -;; -;; This module provides various utility functions for text manipulation, -;; formatting, and navigation. Features include: -;; - Jump between matching delimiters -;; - Format regions/buffers (untabify, reindent, remove trailing whitespace) -;; - Word counting with region awareness -;; - Fraction glyph conversion (¼ ↔ 1/4) -;; - Force align-regexp to use spaces instead of tabs -;; -;; All functions are bound to the cj/custom-keymap for easy access. -;; -;;; Code: - -(require 'keybindings) ;; provides cj/custom-keymap - -(defun cj/jump-to-matching-paren () - "Jump to the matching delimiter if point is on (or just after) one. -If not on a delimiter, show a message. Respects the current syntax table." - (interactive) - (let* ((ca (char-after)) - (cb (char-before)) - ;; Check if on opening paren - (open-p (and ca (eq (char-syntax ca) ?\())) - ;; Check if on or just after closing paren - (close-p (or (and ca (eq (char-syntax ca) ?\))) - (and cb (eq (char-syntax cb) ?\)))))) - (cond - ;; Jump forward from opening - (open-p - (condition-case err - (forward-sexp) - (scan-error - (message "No matching delimiter: %s" (error-message-string err))))) - ;; Jump backward from closing - (close-p - (condition-case err - (backward-sexp) - (scan-error - (message "No matching delimiter: %s" (error-message-string err))))) - ;; Not on delimiter - (t - (message "Point is not on a delimiter."))))) - - -(defun cj/--format-region (start end) - "Internal implementation: Reformat text between START and END. -START and END define the region to operate on. -Replaces tabs with spaces, reindents, and deletes trailing whitespace." - (when (> start end) - (error "Invalid region: start (%d) is greater than end (%d)" start end)) - (save-excursion - (save-restriction - (narrow-to-region start end) - (untabify (point-min) (point-max)) - (indent-region (point-min) (point-max)) - (delete-trailing-whitespace (point-min) (point-max))))) - -(defun cj/format-region-or-buffer () - "Reformat the region or the entire buffer. -Replaces tabs with spaces, deletes trailing whitespace, and reindents." - (interactive) - (let ((start-pos (if (use-region-p) (region-beginning) (point-min))) - (end-pos (if (use-region-p) (region-end) (point-max)))) - (cj/--format-region start-pos end-pos) - (message "Formatted %s" (if (use-region-p) "region" "buffer")))) - -(defun cj/switch-to-previous-buffer () - "Switch to previously open buffer. -Repeated invocations toggle between the two most recently open buffers." - (interactive) - (switch-to-buffer (other-buffer (current-buffer) 1))) - -(defun cj/--count-words (start end) - "Internal implementation: Count words between START and END. -START and END define the region to count. -Returns the word count as an integer." - (when (> start end) - (error "Invalid region: start (%d) is greater than end (%d)" start end)) - (count-words start end)) - -(defun cj/count-words-buffer-or-region () - "Count the number of words in the buffer or region. -Display the result in the minibuffer." - (interactive) - (let* ((use-region (use-region-p)) - (begin (if use-region (region-beginning) (point-min))) - (end (if use-region (region-end) (point-max))) - (area-type (if use-region "the region" "the buffer")) - (word-count (cj/--count-words begin end))) - (message "There are %d words in %s." word-count area-type))) - -(defun cj/--count-characters (start end) - "Internal implementation: Count characters between START and END. -START and END define the region to count. -Returns the character count as an integer." - (when (> start end) - (error "Invalid region: start (%d) is greater than end (%d)" start end)) - (- end start)) - -(defun cj/count-characters-buffer-or-region () - "Count the number of characters in the buffer or region. -Display the result in the minibuffer." - (interactive) - (let* ((use-region (use-region-p)) - (begin (if use-region (region-beginning) (point-min))) - (end (if use-region (region-end) (point-max))) - (area-type (if use-region "the region" "the buffer")) - (char-count (cj/--count-characters begin end))) - (message "There are %d characters in %s." char-count area-type))) - - -(defun cj/--replace-fraction-glyphs (start end to-glyphs) - "Internal implementation: Replace fraction glyphs or text between START and END. -START and END define the region to operate on. -TO-GLYPHS when non-nil converts text (1/4) to glyphs (¼), -otherwise converts glyphs to text." - (when (> start end) - (error "Invalid region: start (%d) is greater than end (%d)" start end)) - (let ((replacements (if to-glyphs - '(("1/4" . "¼") - ("1/2" . "½") - ("3/4" . "¾") - ("1/3" . "⅓") - ("2/3" . "⅔")) - '(("¼" . "1/4") - ("½" . "1/2") - ("¾" . "3/4") - ("⅓" . "1/3") - ("⅔" . "2/3")))) - (count 0) - (end-marker (copy-marker end))) - (save-excursion - (dolist (r replacements) - (goto-char start) - (while (search-forward (car r) end-marker t) - (replace-match (cdr r)) - (setq count (1+ count))))) - count)) - -(defun cj/replace-fraction-glyphs (start end) - "Replace common fraction glyphs between START and END. -Operate on the buffer or region designated by START and END. -Replace the text representations with glyphs when called with a -\\[universal-argument] prefix." - (interactive (if (use-region-p) - (list (region-beginning) (region-end)) - (list (point-min) (point-max)))) - (let ((count (cj/--replace-fraction-glyphs start end current-prefix-arg))) - (message "Replaced %d fraction%s" count (if (= count 1) "" "s")))) - -(defun cj/align-regexp-with-spaces (orig-fun &rest args) - "Call ORIG-FUN with ARGS while temporarily disabling tabs for alignment. -This advice ensures =align-regexp' uses spaces by binding =indent-tabs-mode' -to nil." - (let ((indent-tabs-mode nil)) - (apply orig-fun args))) - -;; avoid double advice stacking in case the file is reloaded -(advice-remove 'align-regexp #'cj/align-regexp-with-spaces) -(advice-add 'align-regexp :around #'cj/align-regexp-with-spaces) - -(cj/register-command ")" #'cj/jump-to-matching-paren) -(cj/register-command "f" #'cj/format-region-or-buffer) -(cj/register-command "# w" #'cj/count-words-buffer-or-region) -(cj/register-command "# c" #'cj/count-characters-buffer-or-region) -(cj/register-command "/" #'cj/replace-fraction-glyphs) -(cj/register-command "A" #'align-regexp) -(cj/register-command "SPC" #'cj/switch-to-previous-buffer) -(cj/register-command "|" #'display-fill-column-indicator-mode) - -(with-eval-after-load 'which-key - (which-key-add-key-based-replacements - "C-; )" "jump to paren" - "C-; f" "format buffer" - "C-; # w" "count words" - "C-; # c" "count characters" - "C-; /" "fraction glyphs" - "C-; A" "align regexp" - "C-; SPC" "prev buffer" - "C-; |" "fill column")) - -(provide 'custom-misc) -;;; custom-misc.el ends here diff --git a/modules/custom-text-transform.el b/modules/custom-text-transform.el new file mode 100644 index 000000000..537f8df21 --- /dev/null +++ b/modules/custom-text-transform.el @@ -0,0 +1,63 @@ +;;; custom-text-transform.el --- Text glyph transforms -*- coding: utf-8; lexical-binding: t; -*- + +;;; Commentary: +;; +;; Layer: 2 (Core UX). +;; Category: L. +;; Load shape: eager. +;; Eager reason: registers its C-; / command binding at load. +;; Top-level side effects: binds cj/replace-fraction-glyphs under C-; /. +;; Runtime requires: keybindings. +;; Direct test load: yes (requires keybindings explicitly). +;; +;; Convert between text fractions (1/4) and their Unicode glyphs (1/4 becomes +;; the vulgar-fraction character), over the region or whole buffer. Split out +;; of the former custom-misc.el grab-bag. + +;;; Code: + +(require 'keybindings) ;; provides cj/register-command + +(defun cj/--replace-fraction-glyphs (start end to-glyphs) + "Internal implementation: Replace fraction glyphs or text between START and END. +START and END define the region to operate on. +TO-GLYPHS when non-nil converts text (1/4) to glyphs (¼), +otherwise converts glyphs to text." + (when (> start end) + (error "Invalid region: start (%d) is greater than end (%d)" start end)) + (let ((replacements (if to-glyphs + '(("1/4" . "¼") + ("1/2" . "½") + ("3/4" . "¾") + ("1/3" . "⅓") + ("2/3" . "⅔")) + '(("¼" . "1/4") + ("½" . "1/2") + ("¾" . "3/4") + ("⅓" . "1/3") + ("⅔" . "2/3")))) + (count 0) + (end-marker (copy-marker end))) + (save-excursion + (dolist (r replacements) + (goto-char start) + (while (search-forward (car r) end-marker t) + (replace-match (cdr r)) + (setq count (1+ count))))) + count)) + +(defun cj/replace-fraction-glyphs (start end) + "Replace common fraction glyphs between START and END. +Operate on the buffer or region designated by START and END. +Replace the text representations with glyphs when called with a +\\[universal-argument] prefix." + (interactive (if (use-region-p) + (list (region-beginning) (region-end)) + (list (point-min) (point-max)))) + (let ((count (cj/--replace-fraction-glyphs start end current-prefix-arg))) + (message "Replaced %d fraction%s" count (if (= count 1) "" "s")))) + +(cj/register-command "/" #'cj/replace-fraction-glyphs "fraction glyphs") + +(provide 'custom-text-transform) +;;; custom-text-transform.el ends here diff --git a/modules/custom-whitespace.el b/modules/custom-whitespace.el index cbf3eff12..52cc4e54d 100644 --- a/modules/custom-whitespace.el +++ b/modules/custom-whitespace.el @@ -228,5 +228,21 @@ Operate on the active region designated by START and END." "C-; w t" "untabify" "C-; w T" "tabify")) +;; --- align-regexp space enforcement + alignment/fill bindings --- +;; (formerly in custom-misc.el) +(defun cj/align-regexp-with-spaces (orig-fun &rest args) + "Call ORIG-FUN with ARGS while temporarily disabling tabs for alignment. +This advice ensures =align-regexp' uses spaces by binding =indent-tabs-mode' +to nil." + (let ((indent-tabs-mode nil)) + (apply orig-fun args))) + +;; avoid double advice stacking in case the file is reloaded +(advice-remove 'align-regexp #'cj/align-regexp-with-spaces) +(advice-add 'align-regexp :around #'cj/align-regexp-with-spaces) + +(cj/register-command "A" #'align-regexp "align regexp") +(cj/register-command "|" #'display-fill-column-indicator-mode "fill column") + (provide 'custom-whitespace) ;;; custom-whitespace.el ends here. diff --git a/tests/test-custom-misc-cj--count-characters.el b/tests/test-custom-counts--count-characters.el index 1834b5c4f..8abd759f9 100644 --- a/tests/test-custom-misc-cj--count-characters.el +++ b/tests/test-custom-counts--count-characters.el @@ -1,7 +1,7 @@ -;;; test-custom-misc-cj--count-characters.el --- Tests for cj/--count-characters -*- lexical-binding: t; -*- +;;; test-custom-counts--count-characters.el --- Tests for cj/--count-characters -*- lexical-binding: t; -*- ;;; Commentary: -;; Tests for the cj/--count-characters internal implementation function from custom-misc.el +;; Tests for the cj/--count-characters internal implementation function from custom-counts.el ;; ;; This internal function counts characters between START and END positions. ;; It validates that START is not greater than END and returns the character count. @@ -18,7 +18,7 @@ "Stub keymap for testing.") ;; Now load the actual production module -(require 'custom-misc) +(require 'custom-counts) ;;; Setup and Teardown @@ -34,7 +34,7 @@ ;;; Normal Cases -(ert-deftest test-custom-misc-cj--count-characters-normal-simple-text-returns-count () +(ert-deftest test-custom-counts--count-characters-normal-simple-text-returns-count () "Should count characters in simple text region." (test-count-characters-setup) (unwind-protect @@ -44,7 +44,7 @@ (should (= result 13)))) (test-count-characters-teardown))) -(ert-deftest test-custom-misc-cj--count-characters-normal-partial-region-returns-count () +(ert-deftest test-custom-counts--count-characters-normal-partial-region-returns-count () "Should count characters in partial region." (test-count-characters-setup) (unwind-protect @@ -54,7 +54,7 @@ (should (= result 5)))) (test-count-characters-teardown))) -(ert-deftest test-custom-misc-cj--count-characters-normal-multiline-returns-count () +(ert-deftest test-custom-counts--count-characters-normal-multiline-returns-count () "Should count characters including newlines." (test-count-characters-setup) (unwind-protect @@ -67,7 +67,7 @@ ;;; Boundary Cases -(ert-deftest test-custom-misc-cj--count-characters-boundary-empty-region-returns-zero () +(ert-deftest test-custom-counts--count-characters-boundary-empty-region-returns-zero () "Should return 0 for empty region (start equals end)." (test-count-characters-setup) (unwind-protect @@ -77,7 +77,7 @@ (should (= result 0)))) (test-count-characters-teardown))) -(ert-deftest test-custom-misc-cj--count-characters-boundary-single-character-returns-one () +(ert-deftest test-custom-counts--count-characters-boundary-single-character-returns-one () "Should return 1 for single character region." (test-count-characters-setup) (unwind-protect @@ -87,7 +87,7 @@ (should (= result 1)))) (test-count-characters-teardown))) -(ert-deftest test-custom-misc-cj--count-characters-boundary-large-region-returns-count () +(ert-deftest test-custom-counts--count-characters-boundary-large-region-returns-count () "Should handle very large region." (test-count-characters-setup) (unwind-protect @@ -98,7 +98,7 @@ (should (= result 100000))))) (test-count-characters-teardown))) -(ert-deftest test-custom-misc-cj--count-characters-boundary-unicode-returns-count () +(ert-deftest test-custom-counts--count-characters-boundary-unicode-returns-count () "Should count unicode characters (emoji, RTL text, combining characters)." (test-count-characters-setup) (unwind-protect @@ -110,7 +110,7 @@ (should (= result (- (point-max) (point-min)))))) (test-count-characters-teardown))) -(ert-deftest test-custom-misc-cj--count-characters-boundary-whitespace-only-returns-count () +(ert-deftest test-custom-counts--count-characters-boundary-whitespace-only-returns-count () "Should count whitespace characters." (test-count-characters-setup) (unwind-protect @@ -121,7 +121,7 @@ (should (= result 7)))) (test-count-characters-teardown))) -(ert-deftest test-custom-misc-cj--count-characters-boundary-newlines-at-boundaries-returns-count () +(ert-deftest test-custom-counts--count-characters-boundary-newlines-at-boundaries-returns-count () "Should count newlines at start and end." (test-count-characters-setup) (unwind-protect @@ -132,7 +132,7 @@ (should (= result 9)))) (test-count-characters-teardown))) -(ert-deftest test-custom-misc-cj--count-characters-boundary-binary-content-returns-count () +(ert-deftest test-custom-counts--count-characters-boundary-binary-content-returns-count () "Should handle binary content." (test-count-characters-setup) (unwind-protect @@ -144,7 +144,7 @@ ;;; Error Cases -(ert-deftest test-custom-misc-cj--count-characters-error-start-greater-than-end-signals-error () +(ert-deftest test-custom-counts--count-characters-error-start-greater-than-end-signals-error () "Should signal error when start is greater than end." (test-count-characters-setup) (unwind-protect @@ -154,7 +154,7 @@ :type 'error)) (test-count-characters-teardown))) -(ert-deftest test-custom-misc-cj--count-characters-error-positions-out-of-bounds-handled () +(ert-deftest test-custom-counts--count-characters-error-positions-out-of-bounds-handled () "Should handle positions beyond buffer bounds (Emacs handles this)." (test-count-characters-setup) (unwind-protect @@ -167,5 +167,5 @@ (should (= result 5)))) (test-count-characters-teardown))) -(provide 'test-custom-misc-cj--count-characters) -;;; test-custom-misc-cj--count-characters.el ends here +(provide 'test-custom-counts--count-characters) +;;; test-custom-counts--count-characters.el ends here diff --git a/tests/test-custom-misc-cj-count-characters-buffer-or-region.el b/tests/test-custom-counts-count-characters-buffer-or-region.el index dbbda00d8..adeb812a8 100644 --- a/tests/test-custom-misc-cj-count-characters-buffer-or-region.el +++ b/tests/test-custom-counts-count-characters-buffer-or-region.el @@ -1,7 +1,7 @@ -;;; test-custom-misc-cj-count-characters-buffer-or-region.el --- Tests for cj/count-characters-buffer-or-region -*- lexical-binding: t; -*- +;;; test-custom-counts-count-characters-buffer-or-region.el --- Tests for cj/count-characters-buffer-or-region -*- lexical-binding: t; -*- ;;; Commentary: -;; Tests for the cj/count-characters-buffer-or-region function from custom-misc.el +;; Tests for the cj/count-characters-buffer-or-region function from custom-counts.el ;; ;; This function counts characters in the active region or the entire buffer ;; if no region is active. It displays the count in the minibuffer. @@ -18,7 +18,7 @@ "Stub keymap for testing.") ;; Now load the actual production module -(require 'custom-misc) +(require 'custom-counts) ;;; Setup and Teardown @@ -35,7 +35,7 @@ ;;; Normal Cases -(ert-deftest test-custom-misc-cj-count-characters-buffer-or-region-normal-whole-buffer-counts-all () +(ert-deftest test-custom-counts-count-characters-buffer-or-region-normal-whole-buffer-counts-all () "Should count all characters in buffer when no region is active." (test-count-characters-buffer-or-region-setup) (unwind-protect @@ -51,7 +51,7 @@ (should (string-match-p "13 characters.*buffer" message-output))))) (test-count-characters-buffer-or-region-teardown))) -(ert-deftest test-custom-misc-cj-count-characters-buffer-or-region-normal-active-region-counts-region () +(ert-deftest test-custom-counts-count-characters-buffer-or-region-normal-active-region-counts-region () "Should count characters in active region." (test-count-characters-buffer-or-region-setup) (unwind-protect @@ -70,7 +70,7 @@ (should (string-match-p "5 characters.*region" message-output))))) (test-count-characters-buffer-or-region-teardown))) -(ert-deftest test-custom-misc-cj-count-characters-buffer-or-region-normal-multiline-buffer-counts-all () +(ert-deftest test-custom-counts-count-characters-buffer-or-region-normal-multiline-buffer-counts-all () "Should count characters including newlines in buffer." (test-count-characters-buffer-or-region-setup) (unwind-protect @@ -86,7 +86,7 @@ (should (string-match-p "20 characters.*buffer" message-output))))) (test-count-characters-buffer-or-region-teardown))) -(ert-deftest test-custom-misc-cj-count-characters-buffer-or-region-normal-multiline-region-counts-region () +(ert-deftest test-custom-counts-count-characters-buffer-or-region-normal-multiline-region-counts-region () "Should count characters including newlines in region." (test-count-characters-buffer-or-region-setup) (unwind-protect @@ -108,7 +108,7 @@ ;;; Boundary Cases -(ert-deftest test-custom-misc-cj-count-characters-buffer-or-region-boundary-empty-buffer-returns-zero () +(ert-deftest test-custom-counts-count-characters-buffer-or-region-boundary-empty-buffer-returns-zero () "Should return 0 for empty buffer." (test-count-characters-buffer-or-region-setup) (unwind-protect @@ -122,7 +122,7 @@ (should (string-match-p "0 characters.*buffer" message-output))))) (test-count-characters-buffer-or-region-teardown))) -(ert-deftest test-custom-misc-cj-count-characters-buffer-or-region-boundary-empty-region-counts-buffer () +(ert-deftest test-custom-counts-count-characters-buffer-or-region-boundary-empty-region-counts-buffer () "Should count whole buffer when region is empty (point equals mark). When mark and point are at the same position, use-region-p returns nil, so the function correctly falls back to counting the entire buffer." @@ -144,7 +144,7 @@ so the function correctly falls back to counting the entire buffer." (should (string-match-p "13 characters.*buffer" message-output))))) (test-count-characters-buffer-or-region-teardown))) -(ert-deftest test-custom-misc-cj-count-characters-buffer-or-region-boundary-large-buffer-counts-all () +(ert-deftest test-custom-counts-count-characters-buffer-or-region-boundary-large-buffer-counts-all () "Should handle very large buffer." (test-count-characters-buffer-or-region-setup) (unwind-protect @@ -160,7 +160,7 @@ so the function correctly falls back to counting the entire buffer." (should (string-match-p "100000 characters.*buffer" message-output)))))) (test-count-characters-buffer-or-region-teardown))) -(ert-deftest test-custom-misc-cj-count-characters-buffer-or-region-boundary-unicode-counts-correctly () +(ert-deftest test-custom-counts-count-characters-buffer-or-region-boundary-unicode-counts-correctly () "Should count unicode characters (emoji, RTL text) correctly." (test-count-characters-buffer-or-region-setup) (unwind-protect @@ -177,7 +177,7 @@ so the function correctly falls back to counting the entire buffer." message-output))))) (test-count-characters-buffer-or-region-teardown))) -(ert-deftest test-custom-misc-cj-count-characters-buffer-or-region-boundary-whitespace-only-counts-whitespace () +(ert-deftest test-custom-counts-count-characters-buffer-or-region-boundary-whitespace-only-counts-whitespace () "Should count whitespace characters." (test-count-characters-buffer-or-region-setup) (unwind-protect @@ -193,7 +193,7 @@ so the function correctly falls back to counting the entire buffer." (should (string-match-p "7 characters.*buffer" message-output))))) (test-count-characters-buffer-or-region-teardown))) -(ert-deftest test-custom-misc-cj-count-characters-buffer-or-region-boundary-single-character-returns-one () +(ert-deftest test-custom-counts-count-characters-buffer-or-region-boundary-single-character-returns-one () "Should return 1 for single character buffer." (test-count-characters-buffer-or-region-setup) (unwind-protect @@ -208,7 +208,7 @@ so the function correctly falls back to counting the entire buffer." (should (string-match-p "1 character.*buffer" message-output))))) (test-count-characters-buffer-or-region-teardown))) -(ert-deftest test-custom-misc-cj-count-characters-buffer-or-region-boundary-narrowed-buffer-counts-visible () +(ert-deftest test-custom-counts-count-characters-buffer-or-region-boundary-narrowed-buffer-counts-visible () "Should count only visible characters in narrowed buffer." (test-count-characters-buffer-or-region-setup) (unwind-protect @@ -227,5 +227,5 @@ so the function correctly falls back to counting the entire buffer." (should (string-match-p "7 characters.*buffer" message-output))))) (test-count-characters-buffer-or-region-teardown))) -(provide 'test-custom-misc-cj-count-characters-buffer-or-region) -;;; test-custom-misc-cj-count-characters-buffer-or-region.el ends here +(provide 'test-custom-counts-count-characters-buffer-or-region) +;;; test-custom-counts-count-characters-buffer-or-region.el ends here diff --git a/tests/test-custom-misc-count-words.el b/tests/test-custom-counts-count-words.el index f2bf793f4..642a5a411 100644 --- a/tests/test-custom-misc-count-words.el +++ b/tests/test-custom-counts-count-words.el @@ -1,7 +1,7 @@ -;;; test-custom-misc-count-words.el --- Tests for cj/--count-words -*- lexical-binding: t; -*- +;;; test-custom-counts-count-words.el --- Tests for cj/--count-words -*- lexical-binding: t; -*- ;;; Commentary: -;; Tests for the cj/--count-words function from custom-misc.el +;; Tests for the cj/--count-words function from custom-counts.el ;; ;; This function counts words in a region using Emacs's built-in count-words. ;; A word is defined by Emacs's word boundaries, which generally means @@ -24,7 +24,7 @@ "Stub keymap for testing.") ;; Now load the actual production module -(require 'custom-misc) +(require 'custom-counts) ;;; Test Helpers @@ -144,5 +144,5 @@ words in it.")) (let ((end (match-end 0))) (should (= 3 (cj/--count-words start end))))))) -(provide 'test-custom-misc-count-words) -;;; test-custom-misc-count-words.el ends here +(provide 'test-custom-counts-count-words) +;;; test-custom-counts-count-words.el ends here diff --git a/tests/test-custom-misc-format-region.el b/tests/test-custom-format-format-region.el index c40a8898e..27f1c6b99 100644 --- a/tests/test-custom-misc-format-region.el +++ b/tests/test-custom-format-format-region.el @@ -1,7 +1,7 @@ -;;; test-custom-misc-format-region.el --- Tests for cj/--format-region -*- lexical-binding: t; -*- +;;; test-custom-format-format-region.el --- Tests for cj/--format-region -*- lexical-binding: t; -*- ;;; Commentary: -;; Tests for the cj/--format-region function from custom-misc.el +;; Tests for the cj/--format-region function from custom-format.el ;; ;; This function reformats text by applying three operations: ;; 1. untabify - converts tabs to spaces @@ -28,7 +28,7 @@ "Stub keymap for testing.") ;; Now load the actual production module -(require 'custom-misc) +(require 'custom-format) ;;; Test Helpers @@ -157,5 +157,5 @@ Returns the buffer string after operation." ;; Should complete without error (should (string= (buffer-string) "hello world"))))) -(provide 'test-custom-misc-format-region) -;;; test-custom-misc-format-region.el ends here +(provide 'test-custom-format-format-region) +;;; test-custom-format-format-region.el ends here diff --git a/tests/test-custom-misc-jump-to-matching-paren.el b/tests/test-custom-line-paragraph-jump-to-matching-paren.el index 973b6dfa9..31853da67 100644 --- a/tests/test-custom-misc-jump-to-matching-paren.el +++ b/tests/test-custom-line-paragraph-jump-to-matching-paren.el @@ -1,7 +1,7 @@ -;;; test-custom-misc-jump-to-matching-paren.el --- Tests for cj/jump-to-matching-paren -*- lexical-binding: t; -*- +;;; test-custom-line-paragraph-jump-to-matching-paren.el --- Tests for cj/jump-to-matching-paren -*- lexical-binding: t; -*- ;;; Commentary: -;; Tests for the cj/jump-to-matching-paren function from custom-misc.el +;; Tests for the cj/jump-to-matching-paren function from custom-line-paragraph.el ;; ;; This function jumps to matching delimiters using Emacs's sexp navigation. ;; It works with any delimiter that has matching syntax according to the @@ -32,7 +32,7 @@ "Stub keymap for testing.") ;; Now load the actual production module -(require 'custom-misc) +(require 'custom-line-paragraph) ;;; Test Helpers @@ -193,5 +193,5 @@ POINT-POSITION is 1-indexed (1 = first character)." ;; The parens in the string should be ignored (should (= 18 (test-jump-to-matching-paren "(\"hello (world)\")" 1)))) -(provide 'test-custom-misc-jump-to-matching-paren) -;;; test-custom-misc-jump-to-matching-paren.el ends here +(provide 'test-custom-line-paragraph-jump-to-matching-paren) +;;; test-custom-line-paragraph-jump-to-matching-paren.el ends here diff --git a/tests/test-custom-misc-replace-fraction-glyphs.el b/tests/test-custom-text-transform-replace-fraction-glyphs.el index 81d1546e1..ed961c63e 100644 --- a/tests/test-custom-misc-replace-fraction-glyphs.el +++ b/tests/test-custom-text-transform-replace-fraction-glyphs.el @@ -1,7 +1,7 @@ -;;; test-custom-misc-replace-fraction-glyphs.el --- Tests for cj/--replace-fraction-glyphs -*- lexical-binding: t; -*- +;;; test-custom-text-transform-replace-fraction-glyphs.el --- Tests for cj/--replace-fraction-glyphs -*- lexical-binding: t; -*- ;;; Commentary: -;; Tests for the cj/--replace-fraction-glyphs function from custom-misc.el +;; Tests for the cj/--replace-fraction-glyphs function from custom-text-transform.el ;; ;; This function bidirectionally converts between text fractions (1/4) and ;; Unicode fraction glyphs (¼). It supports 5 common fractions: @@ -28,7 +28,7 @@ "Stub keymap for testing.") ;; Now load the actual production module -(require 'custom-misc) +(require 'custom-text-transform) ;;; Test Helpers @@ -181,5 +181,5 @@ Returns the buffer string after operation." ;; Should complete without error (should (string= (buffer-string) "1/4"))))) -(provide 'test-custom-misc-replace-fraction-glyphs) -;;; test-custom-misc-replace-fraction-glyphs.el ends here +(provide 'test-custom-text-transform-replace-fraction-glyphs) +;;; test-custom-text-transform-replace-fraction-glyphs.el ends here diff --git a/tests/test-init-module-headers.el b/tests/test-init-module-headers.el index 22dec1d5f..c01f19368 100644 --- a/tests/test-init-module-headers.el +++ b/tests/test-init-module-headers.el @@ -35,7 +35,9 @@ "custom-datetime" "custom-buffer-file" "custom-line-paragraph" - "custom-misc" + "custom-counts" + "custom-format" + "custom-text-transform" "custom-ordering" "custom-text-enclose" "custom-whitespace" @@ -1351,7 +1351,9 @@ Scope: - =custom-comments.el= - =custom-datetime.el= - =custom-line-paragraph.el= -- =custom-misc.el= +- =custom-counts.el= +- =custom-format.el= +- =custom-text-transform.el= - =custom-ordering.el= - =custom-text-enclose.el= - =custom-whitespace.el= |
