diff options
author | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2025-01-21 11:50:44 +0900 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2025-01-25 12:17:32 +0200 |
commit | 192355e54af91ad6e7d1343071a749e1ced29400 (patch) | |
tree | dd4676867cd19ed6f4c6266b993c86f5ea25454f /test/lisp/emacs-lisp | |
parent | d4ca688abefa90cf3e54add036b32c06b7da6363 (diff) | |
download | emacs-192355e54af91ad6e7d1343071a749e1ced29400.tar.gz emacs-192355e54af91ad6e7d1343071a749e1ced29400.tar.bz2 emacs-192355e54af91ad6e7d1343071a749e1ced29400.zip |
lisp: Introduce a `lisp-fill-paragraph-as-displayed' variable.
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. Introduce
`lisp-fill-paragraph-as-displayed' as a new variable allowing
opting out of this new behavior in specific scenarios (such as
when using the Scheme major mode, say).
* lisp/emacs-lisp/lisp-mode.el
(lisp-fill-paragraph-as-displayed): New variable.
(lisp-fill-paragraph): Honor it, by avoiding the logic narrow to
strings before applying fill-paragraph.
* test/lisp/emacs-lisp/lisp-mode-tests.el
(lisp-fill-paragraph-respects-fill-column): Test it.
(lisp-fill-paragraph-docstring-boundaries): New test, as a
safeguard to avoid regressions.
Fixes: bug#56197
Diffstat (limited to 'test/lisp/emacs-lisp')
-rw-r--r-- | test/lisp/emacs-lisp/lisp-mode-tests.el | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/lisp-mode-tests.el b/test/lisp/emacs-lisp/lisp-mode-tests.el index 3a765eab625..96e37114276 100644 --- a/test/lisp/emacs-lisp/lisp-mode-tests.el +++ b/test/lisp/emacs-lisp/lisp-mode-tests.el @@ -309,6 +309,53 @@ Expected initialization file: `%s'\" (should (equal (buffer-string) orig))))) +;;; Filling + +(ert-deftest lisp-fill-paragraph-docstring-boundaries () + "Test bug#28937, ensuring filling the docstring filled is properly +bounded." + (with-temp-buffer + (insert "\ +(defun test () + \"This is a test docstring. +Here is some more text.\" + 1 + 2 + 3 + 4 + 5)") + (let ((correct (buffer-string))) + (emacs-lisp-mode) + (search-backward "This is a test docstring") + (fill-paragraph) ;function under test + (should (equal (buffer-string) correct))))) + +(ert-deftest lisp-fill-paragraph-as-displayed () + "Test bug#56197 -- more specifically, validate that a leading indentation +for a string is preserved in the filled string." + (let ((lisp-fill-paragraph-as-displayed t) ;variable under test + ;; The following is a contrived example that demonstrates the + ;; fill-column problem when the string to fill is indented. + (source "\ +'(description \"This is a very 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.\")")) + (with-temp-buffer + (insert source) + (emacs-lisp-mode) + (search-backward "This is a very long string") + (fill-paragraph) ;function under test + (goto-char (point-min)) + (message "%s" (buffer-substring-no-properties (point-min) (point-max))) + (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 (ert-deftest lisp-fontify-confusables () |