summaryrefslogtreecommitdiff
path: root/lisp/net/shr.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2020-07-17 15:45:04 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2020-07-17 15:45:04 +0200
commit02bad11288d630595de7e088584d3f8b60cac676 (patch)
treeb5ec9780a0aad8d2036e73ac164122cb6e1c4955 /lisp/net/shr.el
parentc7b112b13fd93b83b3a2b4046c3ffa19cad3d18a (diff)
downloademacs-02bad11288d630595de7e088584d3f8b60cac676.tar.gz
emacs-02bad11288d630595de7e088584d3f8b60cac676.tar.bz2
emacs-02bad11288d630595de7e088584d3f8b60cac676.zip
Add support for a shr-max-width variable
* doc/misc/eww.texi (Advanced): Document it. * lisp/net/shr.el (shr-max-width): Add new variable (bug#40909). (shr-insert-document): Use it.
Diffstat (limited to 'lisp/net/shr.el')
-rw-r--r--lisp/net/shr.el27
1 files changed, 26 insertions, 1 deletions
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index daaed3bc4fa..d6bdb4c17e0 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -99,11 +99,28 @@ If nil, don't draw horizontal table lines."
May either be an integer specifying a fixed width in characters,
or nil, meaning that the full width of the window should be used.
If `shr-use-fonts' is set, the mean character width is used to
-compute the pixel width, which is used instead."
+compute the pixel width, which is used instead.
+
+Also see `shr-max-width'."
:version "25.1"
:type '(choice (integer :tag "Fixed width in characters")
(const :tag "Use the width of the window" nil)))
+(defcustom shr-max-width 120
+ "Maximum text width to use for rendering.
+May either be an intereger specifying a fixed width in characters,
+or nil, meaning that there is no maximum width.
+
+If `shr-use-fonts' is set, the mean character width is used to
+compute the pixel width, which is used instead.
+
+Also see `shr-width'. If `shr-width' is set, it overrides
+`shr-max-width', and if `shr-width' is nil, the frame width is
+used to compute the width to use."
+ :version "28.1"
+ :type '(choice (integer :tag "Fixed width in characters")
+ (const :tag "No maximum width" nil)))
+
(defcustom shr-bullet "* "
"Bullet used for unordered lists.
Alternative suggestions are:
@@ -290,6 +307,14 @@ DOM should be a parse tree as generated by
1))))
(max-specpdl-size max-specpdl-size)
bidi-display-reordering)
+ ;; Adjust for max width specification.
+ (when (and shr-max-width
+ (not shr-width))
+ (setq shr-internal-width
+ (min shr-internal-width
+ (if shr-use-fonts
+ (* shr-max-width (frame-char-width))
+ shr-max-width))))
;; If the window was hscrolled for some reason, shr-fill-lines
;; below will misbehave, because it silently assumes that it
;; starts with a non-hscrolled window (vertical-motion will move