diff options
| author | Stefan Monnier | 2021-01-30 16:45:25 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2021-01-30 17:30:08 -0500 |
| commit | 9be4f41b4254c029fc328b10ecef4e71cd2ca024 (patch) | |
| tree | fe7acbcc2bd8041d559775b9c02d15fa72cae7a3 /lisp/gnus/gnus-html.el | |
| parent | acf4ec23d966b6bc92c61b557148afc88f20f99e (diff) | |
| download | emacs-9be4f41b4254c029fc328b10ecef4e71cd2ca024.tar.gz emacs-9be4f41b4254c029fc328b10ecef4e71cd2ca024.zip | |
* lisp/gnus: Misc simplifications found during conversion to lexical
* lisp/gnus/nnoo.el (noo-import-1, nnoo-define-skeleton-1): Use `dolist`.
(noo-map-functions, nnoo-define-basics): Directly emit the code rather than
going through an intermediate function; this also avoids the use of `eval`.
(noo-map-functions-1, nnoo-define-basics-1): Delete functions,
folded into their corresponding macro.
* lisp/gnus/gmm-utils.el (gmm-tool-bar-from-list): Demote `eval` to
`symbol-value`.
* lisp/gnus/gnus-art.el (gnus-button-handle-describe-key): Avoid `eval`
since `kbd` is a function nowadays.
(gnus-treat-part-number): Rename from `part-number`.
(gnus-treat-total-parts): Rename from `total-parts`.
(gnus-treat-article, gnus-treat-predicate): Adjust accordingly.
* lisp/gnus/gnus-cache.el (gnus-agent-load-alist): Use `declare-function`.
* lisp/gnus/gnus-group.el (gnus-cache-active-hashtb): Use `defvar`.
(gnus-group-iterate): Make it a normal function since lexical scoping
avoids the risk of name capture anyway.
(gnus-group-delete-articles): Actually use the `oldp` arg.
* lisp/gnus/gnus-html.el (gnus-html-wash-images): Fix debug message so
it's emitted after the `url` var it prints is actually initialized.
And avoid `setq` while we're at it.
* lisp/gnus/gnus-msg.el (gnus-group-mail, gnus-group-news)
(gnus-summary-mail-other-window, gnus-summary-news-other-window):
Merge `let`s using `let*`.
* lisp/gnus/gnus-spec.el (gnus-update-format-specifications):
Tighten the scope of `buffer`, and tighten a regexp.
(gnus-parse-simple-format): Reduce code duplication.
* lisp/gnus/gnus-start.el (gnus-child-mode): Don't `defvar` it since we
never use that variable and accordingly don't define it as a minor mode.
* lisp/gnus/gnus-util.el (gnus-byte-compile): Simplify so it obeys
`gnus-use-byte-compile` not just on the first call.
(iswitchb-minibuffer-setup): Declare.
* lisp/gnus/mail-source.el (mail-source-bind-1)
(mail-source-bind-common-1): Use `mapcar`.
(mail-source-set-common-1): Use `dolist`.
(display-time-event-handler): Declare.
* lisp/gnus/mml-smime.el (mml-smime-epg-verify): Reduce code duplication.
* lisp/gnus/mml.el (mml-parse-1): Reduce code duplication.
* lisp/gnus/mml2015.el (mml2015-epg-verify): Reduce code duplication.
* lisp/gnus/nnmail.el (nnmail-get-split-group): Tighten regexp.
(nnmail-split-it): Reduce code duplication.
* lisp/gnus/nnweb.el (nnweb-request-article): Avoid `setq`.
* lisp/gnus/spam.el (BBDB): Use the `noerror` arg of `require`, and
define all the functions for BBDB regardless if the require succeeded.
(spam-exists-in-BBDB-p): Don't inline, not worth it.
Diffstat (limited to 'lisp/gnus/gnus-html.el')
| -rw-r--r-- | lisp/gnus/gnus-html.el | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/lisp/gnus/gnus-html.el b/lisp/gnus/gnus-html.el index 855d085c3a9..6a0cc0b47dc 100644 --- a/lisp/gnus/gnus-html.el +++ b/lisp/gnus/gnus-html.el | |||
| @@ -151,7 +151,7 @@ fit these criteria." | |||
| 151 | 151 | ||
| 152 | (defun gnus-html-wash-images () | 152 | (defun gnus-html-wash-images () |
| 153 | "Run through current buffer and replace img tags by images." | 153 | "Run through current buffer and replace img tags by images." |
| 154 | (let (tag parameters string start end images url alt-text | 154 | (let (tag parameters string start end images |
| 155 | inhibit-images blocked-images) | 155 | inhibit-images blocked-images) |
| 156 | (if (buffer-live-p gnus-summary-buffer) | 156 | (if (buffer-live-p gnus-summary-buffer) |
| 157 | (with-current-buffer gnus-summary-buffer | 157 | (with-current-buffer gnus-summary-buffer |
| @@ -169,65 +169,65 @@ fit these criteria." | |||
| 169 | (delete-region (match-beginning 0) (match-end 0))) | 169 | (delete-region (match-beginning 0) (match-end 0))) |
| 170 | (setq end (point)) | 170 | (setq end (point)) |
| 171 | (when (string-match "src=\"\\([^\"]+\\)" parameters) | 171 | (when (string-match "src=\"\\([^\"]+\\)" parameters) |
| 172 | (gnus-message 8 "gnus-html-wash-tags: fetching image URL %s" url) | 172 | (let ((url (gnus-html-encode-url (match-string 1 parameters))) |
| 173 | (setq url (gnus-html-encode-url (match-string 1 parameters)) | 173 | (alt-text (when (string-match "\\(alt\\|title\\)=\"\\([^\"]+\\)" |
| 174 | alt-text (when (string-match "\\(alt\\|title\\)=\"\\([^\"]+\\)" | 174 | parameters) |
| 175 | parameters) | 175 | (xml-substitute-special (match-string 2 parameters))))) |
| 176 | (xml-substitute-special (match-string 2 parameters)))) | 176 | (gnus-message 8 "gnus-html-wash-tags: fetching image URL %s" url) |
| 177 | (add-text-properties | 177 | (add-text-properties |
| 178 | start end | 178 | start end |
| 179 | (list 'image-url url | 179 | (list 'image-url url |
| 180 | 'image-displayer `(lambda (url start end) | 180 | 'image-displayer `(lambda (url start end) |
| 181 | (gnus-html-display-image url start end | 181 | (gnus-html-display-image url start end |
| 182 | ,alt-text)) | 182 | ,alt-text)) |
| 183 | 'help-echo alt-text | 183 | 'help-echo alt-text |
| 184 | 'button t | 184 | 'button t |
| 185 | 'keymap gnus-html-image-map | 185 | 'keymap gnus-html-image-map |
| 186 | 'gnus-image (list url start end alt-text))) | 186 | 'gnus-image (list url start end alt-text))) |
| 187 | (if (string-match "\\`cid:" url) | 187 | (if (string-match "\\`cid:" url) |
| 188 | ;; URLs with cid: have their content stashed in other | 188 | ;; URLs with cid: have their content stashed in other |
| 189 | ;; parts of the MIME structure, so just insert them | 189 | ;; parts of the MIME structure, so just insert them |
| 190 | ;; immediately. | 190 | ;; immediately. |
| 191 | (let* ((handle (mm-get-content-id (substring url (match-end 0)))) | 191 | (let* ((handle (mm-get-content-id (substring url (match-end 0)))) |
| 192 | (image (when (and handle | 192 | (image (when (and handle |
| 193 | (not inhibit-images)) | 193 | (not inhibit-images)) |
| 194 | (gnus-create-image | 194 | (gnus-create-image |
| 195 | (mm-with-part handle (buffer-string)) | 195 | (mm-with-part handle (buffer-string)) |
| 196 | nil t)))) | 196 | nil t)))) |
| 197 | (if image | 197 | (if image |
| 198 | (gnus-add-image | 198 | (gnus-add-image |
| 199 | 'cid | 199 | 'cid |
| 200 | (gnus-put-image | 200 | (gnus-put-image |
| 201 | (gnus-rescale-image | 201 | (gnus-rescale-image |
| 202 | image (gnus-html-maximum-image-size)) | 202 | image (gnus-html-maximum-image-size)) |
| 203 | (gnus-string-or (prog1 | 203 | (gnus-string-or (prog1 |
| 204 | (buffer-substring start end) | 204 | (buffer-substring start end) |
| 205 | (delete-region start end)) | 205 | (delete-region start end)) |
| 206 | "*") | 206 | "*") |
| 207 | 'cid)) | 207 | 'cid)) |
| 208 | (make-text-button start end | ||
| 209 | 'help-echo url | ||
| 210 | 'keymap gnus-html-image-map))) | ||
| 211 | ;; Normal, external URL. | ||
| 212 | (if (or inhibit-images | ||
| 213 | (gnus-html-image-url-blocked-p url blocked-images)) | ||
| 208 | (make-text-button start end | 214 | (make-text-button start end |
| 209 | 'help-echo url | 215 | 'help-echo url |
| 210 | 'keymap gnus-html-image-map))) | 216 | 'keymap gnus-html-image-map) |
| 211 | ;; Normal, external URL. | 217 | ;; Non-blocked url |
| 212 | (if (or inhibit-images | 218 | (let ((width |
| 213 | (gnus-html-image-url-blocked-p url blocked-images)) | 219 | (when (string-match "width=\"?\\([0-9]+\\)" parameters) |
| 214 | (make-text-button start end | 220 | (string-to-number (match-string 1 parameters)))) |
| 215 | 'help-echo url | 221 | (height |
| 216 | 'keymap gnus-html-image-map) | 222 | (when (string-match "height=\"?\\([0-9]+\\)" parameters) |
| 217 | ;; Non-blocked url | 223 | (string-to-number (match-string 1 parameters))))) |
| 218 | (let ((width | 224 | ;; Don't fetch images that are really small. They're |
| 219 | (when (string-match "width=\"?\\([0-9]+\\)" parameters) | 225 | ;; probably tracking pictures. |
| 220 | (string-to-number (match-string 1 parameters)))) | 226 | (when (and (or (null height) |
| 221 | (height | 227 | (> height 4)) |
| 222 | (when (string-match "height=\"?\\([0-9]+\\)" parameters) | 228 | (or (null width) |
| 223 | (string-to-number (match-string 1 parameters))))) | 229 | (> width 4))) |
| 224 | ;; Don't fetch images that are really small. They're | 230 | (gnus-html-display-image url start end alt-text)))))))))) |
| 225 | ;; probably tracking pictures. | ||
| 226 | (when (and (or (null height) | ||
| 227 | (> height 4)) | ||
| 228 | (or (null width) | ||
| 229 | (> width 4))) | ||
| 230 | (gnus-html-display-image url start end alt-text))))))))) | ||
| 231 | 231 | ||
| 232 | (defun gnus-html-display-image (url start end &optional alt-text) | 232 | (defun gnus-html-display-image (url start end &optional alt-text) |
| 233 | "Display image at URL on text from START to END. | 233 | "Display image at URL on text from START to END. |