Subject: bug#16204: eww does not respect shr-width customization

From: Kenjiro NAKAYAMA <[email-masked]>
Date: Sat, 21 Dec 2013 19:48:46 +0900

> 	As currently implemented, eww-display-html simply resets
> 	shr-width to nil, disrespecting any user’s customization
> 	thereof, and providing no easy way to specify the HTML rendering
> 	width to use in EWW buffers.

Yes, I think so too.
I wrote the patch to cusomize rendering-width(shr-width) easily by users.

Signed-off-by: Kenjiro NAKAYAMA <[email-masked]>

        * net/eww.el(eww-rendering-width): New value to set rendering width.
        (eww-mode-map): New key map to eww-set-rendering-width.
        (easy-menu-define): New easy menu of eww-set-rendering-width.
        (eww-set-rendering-width): New function to set rendering width.
        (eww-display-html): Change to enable shr-width to set by users.
        Suggested by Ivan Shmakov <[email-masked]>

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 2263f81..43adb41 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -129,6 +129,7 @@ See also `eww-form-checkbox-selected-symbol'."
 (defvar eww-home-url nil)
 (defvar eww-start-url nil)
 (defvar eww-contents-url nil)
+(defvar eww-rendering-width nil)

 (defvar eww-local-regex "localhost"
   "When this regex is found in the URL, it's not a keyword but an address.")
@@ -255,7 +256,7 @@ word(s) will be searched for via `eww-search-prefix'."
     (setq eww-current-dom document)
     (let ((inhibit-read-only t)
 	  (after-change-functions nil)
-	  (shr-width nil)
+	  (shr-width eww-rendering-width)
 	  (shr-target-id (url-target (url-generic-parse-url url)))
 	  (shr-external-rendering-functions
 	   '((title . eww-tag-title)
@@ -419,6 +420,7 @@ word(s) will be searched for via `eww-search-prefix'."
     (define-key map "B" 'eww-list-bookmarks)
     (define-key map [(meta n)] 'eww-next-bookmark)
     (define-key map [(meta p)] 'eww-previous-bookmark)
+    (define-key map [(meta s)] 'eww-set-rendering-width)

     (easy-menu-define nil map ""
       '("Eww"
@@ -435,7 +437,8 @@ word(s) will be searched for via `eww-search-prefix'."
 	["Copy page URL" eww-copy-page-url t]
 	["Add bookmark" eww-add-bookmark t]
 	["List bookmarks" eww-list-bookmarks t]
-	["List cookies" url-cookie-list t]))
+	["List cookies" url-cookie-list t]
+	["Set rendering width" eww-set-rendering-width t]))
     map))

 (define-derived-mode eww-mode nil "eww"
@@ -543,6 +546,15 @@ appears in a <link> or <a> tag."
   (url-retrieve eww-current-url 'eww-render
 		(list eww-current-url (point))))

+(defun eww-set-rendering-width (width)
+  "Set the redering width."
+  (interactive "nSet new redering width (0: window-width) :")
+  (if (zerop width)
+      (setq eww-rendering-width nil)
+    (if (wholenump width)
+	(setq eww-rendering-width width)
+      (message "Set Number to rendering width"))))
+
 ;; Form support.

 (defvar eww-form nil)
---

Kenjiro NAKAYAMA

[email-masked] writes:

> Package:  emacs
> Severity: wishlist
>
> 	As currently implemented, eww-display-html simply resets
> 	shr-width to nil, disrespecting any user’s customization
> 	thereof, and providing no easy way to specify the HTML rendering
> 	width to use in EWW buffers.