bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#16204: proposed patch for 24.4


From: Ivan Kanis
Subject: bug#16204: proposed patch for 24.4
Date: Thu, 07 Aug 2014 16:21:55 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.92 (gnu/linux)

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]