Synch to No Gnus 200601190601.
[elisp/gnus.git-] / lisp / gnus-ems.el
index 5ea1f4f..1ab143f 100644 (file)
@@ -1,6 +1,7 @@
 ;;; gnus-ems.el --- functions for making Semi-gnus work under different Emacsen
-;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
-;;        Free Software Foundation, Inc.
+
+;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
+;;   2004, 2005 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;;         Tatsuya Ichikawa <t-ichi@niagara.shiojiri.ne.jp>
@@ -20,8 +21,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -49,8 +50,6 @@
   (autoload 'nnheader-find-etc-directory "nnheader"))
 
 (autoload 'smiley-region "smiley")
-;; Fixme: shouldn't require message
-(autoload 'message-text-with-property "message")
 
 (defun gnus-kill-all-overlays ()
   "Delete all overlays in the current buffer."
     glyph))
 
 (defun gnus-remove-image (image &optional category)
-  (let ((regions (message-text-with-property 'display))
-       start end)
-    (while regions
-      (setq start (caar regions)
-           end (cdar regions)
-           regions (cdr regions))
-      (when (and (equal (get-text-property start 'display) image)
-                (equal (get-text-property start 'gnus-image-category)
-                       category))
-       (put-text-property start end 'display nil)
-       (when (get-text-property start 'gnus-image-text-deletable)
-         (delete-region start end))))))
+  "Remove the image matching IMAGE and CATEGORY found first."
+  (let ((start (point-min))
+       val end)
+    (while (and (not end)
+               (or (setq val (get-text-property start 'display))
+                   (and (setq start
+                              (next-single-property-change start 'display))
+                        (setq val (get-text-property start 'display)))))
+      (setq end (or (next-single-property-change start 'display)
+                   (point-max)))
+      (if (and (equal val image)
+              (equal (get-text-property start 'gnus-image-category)
+                     category))
+         (progn
+           (put-text-property start end 'display nil)
+           (when (get-text-property start 'gnus-image-text-deletable)
+             (delete-region start end)))
+       (unless (= end (point-max))
+         (setq start end
+               end nil))))))
 
 (defun-maybe assoc-ignore-case (key alist)
   "Like `assoc', but assumes KEY is a string and ignores case when comparing."