* smiley-ems.el (smiley-region): Return images.
authorLars Magne Ingebrigtsen <larsi@gnus.org>
Mon, 31 Dec 2001 06:21:01 +0000 (06:21 +0000)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Mon, 31 Dec 2001 06:21:01 +0000 (06:21 +0000)
(gnus-smiley-display): Allow toggling.
(smiley-region): Use text properties, not overlays.

* gnus-xmas.el (gnus-xmas-remove-image): New function, not
implemented yet.

lisp/ChangeLog
lisp/gnus-picon.el
lisp/gnus-xmas.el
lisp/smiley-ems.el

index 98728ef..44a2b0c 100644 (file)
@@ -1,5 +1,12 @@
 2001-12-31  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
+       * smiley-ems.el (smiley-region): Return images.
+       (gnus-smiley-display): Allow toggling.
+       (smiley-region): Use text properties, not overlays.
+
+       * gnus-xmas.el (gnus-xmas-remove-image): New function, not
+       implemented yet.
+
        * smiley-ems.el (smiley-update-cache): Check for valid types.
 
        * gnus-art.el (gnus-with-article-buffer): New macro.
index 7f73ea7..5cb616d 100644 (file)
@@ -253,7 +253,7 @@ If picons are already displayed, remove them."
   (interactive)
   (gnus-with-article-buffer
     (if (memq 'newsgroups-picon gnus-article-wash-types)
-       (gnus-delete-images  'newsgroups-picon)
+       (gnus-delete-images 'newsgroups-picon)
       (gnus-picon-transform-newsgroups "newsgroups")
       (gnus-picon-transform-newsgroups "followup-to"))))
 
index d16841e..06cfebe 100644 (file)
@@ -439,6 +439,7 @@ call it with the value of the `gnus-data' text property."
   (defalias 'gnus-image-type-available-p 'gnus-xmas-image-type-available-p)
   (defalias 'gnus-put-image 'gnus-xmas-put-image)
   (defalias 'gnus-create-image 'gnus-xmas-create-image)
+  (defalias 'gnus-remove-image 'gnus-xmas-remove-image)
 
   ;; These ones are not defcutom'ed, sometimes not even defvar'ed. They
   ;; probably should. If that is done, the code below should then be moved
@@ -833,6 +834,9 @@ XEmacs compatibility workaround."
     (set-extent-property annot 'mm t)
     (set-extent-property annot 'duplicable t)))
 
+(defun gnus-xmas-remove-image (image)
+  )
+
 (provide 'gnus-xmas)
 
 ;;; gnus-xmas.el ends here
index f86d4d6..f8a91d9 100644 (file)
@@ -115,7 +115,8 @@ regexp to replace with IMAGE.  IMAGE is the name of a PBM file in
 
 ;;;###autoload
 (defun smiley-region (start end)
-  "Replace in the region `smiley-regexp-alist' matches with corresponding images."
+  "Replace in the region `smiley-regexp-alist' matches with corresponding images.
+A list of images is returned."
   (interactive "r")
   (when (and (fboundp 'display-graphic-p)
             (display-graphic-p))
@@ -125,25 +126,25 @@ regexp to replace with IMAGE.  IMAGE is the name of a PBM file in
            (overlays-in start end))
     (unless smiley-cached-regexp-alist
       (smiley-update-cache))
+    (setq smiley-active t)
     (save-excursion
       (let ((beg (or start (point-min)))
-           group overlay image)
+           group overlay image images)
        (dolist (entry smiley-cached-regexp-alist)
          (setq group (nth 1 entry)
                image (nth 2 entry))
          (goto-char beg)
          (while (re-search-forward (car entry) end t)
            (when image
-             (setq overlay (make-overlay (match-beginning group)
-                                         (match-end group)))
-             (overlay-put overlay
-                          'display `(when smiley-active ,@image))
-             (overlay-put overlay 'mouse-face 'highlight)
-             (overlay-put overlay 'smiley t)
-             (overlay-put overlay
-                          'help-echo "mouse-2: toggle smilies in buffer")
-             (overlay-put overlay 'keymap smiley-mouse-map))))))
-    (setq smiley-active t)))
+             (push image images)
+             (add-text-properties
+              (match-beginning group) (match-end group)
+              `(display ,image
+                        mouse-face highlight
+                        smiley t
+                        help-echo "mouse-2: toggle smilies in buffer"
+                        keymap smiley-mouse-map)))))
+       images))))
 
 (defun smiley-toggle-buffer (&optional arg)
   "Toggle displaying smiley faces.
@@ -168,11 +169,18 @@ With arg, turn displaying on if and only if arg is positive."
   "Display textual emoticaons (\"smilies\") as small graphical icons.
 With arg, turn displaying on if and only if arg is positive."
   (interactive "P")
-  (save-excursion
-    (article-goto-body)
-    (smiley-region (point) (point-max))
-    (if (and (numberp arg) (<= arg 0))
-       (smiley-toggle-buffer arg))))
+  (gnus-with-article-buffer
+    (if (memq 'smiley gnus-article-wash-types)
+       (gnus-delete-images 'smiley)
+      (article-goto-body)
+      (let ((images (smiley-region (point) (point-max))))
+       (when images
+         (gnus-add-wash-type 'smiley)
+         (dolist (image images)
+           (gnus-add-image 'smiley image))))
+      (when (and (numberp arg)
+                (<= arg 0))
+       (smiley-toggle-buffer arg)))))
 
 (provide 'smiley)