From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ivan Kanis Newsgroups: gmane.emacs.bugs Subject: bug#16204: proposed patch for 24.4 Date: Thu, 07 Aug 2014 16:21:55 +0200 Message-ID: <87fvh87530.fsf@kanis.fr> References: <87egx9zrmk.fsf@kanis.fr> <87bnrxy11f.fsf@kanis.fr> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1407421429 25519 80.91.229.3 (7 Aug 2014 14:23:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 7 Aug 2014 14:23:49 +0000 (UTC) Cc: 16204@debbugs.gnu.org To: Lars Magne Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 07 16:23:42 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XFOb7-0007VR-6B for geb-bug-gnu-emacs@m.gmane.org; Thu, 07 Aug 2014 16:23:17 +0200 Original-Received: from localhost ([::1]:46787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFOb6-0001oJ-Nn for geb-bug-gnu-emacs@m.gmane.org; Thu, 07 Aug 2014 10:23:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFOay-0001nG-BJ for bug-gnu-emacs@gnu.org; Thu, 07 Aug 2014 10:23:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XFOas-0005OL-Iw for bug-gnu-emacs@gnu.org; Thu, 07 Aug 2014 10:23:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:55372) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFOas-0005NL-CB for bug-gnu-emacs@gnu.org; Thu, 07 Aug 2014 10:23:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XFOar-0007U5-PE for bug-gnu-emacs@gnu.org; Thu, 07 Aug 2014 10:23:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ivan Kanis Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 07 Aug 2014 14:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 16204 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: pending Original-Received: via spool by 16204-submit@debbugs.gnu.org id=B16204.140742133028680 (code B ref 16204); Thu, 07 Aug 2014 14:23:01 +0000 Original-Received: (at 16204) by debbugs.gnu.org; 7 Aug 2014 14:22:10 +0000 Original-Received: from localhost ([127.0.0.1]:34081 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XFOa0-0007SV-Qz for submit@debbugs.gnu.org; Thu, 07 Aug 2014 10:22:09 -0400 Original-Received: from kanis.fr ([46.19.35.252]:45235 helo=srv2.kanis.fr) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XFOZw-0007Rv-Pf for 16204@debbugs.gnu.org; Thu, 07 Aug 2014 10:22:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kanis.fr; s=alpha; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:References:Subject:Cc:To:From; bh=R03R0MqFPsaS0swiNUFXgw1xG2X04fShMjvy+gA+pIM=; b=jOksvqChyTsAOGzHCZGNEowDB6eH9I+4tD6um8QAs4nnmV5JWZHp3mAlXLazgouMVQMSnwyJeN0XXDz364UPJzBo22sVaehBlfm6/rF5zAbP3tUSyU376XSUaVXEPWs+; Original-Received: from smtp.comencini.fr ([164.138.25.8]) by smtp.comencini.fr with esmtpsa (TLS1.1:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80.1) (envelope-from ) id 1XFOZk-0004fZ-FT; Thu, 07 Aug 2014 16:21:53 +0200 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAAXNSR0IArs4c6QAAAB5QTFRF IBkXUxMTOCwoTC4qcUY8iFxQmmper31txpaJ/v/8aKZ1oAAAAcVJREFUOMt100tu2zAQAFDCXnUZ oAcIqG68LZULVLQBbwuSiffm6AIRRyeotAySJoVu2+FPpJWWC3/4NKOZocSW/yxWfnJ2+Bdwzhj7 8gleWVy7DXC2rkMNr2V/zRbghXIwthf3VbIA9Ffc71vZCSFyCEsBggtNS8ludwvfmhYA0Vn9o4DP zMWxR7+cPWzAYFzwM0ModtdmcDbDS6i/hT7L+RZof5yCXGrYe5jn2YO6BYMjgY+51tCIAqHgBLwR pwLnGuRjAKyBJkuN4yd4U92uCY1vUr2D/c5b8DuxyQwfOHUeaLqDJhnkkuGXbB56h2C1IVBdgncc bBi6feroa9B6jUDojnQPQKupbyXyeeCE1oT7Oqrt+SnfY3mkiyGA/3AmD3H5g32CcBx6hY8pRkwJ 9PpcjRGobUfprFnhAa1vepwcgMOhwG+pdSgKHFU9HAvoAH6XUl7lDUCCq5Qb6GMbVm3Aj++qDYCt wdBc/YHgOFCmS3mjDMRcSE2qY4E3Q3PVIQRQmeodNH4QEbRUFZzW+VotzwX4yTcRTySOML1qjcE5 hTirVqDHkMAP0PjAywp3d18JZtqzvr9zDYD+GaSKtE6Zlr/DLPNFmOcvBAAAAABJRU5ErkJggg== X-Hashcash: 1:20:140807:larsi@gnus.org::x4KDrlYfC9QIJm1f:0000S4X X-Hashcash: 1:20:140807:16204@debbugs.gnu.org::SKlaUKVnqPb4xJEI:00000000000000000000000000000000000000002jJL In-Reply-To: Ivan Kanis's message of "Wed\, 06 Aug 2014 22\:14\:52 +0200" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.92 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:92257 Archived-At: 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 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