aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2021-11-30 16:54:34 +0100
committerLars Ingebrigtsen2021-11-30 16:54:34 +0100
commita2d98c54f71a8f1c0a1dee32dfcd6c36e5d7c107 (patch)
tree83e96e0061670ac230f01251bd4427b2cedcebce
parent10d371e4fa0aa5f18f006f6698052ba18c1f5987 (diff)
downloademacs-a2d98c54f71a8f1c0a1dee32dfcd6c36e5d7c107.tar.gz
emacs-a2d98c54f71a8f1c0a1dee32dfcd6c36e5d7c107.zip
Use pixel-fill-width in shr.el
* lisp/net/shr.el (shr--window-width): Factor out into own function. (shr-insert-document): Use it. (shr-fill-text): Ditto.
-rw-r--r--lisp/net/shr.el40
1 files changed, 14 insertions, 26 deletions
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 5d38a7e19da..d4c7aaf1c87 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -312,6 +312,18 @@ and other things:
312 (or (not (zerop (fringe-columns 'right))) 312 (or (not (zerop (fringe-columns 'right)))
313 (not (zerop (fringe-columns 'left)))))) 313 (not (zerop (fringe-columns 'left))))))
314 314
315(defun shr--window-width ()
316 ;; Compute the width based on the window width. We need to
317 ;; adjust the available width for when the user disables
318 ;; the fringes, which will cause the display engine usurp
319 ;; one column for the continuation glyph.
320 (if (not shr-use-fonts)
321 (- (window-body-width) 1
322 (if (shr--have-one-fringe-p)
323 1
324 0))
325 (pixel-fill-width)))
326
315;;;###autoload 327;;;###autoload
316(defun shr-insert-document (dom) 328(defun shr-insert-document (dom)
317 "Render the parsed document DOM into the current buffer. 329 "Render the parsed document DOM into the current buffer.
@@ -333,21 +345,7 @@ DOM should be a parse tree as generated by
333 (if (not shr-use-fonts) 345 (if (not shr-use-fonts)
334 shr-width 346 shr-width
335 (* shr-width (frame-char-width))) 347 (* shr-width (frame-char-width)))
336 ;; Compute the width based on the window width. We need to 348 (shr--window-width)))
337 ;; adjust the available width for when the user disables
338 ;; the fringes, which will cause the display engine usurp
339 ;; one column for the continuation glyph.
340 (if (not shr-use-fonts)
341 (- (window-body-width) 1
342 (if (shr--have-one-fringe-p)
343 1
344 0))
345 (- (window-body-width nil t)
346 (* 2 (frame-char-width))
347 (if (shr--have-one-fringe-p)
348 0
349 (* (frame-char-width) 2))
350 1))))
351 (max-specpdl-size max-specpdl-size) 349 (max-specpdl-size max-specpdl-size)
352 ;; `bidi-display-reordering' is supposed to be only used for 350 ;; `bidi-display-reordering' is supposed to be only used for
353 ;; debugging purposes, but Shr's naïve filling algorithm 351 ;; debugging purposes, but Shr's naïve filling algorithm
@@ -626,17 +624,7 @@ size, and full-buffer size."
626 (with-temp-buffer 624 (with-temp-buffer
627 (let ((shr-indentation 0) 625 (let ((shr-indentation 0)
628 (shr-start nil) 626 (shr-start nil)
629 (shr-internal-width (- (window-body-width nil t) 627 (shr-internal-width (shr--window-width)))
630 (* 2 (frame-char-width))
631 ;; Adjust the window width for when
632 ;; the user disables the fringes,
633 ;; which causes the display engine
634 ;; to usurp one column for the
635 ;; continuation glyph.
636 (if (and (null shr-width)
637 (not (shr--have-one-fringe-p)))
638 (* (frame-char-width) 2)
639 0))))
640 (shr-insert text) 628 (shr-insert text)
641 (shr-fill-lines (point-min) (point-max)) 629 (shr-fill-lines (point-min) (point-max))
642 (buffer-string))))) 630 (buffer-string)))))