summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2017-12-16 16:09:41 +0200
committerEli Zaretskii <eliz@gnu.org>2017-12-16 16:09:41 +0200
commitf274cbd185ddab4e414ccecf6c0b30e6fd3ef303 (patch)
tree26a033bbc0fd9debd96ba2d72e11fd85bd477756 /lisp
parent78908644131e70f20de28fed08ef4dc2878878a3 (diff)
downloademacs-f274cbd185ddab4e414ccecf6c0b30e6fd3ef303.tar.gz
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)
Diffstat (limited to 'lisp')
-rw-r--r--lisp/net/shr.el11
1 files changed, 8 insertions, 3 deletions
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 8a64f7549f2..c505f25a5a9 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.