From aacf65440070df2ba356af1d118a50993fc8f865 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Mon, 30 Dec 2024 12:02:36 +0900 Subject: [PATCH 1/3] test/lisp: Add new test for filling behavior change. Starting with Emacs 28, filling strings now happens in a narrowed scope, and looses the leading indentation and can cause the string to extend past the fill-column value (see bug#56197). * test/lisp/emacs-lisp/lisp-mode-tests.el (lisp-fill-paragraph-respects-fill-column): New test. --- test/lisp/emacs-lisp/lisp-mode-tests.el | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/lisp/emacs-lisp/lisp-mode-tests.el b/test/lisp/emacs-lisp/lisp-mode-tests.el index da02be65d03..9a2b1ea4654 100644 --- a/test/lisp/emacs-lisp/lisp-mode-tests.el +++ b/test/lisp/emacs-lisp/lisp-mode-tests.el @@ -308,6 +308,33 @@ lisp-indent-defun (indent-region (point-min) (point-max)) (should (equal (buffer-string) orig))))) + +;;; Filling + +(ert-deftest lisp-fill-paragraph-respects-fill-column () + "Test bug#56197 -- more specifically, validate that a leading indentation +for a string is preserved in the filled string." + (with-temp-buffer + ;; The following is a contrived example that demonstrates the + ;; fill-column problem when the string to fill is indented. + (insert "\ +\(defun test () + \"This is a long string which is indented by a considerable value, +causing it to protrude from the configured `fill-column' since +lisp-fill-paragraph was refactored in version 28.\" + (message \"Hi!\"))") + (emacs-lisp-mode) + (search-backward "This is a long string") + (fill-paragraph) ;function under test + (goto-char (point-min)) + (let ((i 1) + (lines-count (count-lines (point-min) (point-max)))) + (while (< i lines-count) + (beginning-of-line i) + (end-of-line) + (should (<= (current-column) fill-column)) + (setq i (1+ i)))))) + ;;; Fontification base-commit: e32484547d0813665334bfd34b741492dde0d374 -- 2.46.0