Importing Oort Gnus v0.04.
[elisp/gnus.git-] / lisp / gnus-xmas.el
index 8b5f2d2..36b2b20 100644 (file)
@@ -50,47 +50,6 @@ automatically."
     (error "Can't find glyph directory. \
 Possibly the `etc' directory has not been installed.")))
 
-;;(format "%02x%02x%02x" 114 66 20) "724214"
-
-(defvar gnus-xmas-logo-color-alist
-  '((flame "#cc3300" "#ff2200")
-    (pine "#c0cc93" "#f8ffb8")
-    (moss "#a1cc93" "#d2ffb8")
-    (irish "#04cc90" "#05ff97")
-    (sky "#049acc" "#05deff")
-    (tin "#6886cc" "#82b6ff")
-    (velvet "#7c68cc" "#8c82ff")
-    (grape "#b264cc" "#cf7df")
-    (labia "#cc64c2" "#fd7dff")
-    (berry "#cc6485" "#ff7db5")
-    (dino "#724214" "#1e3f03")
-    (neutral "#b4b4b4" "#878787")
-    (september "#bf9900" "#ffcc00"))
-  "Color alist used for the Gnus logo.")
-
-(defcustom gnus-xmas-logo-color-style 'dino
-  "*Color styles used for the Gnus logo."
-  :type '(choice (const flame) (const pine) (const moss)
-                (const irish) (const sky) (const tin)
-                (const velvet) (const grape) (const labia)
-                (const berry) (const neutral) (const september)
-                (const dino))
-  :group 'gnus-xmas)
-
-(defvar gnus-xmas-logo-colors
-  (cdr (assq gnus-xmas-logo-color-style gnus-xmas-logo-color-alist))
-  "Colors used for the Gnus logo.")
-
-(defcustom gnus-article-x-face-command
-  (if (or (featurep 'xface)
-         (featurep 'xpm))
-      'gnus-xmas-article-display-xface
-    "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
-  "*String or function to be executed to display an X-Face header.
-If it is a string, the command will be executed in a sub-shell
-asynchronously.         The compressed face will be piped to this command."
-  :type '(choice string function))
-
 ;;; Internal variables.
 
 ;; Don't warn about these undefined variables.
@@ -142,12 +101,12 @@ It is provided only to ease porting of broken FSF Emacs programs."
   (if (stringp buffer)
       nil
     (map-extents (lambda (extent ignored)
-                   (remove-text-properties
-                    start end
-                    (list (extent-property extent 'text-prop) nil)
-                    buffer)
+                  (remove-text-properties
+                   start end
+                   (list (extent-property extent 'text-prop) nil)
+                   buffer)
                   nil)
-                 buffer start end nil nil 'text-prop)
+                buffer start end nil nil 'text-prop)
     (gnus-add-text-properties start end props buffer)))
 
 (defun gnus-xmas-highlight-selected-summary ()
@@ -292,19 +251,19 @@ call it with the value of the `gnus-data' text property."
 (defun gnus-xmas-appt-select-lowest-window ()
   (let* ((lowest-window (selected-window))
         (bottom-edge (car (cdr (cdr (cdr (window-pixel-edges))))))
-         (last-window (previous-window))
-         (window-search t))
+        (last-window (previous-window))
+        (window-search t))
     (while window-search
       (let* ((this-window (next-window))
-             (next-bottom-edge (car (cdr (cdr (cdr
-                                               (window-pixel-edges
+            (next-bottom-edge (car (cdr (cdr (cdr
+                                              (window-pixel-edges
                                                this-window)))))))
-        (when (< bottom-edge next-bottom-edge)
+       (when (< bottom-edge next-bottom-edge)
          (setq bottom-edge next-bottom-edge)
          (setq lowest-window this-window))
 
-        (select-window this-window)
-        (when (eq last-window this-window)
+       (select-window this-window)
+       (when (eq last-window this-window)
          (select-window lowest-window)
          (setq window-search nil))))))
 
@@ -429,7 +388,7 @@ call it with the value of the `gnus-data' text property."
   (defalias 'gnus-put-text-property 'gnus-xmas-put-text-property)
   (defalias 'gnus-deactivate-mark 'ignore)
   (defalias 'gnus-window-edges 'window-pixel-edges)
-
+  
   (if (and (<= emacs-major-version 19)
           (< emacs-minor-version 14))
       (defalias 'gnus-set-text-properties 'gnus-xmas-set-text-properties))
@@ -477,6 +436,10 @@ call it with the value of the `gnus-data' text property."
   (defalias 'gnus-region-active-p 'region-active-p)
   (defalias 'gnus-annotation-in-region-p 'gnus-xmas-annotation-in-region-p)
   (defalias 'gnus-mime-button-menu 'gnus-xmas-mime-button-menu)
+  (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
@@ -508,8 +471,8 @@ call it with the value of the `gnus-data' text property."
                          `[xpm
                            :file ,logo-xpm
                            :color-symbols
-                           (("thing" . ,(car gnus-xmas-logo-colors))
-                            ("shadow" . ,(cadr gnus-xmas-logo-colors))
+                           (("thing" . ,(car gnus-logo-colors))
+                            ("shadow" . ,(cadr gnus-logo-colors))
                             ("background" . ,(face-background 'default)))])
                         ((featurep 'xbm)
                          `[xbm :file ,logo-xbm])
@@ -671,7 +634,7 @@ If it is non-nil, it must be a toolbar.  The five valid values are
                        (cons (current-buffer) bar)))))
 
 (defun gnus-xmas-mail-strip-quoted-names (address)
-  "Protect mail-strip-quoted-names from NIL input.
+  "Protect mail-strip-quoted-names from nil input.
 XEmacs compatibility workaround."
   (if (null address)
       nil
@@ -686,23 +649,19 @@ XEmacs compatibility workaround."
   "Face to show X face"
   :group 'gnus-xmas)
 
-(defun gnus-xmas-article-display-xface (beg end &optional buffer)
-  "Display any XFace headers in BUFFER."
+(defun gnus-xmas-article-display-xface (data)
+  "Display the XFace in DATA."
   (save-excursion
     (let ((xface-glyph
           (cond
            ((featurep 'xface)
             (make-glyph (vector 'xface :data
-                                (concat "X-Face: "
-                                        (if buffer
-                                            (with-current-buffer buffer
-                                              (buffer-substring beg end))
-                                          (buffer-substring beg end))))))
+                                (concat "X-Face: " data))))
            ((featurep 'xpm)
-            (let ((cur (or buffer (current-buffer))))
+            (let ((cur (current-buffer)))
               (save-excursion
                 (gnus-set-work-buffer)
-                (insert-buffer-substring cur beg end)
+                (insert data)
                 (let ((coding-system-for-read 'binary)
                       (coding-system-for-write 'binary))
                   (gnus-xmas-call-region "uncompface")
@@ -713,15 +672,13 @@ XEmacs compatibility workaround."
                   (make-glyph
                    (vector 'xpm :data (buffer-string)))))))
            (t
-            (make-glyph [nothing]))))
-         (ext (make-extent (progn
-                             (goto-char (point-min))
-                             (re-search-forward "^From:" nil t)
-                             (point))
-                           (1+ (point)))))
-      (set-glyph-face xface-glyph 'gnus-x-face)
-      (set-extent-begin-glyph ext xface-glyph)
-      (set-extent-property ext 'duplicable t))))
+            (make-glyph [nothing])))))
+      ;;(set-glyph-face xface-glyph 'gnus-x-face)
+
+      (gnus-article-goto-header "from")
+      (gnus-put-image xface-glyph " ")
+      (gnus-add-wash-type 'xface)
+      (gnus-add-image 'xface xface-glyph))))
 
 (defvar gnus-xmas-modeline-left-extent
   (let ((ext (copy-extent modeline-buffer-id-left-extent)))
@@ -862,6 +819,31 @@ XEmacs compatibility workaround."
   (gnus-xmas-menu-add mailing-list
                      gnus-mailing-list-menu))
 
+(defun gnus-xmas-image-type-available-p (type)
+  (featurep type))
+
+(defun gnus-xmas-create-image (file)
+  (with-temp-buffer
+    (insert-file-contents file)
+    (mm-create-image-xemacs (car (last (split-string file "[.]"))))))
+
+(defun gnus-xmas-put-image (glyph &optional string)
+  (let ((begin (point))
+       extent)
+    (insert string)
+    (setq extent (make-extent begin (point)))
+    (set-extent-property extent 'gnus-image t)
+    (set-extent-property extent 'duplicable t)
+    (set-extent-property extent 'begin-glyph glyph)))
+
+(defun gnus-xmas-remove-image (image)
+  (map-extents
+   (lambda (ext unused)
+     (when (equal (extent-begin-glyph ext) image)
+       (set-extent-property ext 'begin-glyph nil))
+     nil)
+   nil nil nil nil nil 'gnus-image))
+
 (provide 'gnus-xmas)
 
 ;;; gnus-xmas.el ends here