2010-09-04 00:12:44 +00:00
|
|
|
;;; gnus-html.el --- Render HTML in a buffer.
|
2010-08-30 06:13:50 +00:00
|
|
|
|
2019-01-01 00:59:58 +00:00
|
|
|
;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
|
2010-08-30 06:13:50 +00:00
|
|
|
|
|
|
|
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
|
|
|
|
;; Keywords: html, web
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 22:52:52 +00:00
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2010-08-30 06:13:50 +00:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;; The idea is to provide a simple, fast and pretty minimal way to
|
|
|
|
;; render HTML (including links and images) in a buffer, based on an
|
|
|
|
;; external HTML renderer (i.e., w3m).
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2010-09-17 05:38:38 +00:00
|
|
|
(require 'gnus-art)
|
2010-11-02 04:08:43 +00:00
|
|
|
(eval-when-compile (require 'mm-decode))
|
|
|
|
|
2010-08-31 01:15:32 +00:00
|
|
|
(require 'mm-url)
|
2010-09-18 23:36:29 +00:00
|
|
|
(require 'url)
|
2010-09-21 11:48:40 +00:00
|
|
|
(require 'url-cache)
|
2010-09-22 12:14:12 +00:00
|
|
|
(require 'xml)
|
2010-09-23 00:30:37 +00:00
|
|
|
(require 'browse-url)
|
2011-07-19 22:19:06 +00:00
|
|
|
(require 'mm-util)
|
2016-02-11 04:22:45 +00:00
|
|
|
(require 'help-fns)
|
2016-02-13 06:01:31 +00:00
|
|
|
(require 'url-queue)
|
2010-08-31 01:15:32 +00:00
|
|
|
|
2010-09-21 11:48:40 +00:00
|
|
|
(defcustom gnus-html-image-cache-ttl (days-to-time 7)
|
2010-09-23 00:30:37 +00:00
|
|
|
"Time used to determine if we should use images from the cache."
|
2010-09-01 04:44:25 +00:00
|
|
|
:version "24.1"
|
2010-08-30 06:17:45 +00:00
|
|
|
:group 'gnus-art
|
2013-05-09 01:40:20 +00:00
|
|
|
;; FIXME hardly the friendliest type. The allowed value is actually
|
|
|
|
;; any time value, but we are assuming no-one cares about USEC and
|
|
|
|
;; PSEC here. It would be better to eg make it a number of minutes.
|
|
|
|
:type '(list integer integer))
|
2010-08-30 06:17:45 +00:00
|
|
|
|
2010-09-23 00:30:37 +00:00
|
|
|
(defcustom gnus-html-image-automatic-caching t
|
|
|
|
"Whether automatically cache retrieve images."
|
|
|
|
:version "24.1"
|
|
|
|
:group 'gnus-art
|
|
|
|
:type 'boolean)
|
|
|
|
|
2010-08-30 06:17:45 +00:00
|
|
|
(defcustom gnus-html-frame-width 70
|
|
|
|
"What width to use when rendering HTML."
|
2010-09-01 04:44:25 +00:00
|
|
|
:version "24.1"
|
2010-08-30 06:17:45 +00:00
|
|
|
:group 'gnus-art
|
|
|
|
:type 'integer)
|
|
|
|
|
2010-09-23 00:58:01 +00:00
|
|
|
(defcustom gnus-max-image-proportion 0.9
|
2010-09-01 23:53:57 +00:00
|
|
|
"How big pictures displayed are in relation to the window they're in.
|
|
|
|
A value of 0.7 means that they are allowed to take up 70% of the
|
|
|
|
width and height of the window. If they are larger than this,
|
|
|
|
and Emacs supports it, then the images will be rescaled down to
|
|
|
|
fit these criteria."
|
|
|
|
:version "24.1"
|
|
|
|
:group 'gnus-art
|
|
|
|
:type 'float)
|
|
|
|
|
2010-09-04 00:21:34 +00:00
|
|
|
(defvar gnus-html-image-map
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
(define-key map "u" 'gnus-article-copy-string)
|
|
|
|
(define-key map "i" 'gnus-html-insert-image)
|
2010-09-21 11:48:40 +00:00
|
|
|
(define-key map "v" 'gnus-html-browse-url)
|
2010-09-04 00:21:34 +00:00
|
|
|
map))
|
|
|
|
|
2010-09-08 23:59:52 +00:00
|
|
|
(defvar gnus-html-displayed-image-map
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
(define-key map "a" 'gnus-html-show-alt-text)
|
|
|
|
(define-key map "i" 'gnus-html-browse-image)
|
2010-09-09 00:08:06 +00:00
|
|
|
(define-key map "\r" 'gnus-html-browse-url)
|
|
|
|
(define-key map "u" 'gnus-article-copy-string)
|
2019-07-30 13:24:55 +00:00
|
|
|
(define-key map [tab] 'button-forward)
|
2010-09-08 23:59:52 +00:00
|
|
|
map))
|
|
|
|
|
2010-09-23 00:30:37 +00:00
|
|
|
(defun gnus-html-encode-url (url)
|
|
|
|
"Encode URL."
|
2016-02-13 06:00:05 +00:00
|
|
|
(browse-url-url-encode-chars url "[)$ ]"))
|
2010-09-23 00:30:37 +00:00
|
|
|
|
2010-09-21 11:48:40 +00:00
|
|
|
(defun gnus-html-cache-expired (url ttl)
|
|
|
|
"Check if URL is cached for more than TTL."
|
|
|
|
(cond (url-standalone-mode
|
|
|
|
(not (file-exists-p (url-cache-create-filename url))))
|
|
|
|
(t (let ((cache-time (url-is-cached url)))
|
|
|
|
(if cache-time
|
Prefer nil to (current-time) when either works
* doc/misc/gnus.texi (Category Syntax):
* lisp/allout-widgets.el (allout-widgets-post-command-business):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/cedet/pulse.el (pulse-momentary-highlight-overlay)
(pulse-tick):
* lisp/cedet/semantic.el (bovinate):
* lisp/cedet/semantic/analyze.el:
(semantic-analyze-current-symbol-default, semantic-adebug-analyze):
* lisp/cedet/semantic/analyze/refs.el (semantic-analyze-current-tag):
* lisp/cedet/semantic/lex.el (semantic-lex-test):
* lisp/cedet/semantic/symref/filter.el:
(semantic-symref-test-count-hits-in-tag):
* lisp/cedet/srecode/dictionary.el (srecode-adebug-dictionary):
* lisp/cedet/srecode/map.el (srecode-adebug-maps):
* lisp/desktop.el (desktop-create-buffer):
* lisp/emacs-lisp/benchmark.el (benchmark-elapse):
* lisp/emacs-lisp/elp.el (elp--make-wrapper):
* lisp/epa.el (epa--show-key):
* lisp/erc/erc.el (erc-lurker-cleanup, erc-lurker-p):
* lisp/gnus/gnus-agent.el (gnus-agent-fetch-articles)
(gnus-agent-expire-group-1, gnus-agent-store-article):
* lisp/gnus/gnus-art.el (article-lapsed-string):
* lisp/gnus/gnus-cloud.el (gnus-cloud-update-newsrc-data)
(gnus-cloud-collect-full-newsrc):
* lisp/gnus/gnus-group.el (gnus-group-timestamp-delta):
* lisp/gnus/gnus-html.el (gnus-html-cache-expired):
* lisp/gnus/gnus-score.el (gnus-score-load-file)
(gnus-decay-scores):
* lisp/gnus/nndiary.el (nndiary-expired-article-p):
* lisp/gnus/nnmail.el (nnmail-expired-article-p):
* lisp/gnus/nnmaildir.el (nnmaildir--scan):
* lisp/gnus/score-mode.el (gnus-score-edit-insert-date):
* lisp/image/gravatar.el (gravatar-cache-expired):
* lisp/net/newst-backend.el (newsticker--image-get)
(newsticker--cache-mark-expired):
* lisp/nxml/rng-maint.el (rng-time-function):
* lisp/org/org-agenda.el (org-agenda-to-appt):
* lisp/org/org-clock.el (org-clock-resolve-clock)
(org-clock-resolve, org-resolve-clocks-if-idle):
* lisp/org/org-colview.el (org-columns-edit-value, org-columns)
(org-columns-compute-all, org-agenda-columns):
* lisp/org/org-element.el (org-element--cache-interrupt-p)
(org-element--cache-sync):
* lisp/org/org-habit.el (org-habit-get-faces)
(org-habit-insert-consistency-graphs):
* lisp/org/org-indent.el (org-indent-add-properties):
* lisp/org/org-timer.el (org-timer-start)
(org-timer-pause-or-continue, org-timer-seconds)
(org-timer-show-remaining-time, org-timer-set-timer):
* lisp/org/org.el (org-babel-load-file, org-current-time)
(org-today, org-auto-repeat-maybe, org-read-date-analyze)
(org-small-year-to-year, org-goto-calendar):
* lisp/org/ox.el (org-export-insert-default-template):
* lisp/time.el (emacs-uptime):
* lisp/type-break.el (type-break-mode, type-break)
(type-break-time-warning-schedule, type-break-check):
* lisp/url/url-cache.el (url-cache-expired):
* lisp/url/url.el (url-retrieve-synchronously):
* test/lisp/char-fold-tests.el (char-fold--speed-test):
* test/manual/cedet/semantic-ia-utest.el:
(semantic-symref-test-count-hits-in-tag):
* test/manual/cedet/semantic-tests.el (semantic-idle-pnf-test)
(semantic-lex-test-full-depth):
Use nil instead of (current-time) where either will do, as nil is
a bit more efficient and should have less timing error.
2017-10-21 02:40:09 +00:00
|
|
|
(time-less-p (time-add cache-time ttl) nil)
|
2010-09-21 11:48:40 +00:00
|
|
|
t)))))
|
|
|
|
|
2010-08-30 06:13:50 +00:00
|
|
|
;;;###autoload
|
2010-09-06 00:41:06 +00:00
|
|
|
(defun gnus-article-html (&optional handle)
|
2010-08-30 06:13:50 +00:00
|
|
|
(let ((article-buffer (current-buffer)))
|
2010-09-06 00:41:06 +00:00
|
|
|
(unless handle
|
|
|
|
(setq handle (mm-dissect-buffer t)))
|
2010-08-30 06:13:50 +00:00
|
|
|
(save-restriction
|
|
|
|
(narrow-to-region (point) (point))
|
|
|
|
(save-excursion
|
2010-08-30 06:17:45 +00:00
|
|
|
(mm-with-part handle
|
|
|
|
(let* ((coding-system-for-read 'utf-8)
|
|
|
|
(coding-system-for-write 'utf-8)
|
|
|
|
(default-process-coding-system
|
2010-09-01 06:04:49 +00:00
|
|
|
(cons coding-system-for-read coding-system-for-write))
|
|
|
|
(charset (mail-content-type-get (mm-handle-type handle)
|
|
|
|
'charset)))
|
|
|
|
(when (and charset
|
2013-11-27 06:39:37 +00:00
|
|
|
(setq charset (mm-charset-to-coding-system
|
|
|
|
charset nil t))
|
2010-09-01 06:04:49 +00:00
|
|
|
(not (eq charset 'ascii)))
|
2010-09-02 03:47:31 +00:00
|
|
|
(insert (prog1
|
2016-02-12 03:39:30 +00:00
|
|
|
(decode-coding-string (buffer-string) charset)
|
2010-09-02 03:47:31 +00:00
|
|
|
(erase-buffer)
|
|
|
|
(mm-enable-multibyte))))
|
2010-08-30 06:17:45 +00:00
|
|
|
(call-process-region (point-min) (point-max)
|
2010-09-02 01:42:32 +00:00
|
|
|
"w3m"
|
2010-08-30 06:17:45 +00:00
|
|
|
nil article-buffer nil
|
|
|
|
"-halfdump"
|
|
|
|
"-no-cookie"
|
2010-08-31 00:23:25 +00:00
|
|
|
"-I" "UTF-8"
|
2010-08-30 06:17:45 +00:00
|
|
|
"-O" "UTF-8"
|
|
|
|
"-o" "ext_halfdump=1"
|
2010-09-20 00:36:54 +00:00
|
|
|
"-o" "display_ins_del=2"
|
2010-08-31 00:23:25 +00:00
|
|
|
"-o" "pre_conv=1"
|
2010-08-30 06:17:45 +00:00
|
|
|
"-t" (format "%s" tab-width)
|
|
|
|
"-cols" (format "%s" gnus-html-frame-width)
|
2010-09-02 01:29:42 +00:00
|
|
|
"-o" "display_image=on"
|
2010-08-30 06:17:45 +00:00
|
|
|
"-T" "text/html"))))
|
2010-08-30 06:13:50 +00:00
|
|
|
(gnus-html-wash-tags))))
|
|
|
|
|
2010-08-31 19:47:35 +00:00
|
|
|
(defvar gnus-article-mouse-face)
|
|
|
|
|
2010-09-09 00:08:06 +00:00
|
|
|
(defun gnus-html-pre-wash ()
|
|
|
|
(goto-char (point-min))
|
|
|
|
(while (re-search-forward " *<pre_int> *</pre_int> *\n" nil t)
|
|
|
|
(replace-match "" t t))
|
|
|
|
(goto-char (point-min))
|
|
|
|
(while (re-search-forward "<a name[^\n>]+>" nil t)
|
|
|
|
(replace-match "" t t)))
|
|
|
|
|
2010-09-10 00:07:33 +00:00
|
|
|
(defun gnus-html-wash-images ()
|
2010-09-21 11:48:40 +00:00
|
|
|
"Run through current buffer and replace img tags by images."
|
2010-11-19 04:55:16 +00:00
|
|
|
(let (tag parameters string start end images url alt-text
|
|
|
|
inhibit-images blocked-images)
|
|
|
|
(if (buffer-live-p gnus-summary-buffer)
|
|
|
|
(with-current-buffer gnus-summary-buffer
|
|
|
|
(setq inhibit-images gnus-inhibit-images
|
|
|
|
blocked-images (gnus-blocked-images)))
|
|
|
|
(setq inhibit-images gnus-inhibit-images
|
|
|
|
blocked-images (gnus-blocked-images)))
|
2010-08-30 06:13:50 +00:00
|
|
|
(goto-char (point-min))
|
2010-09-09 00:08:06 +00:00
|
|
|
;; Search for all the images first.
|
|
|
|
(while (re-search-forward "<img_alt \\([^>]*\\)>" nil t)
|
|
|
|
(setq parameters (match-string 1)
|
|
|
|
start (match-beginning 0))
|
|
|
|
(delete-region start (point))
|
|
|
|
(when (search-forward "</img_alt>" (line-end-position) t)
|
|
|
|
(delete-region (match-beginning 0) (match-end 0)))
|
|
|
|
(setq end (point))
|
|
|
|
(when (string-match "src=\"\\([^\"]+\\)" parameters)
|
|
|
|
(gnus-message 8 "gnus-html-wash-tags: fetching image URL %s" url)
|
2010-11-18 02:00:00 +00:00
|
|
|
(setq url (gnus-html-encode-url (match-string 1 parameters))
|
|
|
|
alt-text (when (string-match "\\(alt\\|title\\)=\"\\([^\"]+\\)"
|
|
|
|
parameters)
|
|
|
|
(xml-substitute-special (match-string 2 parameters))))
|
2016-02-13 07:13:03 +00:00
|
|
|
(add-text-properties
|
2010-11-18 02:00:00 +00:00
|
|
|
start end
|
|
|
|
(list 'image-url url
|
|
|
|
'image-displayer `(lambda (url start end)
|
|
|
|
(gnus-html-display-image url start end
|
|
|
|
,alt-text))
|
2019-07-30 13:24:55 +00:00
|
|
|
'help-echo alt-text
|
|
|
|
'button t
|
|
|
|
'keymap gnus-html-image-map
|
2010-11-18 02:00:00 +00:00
|
|
|
'gnus-image (list url start end alt-text)))
|
|
|
|
(if (string-match "\\`cid:" url)
|
2010-09-09 00:08:06 +00:00
|
|
|
;; URLs with cid: have their content stashed in other
|
|
|
|
;; parts of the MIME structure, so just insert them
|
|
|
|
;; immediately.
|
2010-11-18 02:00:00 +00:00
|
|
|
(let* ((handle (mm-get-content-id (substring url (match-end 0))))
|
|
|
|
(image (when (and handle
|
2010-11-19 04:55:16 +00:00
|
|
|
(not inhibit-images))
|
2010-11-18 02:00:00 +00:00
|
|
|
(gnus-create-image
|
2010-11-16 00:04:25 +00:00
|
|
|
(mm-with-part handle (buffer-string))
|
|
|
|
nil t))))
|
2010-11-18 02:00:00 +00:00
|
|
|
(if image
|
2011-05-10 03:14:44 +00:00
|
|
|
(gnus-add-image
|
|
|
|
'cid
|
|
|
|
(gnus-put-image
|
|
|
|
(gnus-rescale-image
|
|
|
|
image (gnus-html-maximum-image-size))
|
|
|
|
(gnus-string-or (prog1
|
|
|
|
(buffer-substring start end)
|
|
|
|
(delete-region start end))
|
|
|
|
"*")
|
|
|
|
'cid))
|
2019-07-30 13:24:55 +00:00
|
|
|
(make-text-button start end
|
|
|
|
'help-echo url
|
|
|
|
'keymap gnus-html-image-map)))
|
2010-09-09 00:08:06 +00:00
|
|
|
;; Normal, external URL.
|
2010-11-19 04:55:16 +00:00
|
|
|
(if (or inhibit-images
|
|
|
|
(gnus-html-image-url-blocked-p url blocked-images))
|
2019-07-30 13:24:55 +00:00
|
|
|
(make-text-button start end
|
|
|
|
'help-echo url
|
|
|
|
'keymap gnus-html-image-map)
|
2010-11-18 02:00:00 +00:00
|
|
|
;; Non-blocked url
|
|
|
|
(let ((width
|
|
|
|
(when (string-match "width=\"?\\([0-9]+\\)" parameters)
|
|
|
|
(string-to-number (match-string 1 parameters))))
|
|
|
|
(height
|
|
|
|
(when (string-match "height=\"?\\([0-9]+\\)" parameters)
|
|
|
|
(string-to-number (match-string 1 parameters)))))
|
|
|
|
;; Don't fetch images that are really small. They're
|
|
|
|
;; probably tracking pictures.
|
|
|
|
(when (and (or (null height)
|
|
|
|
(> height 4))
|
|
|
|
(or (null width)
|
|
|
|
(> width 4)))
|
|
|
|
(gnus-html-display-image url start end alt-text)))))))))
|
2010-09-21 11:48:40 +00:00
|
|
|
|
2010-11-15 23:45:55 +00:00
|
|
|
(defun gnus-html-display-image (url start end &optional alt-text)
|
2010-09-21 11:48:40 +00:00
|
|
|
"Display image at URL on text from START to END.
|
|
|
|
Use ALT-TEXT for the image string."
|
2010-11-18 02:00:00 +00:00
|
|
|
(or alt-text (setq alt-text "*"))
|
|
|
|
(if (string-match "\\`cid:" url)
|
|
|
|
(let ((handle (mm-get-content-id (substring url (match-end 0)))))
|
|
|
|
(when handle
|
|
|
|
(gnus-html-put-image (mm-with-part handle (buffer-string))
|
|
|
|
url alt-text)))
|
|
|
|
(if (gnus-html-cache-expired url gnus-html-image-cache-ttl)
|
|
|
|
;; We don't have it, so schedule it for fetching
|
|
|
|
;; asynchronously.
|
|
|
|
(gnus-html-schedule-image-fetching
|
|
|
|
(current-buffer)
|
|
|
|
(list url alt-text))
|
|
|
|
;; It's already cached, so just insert it.
|
|
|
|
(gnus-html-put-image (gnus-html-get-image-data url) url alt-text))))
|
2010-09-10 00:07:33 +00:00
|
|
|
|
|
|
|
(defun gnus-html-wash-tags ()
|
|
|
|
(let (tag parameters string start end images url)
|
|
|
|
(gnus-html-pre-wash)
|
|
|
|
(gnus-html-wash-images)
|
2010-09-09 00:08:06 +00:00
|
|
|
|
2010-09-06 23:58:34 +00:00
|
|
|
(goto-char (point-min))
|
2010-09-09 00:08:06 +00:00
|
|
|
;; Then do the other tags.
|
2010-08-30 06:17:45 +00:00
|
|
|
(while (re-search-forward "<\\([^ />]+\\)\\([^>]*\\)>" nil t)
|
2010-08-30 06:13:50 +00:00
|
|
|
(setq tag (match-string 1)
|
|
|
|
parameters (match-string 2)
|
2010-08-30 06:17:45 +00:00
|
|
|
start (match-beginning 0))
|
2010-10-03 19:54:31 +00:00
|
|
|
(when (> (length parameters) 0)
|
2010-08-30 06:17:45 +00:00
|
|
|
(set-text-properties 0 (1- (length parameters)) nil parameters))
|
|
|
|
(delete-region start (point))
|
2010-09-10 00:07:33 +00:00
|
|
|
(when (search-forward (concat "</" tag ">") nil t)
|
2010-08-30 06:17:45 +00:00
|
|
|
(delete-region (match-beginning 0) (match-end 0)))
|
|
|
|
(setq end (point))
|
2010-08-30 06:13:50 +00:00
|
|
|
(cond
|
|
|
|
;; Fetch and insert a picture.
|
2010-09-09 00:08:06 +00:00
|
|
|
((equal tag "img_alt"))
|
2010-08-30 06:13:50 +00:00
|
|
|
;; Add a link.
|
2010-09-02 01:02:03 +00:00
|
|
|
((or (equal tag "a")
|
|
|
|
(equal tag "A"))
|
2010-08-30 06:13:50 +00:00
|
|
|
(when (string-match "href=\"\\([^\"]+\\)" parameters)
|
2010-08-31 13:28:02 +00:00
|
|
|
(setq url (match-string 1 parameters))
|
2010-09-02 01:18:45 +00:00
|
|
|
(gnus-message 8 "gnus-html-wash-tags: fetching link URL %s" url)
|
2010-08-30 06:13:50 +00:00
|
|
|
(gnus-article-add-button start end
|
2010-10-05 10:46:15 +00:00
|
|
|
'browse-url (mm-url-decode-entities-string url)
|
2010-08-31 13:28:02 +00:00
|
|
|
url)
|
[Gnus]: Use overlay functions directly
* lisp/gnus/gnus-art.el (gnus-mime-inline-part, gnus-mm-display-part)
(gnus-insert-mime-button, gnus-mime-buttonize-attachments-in-header)
(gnus-article-highlight-signature, gnus-article-extend-url-button)
(gnus-article-add-button, gnus-insert-prev-page-button)
(gnus-insert-next-page-button, gnus-insert-mime-security-button):
* lisp/gnus/gnus-cite.el (gnus-cite-delete-overlays)
(gnus-cite-add-face):
* lisp/gnus/gnus-html.el (gnus-html-wash-tags):
* lisp/gnus/gnus-salt.el (gnus-tree-read-summary-keys)
(gnus-tree-recenter, gnus-highlight-selected-tree):
* lisp/gnus/gnus-sum.el (gnus-summary-show-all-threads)
(gnus-summary-show-thread, gnus-summary-hide-thread)
(gnus-highlight-selected-summary):
* lisp/gnus/gnus-util.el (gnus-put-overlay-excluding-newlines):
* lisp/gnus/message.el (message-fix-before-sending)
(message-toggle-image-thumbnails):
* lisp/gnus/mm-decode.el (mm-convert-shr-links):
* lisp/gnus/sieve.el (sieve-highlight, sieve-insert-scripts):
Use overlay functions directly instead of using gnus-overlay-*,
message-overlay-*, and sieve-overlay-*.
* lisp/gnus/gnus-sum.el (gnus-remove-overlays):
* lisp/gnus/gnus.el (gnus-make-overlay, gnus-copy-overlay)
(gnus-delete-overlay, gnus-overlay-get, gnus-overlay-put)
(gnus-move-overlay, gnus-overlay-buffer, gnus-overlay-start)
(gnus-overlay-end, gnus-overlays-at, gnus-overlays-in):
* lisp/gnus/message.el (message-delete-overlay, message-make-overlay)
(message-overlay-get, message-overlay-put, message-overlays-in):
* lisp/gnus/sieve.el (sieve-make-overlay, sieve-overlay-put)
(sieve-overlays-at):
Remove.
2015-08-19 09:06:40 +00:00
|
|
|
(let ((overlay (make-overlay start end)))
|
|
|
|
(overlay-put overlay 'evaporate t)
|
|
|
|
(overlay-put overlay 'gnus-button-url url)
|
2016-02-13 07:13:03 +00:00
|
|
|
(put-text-property start end 'gnus-string url)
|
2010-08-30 06:13:50 +00:00
|
|
|
(when gnus-article-mouse-face
|
[Gnus]: Use overlay functions directly
* lisp/gnus/gnus-art.el (gnus-mime-inline-part, gnus-mm-display-part)
(gnus-insert-mime-button, gnus-mime-buttonize-attachments-in-header)
(gnus-article-highlight-signature, gnus-article-extend-url-button)
(gnus-article-add-button, gnus-insert-prev-page-button)
(gnus-insert-next-page-button, gnus-insert-mime-security-button):
* lisp/gnus/gnus-cite.el (gnus-cite-delete-overlays)
(gnus-cite-add-face):
* lisp/gnus/gnus-html.el (gnus-html-wash-tags):
* lisp/gnus/gnus-salt.el (gnus-tree-read-summary-keys)
(gnus-tree-recenter, gnus-highlight-selected-tree):
* lisp/gnus/gnus-sum.el (gnus-summary-show-all-threads)
(gnus-summary-show-thread, gnus-summary-hide-thread)
(gnus-highlight-selected-summary):
* lisp/gnus/gnus-util.el (gnus-put-overlay-excluding-newlines):
* lisp/gnus/message.el (message-fix-before-sending)
(message-toggle-image-thumbnails):
* lisp/gnus/mm-decode.el (mm-convert-shr-links):
* lisp/gnus/sieve.el (sieve-highlight, sieve-insert-scripts):
Use overlay functions directly instead of using gnus-overlay-*,
message-overlay-*, and sieve-overlay-*.
* lisp/gnus/gnus-sum.el (gnus-remove-overlays):
* lisp/gnus/gnus.el (gnus-make-overlay, gnus-copy-overlay)
(gnus-delete-overlay, gnus-overlay-get, gnus-overlay-put)
(gnus-move-overlay, gnus-overlay-buffer, gnus-overlay-start)
(gnus-overlay-end, gnus-overlays-at, gnus-overlays-in):
* lisp/gnus/message.el (message-delete-overlay, message-make-overlay)
(message-overlay-get, message-overlay-put, message-overlays-in):
* lisp/gnus/sieve.el (sieve-make-overlay, sieve-overlay-put)
(sieve-overlays-at):
Remove.
2015-08-19 09:06:40 +00:00
|
|
|
(overlay-put overlay 'mouse-face gnus-article-mouse-face)))))
|
2010-09-01 23:40:39 +00:00
|
|
|
;; The upper-case IMG_ALT is apparently just an artifact that
|
|
|
|
;; should be deleted.
|
|
|
|
((equal tag "IMG_ALT")
|
|
|
|
(delete-region start end))
|
2010-09-20 00:36:54 +00:00
|
|
|
;; w3m does not normalize the case
|
|
|
|
((or (equal tag "b")
|
|
|
|
(equal tag "B"))
|
[Gnus]: Use overlay functions directly
* lisp/gnus/gnus-art.el (gnus-mime-inline-part, gnus-mm-display-part)
(gnus-insert-mime-button, gnus-mime-buttonize-attachments-in-header)
(gnus-article-highlight-signature, gnus-article-extend-url-button)
(gnus-article-add-button, gnus-insert-prev-page-button)
(gnus-insert-next-page-button, gnus-insert-mime-security-button):
* lisp/gnus/gnus-cite.el (gnus-cite-delete-overlays)
(gnus-cite-add-face):
* lisp/gnus/gnus-html.el (gnus-html-wash-tags):
* lisp/gnus/gnus-salt.el (gnus-tree-read-summary-keys)
(gnus-tree-recenter, gnus-highlight-selected-tree):
* lisp/gnus/gnus-sum.el (gnus-summary-show-all-threads)
(gnus-summary-show-thread, gnus-summary-hide-thread)
(gnus-highlight-selected-summary):
* lisp/gnus/gnus-util.el (gnus-put-overlay-excluding-newlines):
* lisp/gnus/message.el (message-fix-before-sending)
(message-toggle-image-thumbnails):
* lisp/gnus/mm-decode.el (mm-convert-shr-links):
* lisp/gnus/sieve.el (sieve-highlight, sieve-insert-scripts):
Use overlay functions directly instead of using gnus-overlay-*,
message-overlay-*, and sieve-overlay-*.
* lisp/gnus/gnus-sum.el (gnus-remove-overlays):
* lisp/gnus/gnus.el (gnus-make-overlay, gnus-copy-overlay)
(gnus-delete-overlay, gnus-overlay-get, gnus-overlay-put)
(gnus-move-overlay, gnus-overlay-buffer, gnus-overlay-start)
(gnus-overlay-end, gnus-overlays-at, gnus-overlays-in):
* lisp/gnus/message.el (message-delete-overlay, message-make-overlay)
(message-overlay-get, message-overlay-put, message-overlays-in):
* lisp/gnus/sieve.el (sieve-make-overlay, sieve-overlay-put)
(sieve-overlays-at):
Remove.
2015-08-19 09:06:40 +00:00
|
|
|
(overlay-put (make-overlay start end) 'face 'gnus-emphasis-bold))
|
2010-09-20 00:36:54 +00:00
|
|
|
((or (equal tag "u")
|
|
|
|
(equal tag "U"))
|
[Gnus]: Use overlay functions directly
* lisp/gnus/gnus-art.el (gnus-mime-inline-part, gnus-mm-display-part)
(gnus-insert-mime-button, gnus-mime-buttonize-attachments-in-header)
(gnus-article-highlight-signature, gnus-article-extend-url-button)
(gnus-article-add-button, gnus-insert-prev-page-button)
(gnus-insert-next-page-button, gnus-insert-mime-security-button):
* lisp/gnus/gnus-cite.el (gnus-cite-delete-overlays)
(gnus-cite-add-face):
* lisp/gnus/gnus-html.el (gnus-html-wash-tags):
* lisp/gnus/gnus-salt.el (gnus-tree-read-summary-keys)
(gnus-tree-recenter, gnus-highlight-selected-tree):
* lisp/gnus/gnus-sum.el (gnus-summary-show-all-threads)
(gnus-summary-show-thread, gnus-summary-hide-thread)
(gnus-highlight-selected-summary):
* lisp/gnus/gnus-util.el (gnus-put-overlay-excluding-newlines):
* lisp/gnus/message.el (message-fix-before-sending)
(message-toggle-image-thumbnails):
* lisp/gnus/mm-decode.el (mm-convert-shr-links):
* lisp/gnus/sieve.el (sieve-highlight, sieve-insert-scripts):
Use overlay functions directly instead of using gnus-overlay-*,
message-overlay-*, and sieve-overlay-*.
* lisp/gnus/gnus-sum.el (gnus-remove-overlays):
* lisp/gnus/gnus.el (gnus-make-overlay, gnus-copy-overlay)
(gnus-delete-overlay, gnus-overlay-get, gnus-overlay-put)
(gnus-move-overlay, gnus-overlay-buffer, gnus-overlay-start)
(gnus-overlay-end, gnus-overlays-at, gnus-overlays-in):
* lisp/gnus/message.el (message-delete-overlay, message-make-overlay)
(message-overlay-get, message-overlay-put, message-overlays-in):
* lisp/gnus/sieve.el (sieve-make-overlay, sieve-overlay-put)
(sieve-overlays-at):
Remove.
2015-08-19 09:06:40 +00:00
|
|
|
(overlay-put (make-overlay start end) 'face 'gnus-emphasis-underline))
|
2010-09-20 00:36:54 +00:00
|
|
|
((or (equal tag "i")
|
|
|
|
(equal tag "I"))
|
[Gnus]: Use overlay functions directly
* lisp/gnus/gnus-art.el (gnus-mime-inline-part, gnus-mm-display-part)
(gnus-insert-mime-button, gnus-mime-buttonize-attachments-in-header)
(gnus-article-highlight-signature, gnus-article-extend-url-button)
(gnus-article-add-button, gnus-insert-prev-page-button)
(gnus-insert-next-page-button, gnus-insert-mime-security-button):
* lisp/gnus/gnus-cite.el (gnus-cite-delete-overlays)
(gnus-cite-add-face):
* lisp/gnus/gnus-html.el (gnus-html-wash-tags):
* lisp/gnus/gnus-salt.el (gnus-tree-read-summary-keys)
(gnus-tree-recenter, gnus-highlight-selected-tree):
* lisp/gnus/gnus-sum.el (gnus-summary-show-all-threads)
(gnus-summary-show-thread, gnus-summary-hide-thread)
(gnus-highlight-selected-summary):
* lisp/gnus/gnus-util.el (gnus-put-overlay-excluding-newlines):
* lisp/gnus/message.el (message-fix-before-sending)
(message-toggle-image-thumbnails):
* lisp/gnus/mm-decode.el (mm-convert-shr-links):
* lisp/gnus/sieve.el (sieve-highlight, sieve-insert-scripts):
Use overlay functions directly instead of using gnus-overlay-*,
message-overlay-*, and sieve-overlay-*.
* lisp/gnus/gnus-sum.el (gnus-remove-overlays):
* lisp/gnus/gnus.el (gnus-make-overlay, gnus-copy-overlay)
(gnus-delete-overlay, gnus-overlay-get, gnus-overlay-put)
(gnus-move-overlay, gnus-overlay-buffer, gnus-overlay-start)
(gnus-overlay-end, gnus-overlays-at, gnus-overlays-in):
* lisp/gnus/message.el (message-delete-overlay, message-make-overlay)
(message-overlay-get, message-overlay-put, message-overlays-in):
* lisp/gnus/sieve.el (sieve-make-overlay, sieve-overlay-put)
(sieve-overlays-at):
Remove.
2015-08-19 09:06:40 +00:00
|
|
|
(overlay-put (make-overlay start end) 'face 'gnus-emphasis-italic))
|
2010-09-20 00:36:54 +00:00
|
|
|
((or (equal tag "s")
|
|
|
|
(equal tag "S"))
|
[Gnus]: Use overlay functions directly
* lisp/gnus/gnus-art.el (gnus-mime-inline-part, gnus-mm-display-part)
(gnus-insert-mime-button, gnus-mime-buttonize-attachments-in-header)
(gnus-article-highlight-signature, gnus-article-extend-url-button)
(gnus-article-add-button, gnus-insert-prev-page-button)
(gnus-insert-next-page-button, gnus-insert-mime-security-button):
* lisp/gnus/gnus-cite.el (gnus-cite-delete-overlays)
(gnus-cite-add-face):
* lisp/gnus/gnus-html.el (gnus-html-wash-tags):
* lisp/gnus/gnus-salt.el (gnus-tree-read-summary-keys)
(gnus-tree-recenter, gnus-highlight-selected-tree):
* lisp/gnus/gnus-sum.el (gnus-summary-show-all-threads)
(gnus-summary-show-thread, gnus-summary-hide-thread)
(gnus-highlight-selected-summary):
* lisp/gnus/gnus-util.el (gnus-put-overlay-excluding-newlines):
* lisp/gnus/message.el (message-fix-before-sending)
(message-toggle-image-thumbnails):
* lisp/gnus/mm-decode.el (mm-convert-shr-links):
* lisp/gnus/sieve.el (sieve-highlight, sieve-insert-scripts):
Use overlay functions directly instead of using gnus-overlay-*,
message-overlay-*, and sieve-overlay-*.
* lisp/gnus/gnus-sum.el (gnus-remove-overlays):
* lisp/gnus/gnus.el (gnus-make-overlay, gnus-copy-overlay)
(gnus-delete-overlay, gnus-overlay-get, gnus-overlay-put)
(gnus-move-overlay, gnus-overlay-buffer, gnus-overlay-start)
(gnus-overlay-end, gnus-overlays-at, gnus-overlays-in):
* lisp/gnus/message.el (message-delete-overlay, message-make-overlay)
(message-overlay-get, message-overlay-put, message-overlays-in):
* lisp/gnus/sieve.el (sieve-make-overlay, sieve-overlay-put)
(sieve-overlays-at):
Remove.
2015-08-19 09:06:40 +00:00
|
|
|
(overlay-put (make-overlay start end) 'face 'gnus-emphasis-strikethru))
|
2010-09-20 00:36:54 +00:00
|
|
|
((or (equal tag "ins")
|
|
|
|
(equal tag "INS"))
|
[Gnus]: Use overlay functions directly
* lisp/gnus/gnus-art.el (gnus-mime-inline-part, gnus-mm-display-part)
(gnus-insert-mime-button, gnus-mime-buttonize-attachments-in-header)
(gnus-article-highlight-signature, gnus-article-extend-url-button)
(gnus-article-add-button, gnus-insert-prev-page-button)
(gnus-insert-next-page-button, gnus-insert-mime-security-button):
* lisp/gnus/gnus-cite.el (gnus-cite-delete-overlays)
(gnus-cite-add-face):
* lisp/gnus/gnus-html.el (gnus-html-wash-tags):
* lisp/gnus/gnus-salt.el (gnus-tree-read-summary-keys)
(gnus-tree-recenter, gnus-highlight-selected-tree):
* lisp/gnus/gnus-sum.el (gnus-summary-show-all-threads)
(gnus-summary-show-thread, gnus-summary-hide-thread)
(gnus-highlight-selected-summary):
* lisp/gnus/gnus-util.el (gnus-put-overlay-excluding-newlines):
* lisp/gnus/message.el (message-fix-before-sending)
(message-toggle-image-thumbnails):
* lisp/gnus/mm-decode.el (mm-convert-shr-links):
* lisp/gnus/sieve.el (sieve-highlight, sieve-insert-scripts):
Use overlay functions directly instead of using gnus-overlay-*,
message-overlay-*, and sieve-overlay-*.
* lisp/gnus/gnus-sum.el (gnus-remove-overlays):
* lisp/gnus/gnus.el (gnus-make-overlay, gnus-copy-overlay)
(gnus-delete-overlay, gnus-overlay-get, gnus-overlay-put)
(gnus-move-overlay, gnus-overlay-buffer, gnus-overlay-start)
(gnus-overlay-end, gnus-overlays-at, gnus-overlays-in):
* lisp/gnus/message.el (message-delete-overlay, message-make-overlay)
(message-overlay-get, message-overlay-put, message-overlays-in):
* lisp/gnus/sieve.el (sieve-make-overlay, sieve-overlay-put)
(sieve-overlays-at):
Remove.
2015-08-19 09:06:40 +00:00
|
|
|
(overlay-put (make-overlay start end) 'face 'gnus-emphasis-underline))
|
2010-09-20 00:36:54 +00:00
|
|
|
;; Handle different UL types
|
|
|
|
((equal tag "_SYMBOL")
|
|
|
|
(when (string-match "TYPE=\\(.+\\)" parameters)
|
|
|
|
(let ((type (string-to-number (match-string 1 parameters))))
|
|
|
|
(delete-region start end)
|
|
|
|
(cond ((= type 33) (insert " "))
|
|
|
|
((= type 34) (insert " "))
|
|
|
|
((= type 35) (insert " "))
|
|
|
|
((= type 36) (insert " "))
|
|
|
|
((= type 37) (insert " "))
|
|
|
|
((= type 38) (insert " "))
|
|
|
|
((= type 39) (insert " "))
|
|
|
|
((= type 40) (insert " "))
|
|
|
|
((= type 42) (insert " "))
|
|
|
|
((= type 43) (insert " "))
|
|
|
|
(t (insert " "))))))
|
2010-08-30 06:13:50 +00:00
|
|
|
;; Whatever. Just ignore the tag.
|
|
|
|
(t
|
2010-08-30 06:17:45 +00:00
|
|
|
))
|
|
|
|
(goto-char start))
|
|
|
|
(goto-char (point-min))
|
|
|
|
;; The output from -halfdump isn't totally regular, so strip
|
|
|
|
;; off any </pre_int>s that were left over.
|
2010-09-07 00:08:33 +00:00
|
|
|
(while (re-search-forward "</pre_int>\\|</internal>" nil t)
|
2010-08-30 06:17:45 +00:00
|
|
|
(replace-match "" t t))
|
2010-09-04 00:50:02 +00:00
|
|
|
(mm-url-decode-entities)))
|
2010-08-30 06:17:45 +00:00
|
|
|
|
2010-11-18 02:00:00 +00:00
|
|
|
(defun gnus-html-insert-image (&rest args)
|
2010-09-04 00:21:34 +00:00
|
|
|
"Fetch and insert the image under point."
|
|
|
|
(interactive)
|
2010-09-21 11:48:40 +00:00
|
|
|
(apply 'gnus-html-display-image (get-text-property (point) 'gnus-image)))
|
2010-09-04 00:21:34 +00:00
|
|
|
|
2010-09-08 23:59:52 +00:00
|
|
|
(defun gnus-html-show-alt-text ()
|
|
|
|
"Show the ALT text of the image under point."
|
|
|
|
(interactive)
|
|
|
|
(message "%s" (get-text-property (point) 'gnus-alt-text)))
|
|
|
|
|
|
|
|
(defun gnus-html-browse-image ()
|
|
|
|
"Browse the image under point."
|
|
|
|
(interactive)
|
2010-11-15 23:45:55 +00:00
|
|
|
(browse-url (get-text-property (point) 'image-url)))
|
2010-09-08 23:59:52 +00:00
|
|
|
|
2010-09-09 00:08:06 +00:00
|
|
|
(defun gnus-html-browse-url ()
|
|
|
|
"Browse the image under point."
|
|
|
|
(interactive)
|
|
|
|
(let ((url (get-text-property (point) 'gnus-string)))
|
2010-11-04 22:18:09 +00:00
|
|
|
(cond
|
|
|
|
((not url)
|
|
|
|
(message "No link under point"))
|
|
|
|
((string-match "^mailto:" url)
|
|
|
|
(gnus-url-mailto url))
|
|
|
|
(t
|
|
|
|
(browse-url url)))))
|
2010-09-09 00:08:06 +00:00
|
|
|
|
2010-09-21 11:48:40 +00:00
|
|
|
(defun gnus-html-schedule-image-fetching (buffer image)
|
|
|
|
"Retrieve IMAGE, and place it into BUFFER on arrival."
|
|
|
|
(gnus-message 8 "gnus-html-schedule-image-fetching: buffer %s, image %s"
|
|
|
|
buffer image)
|
2016-02-13 06:01:31 +00:00
|
|
|
(url-queue-retrieve (car image)
|
|
|
|
'gnus-html-image-fetched
|
|
|
|
(list buffer image) t t))
|
2010-08-30 06:17:45 +00:00
|
|
|
|
2010-09-18 23:36:29 +00:00
|
|
|
(defun gnus-html-image-fetched (status buffer image)
|
2010-09-23 00:30:37 +00:00
|
|
|
"Callback function called when image has been fetched."
|
|
|
|
(unless (plist-get status :error)
|
|
|
|
(when (and (or (search-forward "\n\n" nil t)
|
|
|
|
(search-forward "\r\n\r\n" nil t))
|
2011-08-21 22:10:49 +00:00
|
|
|
(not (eobp)))
|
|
|
|
(when gnus-html-image-automatic-caching
|
|
|
|
(url-store-in-cache (current-buffer)))
|
|
|
|
(when (buffer-live-p buffer)
|
|
|
|
(let ((data (buffer-substring (point) (point-max))))
|
|
|
|
(with-current-buffer buffer
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
(gnus-html-put-image data (car image) (cadr image))))))))
|
2010-09-21 11:48:40 +00:00
|
|
|
(kill-buffer (current-buffer)))
|
|
|
|
|
|
|
|
(defun gnus-html-get-image-data (url)
|
|
|
|
"Get image data for URL.
|
|
|
|
Return a string with image data."
|
|
|
|
(with-temp-buffer
|
|
|
|
(mm-disable-multibyte)
|
|
|
|
(url-cache-extract (url-cache-create-filename url))
|
2010-09-23 00:30:37 +00:00
|
|
|
(when (or (search-forward "\n\n" nil t)
|
|
|
|
(search-forward "\r\n\r\n" nil t))
|
2010-09-21 11:48:40 +00:00
|
|
|
(buffer-substring (point) (point-max)))))
|
|
|
|
|
2010-10-05 13:19:07 +00:00
|
|
|
(defun gnus-html-maximum-image-size ()
|
|
|
|
"Return the maximum size of an image according to `gnus-max-image-proportion'."
|
2016-02-09 22:53:13 +00:00
|
|
|
(let ((edges (window-inside-pixel-edges
|
2010-10-05 13:19:07 +00:00
|
|
|
(get-buffer-window (current-buffer)))))
|
|
|
|
;; (width . height)
|
|
|
|
(cons
|
|
|
|
;; Aimed width
|
|
|
|
(truncate
|
|
|
|
(* gnus-max-image-proportion
|
|
|
|
(- (nth 2 edges) (nth 0 edges))))
|
|
|
|
;; Aimed height
|
|
|
|
(truncate (* gnus-max-image-proportion
|
|
|
|
(- (nth 3 edges) (nth 1 edges)))))))
|
|
|
|
|
2013-09-13 07:19:15 +00:00
|
|
|
;; Behind display-graphic-p test.
|
|
|
|
(declare-function image-size "image.c" (spec &optional pixels frame))
|
|
|
|
|
2010-09-23 00:30:37 +00:00
|
|
|
(defun gnus-html-put-image (data url &optional alt-text)
|
2010-10-05 13:19:07 +00:00
|
|
|
"Put an image with DATA from URL and optional ALT-TEXT."
|
2016-02-11 05:39:23 +00:00
|
|
|
(when (display-graphic-p)
|
2010-10-03 00:33:27 +00:00
|
|
|
(let* ((start (text-property-any (point-min) (point-max)
|
2010-11-15 23:45:55 +00:00
|
|
|
'image-url url))
|
2010-09-23 00:30:37 +00:00
|
|
|
(end (when start
|
2010-11-15 23:45:55 +00:00
|
|
|
(next-single-property-change start 'image-url))))
|
2010-09-23 00:30:37 +00:00
|
|
|
;; Image found?
|
|
|
|
(when start
|
|
|
|
(let* ((image
|
|
|
|
(ignore-errors
|
|
|
|
(gnus-create-image data nil t)))
|
2016-02-11 04:22:45 +00:00
|
|
|
(size (and image (image-size image t))))
|
2010-09-23 00:30:37 +00:00
|
|
|
(save-excursion
|
|
|
|
(goto-char start)
|
2010-10-03 00:33:27 +00:00
|
|
|
(let ((alt-text (or alt-text
|
2010-11-18 02:00:00 +00:00
|
|
|
(buffer-substring-no-properties start end)))
|
|
|
|
(inhibit-read-only t))
|
2010-09-23 00:30:37 +00:00
|
|
|
(if (and image
|
|
|
|
;; Kludge to avoid displaying 30x30 gif images, which
|
|
|
|
;; seems to be a signal of a broken image.
|
2016-02-11 04:22:45 +00:00
|
|
|
(not (and (listp image)
|
|
|
|
(eq (plist-get (cdr image) :type)
|
2010-09-23 00:30:37 +00:00
|
|
|
'gif)
|
|
|
|
(= (car size) 30)
|
|
|
|
(= (cdr size) 30))))
|
|
|
|
;; Good image, add it!
|
2010-10-05 13:19:07 +00:00
|
|
|
(let ((image (gnus-rescale-image image (gnus-html-maximum-image-size))))
|
2010-09-23 00:30:37 +00:00
|
|
|
(delete-region start end)
|
|
|
|
(gnus-put-image image alt-text 'external)
|
2019-07-30 13:24:55 +00:00
|
|
|
(make-text-button start (point)
|
|
|
|
'help-echo alt-text
|
|
|
|
'keymap gnus-html-displayed-image-map)
|
2016-02-13 07:13:03 +00:00
|
|
|
(put-text-property start (point) 'gnus-alt-text alt-text)
|
2010-09-23 00:30:37 +00:00
|
|
|
(when url
|
2016-02-13 07:13:03 +00:00
|
|
|
(add-text-properties
|
2011-05-13 05:35:56 +00:00
|
|
|
start (point)
|
|
|
|
`(image-url
|
|
|
|
,url
|
|
|
|
image-displayer
|
|
|
|
(lambda (url start end)
|
2011-05-13 07:53:12 +00:00
|
|
|
(gnus-html-display-image url start end
|
2011-05-13 05:35:56 +00:00
|
|
|
,alt-text)))))
|
2010-09-23 00:30:37 +00:00
|
|
|
(gnus-add-image 'external image)
|
|
|
|
t)
|
|
|
|
;; Bad image, try to show something else
|
|
|
|
(when (fboundp 'find-image)
|
|
|
|
(delete-region start end)
|
2010-10-03 00:33:27 +00:00
|
|
|
(setq image (find-image
|
|
|
|
'((:type xpm :file "lock-broken.xpm"))))
|
2010-09-23 00:30:37 +00:00
|
|
|
(gnus-put-image image alt-text 'internal)
|
|
|
|
(gnus-add-image 'internal image))
|
|
|
|
nil))))))))
|
2010-09-21 11:48:40 +00:00
|
|
|
|
2010-09-02 01:02:03 +00:00
|
|
|
(defun gnus-html-image-url-blocked-p (url blocked-images)
|
2010-09-08 23:59:52 +00:00
|
|
|
"Find out if URL is blocked by BLOCKED-IMAGES."
|
2010-09-02 01:02:03 +00:00
|
|
|
(let ((ret (and blocked-images
|
|
|
|
(string-match blocked-images url))))
|
2010-09-02 01:18:45 +00:00
|
|
|
(if ret
|
|
|
|
(gnus-message 8 "gnus-html-image-url-blocked-p: %s blocked by regex %s"
|
|
|
|
url blocked-images)
|
|
|
|
(gnus-message 9 "gnus-html-image-url-blocked-p: %s passes regex %s"
|
|
|
|
url blocked-images))
|
2010-09-02 00:17:40 +00:00
|
|
|
ret))
|
|
|
|
|
2010-08-30 06:17:45 +00:00
|
|
|
;;;###autoload
|
|
|
|
(defun gnus-html-prefetch-images (summary)
|
2010-09-20 00:36:54 +00:00
|
|
|
(when (buffer-live-p summary)
|
2010-11-19 04:55:16 +00:00
|
|
|
(let (inhibit-images blocked-images)
|
2010-11-19 05:11:59 +00:00
|
|
|
(with-current-buffer summary
|
2010-11-19 04:55:16 +00:00
|
|
|
(setq inhibit-images gnus-inhibit-images
|
|
|
|
blocked-images (gnus-blocked-images)))
|
2010-08-30 06:17:45 +00:00
|
|
|
(save-match-data
|
2010-10-21 03:48:01 +00:00
|
|
|
(while (re-search-forward "<img[^>]+src=[\"']\\(http[^\"']+\\)" nil t)
|
2010-10-24 09:55:56 +00:00
|
|
|
(let ((url (gnus-html-encode-url
|
|
|
|
(mm-url-decode-entities-string (match-string 1)))))
|
2010-11-19 04:55:16 +00:00
|
|
|
(unless (or inhibit-images
|
2010-11-18 02:00:00 +00:00
|
|
|
(gnus-html-image-url-blocked-p url blocked-images))
|
2010-09-21 11:48:40 +00:00
|
|
|
(when (gnus-html-cache-expired url gnus-html-image-cache-ttl)
|
|
|
|
(gnus-html-schedule-image-fetching nil
|
|
|
|
(list url))))))))))
|
2010-08-30 06:17:45 +00:00
|
|
|
|
|
|
|
(provide 'gnus-html)
|
2010-08-30 06:13:50 +00:00
|
|
|
|
|
|
|
;;; gnus-html.el ends here
|