]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix disruption of windows' display by shr.el
authorEli Zaretskii <eliz@gnu.org>
Thu, 16 Jun 2022 16:53:45 +0000 (19:53 +0300)
committerEli Zaretskii <eliz@gnu.org>
Thu, 16 Jun 2022 16:53:45 +0000 (19:53 +0300)
* 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
src/window.c

index 505a093392e990349a044523163b26cb988ef515..b54144576ef17466378f0d2fde85174d5b866501 100644 (file)
@@ -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))))
 
index c94e7bde29f7489b788573474f52e26fe4eac7a2..ad7a85cf550ec04a2dbad1f013b319e2938b3ffb 100644 (file)
@@ -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);