]> git.eshelyaron.com Git - emacs.git/commitdiff
Allow users to specify `shr-width'
authorIvan Kanis <ivan@kanis.fr>
Thu, 18 Sep 2014 19:18:34 +0000 (21:18 +0200)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Thu, 18 Sep 2014 19:18:34 +0000 (21:18 +0200)
* net/shr.el, net/eww.el: Don't override `shr-width', but
introduce a new variable `shr-internal-width'.  This allows users
to specify a width themselves.

lisp/ChangeLog
lisp/net/eww.el
lisp/net/shr.el

index 709627ceed31335004e6e1d10830b6fc66a6b4ed..6f5e70ab6cb707a47ea65e14e10e3ce6a57c2676 100644 (file)
@@ -1,3 +1,9 @@
+2014-09-18  Ivan Kanis  <ivan@kanis.fr>
+
+       * net/shr.el, net/eww.el: Don't override `shr-width', but
+       introduce a new variable `shr-internal-width'.  This allows users
+       to specify a width themselves.
+
 2014-09-18  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * image-mode.el (image-toggle-display-image): If we have a
index f99148162e49baec15d1d6f1a553bb5566207f63..6e34856a0167961ab90a4b1b0822bf0774fe0b90 100644 (file)
@@ -270,7 +270,6 @@ 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-target-id (url-target (url-generic-parse-url url)))
          (shr-external-rendering-functions
           '((title . eww-tag-title)
index 0138640e9af76ca4860c2a4ca93cb7f9556c1d21..878728c93199c24087777f23b88dc2a91617e566 100644 (file)
@@ -130,6 +130,7 @@ cid: URL as the argument.")
 (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 @@ DOM should be a parse tree as generated by
        (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))))
 
@@ -471,8 +472,8 @@ size, and full-buffer size."
       (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))))
@@ -486,10 +487,10 @@ size, and full-buffer size."
          (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)))))
@@ -497,7 +498,7 @@ size, and full-buffer size."
       (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)
@@ -537,7 +538,7 @@ size, and full-buffer size."
           ;; 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)))))
@@ -1344,7 +1345,7 @@ The preference is a float determined from `shr-prefer-media-type'."
 
 (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))
@@ -1637,7 +1638,7 @@ The preference is a float determined from `shr-prefer-media-type'."
        (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.
@@ -1709,7 +1710,8 @@ The preference is a float determined from `shr-prefer-media-type'."
     (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))