Allow gnus-blocked-images to be a function.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Wed, 20 Oct 2010 16:39:37 +0000 (18:39 +0200)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Wed, 20 Oct 2010 16:39:37 +0000 (18:39 +0200)
lisp/ChangeLog
lisp/gnus-art.el
lisp/gnus-html.el
texi/ChangeLog
texi/gnus.texi

index 22f989e..33e55c6 100644 (file)
@@ -1,3 +1,8 @@
+2010-10-20  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+       * gnus-art.el (gnus-blocked-images): New function.  Allow the
+       `gnus-blocked-images' to be a function.
+
 2010-10-20  Julien Danjou  <julien@danjou.info>
 
        * spam.el (spam-list-of-processors): Mark as obsolete.
index 537ae4d..f42838d 100644 (file)
@@ -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
 ;;;
index c147211..861ad73 100644 (file)
@@ -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 "<img[^>]+src=[\"']\\([^\"']+\\)" nil t)
          (let ((url (gnus-html-encode-url (match-string 1))))
index f61eecc..4641b48 100644 (file)
@@ -1,3 +1,8 @@
+2010-10-20  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+       * gnus.texi (HTML): Document the function value of
+       gnus-blocked-images.
+
 2010-10-20  Julien Danjou  <julien@danjou.info>
 
        * emacs-mime.texi (Flowed text): Add a note about mml-enable-flowed
index acfe0aa..337e85c 100644 (file)
@@ -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