* nnimap.el (nnimap-split-fancy): Ditto.
[gnus] / lisp / gnus-ems.el
index 91f4554..58e5cbb 100644 (file)
@@ -1,5 +1,5 @@
 ;;; gnus-ems.el --- functions for making Gnus work under different Emacsen
-;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
 ;;        Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
@@ -47,9 +47,7 @@
   (autoload 'gnus-xmas-redefine "gnus-xmas")
   (autoload 'appt-select-lowest-window "appt"))
 
-(if (featurep 'xemacs)
-    (autoload 'smiley-region "smiley")
-  (autoload 'smiley-region "smiley-ems")) ; override XEmacs version
+(autoload 'smiley-region "smiley")
 
 (defun gnus-kill-all-overlays ()
   "Delete all overlays in the current buffer."
     (defvar gnus-mouse-face-prop 'mouse-face
       "Property used for highlighting mouse regions.")))
 
-(eval-and-compile
-  (let ((case-fold-search t))
-    (cond
-     ((string-match "windows-nt\\|os/2\\|emx\\|cygwin32"
-                   (symbol-name system-type))
-      (setq nnheader-file-name-translation-alist
-           (append nnheader-file-name-translation-alist
-                   (mapcar (lambda (c) (cons c ?_))
-                           '(?: ?* ?\" ?< ?> ??))
-                   (if (string-match "windows-nt\\|cygwin32"
-                                     (symbol-name system-type))
-                       nil
-                     '((?+ . ?-)))))))))
-
 (defvar gnus-tmp-unread)
 (defvar gnus-tmp-replied)
 (defvar gnus-tmp-score-char)
     ;; original MULE, XEmacs/mule and Emacs 20+ including
     ;; MULE features.  Unfortunately these API are different.  In
     ;; particular, Emacs (including original MULE) and XEmacs are
-    ;; quite different.  Howvere, this version of Gnus doesn't support
+    ;; quite different.  However, this version of Gnus doesn't support
     ;; anything other than XEmacs 20+ and Emacs 20.3+.
 
     ;; Predicates to check are following:
        (boundp 'mark-active)
        mark-active))
 
+(defun gnus-mark-active-p ()
+  "Non-nil means the mark and region are currently active in this buffer."
+  mark-active) ; aliased to region-exists-p in XEmacs.
+
 (if (fboundp 'add-minor-mode)
     (defalias 'gnus-add-minor-mode 'add-minor-mode)
   (defun gnus-add-minor-mode (mode name map &rest rest)
        (when (and dir
                   (file-exists-p (setq file
                                        (expand-file-name "x-splash" dir))))
-         (with-temp-buffer
-           (insert-file-contents file)
-           (goto-char (point-min))
-           (ignore-errors
-             (setq pixmap (read (current-buffer))))))
+         (let ((coding-system-for-read 'raw-text)
+               default-enable-multibyte-characters)
+           (with-temp-buffer
+             (insert-file-contents file)
+             (goto-char (point-min))
+             (ignore-errors
+               (setq pixmap (read (current-buffer)))))))
        (when pixmap
          (make-face 'gnus-splash)
          (setq height (/ (car pixmap) (frame-char-height))
          (goto-char (point-min))
          (sit-for 0))))))
 
-(defvar gnus-article-xface-ring-internal nil
-  "Cache for face data.")
-
-;; Worth customizing?
-(defvar gnus-article-xface-ring-size 6
-  "Length of the ring used for `gnus-article-xface-ring-internal'.")
-
-(defun gnus-article-display-xface (data)
-  "Display the XFace header FACE in the current buffer.
-Requires support for images in your Emacs and the external programs
-`uncompface', and `icontopbm'.  On a GNU/Linux system these
-might be in packages with names like `compface' or `faces-xface' and
-`netpbm' or `libgr-progs', for instance.  See also
-`gnus-article-compface-xbm'.
-
-This function is for Emacs 21+.  See `gnus-xmas-article-display-xface'
-for XEmacs."
-  ;; It might be worth converting uncompface's output in Lisp.
-
-  (when (if (fboundp 'display-graphic-p)
-           (display-graphic-p))
-    (unless gnus-article-xface-ring-internal ; Only load ring when needed.
-      (setq gnus-article-xface-ring-internal
-           (make-ring gnus-article-xface-ring-size)))
-    (save-excursion
-      (let* ((cur (current-buffer))
-            (image (cdr-safe (assoc data (ring-elements
-                                          gnus-article-xface-ring-internal))))
-            default-enable-multibyte-characters
-            face)
-       (unless image
-         (when (setq face (uncompface data))
-           ;; Miles Bader says that faces don't look right as
-           ;; light on dark.
-           (if (eq 'dark (cdr-safe (assq 'background-mode
-                                         (frame-parameters))))
-               (setq image (create-image face 'pbm
-                                         t
-                                         :ascent 'center
-                                         :foreground "black"
-                                         :background "white"))
-             (setq image (create-image face 'pbm
-                                       t :ascent 'center))))
-         (ring-insert gnus-article-xface-ring-internal (cons data image)))
-       (when image
-         (goto-char (point-min))
-         (re-search-forward "^From:" nil 'move)
-         (gnus-add-wash-type 'xface)
-         (gnus-add-image 'xface image)
-         (insert-image image " ")
-         (put-text-property (1- (point)) (point) 
-                            'gnus-image-text-deletable t))))))
-
 ;;; Image functions.
 
 (defun gnus-image-type-available-p (type)
   (and (fboundp 'image-type-available-p)
        (image-type-available-p type)))
 
-(defun gnus-create-image (file &optional type data-p)
-  (create-image file type data-p))
+(defun gnus-create-image (file &optional type data-p &rest props)
+  (let ((face (plist-get props :face)))
+    (when face
+      (setq props (plist-put props :foreground (face-foreground face)))
+      (setq props (plist-put props :background (face-background face))))
+    (apply 'create-image file type data-p props)))
 
 (defun gnus-put-image (glyph &optional string)
-  (insert-image glyph string))
+  (insert-image glyph (or string " "))
+  (unless string
+    (put-text-property (1- (point)) (point)
+                      'gnus-image-text-deletable t))
+  glyph)
 
 (defun gnus-remove-image (image)
   (dolist (position (message-text-with-property 'display))
     (when (equal (get-text-property position 'display) image)
       (put-text-property position (1+ position) 'display nil)
-      (if (get-text-property position 'gnus-image-text-deletable)
-         (delete-region position (1+ position))))))
+      (when (get-text-property position 'gnus-image-text-deletable)
+       (delete-region position (1+ position))))))
 
 (provide 'gnus-ems)