summaryrefslogtreecommitdiff
path: root/lisp/net
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2021-11-30 16:54:34 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2021-11-30 16:54:34 +0100
commita2d98c54f71a8f1c0a1dee32dfcd6c36e5d7c107 (patch)
tree83e96e0061670ac230f01251bd4427b2cedcebce /lisp/net
parent10d371e4fa0aa5f18f006f6698052ba18c1f5987 (diff)
downloademacs-a2d98c54f71a8f1c0a1dee32dfcd6c36e5d7c107.tar.gz
emacs-a2d98c54f71a8f1c0a1dee32dfcd6c36e5d7c107.tar.bz2
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.
Diffstat (limited to 'lisp/net')
-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:
(or (not (zerop (fringe-columns 'right)))
(not (zerop (fringe-columns 'left))))))
+(defun shr--window-width ()
+ ;; Compute the width based on the window width. We need to
+ ;; adjust the available width for when the user disables
+ ;; the fringes, which will cause the display engine usurp
+ ;; one column for the continuation glyph.
+ (if (not shr-use-fonts)
+ (- (window-body-width) 1
+ (if (shr--have-one-fringe-p)
+ 1
+ 0))
+ (pixel-fill-width)))
+
;;;###autoload
(defun shr-insert-document (dom)
"Render the parsed document DOM into the current buffer.
@@ -333,21 +345,7 @@ DOM should be a parse tree as generated by
(if (not shr-use-fonts)
shr-width
(* shr-width (frame-char-width)))
- ;; Compute the width based on the window width. We need to
- ;; adjust the available width for when the user disables
- ;; the fringes, which will cause the display engine usurp
- ;; one column for the continuation glyph.
- (if (not shr-use-fonts)
- (- (window-body-width) 1
- (if (shr--have-one-fringe-p)
- 1
- 0))
- (- (window-body-width nil t)
- (* 2 (frame-char-width))
- (if (shr--have-one-fringe-p)
- 0
- (* (frame-char-width) 2))
- 1))))
+ (shr--window-width)))
(max-specpdl-size max-specpdl-size)
;; `bidi-display-reordering' is supposed to be only used for
;; debugging purposes, but Shr's naïve filling algorithm
@@ -626,17 +624,7 @@ size, and full-buffer size."
(with-temp-buffer
(let ((shr-indentation 0)
(shr-start nil)
- (shr-internal-width (- (window-body-width nil t)
- (* 2 (frame-char-width))
- ;; Adjust the window width for when
- ;; the user disables the fringes,
- ;; which causes the display engine
- ;; to usurp one column for the
- ;; continuation glyph.
- (if (and (null shr-width)
- (not (shr--have-one-fringe-p)))
- (* (frame-char-width) 2)
- 0))))
+ (shr-internal-width (shr--window-width)))
(shr-insert text)
(shr-fill-lines (point-min) (point-max))
(buffer-string)))))