1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-23 07:19:15 +00:00

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.
This commit is contained in:
Lars Ingebrigtsen 2020-07-17 15:45:04 +02:00
parent c7b112b13f
commit 02bad11288
3 changed files with 42 additions and 1 deletions

View File

@ -283,6 +283,14 @@ contrast. If that is still too low for you, you can customize the
variables @code{shr-color-visible-distance-min} and
@code{shr-color-visible-luminance-min} to get a better contrast.
@vindex shr-max-width
@vindex shr-width
By default, the max width used when rendering is 120 characters, but
this can be adjusted by changing the @code{shr-max-width} variable.
If a specified width is preferred no matter what the width of the
window is, @code{shr-width} can be set. If both variables are
@code{nil}, the window width will always be used.
@vindex shr-discard-aria-hidden
@cindex @code{aria-hidden}, HTML attribute
The HTML attribute @code{aria-hidden} is meant to tell screen

View File

@ -478,6 +478,14 @@ other function, it will now be called instead of the default.
** EWW
+++
*** New variable 'shr-max-width'
This defaults to 120 characters, which means that even if you have
very wide frames, HTML text will be rendered more narrowly, which
usually leads to a more readable text. If nil, 'shr-width' is adhered
to as before, and as that defaults to nil, the window width is always
used.
---
*** The command 'eww-follow-link' now supports custom mailto handlers.
The function that is invoked when clicking on or otherwise following a

View File

@ -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