aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen2015-02-10 15:32:50 +1100
committerLars Magne Ingebrigtsen2015-02-10 15:32:50 +1100
commitf149da7e9517d2fc6825e6235b3bcbbc68122d2b (patch)
treeaac72e4b4a3960fec4b60f7502ea2fd533d23a7c
parent35d95a222d45ad79d5b22a9733bb044309ce02c5 (diff)
downloademacs-shr-fontified.tar.gz
emacs-shr-fontified.zip
shr indentation fixesshr-fontified
* gnus/mm-decode.el (mm-shr): Only pass the fill column when not using fonts, because limiting the width to what's appropriate for followups doesn't really help when not using proportional fonts. * net/shr.el (shr-fill-lines): Change name from "fold". (shr-indent): Use spaces for indentation when not using fonts, since `move-to-column' doesn't work with :width display specs.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/gnus/ChangeLog6
-rw-r--r--lisp/gnus/mm-decode.el6
-rw-r--r--lisp/net/shr.el36
4 files changed, 36 insertions, 18 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e56741f1427..6e22679a73a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12015-02-10 Lars Ingebrigtsen <larsi@gnus.org>
2
3 * net/shr.el (shr-fill-lines): Change name from "fold".
4 (shr-indent): Use spaces for indentation when not using fonts,
5 since `move-to-column' doesn't work with :width display specs.
6
12015-02-09 Lars Ingebrigtsen <larsi@gnus.org> 72015-02-09 Lars Ingebrigtsen <larsi@gnus.org>
2 8
3 * net/shr.el (shr-fold-line): Indent <li> properly. 9 * net/shr.el (shr-fold-line): Indent <li> properly.
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 6b21888c27e..396ad2fd2a6 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,9 @@
12015-02-10 Lars Ingebrigtsen <larsi@gnus.org>
2
3 * mm-decode.el (mm-shr): Only pass the fill column when not using
4 fonts, because limiting the width to what's appropriate for followups
5 doesn't really help when not using proportional fonts.
6
12015-02-09 Lars Ingebrigtsen <larsi@gnus.org> 72015-02-09 Lars Ingebrigtsen <larsi@gnus.org>
2 8
3 * mm-decode.el (mm-convert-shr-links): Don't overwrite the faces from 9 * mm-decode.el (mm-convert-shr-links): Don't overwrite the faces from
diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el
index 463d125a2b2..5a8375cf4e6 100644
--- a/lisp/gnus/mm-decode.el
+++ b/lisp/gnus/mm-decode.el
@@ -1815,6 +1815,7 @@ If RECURSIVE, search recursively."
1815 (start end &optional base-url)) 1815 (start end &optional base-url))
1816(declare-function shr-insert-document "shr" (dom)) 1816(declare-function shr-insert-document "shr" (dom))
1817(defvar shr-blocked-images) 1817(defvar shr-blocked-images)
1818(defvar shr-use-fonts)
1818(defvar gnus-inhibit-images) 1819(defvar gnus-inhibit-images)
1819(autoload 'gnus-blocked-images "gnus-art") 1820(autoload 'gnus-blocked-images "gnus-art")
1820 1821
@@ -1822,7 +1823,10 @@ If RECURSIVE, search recursively."
1822 ;; Require since we bind its variables. 1823 ;; Require since we bind its variables.
1823 (require 'shr) 1824 (require 'shr)
1824 (let ((article-buffer (current-buffer)) 1825 (let ((article-buffer (current-buffer))
1825 (shr-width (if shr-use-fonts nil fill-column)) 1826 (shr-width (if (and (boundp 'shr-use-fonts)
1827 shr-use-fonts)
1828 nil
1829 fill-column))
1826 (shr-content-function (lambda (id) 1830 (shr-content-function (lambda (id)
1827 (let ((handle (mm-get-content-id id))) 1831 (let ((handle (mm-get-content-id id)))
1828 (when handle 1832 (when handle
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
229 (- (window-pixel-width) 229 (- (window-pixel-width)
230 (* (frame-fringe-width) 2)))))) 230 (* (frame-fringe-width) 2))))))
231 (shr-descend dom) 231 (shr-descend dom)
232 (shr-fill-lines start (point))
232 (shr-remove-trailing-whitespace start (point)) 233 (shr-remove-trailing-whitespace start (point))
233 (setq adom dom) 234 (setq adom dom)
234 (when shr-warning 235 (when shr-warning
@@ -324,7 +325,7 @@ redirects somewhere else."
324 (let ((text (get-text-property (point) 'shr-alt))) 325 (let ((text (get-text-property (point) 'shr-alt)))
325 (if (not text) 326 (if (not text)
326 (message "No image under point") 327 (message "No image under point")
327 (message "%s" (shr-fold-text text))))) 328 (message "%s" (shr-fill-text text)))))
328 329
329(defun shr-browse-image (&optional copy-url) 330(defun shr-browse-image (&optional copy-url)
330 "Browse the image under point. 331 "Browse the image under point.
@@ -435,7 +436,7 @@ size, and full-buffer size."
435 (cdr (assq 'color shr-stylesheet)) 436 (cdr (assq 'color shr-stylesheet))
436 (cdr (assq 'background-color shr-stylesheet)))))))) 437 (cdr (assq 'background-color shr-stylesheet))))))))
437 438
438(defun shr-fold-text (text) 439(defun shr-fill-text (text)
439 (if (zerop (length text)) 440 (if (zerop (length text))
440 text 441 text
441 (with-temp-buffer 442 (with-temp-buffer
@@ -524,18 +525,18 @@ size, and full-buffer size."
524 (or shr-current-font 'variable-pitch) 525 (or shr-current-font 'variable-pitch)
525 t))))))) 526 t)))))))
526 527
527(defun shr-fold-lines (start end) 528(defun shr-fill-lines (start end)
528 (if (<= shr-internal-width 0) 529 (if (<= shr-internal-width 0)
529 nil 530 nil
530 (save-restriction 531 (save-restriction
531 (narrow-to-region start end) 532 (narrow-to-region start end)
532 (goto-char start) 533 (goto-char start)
533 (when (get-text-property (point) 'shr-indentation) 534 (when (get-text-property (point) 'shr-indentation)
534 (shr-fold-line)) 535 (shr-fill-line))
535 (while (setq start (next-single-property-change start 'shr-indentation)) 536 (while (setq start (next-single-property-change start 'shr-indentation))
536 (goto-char start) 537 (goto-char start)
537 (when (bolp) 538 (when (bolp)
538 (shr-fold-line))) 539 (shr-fill-line)))
539 (goto-char (point-max))))) 540 (goto-char (point-max)))))
540 541
541(defun shr-vertical-motion (column) 542(defun shr-vertical-motion (column)
@@ -547,7 +548,7 @@ size, and full-buffer size."
547 (unless (eolp) 548 (unless (eolp)
548 (forward-char 1)))) 549 (forward-char 1))))
549 550
550(defun shr-fold-line () 551(defun shr-fill-line ()
551 (let ((shr-indentation (get-text-property (point) 'shr-indentation)) 552 (let ((shr-indentation (get-text-property (point) 'shr-indentation))
552 (continuation (get-text-property 553 (continuation (get-text-property
553 (point) 'shr-continuation-indentation)) 554 (point) 'shr-continuation-indentation))
@@ -733,11 +734,11 @@ size, and full-buffer size."
733(defun shr-indent () 734(defun shr-indent ()
734 (when (> shr-indentation 0) 735 (when (> shr-indentation 0)
735 (insert 736 (insert
736 (propertize " " 737 (if (not shr-use-fonts)
737 'display 738 (make-string shr-indentation ?\s)
738 `(space :width (,(if (not shr-use-fonts) 739 (propertize " "
739 (* shr-indentation (frame-char-width)) 740 'display
740 shr-indentation))))))) 741 `(space :width (,shr-indentation)))))))
741 742
742(defun shr-fontize-dom (dom &rest types) 743(defun shr-fontize-dom (dom &rest types)
743 (let ((start (point))) 744 (let ((start (point)))
@@ -1080,8 +1081,7 @@ ones, in case fg and bg are nil."
1080 (shr-stylesheet (list (cons 'color fgcolor) 1081 (shr-stylesheet (list (cons 'color fgcolor)
1081 (cons 'background-color bgcolor)))) 1082 (cons 'background-color bgcolor))))
1082 (shr-generic dom) 1083 (shr-generic dom)
1083 (shr-colorize-region start (point) fgcolor bgcolor) 1084 (shr-colorize-region start (point) fgcolor bgcolor)))
1084 (shr-fold-lines start (point))))
1085 1085
1086(defun shr-tag-style (_dom) 1086(defun shr-tag-style (_dom)
1087 ) 1087 )
@@ -1372,7 +1372,7 @@ The preference is a float determined from `shr-prefer-media-type'."
1372 (put-text-property start (point) 'image-displayer 1372 (put-text-property start (point) 'image-displayer
1373 (shr-image-displayer shr-content-function)) 1373 (shr-image-displayer shr-content-function))
1374 (put-text-property start (point) 'help-echo 1374 (put-text-property start (point) 'help-echo
1375 (shr-fold-text 1375 (shr-fill-text
1376 (or (dom-attr dom 'title) alt)))))))) 1376 (or (dom-attr dom 'title) alt))))))))
1377 1377
1378(defun shr-tag-pre (dom) 1378(defun shr-tag-pre (dom)
@@ -1437,8 +1437,10 @@ The preference is a float determined from `shr-prefer-media-type'."
1437 (shr-generic dom))))) 1437 (shr-generic dom)))))
1438 1438
1439(defun shr-mark-fill (start) 1439(defun shr-mark-fill (start)
1440 (put-text-property start (1+ start) 1440 ;; We may not have inserted any text to fill.
1441 'shr-indentation shr-indentation)) 1441 (unless (= start (point))
1442 (put-text-property start (1+ start)
1443 'shr-indentation shr-indentation)))
1442 1444
1443(defun shr-tag-br (dom) 1445(defun shr-tag-br (dom)
1444 (when (and (not (bobp)) 1446 (when (and (not (bobp))
@@ -1929,7 +1931,7 @@ The preference is a float determined from `shr-prefer-media-type'."
1929 (<= natural-width width)) 1931 (<= natural-width width))
1930 (setq max-width natural-width) 1932 (setq max-width natural-width)
1931 (let ((shr-internal-width width)) 1933 (let ((shr-internal-width width))
1932 (shr-fold-lines (point-min) (point-max)) 1934 (shr-fill-lines (point-min) (point-max))
1933 (setq max-width (shr-pixel-buffer-width))))) 1935 (setq max-width (shr-pixel-buffer-width)))))
1934 (goto-char (point-max)) 1936 (goto-char (point-max))
1935 ;; Delete padding at the bottom of the TDs. 1937 ;; Delete padding at the bottom of the TDs.