From 84379e0c711ca6d817f1994ae39c93476c77dc65 Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Wed, 20 Oct 2010 18:39:37 +0200 Subject: [PATCH] Allow gnus-blocked-images to be a function. --- lisp/ChangeLog | 5 +++++ lisp/gnus-art.el | 19 +++++++++++++++++-- lisp/gnus-html.el | 6 +++--- texi/ChangeLog | 5 +++++ texi/gnus.texi | 13 +++++++++---- 5 files changed, 39 insertions(+), 9 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 22f989efd..33e55c63d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2010-10-20 Lars Magne Ingebrigtsen + + * gnus-art.el (gnus-blocked-images): New function. Allow the + `gnus-blocked-images' to be a function. + 2010-10-20 Julien Danjou * spam.el (spam-list-of-processors): Mark as obsolete. diff --git a/lisp/gnus-art.el b/lisp/gnus-art.el index 537ae4da8..f42838d08 100644 --- a/lisp/gnus-art.el +++ b/lisp/gnus-art.el @@ -1639,8 +1639,11 @@ This requires GNU Libidn, and by default only enabled if it is found." :group 'gnus-article :type 'boolean) -(defcustom gnus-blocked-images "." - "Images that have URLs matching this regexp will be blocked." +(defcustom gnus-blocked-images 'gnus-block-private-groups + "Images that have URLs matching this regexp will be blocked. +This can also be a function to be evaluated. If so, it will be +called with the group name as the parameter, and should return a +regexp." :version "24.1" :group 'gnus-art :type 'regexp) @@ -6896,6 +6899,18 @@ If given a prefix, show the hidden text instead." (point)) (set-buffer buf)))))) +(defun gnus-block-private-groups (group) + (if (gnus-news-group-p group) + ;; Block nothing in news groups. + nil + ;; Block everything anywhere else. + ".")) + +(defun gnus-blocked-images () + (if (functionp gnus-blocked-images) + (funcall gnus-blocked-images gnus-newsgroup-name) + gnus-blocked-images)) + ;;; ;;; Article editing ;;; diff --git a/lisp/gnus-html.el b/lisp/gnus-html.el index c1472118c..861ad73d0 100644 --- a/lisp/gnus-html.el +++ b/lisp/gnus-html.el @@ -205,8 +205,8 @@ CHARS is a regexp-like character alternative (e.g., \"[)$]\")." url (if (buffer-live-p gnus-summary-buffer) (with-current-buffer gnus-summary-buffer - gnus-blocked-images) - gnus-blocked-images)) + (gnus-blocked-images)) + (gnus-blocked-images))) (progn (widget-convert-button 'link start end @@ -491,7 +491,7 @@ This only works if the article in question is HTML." (defun gnus-html-prefetch-images (summary) (when (buffer-live-p summary) (let ((blocked-images (with-current-buffer summary - gnus-blocked-images))) + (gnus-blocked-images)))) (save-match-data (while (re-search-forward "]+src=[\"']\\([^\"']+\\)" nil t) (let ((url (gnus-html-encode-url (match-string 1)))) diff --git a/texi/ChangeLog b/texi/ChangeLog index f61eeccdd..4641b4819 100644 --- a/texi/ChangeLog +++ b/texi/ChangeLog @@ -1,3 +1,8 @@ +2010-10-20 Lars Magne Ingebrigtsen + + * gnus.texi (HTML): Document the function value of + gnus-blocked-images. + 2010-10-20 Julien Danjou * emacs-mime.texi (Flowed text): Add a note about mml-enable-flowed diff --git a/texi/gnus.texi b/texi/gnus.texi index acfe0aa67..337e85cf1 100644 --- a/texi/gnus.texi +++ b/texi/gnus.texi @@ -12462,15 +12462,20 @@ that's based on @code{w3m}. @item gnus-blocked-images @vindex gnus-blocked-images -Images that have @acronym{URL}s that match this regexp won't be -fetched and displayed. For instance, do block all @acronym{URL}s that -have the string ``ads'' in them, do the following: +External images that have @acronym{URL}s that match this regexp won't +be fetched and displayed. For instance, do block all @acronym{URL}s +that have the string ``ads'' in them, do the following: @lisp (setq gnus-blocked-images "ads") @end lisp -The default is to block all external images. +This can also be a function to be evaluated. If so, it will be +called with the group name as the parameter. The default value is +@code{gnus-block-private-groups}, which will return @samp{"."} for +anything that isn't a newsgroup. This means that no external images +will be fetched as a result of reading mail, so that nobody can use +web bugs (and the like) to track whether you've read email. @item gnus-html-cache-directory @vindex gnus-html-cache-directory -- 2.25.1