From b208b08371044f5c932eb67d85c2a98cc63691b2 Mon Sep 17 00:00:00 2001 From: Roi Martin Date: Wed, 26 Nov 2025 00:16:24 +0100 Subject: [PATCH] Fix bug in semantic linefeed filling Fix bug in semantic linefeed filling related to wide characters and `sentence-end-without-space'. * lisp/textmodes/fill.el (fill-region-as-paragraph-semlf): Fix the calculation of the maximum column. Do not depend on where `fill-region-as-paragraph-default' leaves point after being called. (Bug#79575) --- lisp/textmodes/fill.el | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el index 4ab639497ec..a6858fdea8b 100644 --- a/lisp/textmodes/fill.el +++ b/lisp/textmodes/fill.el @@ -1657,7 +1657,7 @@ For more details about semantic linefeeds, see `https://sembr.org/' and (to (copy-marker (max from to) t)) pfx) (goto-char from) - (let ((fill-column (point-max))) + (let ((fill-column (* 2 (point-max)))) ; Wide characters span up to two columns. (setq pfx (or (save-excursion (fill-region-as-paragraph-default (point) to @@ -1666,14 +1666,18 @@ For more details about semantic linefeeds, see `https://sembr.org/' and squeeze-after)) ""))) (while (< (point) to) - (let ((fill-prefix pfx)) + (let ((fill-to (copy-marker + (min to + (save-excursion + (forward-sentence) + (point))) + t)) + (fill-prefix pfx)) (fill-region-as-paragraph-default (point) - (min to - (save-excursion - (forward-sentence) - (point))) + fill-to justify - t)) + t) + (goto-char fill-to)) (when (and (> (point) (line-beginning-position)) (< (point) (line-end-position)) (< (point) to))