]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid reordering of output in 'shr-insert-document'
authorEli Zaretskii <eliz@gnu.org>
Sat, 16 Dec 2017 14:09:41 +0000 (16:09 +0200)
committerEli Zaretskii <eliz@gnu.org>
Sat, 16 Dec 2017 14:09:41 +0000 (16:09 +0200)
* lisp/net/shr.el (shr-string-pixel-width): Preserve point across
shr-pixel-column invocations.  (Bug#29734)

lisp/net/shr.el

index 8a64f7549f28493c02fa000422e4d13d8cc6754c..c505f25a5a945bd4ea1070f2ab9a46af1223ed82 100644 (file)
@@ -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.