diff options
| author | Lars Ingebrigtsen | 2022-01-26 16:17:49 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-01-26 16:20:05 +0100 |
| commit | c9524819eaf4e561a184b04dfca7e42970dc8809 (patch) | |
| tree | 9aca5d7f6cad95f8fe3c6a67aeedb24d9cf78b4a | |
| parent | 6075ea0b79922765df29ac148ac3a1fbb236ed94 (diff) | |
| download | emacs-c9524819eaf4e561a184b04dfca7e42970dc8809.tar.gz emacs-c9524819eaf4e561a184b04dfca7e42970dc8809.zip | |
Partially revert a fill-region-as-paragraph regression
* lisp/textmodes/fill.el (fill-region-as-paragraph): Revert
e186af261 (bug#53537), because it leads to regressions. (But
leave tests in place.)
| -rw-r--r-- | lisp/textmodes/fill.el | 18 | ||||
| -rw-r--r-- | test/lisp/textmodes/fill-tests.el | 23 |
2 files changed, 27 insertions, 14 deletions
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el index 92e50ec2908..beb30c6e950 100644 --- a/lisp/textmodes/fill.el +++ b/lisp/textmodes/fill.el | |||
| @@ -714,8 +714,7 @@ space does not end a sentence, so don't break a line there." | |||
| 714 | (or justify (setq justify (current-justification))) | 714 | (or justify (setq justify (current-justification))) |
| 715 | 715 | ||
| 716 | ;; Don't let Adaptive Fill mode alter the fill prefix permanently. | 716 | ;; Don't let Adaptive Fill mode alter the fill prefix permanently. |
| 717 | (let ((actual-fill-prefix fill-prefix) | 717 | (let ((fill-prefix fill-prefix)) |
| 718 | (fill-prefix fill-prefix)) | ||
| 719 | ;; Figure out how this paragraph is indented, if desired. | 718 | ;; Figure out how this paragraph is indented, if desired. |
| 720 | (when (and adaptive-fill-mode | 719 | (when (and adaptive-fill-mode |
| 721 | (or (null fill-prefix) (string= fill-prefix ""))) | 720 | (or (null fill-prefix) (string= fill-prefix ""))) |
| @@ -755,18 +754,9 @@ space does not end a sentence, so don't break a line there." | |||
| 755 | 754 | ||
| 756 | ;; This is the actual filling loop. | 755 | ;; This is the actual filling loop. |
| 757 | (goto-char from) | 756 | (goto-char from) |
| 758 | (let ((first t) | 757 | (let (linebeg) |
| 759 | linebeg) | 758 | (while (< (point) to) |
| 760 | (while (< (point) to) | 759 | (setq linebeg (point)) |
| 761 | ;; On the first line, there may be text in the fill prefix | ||
| 762 | ;; zone (when `fill-prefix' is specified externally, and | ||
| 763 | ;; not computed). In that case, don't consider that area | ||
| 764 | ;; when trying to find a place to put a line break | ||
| 765 | ;; (bug#45720). | ||
| 766 | (if (not first) | ||
| 767 | (setq linebeg (point)) | ||
| 768 | (setq first nil | ||
| 769 | linebeg (+ (point) (length actual-fill-prefix)))) | ||
| 770 | (move-to-column (current-fill-column)) | 760 | (move-to-column (current-fill-column)) |
| 771 | (if (when (and (< (point) to) (< linebeg to)) | 761 | (if (when (and (< (point) to) (< linebeg to)) |
| 772 | ;; Find the position where we'll break the line. | 762 | ;; Find the position where we'll break the line. |
diff --git a/test/lisp/textmodes/fill-tests.el b/test/lisp/textmodes/fill-tests.el index 39e5dd3d26c..8b9f144dfff 100644 --- a/test/lisp/textmodes/fill-tests.el +++ b/test/lisp/textmodes/fill-tests.el | |||
| @@ -45,6 +45,8 @@ | |||
| 45 | (should (string= (buffer-string) "Abc\nd efg\n(h ijk).")))) | 45 | (should (string= (buffer-string) "Abc\nd efg\n(h ijk).")))) |
| 46 | 46 | ||
| 47 | (ert-deftest fill-test-unbreakable-paragraph () | 47 | (ert-deftest fill-test-unbreakable-paragraph () |
| 48 | ;; See bug#45720 and bug#53537. | ||
| 49 | :expected-result :failed | ||
| 48 | (with-temp-buffer | 50 | (with-temp-buffer |
| 49 | (let ((string "aaa = baaaaaaaaaaaaaaaaaaaaaaaaaaaa\n")) | 51 | (let ((string "aaa = baaaaaaaaaaaaaaaaaaaaaaaaaaaa\n")) |
| 50 | (insert string) | 52 | (insert string) |
| @@ -76,6 +78,27 @@ | |||
| 76 | (buffer-string) | 78 | (buffer-string) |
| 77 | "aaa = baaaaaaaa aaaaaaaaaa\n aaaaaaaaaa\n"))))) | 79 | "aaa = baaaaaaaa aaaaaaaaaa\n aaaaaaaaaa\n"))))) |
| 78 | 80 | ||
| 81 | (ert-deftest test-fill-haskell () | ||
| 82 | (should | ||
| 83 | (equal | ||
| 84 | (with-temp-buffer | ||
| 85 | (asm-mode) | ||
| 86 | (dolist (line '(" ;; a b c" | ||
| 87 | " ;; d e f" | ||
| 88 | " ;; x y z" | ||
| 89 | " ;; w")) | ||
| 90 | (insert line "\n")) | ||
| 91 | (goto-char (point-min)) | ||
| 92 | (end-of-line) | ||
| 93 | (setf fill-column 10) | ||
| 94 | (fill-paragraph nil) | ||
| 95 | (buffer-string)) | ||
| 96 | " ;; a b c | ||
| 97 | ;; d e f | ||
| 98 | ;; x y z | ||
| 99 | ;; w | ||
| 100 | "))) | ||
| 101 | |||
| 79 | (provide 'fill-tests) | 102 | (provide 'fill-tests) |
| 80 | 103 | ||
| 81 | ;;; fill-tests.el ends here | 104 | ;;; fill-tests.el ends here |