emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-26 f274cbd: Avoid reordering of output in 'shr-inser


From: Eli Zaretskii
Subject: [Emacs-diffs] emacs-26 f274cbd: Avoid reordering of output in 'shr-insert-document'
Date: Sat, 16 Dec 2017 09:10:56 -0500 (EST)

branch: emacs-26
commit f274cbd185ddab4e414ccecf6c0b30e6fd3ef303
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Avoid reordering of output in 'shr-insert-document'
    
    * lisp/net/shr.el (shr-string-pixel-width): Preserve point across
    shr-pixel-column invocations.  (Bug#29734)
---
 lisp/net/shr.el | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 8a64f75..c505f25 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -591,9 +591,14 @@ size, and full-buffer size."
 (defun shr-string-pixel-width (string)
   (if (not shr-use-fonts)
       (length string)
-    (with-temp-buffer
-      (insert string)
-      (shr-pixel-column))))
+    ;; Save and restore point across with-temp-buffer, since
+    ;; shr-pixel-column uses save-window-excursion, which can reset
+    ;; point to 1.
+    (let ((pt (point)))
+      (with-temp-buffer
+        (insert string)
+        (shr-pixel-column))
+      (goto-char pt))))
 
 (defsubst shr--translate-insertion-chars ()
   ;; Remove soft hyphens.



reply via email to

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