mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-01 11:14:55 +00:00
Allow users to specify `shr-width'
* 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.
This commit is contained in:
parent
c59f47da5c
commit
212b4d631b
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user