* gnus-art.el (gnus-use-idna)
[gnus] / lisp / gnus-xmas.el
index cc1034e..05da0e4 100644 (file)
@@ -1,7 +1,7 @@
 ;;; gnus-xmas.el --- Gnus functions for XEmacs
 
-;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000
-;;      Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
+;;   2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; Keywords: news
@@ -10,7 +10,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 
 ;; 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:
 
 ;;; Code:
 
+(eval-when-compile
+  (autoload 'gnus-active "gnus" nil nil 'macro)
+  (autoload 'gnus-group-entry "gnus" nil nil 'macro)
+  (autoload 'gnus-info-level "gnus" nil nil 'macro)
+  (autoload 'gnus-info-marks "gnus" nil nil 'macro)
+  (autoload 'gnus-info-method "gnus" nil nil 'macro)
+  (autoload 'gnus-info-score "gnus" nil nil 'macro))
+
 (require 'text-props)
 (defvar menu-bar-mode (featurep 'menubar))
 (require 'messagexmas)
@@ -45,59 +53,15 @@ automatically."
   :group 'gnus-xmas)
 
 (unless gnus-xmas-glyph-directory
-  (unless (setq gnus-xmas-glyph-directory 
+  (unless (setq gnus-xmas-glyph-directory
                (message-xmas-find-glyph-directory "gnus"))
-    (gnus-error 1 "Can't find glyph directory. Possibly the `etc' directory is not 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))
+    (error "Can't find glyph directory. \
+Possibly the `etc' directory has not been installed.")))
 
 ;;; Internal variables.
 
 ;; Don't warn about these undefined variables.
 
-(defvar gnus-group-mode-hook)
-(defvar gnus-summary-mode-hook)
-(defvar gnus-article-mode-hook)
-
 ;;defined in gnus.el
 (defvar gnus-active-hashtb)
 (defvar gnus-article-buffer)
@@ -139,27 +103,13 @@ asynchronously.    The compressed face will be piped to this command."
 (defvar standard-display-table)
 (defvar gnus-tree-minimize-window)
 
-(defun gnus-xmas-set-text-properties (start end props &optional buffer)
-  "You should NEVER use this function.  It is ideologically blasphemous.
-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)
-                  nil)
-                 buffer start end nil nil 'text-prop)
-    (gnus-add-text-properties start end props buffer)))
-
 (defun gnus-xmas-highlight-selected-summary ()
   ;; Highlight selected article in summary buffer
   (when gnus-summary-selected-face
     (when gnus-newsgroup-selected-overlay
       (delete-extent gnus-newsgroup-selected-overlay))
     (setq gnus-newsgroup-selected-overlay
-         (make-extent (gnus-point-at-bol) (gnus-point-at-eol)))
+         (make-extent (point-at-bol) (point-at-eol)))
     (set-extent-face gnus-newsgroup-selected-overlay
                     gnus-summary-selected-face)))
 
@@ -202,7 +152,7 @@ displayed, no centering will be performed."
        ;; whichever is the least.
        ;; NOFORCE parameter suggested by Daniel Pittman <daniel@danann.net>.
        (set-window-start
-        window (min bottom (save-excursion (forward-line (- top)) (point))) 
+        window (min bottom (save-excursion (forward-line (- top)) (point)))
         t))
       ;; Do horizontal recentering while we're at it.
       (when (and (get-buffer-window (current-buffer) t)
@@ -292,22 +242,22 @@ call it with the value of the `gnus-data' text property."
          (select-window selected))))))
 
 ;; Select the lowest window on the frame.
-(defun gnus-xmas-appt-select-lowest-window ()
+(defun gnus-xmas-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))))))
 
@@ -333,7 +283,8 @@ call it with the value of the `gnus-data' text property."
 
 (defun gnus-xmas-article-menu-add ()
   (gnus-xmas-menu-add article
-    gnus-article-article-menu gnus-article-treatment-menu))
+    gnus-article-article-menu gnus-article-treatment-menu
+    gnus-article-post-menu gnus-article-commands-menu))
 
 (defun gnus-xmas-score-menu-add ()
   (gnus-xmas-menu-add score
@@ -379,12 +330,10 @@ call it with the value of the `gnus-data' text property."
   (gnus-xmas-menu-add browse
     gnus-browse-menu))
 
-(defun gnus-xmas-grouplens-menu-add ()
-  (gnus-xmas-menu-add grouplens
-    gnus-grouplens-menu))
-
-(defun gnus-xmas-read-event-char ()
+(defun gnus-xmas-read-event-char (&optional prompt)
   "Get the next event."
+  (when prompt
+    (message "%s" prompt))
   (let ((event (next-command-event)))
     (sit-for 0)
     ;; We junk all non-key events.  Is this naughty?
@@ -418,7 +367,12 @@ call it with the value of the `gnus-data' text property."
    (t
     (defalias 'gnus-characterp 'characterp)))
 
-  (defalias 'gnus-make-overlay 'make-extent)
+  (defalias 'gnus-make-overlay
+    (lambda (beg end &optional buffer front-advance rear-advance)
+      "Create a new overlay with range BEG to END in BUFFER.
+FRONT-ADVANCE and REAR-ADVANCE are ignored."
+      (make-extent beg end buffer)))
+
   (defalias 'gnus-delete-overlay 'delete-extent)
   (defalias 'gnus-overlay-put 'set-extent-property)
   (defalias 'gnus-move-overlay 'gnus-xmas-move-overlay)
@@ -431,13 +385,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))
-
-  (when (fboundp 'turn-off-scroll-in-place)
-    (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
+  (defalias 'gnus-assq-delete-all 'gnus-xmas-assq-delete-all)
 
   (unless (boundp 'standard-display-table)
     (setq standard-display-table nil))
@@ -459,7 +407,10 @@ call it with the value of the `gnus-data' text property."
            'x-color-values
          (lambda (color)
            (color-instance-rgb-components
-            (make-color-instance color))))))
+            (make-color-instance color)))))
+
+  (unless (fboundp 'char-width)
+    (defalias 'char-width (lambda (ch) 1))))
 
 (defun gnus-xmas-redefine ()
   "Redefine lots of Gnus functions for XEmacs."
@@ -472,41 +423,34 @@ call it with the value of the `gnus-data' text property."
   (defalias 'gnus-read-event-char 'gnus-xmas-read-event-char)
   (defalias 'gnus-group-startup-message 'gnus-xmas-group-startup-message)
   (defalias 'gnus-tree-minimize 'gnus-xmas-tree-minimize)
-  (defalias 'gnus-appt-select-lowest-window
-       'gnus-xmas-appt-select-lowest-window)
+  (defalias 'gnus-select-lowest-window
+    'gnus-xmas-select-lowest-window)
   (defalias 'gnus-mail-strip-quoted-names 'gnus-xmas-mail-strip-quoted-names)
   (defalias 'gnus-character-to-event 'character-to-event)
   (defalias 'gnus-mode-line-buffer-identification
-       'gnus-xmas-mode-line-buffer-identification)
+    'gnus-xmas-mode-line-buffer-identification)
   (defalias 'gnus-key-press-event-p 'key-press-event-p)
   (defalias 'gnus-region-active-p 'region-active-p)
+  (defalias 'gnus-mark-active-p 'region-exists-p)
   (defalias 'gnus-annotation-in-region-p 'gnus-xmas-annotation-in-region-p)
   (defalias 'gnus-mime-button-menu 'gnus-xmas-mime-button-menu)
-
-  (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
-  (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
-  (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add)
+  (defalias 'gnus-mime-security-button-menu
+    'gnus-xmas-mime-security-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
+  ;; where each variable is defined, in order not to mess with user settings.
+  ;; -- didier
   (add-hook 'gnus-score-mode-hook 'gnus-xmas-score-menu-add)
-
-  (add-hook 'gnus-pick-mode-hook 'gnus-xmas-pick-menu-add)
-  (add-hook 'gnus-topic-mode-hook 'gnus-xmas-topic-menu-add)
-  (add-hook 'gnus-tree-mode-hook 'gnus-xmas-tree-menu-add)
   (add-hook 'gnus-binary-mode-hook 'gnus-xmas-binary-menu-add)
-  (add-hook 'gnus-grouplens-mode-hook 'gnus-xmas-grouplens-menu-add)
   (add-hook 'gnus-server-mode-hook 'gnus-xmas-server-menu-add)
   (add-hook 'gnus-browse-mode-hook 'gnus-xmas-browse-menu-add)
-
-  (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar)
-  (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
-
-  (add-hook 'gnus-agent-summary-mode-hook 'gnus-xmas-agent-summary-menu-add)
-  (add-hook 'gnus-agent-group-mode-hook 'gnus-xmas-agent-group-menu-add)
-  (add-hook 'gnus-agent-server-mode-hook 'gnus-xmas-agent-server-menu-add)
-
   (add-hook 'gnus-draft-mode-hook 'gnus-xmas-draft-menu-add)
-  (add-hook 'gnus-summary-mode-hook
-           'gnus-xmas-switch-horizontal-scrollbar-off)
-  (add-hook 'gnus-tree-mode-hook 'gnus-xmas-switch-horizontal-scrollbar-off))
+  (add-hook 'gnus-mailing-list-mode-hook 'gnus-xmas-mailing-list-menu-add))
 
 
 ;;; XEmacs logo and toolbar.
@@ -526,8 +470,9 @@ 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))
+                            ("oort" . "#eeeeee")
                             ("background" . ,(face-background 'default)))])
                         ((featurep 'xbm)
                          `[xbm :file ,logo-xbm])
@@ -578,7 +523,7 @@ call it with the value of the `gnus-data' text property."
           (rest (- wheight pheight)))
       (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
     ;; Paint it.
-    (put-text-property (point-min) (point-max) 'face 'gnus-splash-face)))
+    (put-text-property (point-min) (point-max) 'face 'gnus-splash)))
   (setq modeline-buffer-identification
        (list (concat gnus-version ": *Group*")))
   (set-buffer-modified-p t))
@@ -586,17 +531,53 @@ call it with the value of the `gnus-data' text property."
 
 ;;; The toolbar.
 
-(defcustom gnus-use-toolbar (if (featurep 'toolbar)
-                               'default-toolbar
-                             nil)
-  "*If nil, do not use a toolbar.
-If it is non-nil, it must be a toolbar.  The five valid values are
-`default-toolbar', `top-toolbar', `bottom-toolbar',
-`right-toolbar', and `left-toolbar'."
-  :type '(choice (const default-toolbar)
-                (const top-toolbar) (const bottom-toolbar)
-                (const left-toolbar) (const right-toolbar)
+(defun gnus-xmas-update-toolbars ()
+  "Update the toolbars' appearance."
+  (when (and (not noninteractive)
+            (featurep 'gnus-xmas))
+    (save-excursion
+      (dolist (buffer (buffer-list))
+       (set-buffer buffer)
+       (cond ((eq major-mode 'gnus-group-mode)
+              (gnus-xmas-setup-group-toolbar))
+             ((eq major-mode 'gnus-summary-mode)
+              (gnus-xmas-setup-summary-toolbar)))))))
+
+(defcustom gnus-use-toolbar (if (featurep 'toolbar) 'default)
+  "*Position to display the toolbar.  Nil means do not use a toolbar.
+If it is non-nil, it should be one of the symbols `defau