emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 5eb9383ccc: Fix disruption of windows' display by shr.el


From: Eli Zaretskii
Subject: master 5eb9383ccc: Fix disruption of windows' display by shr.el
Date: Thu, 16 Jun 2022 12:55:32 -0400 (EDT)

branch: master
commit 5eb9383ccc9cc74c4e788e5c390412c98da56296
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Fix disruption of windows' display by shr.el
    
    * src/window.c (struct saved_window): New member 'vscroll'.
    (Fset_window_configuration, save_window_save): Save and restore
    the window's vscroll value.
    
    * lisp/net/shr.el (shr-insert-document): Restore the original
    window's hscroll, in case we are rendering in a window other than
    where the document will be eventually displayed.  This avoids
    resetting hscroll of windows we use temporarily for shr's
    rendering job.  (Bug#56008)
---
 lisp/net/shr.el | 14 +++++++++-----
 src/window.c    |  3 +++
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 505a093392..b54144576e 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -361,6 +361,7 @@ DOM should be a parse tree as generated by
            (shr--window-width)))
         (max-specpdl-size max-specpdl-size)
         (shr--link-targets nil)
+        (hscroll (window-hscroll))
         ;; `bidi-display-reordering' is supposed to be only used for
         ;; debugging purposes, but Shr's naïve filling algorithm
         ;; cannot cope with the complexity of RTL text in an LTR
@@ -380,11 +381,14 @@ DOM should be a parse tree as generated by
     ;; below will misbehave, because it silently assumes that it
     ;; starts with a non-hscrolled window (vertical-motion will move
     ;; to a wrong place otherwise).
-    (set-window-hscroll nil 0)
-    (shr-descend dom)
-    (shr-fill-lines start (point))
-    (shr--remove-blank-lines-at-the-end start (point))
-    (shr--set-target-ids shr--link-targets)
+    (unwind-protect
+        (progn
+          (set-window-hscroll nil 0)
+          (shr-descend dom)
+          (shr-fill-lines start (point))
+          (shr--remove-blank-lines-at-the-end start (point))
+          (shr--set-target-ids shr--link-targets))
+      (set-window-hscroll nil hscroll))
     (when shr-warning
       (message "%s" shr-warning))))
 
diff --git a/src/window.c b/src/window.c
index c94e7bde29..ad7a85cf55 100644
--- a/src/window.c
+++ b/src/window.c
@@ -6901,6 +6901,7 @@ struct saved_window
   Lisp_Object left_col, top_line, total_cols, total_lines;
   Lisp_Object normal_cols, normal_lines;
   Lisp_Object hscroll, min_hscroll, hscroll_whole, suspend_auto_hscroll;
+  Lisp_Object vscroll;
   Lisp_Object parent, prev;
   Lisp_Object start_at_line_beg;
   Lisp_Object display_table;
@@ -7128,6 +7129,7 @@ the return value is nil.  Otherwise the value is t.  */)
          w->suspend_auto_hscroll = !NILP (p->suspend_auto_hscroll);
          w->min_hscroll = XFIXNAT (p->min_hscroll);
          w->hscroll_whole = XFIXNAT (p->hscroll_whole);
+         w->vscroll = -XFIXNAT (p->vscroll);
          wset_display_table (w, p->display_table);
          w->left_margin_cols = XFIXNUM (p->left_margin_cols);
          w->right_margin_cols = XFIXNUM (p->right_margin_cols);
@@ -7462,6 +7464,7 @@ save_window_save (Lisp_Object window, struct Lisp_Vector 
*vector, ptrdiff_t i)
       p->suspend_auto_hscroll = w->suspend_auto_hscroll ? Qt : Qnil;
       XSETFASTINT (p->min_hscroll, w->min_hscroll);
       XSETFASTINT (p->hscroll_whole, w->hscroll_whole);
+      XSETFASTINT (p->vscroll, -w->vscroll);
       p->display_table = w->display_table;
       p->left_margin_cols = make_fixnum (w->left_margin_cols);
       p->right_margin_cols = make_fixnum (w->right_margin_cols);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]