X-Git-Url: https://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Fshr.el;h=f8a85579b4f8024b87f7fa90ba780ce258f46b3d;hb=6d225814ad9bb5ebd7047a4c3b2117ba6a4f5894;hp=75c6d5d9ce775a695d92ea809b5ccc0e8797fbad;hpb=6c223aabc603a94224e5ade757754d3a115bff3e;p=gnus diff --git a/lisp/shr.el b/lisp/shr.el index 75c6d5d9c..f8a85579b 100644 --- a/lisp/shr.el +++ b/lisp/shr.el @@ -183,14 +183,23 @@ redirects somewhere else." (message "No image under point") (message "%s" text)))) -(defun shr-browse-image () - "Browse the image under point." - (interactive) +(defun shr-browse-image (&optional copy-url) + "Browse the image under point. +If COPY-URL (the prefix if called interactively) is non-nil, copy +the URL of the image to the kill buffer instead." + (interactive "P") (let ((url (get-text-property (point) 'image-url))) - (if (not url) - (message "No image under point") + (cond + ((not url) + (message "No image under point")) + (copy-url + (with-temp-buffer + (insert url) + (copy-region-as-kill (point-min) (point-max)) + (message "Copied %s" url))) + (t (message "Browsing %s..." url) - (browse-url url)))) + (browse-url url))))) (defun shr-insert-image () "Insert the image under point into the buffer." @@ -517,15 +526,18 @@ redirects somewhere else." (when (and (> (current-column) 0) (> (car (image-size image t)) 400)) (insert "\n")) - (insert-image image (or alt "*"))) + (insert-image image (or alt "*")) + (when (image-animated-p image) + (image-animate image nil 60))) image) (insert alt))) (defun shr-rescale-image (data) (if (or (not (fboundp 'imagemagick-types)) (not (get-buffer-window (current-buffer)))) - (create-image data nil t) - (let* ((image (create-image data nil t)) + (create-image data nil t + :ascent 100) + (let* ((image (create-image data nil t :ascent 100)) (size (image-size image t)) (width (car size)) (height (cdr size)) @@ -544,11 +556,9 @@ redirects somewhere else." (when (> (car size) window-width) (setq image (or (create-image data 'imagemagick t - :width window-width) + :width window-width + :ascent 100) image))) - (when (and (fboundp 'create-animated-image) - (eq (image-type data nil t) 'gif)) - (setq image (create-animated-image data 'gif t))) image))) ;; url-cache-extract autoloads url-cache. @@ -582,7 +592,7 @@ START, and END. Note that START and END should be merkers." (when image (goto-char start) (funcall shr-put-image-function - image (buffer-substring-no-properties start end)) + image (buffer-substring start end)) (delete-region (point) end)))) (url-retrieve url 'shr-image-fetched (list (current-buffer) start end) @@ -601,7 +611,7 @@ START, and END. Note that START and END should be merkers." :help-echo (if title (format "%s (%s)" url title) url) :keymap shr-map url) - (put-text-property start (point) 'face 'shr-link) + (shr-add-font start (point) 'shr-link) (put-text-property start (point) 'shr-url url)) (defun shr-encode-url (url) @@ -780,6 +790,9 @@ ones, in case fg and bg are nil." (defun shr-tag-s (cont) (shr-fontize-cont cont 'shr-strike-through)) +(defun shr-tag-del (cont) + (shr-fontize-cont cont 'shr-strike-through)) + (defun shr-tag-b (cont) (shr-fontize-cont cont 'bold))