aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2011-01-25 08:42:32 +0000
committerKatsumi Yamaoka2011-01-25 08:42:32 +0000
commitd709b79ac8969fd305b5bec23cb02b927dfe1507 (patch)
treec7f22c402a40c42df35af272634d481061937be4
parent0fe719e691955e8e4a7f5bc74ed981b2e8ca17ce (diff)
downloademacs-d709b79ac8969fd305b5bec23cb02b927dfe1507.tar.gz
emacs-d709b79ac8969fd305b5bec23cb02b927dfe1507.zip
shr.el (shr-expand-newlines): Make nested boxes work.
-rw-r--r--lisp/gnus/ChangeLog4
-rw-r--r--lisp/gnus/shr.el38
2 files changed, 39 insertions, 3 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 34c97a97dd7..16d0787f768 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,7 @@
12011-01-25 Lars Ingebrigtsen <larsi@gnus.org>
2
3 * shr.el (shr-expand-newlines): Make nested boxes work.
4
12011-01-24 Lars Ingebrigtsen <larsi@gnus.org> 52011-01-24 Lars Ingebrigtsen <larsi@gnus.org>
2 6
3 * shr.el (shr-expand-newlines): Proof of concept implemantation of boxy 7 * shr.el (shr-expand-newlines): Proof of concept implemantation of boxy
diff --git a/lisp/gnus/shr.el b/lisp/gnus/shr.el
index fb0db90e580..aa05a061868 100644
--- a/lisp/gnus/shr.el
+++ b/lisp/gnus/shr.el
@@ -648,6 +648,15 @@ ones, in case fg and bg are nil."
648 648
649(defun shr-expand-newlines (start end color) 649(defun shr-expand-newlines (start end color)
650 (save-restriction 650 (save-restriction
651 ;; Skip past all white space at the start and ends.
652 (goto-char start)
653 (skip-chars-forward " \t\n")
654 (beginning-of-line)
655 (setq start (point))
656 (goto-char end)
657 (skip-chars-backward " \t\n")
658 (forward-line 1)
659 (setq end (point))
651 (narrow-to-region start end) 660 (narrow-to-region start end)
652 (let ((width (shr-natural-width)) 661 (let ((width (shr-natural-width))
653 column) 662 column)
@@ -655,13 +664,36 @@ ones, in case fg and bg are nil."
655 (while (not (eobp)) 664 (while (not (eobp))
656 (end-of-line) 665 (end-of-line)
657 (when (and (< (setq current-column (current-column)) width) 666 (when (and (< (setq current-column (current-column)) width)
658 (not (overlays-at (point)))) 667 (< (setq current-column (shr-previous-newline-padding-width
668 current-column))
669 width))
659 (let ((overlay (make-overlay (point) (1+ (point))))) 670 (let ((overlay (make-overlay (point) (1+ (point)))))
660 (overlay-put overlay 'before-string 671 (overlay-put overlay 'before-string
661 (propertize (make-string (- width current-column) ? ) 672 (concat
662 'face (list :background color))))) 673 (mapconcat
674 (lambda (overlay)
675 (let ((string (getf (overlay-properties overlay) 'before-string)))
676 (if (not string)
677 ""
678 (overlay-put overlay 'before-string "")
679 string)))
680 (overlays-at (point))
681 "")
682 (propertize (make-string (- width current-column) ? )
683 'face (list :background color))))))
663 (forward-line 1))))) 684 (forward-line 1)))))
664 685
686(defun shr-previous-newline-padding-width (width)
687 (let ((overlays (overlays-at (point)))
688 (previous-width 0))
689 (if (null overlays)
690 width
691 (dolist (overlay overlays)
692 (setq previous-width
693 (+ previous-width
694 (length (getf (overlay-properties overlay) 'before-string)))))
695 (+ width previous-width))))
696
665(defun shr-put-color-1 (start end type color) 697(defun shr-put-color-1 (start end type color)
666 (let* ((old-props (get-text-property start 'face)) 698 (let* ((old-props (get-text-property start 'face))
667 (do-put (not (memq type old-props))) 699 (do-put (not (memq type old-props)))