From 15a4c19fc24a4422122844e20be7ab569d676865 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 11 Jul 2026 14:18:02 -0500 Subject: fix(custom-comments): correct comment-reformat and inline-border cj/comment-reformat printed "No region was selected" on every call, even successful ones, because the message sat outside the if. Its fill-column shrink used a raw setq and restore, so an error mid-join left fill-column permanently at -3. It now signals a user-error when there's no region and dynamically binds fill-column, which restores itself. cj/--comment-inline-border sized the right decoration from text-length parity, leaving even-length and empty text two columns short and misaligning stacked dividers. It now fills the exact remaining width. Both fixes ship with tests, and the inline-border test asserts exact width across parities. --- tests/test-custom-comments-comment-reformat.el | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'tests/test-custom-comments-comment-reformat.el') diff --git a/tests/test-custom-comments-comment-reformat.el b/tests/test-custom-comments-comment-reformat.el index 83248aee..91b7dfe3 100644 --- a/tests/test-custom-comments-comment-reformat.el +++ b/tests/test-custom-comments-comment-reformat.el @@ -146,19 +146,12 @@ Insert CONTENT-BEFORE, select all, run cj/comment-reformat, verify EXPECTED-AFTE (should (string-match-p ";; Start line 1.*Start line 2" (buffer-string))))) (ert-deftest test-comment-reformat-elisp-no-region-active () - "Should show message when no region selected." + "Should signal `user-error' when no region is selected." (with-temp-buffer (emacs-lisp-mode) (insert ";; Comment line") (deactivate-mark) - (let ((message-log-max nil) - (messages '())) - ;; Capture messages - (cl-letf (((symbol-function 'message) - (lambda (format-string &rest args) - (push (apply #'format format-string args) messages)))) - (cj/comment-reformat) - (should (string-match-p "No region was selected" (car messages))))))) + (should-error (cj/comment-reformat) :type 'user-error))) (ert-deftest test-comment-reformat-elisp-read-only-buffer () "Should signal error in read-only buffer." -- cgit v1.2.3