Subject: Re: bug#56815: 29.0.50; Isearch lazy-highlight highlights too much when truncate-lines is in effect

From: Juri Linkov <[email-masked]>
Date: Tue, 23 Aug 2022 10:41:21 +0300

>> Or can truncated-partial-width-window-p be called directly?  By just
>>
>>   (or truncate-lines (truncated-partial-width-window-p))
>
> Fine by me.

Then I'll push a better patch:

diff --git a/lisp/simple.el b/lisp/simple.el
index 460aff8bd8..72674d3a1d 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -7700,13 +7700,7 @@ line-move
                  ;; Lines are not truncated...
                  (not
                   (and
-                   (or truncate-lines
-                       (and (integerp truncate-partial-width-windows)
-                            (< (window-total-width)
-                               truncate-partial-width-windows))
-                       (and truncate-partial-width-windows
-                            (not (integerp truncate-partial-width-windows))
-                            (not (window-full-width-p))))
+                   (or truncate-lines (truncated-partial-width-window-p))
                    ;; ...or if lines are truncated, this buffer
                    ;; doesn't have very long lines.
                    (long-line-optimizations-p)))
@@ -7716,14 +7710,7 @@ line-move
 	       ;; Display-based column are incompatible with goal-column.
 	       (not goal-column)
                ;; Lines aren't truncated.
-               (not
-                (or truncate-lines
-                    (and (integerp truncate-partial-width-windows)
-                         (< (window-width)
-                            truncate-partial-width-windows))
-                    (and truncate-partial-width-windows
-                         (not (integerp truncate-partial-width-windows))
-                         (not (window-full-width-p)))))
+               (not (or truncate-lines (truncated-partial-width-window-p)))
 	       ;; When the text in the window is scrolled to the left,
 	       ;; display-based motion doesn't make sense (because each
 	       ;; logical line occupies exactly one screen line).
diff --git a/lisp/window.el b/lisp/window.el
index 4d88ffa903..98c14e7bbc 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -9044,10 +9055,7 @@ count-screen-lines
       ;; vertical-motion returns a number that is 1 larger than it
       ;; should.  We need to fix that.
       (setq end-invisible-p
-            (and (or truncate-lines
-                     (and (natnump truncate-partial-width-windows)
-                          (< (window-total-width window)
-                             truncate-partial-width-windows)))
+            (and (or truncate-lines (truncated-partial-width-window-p window))
                  (save-excursion
                    (goto-char finish)
                    (> (- (current-column) (window-hscroll window))