summaryrefslogtreecommitdiff
path: root/lisp/net/shr.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/net/shr.el')
-rw-r--r--lisp/net/shr.el36
1 files changed, 19 insertions, 17 deletions
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 2f439be4adf..e1d43e47ce0 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -229,6 +229,7 @@ DOM should be a parse tree as generated by
(- (window-pixel-width)
(* (frame-fringe-width) 2))))))
(shr-descend dom)
+ (shr-fill-lines start (point))
(shr-remove-trailing-whitespace start (point))
(setq adom dom)
(when shr-warning
@@ -324,7 +325,7 @@ redirects somewhere else."
(let ((text (get-text-property (point) 'shr-alt)))
(if (not text)
(message "No image under point")
- (message "%s" (shr-fold-text text)))))
+ (message "%s" (shr-fill-text text)))))
(defun shr-browse-image (&optional copy-url)
"Browse the image under point.
@@ -435,7 +436,7 @@ size, and full-buffer size."
(cdr (assq 'color shr-stylesheet))
(cdr (assq 'background-color shr-stylesheet))))))))
-(defun shr-fold-text (text)
+(defun shr-fill-text (text)
(if (zerop (length text))
text
(with-temp-buffer
@@ -524,18 +525,18 @@ size, and full-buffer size."
(or shr-current-font 'variable-pitch)
t)))))))
-(defun shr-fold-lines (start end)
+(defun shr-fill-lines (start end)
(if (<= shr-internal-width 0)
nil
(save-restriction
(narrow-to-region start end)
(goto-char start)
(when (get-text-property (point) 'shr-indentation)
- (shr-fold-line))
+ (shr-fill-line))
(while (setq start (next-single-property-change start 'shr-indentation))
(goto-char start)
(when (bolp)
- (shr-fold-line)))
+ (shr-fill-line)))
(goto-char (point-max)))))
(defun shr-vertical-motion (column)
@@ -547,7 +548,7 @@ size, and full-buffer size."
(unless (eolp)
(forward-char 1))))
-(defun shr-fold-line ()
+(defun shr-fill-line ()
(let ((shr-indentation (get-text-property (point) 'shr-indentation))
(continuation (get-text-property
(point) 'shr-continuation-indentation))
@@ -733,11 +734,11 @@ size, and full-buffer size."
(defun shr-indent ()
(when (> shr-indentation 0)
(insert
- (propertize " "
- 'display
- `(space :width (,(if (not shr-use-fonts)
- (* shr-indentation (frame-char-width))
- shr-indentation)))))))
+ (if (not shr-use-fonts)
+ (make-string shr-indentation ?\s)
+ (propertize " "
+ 'display
+ `(space :width (,shr-indentation)))))))
(defun shr-fontize-dom (dom &rest types)
(let ((start (point)))
@@ -1080,8 +1081,7 @@ ones, in case fg and bg are nil."
(shr-stylesheet (list (cons 'color fgcolor)
(cons 'background-color bgcolor))))
(shr-generic dom)
- (shr-colorize-region start (point) fgcolor bgcolor)
- (shr-fold-lines start (point))))
+ (shr-colorize-region start (point) fgcolor bgcolor)))
(defun shr-tag-style (_dom)
)
@@ -1372,7 +1372,7 @@ The preference is a float determined from `shr-prefer-media-type'."
(put-text-property start (point) 'image-displayer
(shr-image-displayer shr-content-function))
(put-text-property start (point) 'help-echo
- (shr-fold-text
+ (shr-fill-text
(or (dom-attr dom 'title) alt))))))))
(defun shr-tag-pre (dom)
@@ -1437,8 +1437,10 @@ The preference is a float determined from `shr-prefer-media-type'."
(shr-generic dom)))))
(defun shr-mark-fill (start)
- (put-text-property start (1+ start)
- 'shr-indentation shr-indentation))
+ ;; We may not have inserted any text to fill.
+ (unless (= start (point))
+ (put-text-property start (1+ start)
+ 'shr-indentation shr-indentation)))
(defun shr-tag-br (dom)
(when (and (not (bobp))
@@ -1929,7 +1931,7 @@ The preference is a float determined from `shr-prefer-media-type'."
(<= natural-width width))
(setq max-width natural-width)
(let ((shr-internal-width width))
- (shr-fold-lines (point-min) (point-max))
+ (shr-fill-lines (point-min) (point-max))
(setq max-width (shr-pixel-buffer-width)))))
(goto-char (point-max))
;; Delete padding at the bottom of the TDs.