diff options
author | Lars Magne Ingebrigtsen <larsi@gnus.org> | 2015-02-10 15:32:50 +1100 |
---|---|---|
committer | Lars Magne Ingebrigtsen <larsi@gnus.org> | 2015-02-10 15:32:50 +1100 |
commit | f149da7e9517d2fc6825e6235b3bcbbc68122d2b (patch) | |
tree | aac72e4b4a3960fec4b60f7502ea2fd533d23a7c | |
parent | 35d95a222d45ad79d5b22a9733bb044309ce02c5 (diff) | |
download | emacs-shr-fontified.tar.gz |
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/ChangeLog | 6 | ||||
-rw-r--r-- | lisp/gnus/ChangeLog | 6 | ||||
-rw-r--r-- | lisp/gnus/mm-decode.el | 6 | ||||
-rw-r--r-- | lisp/net/shr.el | 36 |
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 @@ +2015-02-10 Lars Ingebrigtsen <larsi@gnus.org> + + * 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. + 2015-02-09 Lars Ingebrigtsen <larsi@gnus.org> * 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 @@ +2015-02-10 Lars Ingebrigtsen <larsi@gnus.org> + + * 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. + 2015-02-09 Lars Ingebrigtsen <larsi@gnus.org> * 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." (start end &optional base-url)) (declare-function shr-insert-document "shr" (dom)) (defvar shr-blocked-images) +(defvar shr-use-fonts) (defvar gnus-inhibit-images) (autoload 'gnus-blocked-images "gnus-art") @@ -1822,7 +1823,10 @@ If RECURSIVE, search recursively." ;; Require since we bind its variables. (require 'shr) (let ((article-buffer (current-buffer)) - (shr-width (if shr-use-fonts nil fill-column)) + (shr-width (if (and (boundp 'shr-use-fonts) + shr-use-fonts) + nil + fill-column)) (shr-content-function (lambda (id) (let ((handle (mm-get-content-id id))) (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 (- (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. |