Make html image insertion probably work for XEmacs, too.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Mon, 30 Aug 2010 16:51:04 +0000 (18:51 +0200)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Mon, 30 Aug 2010 16:51:04 +0000 (18:51 +0200)
* gnus-xmas.el (gnus-xmas-put-image): Ditto.

* gnus-ems.el (gnus-put-image): Have gnus-put-image take an optional
point parameter.

* gnus-html.el (gnus-html-put-image): Use gnus-put-image.

lisp/ChangeLog
lisp/gnus-ems.el
lisp/gnus-html.el
lisp/gnus-xmas.el

index 783c283..65e1b9f 100644 (file)
@@ -1,5 +1,12 @@
 2010-08-30  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
+       * gnus-html.el (gnus-html-put-image): Use gnus-put-image.
+
+       * gnus-ems.el (gnus-put-image): Have gnus-put-image take an optional
+       point parameter.
+
+       * gnus-xmas.el (gnus-xmas-put-image): Ditto.
+
        * gnus-group.el (gnus-group-completing-read): Add 'substring to
        completion-styles for group selection.
 
index efa7414..b7dc487 100644 (file)
       (setq props (plist-put props :background (face-background face))))
     (apply 'create-image file type data-p props)))
 
-(defun gnus-put-image (glyph &optional string category)
-  (let ((point (point)))
-    (insert-image glyph (or string " "))
-    (put-text-property point (point) 'gnus-image-category category)
-    (unless string
-      (put-text-property (1- (point)) (point)
-                        'gnus-image-text-deletable t))
+(defun gnus-put-image (glyph &optional string category point)
+  (let ((point (or point (point))))
+    (save-excursion
+      (goto-char point)
+      (put-image glyph point)
+      (put-text-property point (point) 'gnus-image-category category)
+      (unless string
+       (put-text-property (1- (point)) (point)
+                          'gnus-image-text-deletable t)))
     glyph))
 
 (defun gnus-remove-image (image &optional category)
index eb35aca..9c9908e 100644 (file)
                       (= (car (image-size image t)) 30)
                       (= (cdr (image-size image t)) 30))))
        (progn
-         (put-image image point)
+         (gnus-put-image image nil nil point)
          t)
       (when (fboundp 'find-image)
-       (put-image (find-image '((:type xpm :file "lock-broken.xpm")))
-                  point))
+       (gnus-put-image (find-image '((:type xpm :file "lock-broken.xpm")))
+                       nil nil point))
       nil)))
 
 (defun gnus-html-prune-cache ()
index b533818..7fe972c 100644 (file)
@@ -964,22 +964,24 @@ XEmacs compatibility workaround."
       (set-glyph-face glyph face))
     glyph))
 
-(defun gnus-xmas-put-image (glyph &optional string category)
+(defun gnus-xmas-put-image (glyph &optional string category point)
   "Insert STRING, but display GLYPH.
 Warning: Don't insert text immediately after the image."
-  (let ((begin (point))
+  (let ((begin (or point (point)))
        extent)
-    (if (and (bobp) (not string))
-       (setq string " "))
-    (if string
-       (insert string)
-      (setq begin (1- begin)))
-    (setq extent (make-extent begin (point)))
-    (set-extent-property extent 'gnus-image category)
-    (set-extent-property extent 'duplicable t)
-    (if string
-       (set-extent-property extent 'invisible t))
-    (set-extent-property extent 'end-glyph glyph))
+    (save-excursion
+      (goto-char begin)
+      (if (and (bobp) (not string))
+         (setq string " "))
+      (if string
+         (insert string)
+       (setq begin (1- begin)))
+      (setq extent (make-extent begin (point)))
+      (set-extent-property extent 'gnus-image category)
+      (set-extent-property extent 'duplicable t)
+      (if string
+         (set-extent-property extent 'invisible t))
+      (set-extent-property extent 'end-glyph glyph)))
   glyph)
 
 (defun gnus-xmas-remove-image (image &optional category)