[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master a8862f313b: Merge from origin/emacs-28
From: |
Stefan Kangas |
Subject: |
master a8862f313b: Merge from origin/emacs-28 |
Date: |
Thu, 27 Jan 2022 04:04:34 -0500 (EST) |
branch: master
commit a8862f313b92ac0fad35c7240ef4da8e52d55c1d
Merge: 82aa5be7ce c9524819ea
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>
Merge from origin/emacs-28
c9524819ea Partially revert a fill-region-as-paragraph regression
6075ea0b79 Fix 'make_lispy_position' when there's an image at EOB
# Conflicts:
# test/lisp/textmodes/fill-tests.el
---
lisp/textmodes/fill.el | 18 ++++--------------
src/xdisp.c | 3 ++-
test/lisp/textmodes/fill-tests.el | 23 +++++++++++++++++++++++
3 files changed, 29 insertions(+), 15 deletions(-)
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
index f41fd186e7..87cea5216a 100644
--- a/lisp/textmodes/fill.el
+++ b/lisp/textmodes/fill.el
@@ -713,8 +713,7 @@ space does not end a sentence, so don't break a line there."
(or justify (setq justify (current-justification)))
;; Don't let Adaptive Fill mode alter the fill prefix permanently.
- (let ((actual-fill-prefix fill-prefix)
- (fill-prefix fill-prefix))
+ (let ((fill-prefix fill-prefix))
;; Figure out how this paragraph is indented, if desired.
(when (and adaptive-fill-mode
(or (null fill-prefix) (string= fill-prefix "")))
@@ -754,18 +753,9 @@ space does not end a sentence, so don't break a line
there."
;; This is the actual filling loop.
(goto-char from)
- (let ((first t)
- linebeg)
- (while (< (point) to)
- ;; On the first line, there may be text in the fill prefix
- ;; zone (when `fill-prefix' is specified externally, and
- ;; not computed). In that case, don't consider that area
- ;; when trying to find a place to put a line break
- ;; (bug#45720).
- (if (not first)
- (setq linebeg (point))
- (setq first nil
- linebeg (+ (point) (length actual-fill-prefix))))
+ (let (linebeg)
+ (while (< (point) to)
+ (setq linebeg (point))
(move-to-column (current-fill-column))
(if (when (and (< (point) to) (< linebeg to))
;; Find the position where we'll break the line.
diff --git a/src/xdisp.c b/src/xdisp.c
index 9c0764be69..26bd45a861 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -10216,7 +10216,8 @@ move_it_to (struct it *it, ptrdiff_t to_charpos, int
to_x, int to_y, int to_vpos
could have both positions after TO_CHARPOS or
both positions before it, due to bidi
reordering.) */
- if (IT_CHARPOS (*it) != to_charpos
+ if (to_charpos > 0
+ && IT_CHARPOS (*it) != to_charpos
&& ((IT_CHARPOS (it_backup) > to_charpos)
== (IT_CHARPOS (*it) > to_charpos)))
{
diff --git a/test/lisp/textmodes/fill-tests.el
b/test/lisp/textmodes/fill-tests.el
index a3265e2445..b730de5a69 100644
--- a/test/lisp/textmodes/fill-tests.el
+++ b/test/lisp/textmodes/fill-tests.el
@@ -45,6 +45,8 @@
(should (string= (buffer-string) "Abc\nd efg\n(h ijk)."))))
(ert-deftest fill-test-unbreakable-paragraph ()
+ ;; See bug#45720 and bug#53537.
+ :expected-result :failed
(with-temp-buffer
(let ((string "aaa = baaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"))
(insert string)
@@ -98,6 +100,27 @@
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eius. Foo")))
+(ert-deftest test-fill-haskell ()
+ (should
+ (equal
+ (with-temp-buffer
+ (asm-mode)
+ (dolist (line '(" ;; a b c"
+ " ;; d e f"
+ " ;; x y z"
+ " ;; w"))
+ (insert line "\n"))
+ (goto-char (point-min))
+ (end-of-line)
+ (setf fill-column 10)
+ (fill-paragraph nil)
+ (buffer-string))
+ " ;; a b c
+ ;; d e f
+ ;; x y z
+ ;; w
+")))
+
(provide 'fill-tests)
;;; fill-tests.el ends here