(defcustom shr-table-line ?-
"Character used to draw table line."
:group 'shr
- :type 'char)
+ :type 'character)
(defcustom shr-table-corner ?+
"Character used to draw table corner."
:group 'shr
- :type 'char)
+ :type 'character)
(defcustom shr-hr-line ?-
"Character used to draw hr line."
:group 'shr
- :type 'char)
+ :type 'character)
+
+(defcustom shr-width fill-column
+ "Frame width to use for rendering."
+ :type 'integer
+ :group 'shr)
(defvar shr-content-function nil
"If bound, this should be a function that will return the content.
This is used for cid: URLs, and the function is called with the
cid: URL as the argument.")
-(defvar shr-width 70
- "Frame width to use for rendering.")
-
;;; Internal variables.
(defvar shr-folding-mode nil)
(unless shr-start
(setq shr-start (point)))
(insert elem)
- (when (> (shr-current-column) shr-width)
- (if (not (search-backward " " (line-beginning-position) t))
+ (while (> (current-column) shr-width)
+ (if (not (shr-find-fill-point))
(insert "\n")
(delete-char 1)
(insert "\n")
(defun shr-find-fill-point ()
(let ((found nil))
(while (and (not found)
- (not (bolp)))
- (when (or (eq (preceding-char) ? )
- (aref fill-find-break-point-function-table (preceding-char)))
+ (> (current-column) shr-indentation))
+ (when (and (or (eq (preceding-char) ? )
+ (aref fill-find-break-point-function-table
+ (preceding-char)))
+ (<= (current-column) shr-width))
(setq found (point)))
(backward-char 1))
(or found
(end-of-line))))
-(defun shr-current-column ()
- (let ((column 0))
- (save-excursion
- (beginning-of-line)
- (while (not (eolp))
- (incf column (char-width (following-char)))
- (forward-char 1)))
- column))
-
(defun shr-ensure-newline ()
(unless (zerop (current-column))
(insert "\n")))
(with-temp-buffer
(mm-disable-multibyte)
(when (ignore-errors
- (url-cache-extract (url-cache-create-filename url))
+ (url-cache-extract (url-cache-create-filename (shr-encode-url url)))
t)
(when (or (search-forward "\n\n" nil t)
(search-forward "\r\n\r\n" nil t))
shr-start)
(shr-generic cont)
(widget-convert-button
- 'link (or shr-start start) (point)
- :help-echo url)
- (put-text-property (or shr-start start) (point) 'keymap shr-map)
+ 'url-link (or shr-start start) (point)
+ :help-echo url
+ :keymap shr-map
+ url)
(put-text-property (or shr-start start) (point) 'shr-url url)))
(defun shr-encode-url (url)
(insert "\n"))
(let ((alt (cdr (assq :alt cont)))
(url (cdr (assq :src cont)))
- (align (cdr (assq :align cont))))
- (cond ((string= align "right")
- (insert
- (make-string (- fill-column (- (point) (line-beginning-position))) ? )))
- ((string= align "center")
- (insert
- (make-string (- (/ fill-column 2) (- (point) (line-beginning-position))) ? ))))
+ (width (cdr (assq :width cont))))
+ ;; Only respect align if width specified.
+ (when width
+ ;; Check that width is not larger than max width, otherwise ignore
+ ;; align
+ (let ((max-width (* shr-width (frame-char-width)))
+ (width (string-to-number width)))
+ (when (< width max-width)
+ (let ((align (cdr (assq :align cont))))
+ (cond ((string= align "right")
+ (insert (propertize
+ " " 'display
+ `(space . (:align-to ,(list (- max-width width)))))))
+ ((string= align "center")
+ (insert (propertize
+ " " 'display
+ `(space . (:balign-to ,(list (- (/ max-width 2) width))))))))))))
(let ((start (point-marker)))
(when (zerop (length alt))
(setq alt "[img]"))