Implement indentation in blockquotes.
[gnus] / lisp / shr.el
index 04ed016..7af1945 100644 (file)
@@ -53,6 +53,7 @@ fit these criteria."
 (defvar shr-folding-mode nil)
 (defvar shr-state nil)
 (defvar shr-start nil)
+(defvar shr-indentation 0)
 
 (defvar shr-width 70)
 
@@ -89,8 +90,9 @@ fit these criteria."
       (shr-descend sub)))))
 
 (defun shr-tag-p (cont)
-  (shr-ensure-newline)
-  (insert "\n")
+  (unless (bobp)
+    (shr-ensure-newline)
+    (insert "\n"))
   (shr-generic cont)
   (insert "\n"))
 
@@ -179,7 +181,7 @@ fit these criteria."
          (not (get-buffer-window (current-buffer))))
       (create-image data nil t)
     (let* ((image (create-image data nil t))
-          (size (image-size image))
+          (size (image-size image t))
           (width (car size))
           (height (cdr size))
           (edges (window-inside-pixel-edges
@@ -208,7 +210,8 @@ fit these criteria."
     (shr-ensure-newline)))
 
 (defun shr-tag-blockquote (cont)
-  (shr-tag-pre cont))
+  (let ((shr-indentation (+ shr-indentation 4)))
+    (shr-tag-pre cont)))
 
 (defun shr-ensure-newline ()
   (unless (zerop (current-column))
@@ -229,6 +232,9 @@ fit these criteria."
          (if (> (+ column (length elem) 1) shr-width)
              (insert "\n")
            (insert " ")))
+       (when (and (bolp)
+                  (plusp shr-indentation))
+         (insert (make-string shr-indentation ? )))
        ;; The shr-start is a special variable that is used to pass
        ;; upwards the first point in the buffer where the text really
        ;; starts.