From: Ivan Kanis <ivan@kanis.fr>
To: Lars Magne Ingebrigtsen <larsi@gnus.org>
Cc: 16204@debbugs.gnu.org
Subject: bug#16204: proposed patch for 24.4
Date: Thu, 07 Aug 2014 16:21:55 +0200 [thread overview]
Message-ID: <87fvh87530.fsf@kanis.fr> (raw)
In-Reply-To: Ivan Kanis's message of "Wed\, 06 Aug 2014 22\:14\:52 +0200"
August, 06 at 22:14 Ivan wrote:
> August, 06 at 19:34 Ivan wrote:
>
>> August, 05 at 19:31 Lars Magne Ingebrigtsen wrote:
>>
>>> Ivan Kanis <ivan@kanis.fr> writes:
>>>
>>>> I can commit it if everyone is OK with this.
>>>
>>> Yes, looks good to me. Please apply.
>>
>> Things have drastically changed. I can't even apply my patch by hand. I
>> am compiling the latest emacs-24 and let you know how it behaves.
Hi Lars,
I could not apply my patch because it was already applied. Duh.
Since I wrote the patch shr-width is used throughout the code. If it is
set to nil it will fail with comparison < <=.
I think the easiest way to work around this is to create a new variable
shr-internal-width that holds the internal value of the web page without
changing the user's customized shr-width.
I have attached the patch below.
I can think of three other ways to fix it:
1) create a function
2) create a macro
3) use (let ((shr-internal-width everywhere shr-width is used
They all seem overkill.
Let me know what you think.
Ivan
=== modified file 'lisp/net/eww.el'
--- lisp/net/eww.el 2014-06-27 00:48:34 +0000
+++ lisp/net/eww.el 2014-08-06 17:22:14 +0000
@@ -264,7 +264,6 @@
(setq eww-current-dom document)
(let ((inhibit-read-only t)
(after-change-functions nil)
- (shr-width nil)
(shr-target-id (url-target (url-generic-parse-url url)))
(shr-external-rendering-functions
'((title . eww-tag-title)
=== modified file 'lisp/net/shr.el'
--- lisp/net/shr.el 2014-04-14 22:01:54 +0000
+++ lisp/net/shr.el 2014-08-07 14:10:57 +0000
@@ -130,6 +130,7 @@
(defvar shr-start nil)
(defvar shr-indentation 0)
(defvar shr-inhibit-images nil)
+(defvar shr-internal-width (or shr-width (1- (window-width))))
(defvar shr-list-mode nil)
(defvar shr-content-cache nil)
(defvar shr-kinsoku-shorten nil)
@@ -197,7 +198,7 @@
(shr-state nil)
(shr-start nil)
(shr-base nil)
- (shr-width (or shr-width (1- (window-width)))))
+ (shr-internal-width (or shr-width (1- (window-width)))))
(shr-descend (shr-transform-dom dom))
(shr-remove-trailing-whitespace start (point))))
@@ -467,8 +468,8 @@
(insert elem)
(setq shr-state nil)
(let (found)
- (while (and (> (current-column) shr-width)
- (> shr-width 0)
+ (while (and (> (current-column) shr-internal-width)
+ (> shr-internal-width 0)
(progn
(setq found (shr-find-fill-point))
(not (eolp))))
@@ -482,10 +483,10 @@
(when (> shr-indentation 0)
(shr-indent))
(end-of-line))
- (if (<= (current-column) shr-width)
+ (if (<= (current-column) shr-internal-width)
(insert " ")
;; In case we couldn't get a valid break point (because of a
- ;; word that's longer than `shr-width'), just break anyway.
+ ;; word that's longer than `shr-internal-width'), just break anyway.
(insert "\n")
(when (> shr-indentation 0)
(shr-indent)))))
@@ -493,7 +494,7 @@
(delete-char -1)))))
(defun shr-find-fill-point ()
- (when (> (move-to-column shr-width) shr-width)
+ (when (> (move-to-column shr-internal-width) shr-internal-width)
(backward-char 1))
(let ((bp (point))
failed)
@@ -533,7 +534,7 @@
;; so we look for the second best position.
(while (and (progn
(forward-char 1)
- (<= (current-column) shr-width))
+ (<= (current-column) shr-internal-width))
(progn
(setq bp (point))
(shr-char-kinsoku-eol-p (following-char)))))
@@ -1336,7 +1337,7 @@
(defun shr-tag-hr (_cont)
(shr-ensure-newline)
- (insert (make-string shr-width shr-hr-line) "\n"))
+ (insert (make-string shr-internal-width shr-hr-line) "\n"))
(defun shr-tag-title (cont)
(shr-heading cont 'bold 'underline))
@@ -1629,7 +1630,7 @@
(setq style (nconc (list (cons 'color fgcolor)) style)))
(when style
(setq shr-stylesheet (append style shr-stylesheet)))
- (let ((shr-width width)
+ (let ((shr-internal-width width)
(shr-indentation 0))
(shr-descend (cons 'td cont)))
;; Delete padding at the bottom of the TDs.
@@ -1701,7 +1702,8 @@
(dotimes (i (length columns))
(aset widths i (max (truncate (* (aref columns i)
total-percentage
- (- shr-width (1+ (length columns)))))
+ (- shr-internal-width
+ (1+ (length columns)))))
10)))
widths))
--
No race can prosper till it learns that there is as much dignity in
tilling a field as in writing a poem.
-- Booker T. Washington
next prev parent reply other threads:[~2014-08-07 14:21 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-20 17:01 bug#16204: eww does not respect shr-width customization Ivan Shmakov
2013-12-21 10:48 ` Kenjiro NAKAYAMA
2013-12-21 11:08 ` Ivan Shmakov
2013-12-21 14:49 ` Kenjiro NAKAYAMA
2013-12-21 16:59 ` Ivan Shmakov
2013-12-21 20:24 ` bug#16204: eww does not respect shr-width customization, " Ted Zlatanov
2013-12-24 8:01 ` Lars Ingebrigtsen
2014-07-25 9:58 ` bug#16204: proposed patch for 24.4 Ivan Kanis
2014-08-05 17:31 ` Lars Magne Ingebrigtsen
2014-08-06 17:34 ` Ivan Kanis
2014-08-07 14:21 ` Ivan Kanis [this message]
2014-09-18 19:19 ` Lars Magne Ingebrigtsen
2014-09-18 23:48 ` Ivan Kanis
2014-09-21 12:27 ` Lars Magne Ingebrigtsen
2014-09-22 0:31 ` Ivan Kanis
2014-10-19 22:36 ` Lars Magne Ingebrigtsen
2014-10-20 17:40 ` Ivan Kanis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fvh87530.fsf@kanis.fr \
--to=ivan@kanis.fr \
--cc=16204@debbugs.gnu.org \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.