*** empty log message ***
[gnus] / lisp / gnus-xmas.el
1 ;;; gnus-xmas.el --- Gnus functions for XEmacs
2 ;; Copyright (C) 1995,96 Free Software Foundation, Inc.
3
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
5 ;; Keywords: news
6
7 ;; This file is part of GNU Emacs.
8
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
13
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
23
24 ;;; Commentary:
25
26 ;;; Code:
27
28 (require 'text-props)
29 (defvar menu-bar-mode (featurep 'menubar))
30 (require 'messagexmas)
31
32 (defvar gnus-xmas-glyph-directory nil
33   "*Directory where Gnus logos and icons are located.
34 If this variable is nil, Gnus will try to locate the directory
35 automatically.")
36
37 (defvar gnus-xmas-logo-color-alist
38   '((flame "#cc3300" "#ff2200")
39     (pine "#c0cc93" "#f8ffb8")
40     (moss "#a1cc93" "#d2ffb8")
41     (irish "#04cc90" "#05ff97")
42     (sky "#049acc" "#05deff")
43     (tin "#6886cc" "#82b6ff")
44     (velvet "#7c68cc" "#8c82ff")
45     (grape "#b264cc" "#cf7df")
46     (labia "#cc64c2" "#fd7dff")
47     (berry "#cc6485" "#ff7db5")
48     (neutral "#b4b4b4" "#878787")
49     (september "#bf9900" "#ffcc00"))
50   "Color alist used for the Gnus logo.")
51
52 (defvar gnus-xmas-logo-color-style 'flame
53   "Color styles used for the Gnus logo.")
54
55 (defvar gnus-xmas-logo-colors
56   (cdr (assq gnus-xmas-logo-color-style gnus-xmas-logo-color-alist))
57   "Colors used for the Gnus logo.")
58
59 (defvar gnus-article-x-face-command
60   (if (featurep 'xface)
61       'gnus-xmas-article-display-xface
62     "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -")
63   "String or function to be executed to display an X-Face header.
64 If it is a string, the command will be executed in a sub-shell
65 asynchronously.  The compressed face will be piped to this command.")
66
67 ;;; Internal variables.
68
69 ;; Don't warn about these undefined variables.
70
71 (defvar gnus-group-mode-hook)
72 (defvar gnus-summary-mode-hook)
73 (defvar gnus-article-mode-hook)
74
75 ;;defined in gnus.el
76 (defvar gnus-active-hashtb)
77 (defvar gnus-article-buffer)
78 (defvar gnus-auto-center-summary)
79 (defvar gnus-buffer-list)
80 (defvar gnus-current-headers)
81 (defvar gnus-level-killed)
82 (defvar gnus-level-zombie)
83 (defvar gnus-newsgroup-bookmarks)
84 (defvar gnus-newsgroup-dependencies)
85 (defvar gnus-newsgroup-selected-overlay)
86 (defvar gnus-newsrc-hashtb)
87 (defvar gnus-read-mark)
88 (defvar gnus-refer-article-method)
89 (defvar gnus-reffed-article-number)
90 (defvar gnus-unread-mark)
91 (defvar gnus-version)
92 (defvar gnus-view-pseudos)
93 (defvar gnus-view-pseudos-separately)
94 (defvar gnus-visual)
95 (defvar gnus-zombie-list)
96 ;;defined in gnus-msg.el
97 (defvar gnus-article-copy)
98 (defvar gnus-check-before-posting)
99 ;;defined in gnus-vis.el
100 (defvar gnus-article-button-face)
101 (defvar gnus-article-mouse-face)
102 (defvar gnus-summary-selected-face)
103 (defvar gnus-group-reading-menu)
104 (defvar gnus-group-group-menu)
105 (defvar gnus-group-misc-menu)
106 (defvar gnus-summary-article-menu)
107 (defvar gnus-summary-thread-menu)
108 (defvar gnus-summary-misc-menu)
109 (defvar gnus-summary-post-menu)
110 (defvar gnus-summary-kill-menu)
111 (defvar gnus-article-article-menu)
112 (defvar gnus-article-treatment-menu)
113 (defvar gnus-mouse-2)
114 (defvar standard-display-table)
115 (defvar gnus-tree-minimize-window)
116
117 (defun gnus-xmas-set-text-properties (start end props &optional buffer)
118   "You should NEVER use this function.  It is ideologically blasphemous.
119 It is provided only to ease porting of broken FSF Emacs programs."
120   (if (stringp buffer)
121       nil
122     (map-extents (lambda (extent ignored)
123                    (remove-text-properties 
124                     start end
125                     (list (extent-property extent 'text-prop) nil)
126                     buffer))
127                  buffer start end nil nil 'text-prop)
128     (gnus-add-text-properties start end props buffer)))
129
130 (defun gnus-xmas-highlight-selected-summary ()
131   ;; Highlight selected article in summary buffer
132   (when gnus-summary-selected-face
133     (when gnus-newsgroup-selected-overlay
134       (delete-extent gnus-newsgroup-selected-overlay))
135     (setq gnus-newsgroup-selected-overlay 
136           (make-extent (gnus-point-at-bol) (gnus-point-at-eol)))
137     (set-extent-face gnus-newsgroup-selected-overlay
138                      gnus-summary-selected-face)))
139
140 (defun gnus-xmas-summary-recenter ()
141   "\"Center\" point in the summary window.
142 If `gnus-auto-center-summary' is nil, or the article buffer isn't
143 displayed, no centering will be performed."
144   ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
145   ;; Recenter only when requested.  Suggested by popovich@park.cs.columbia.edu.
146   ;; Force redisplay to get properly computed window height.
147   (sit-for 0)
148   (when gnus-auto-center-summary
149     (let* ((height (if (fboundp 'window-displayed-height)
150                        (window-displayed-height)
151                      (- (window-height) 2)))
152            (top (cond ((< height 4) 0)
153                       ((< height 7) 1)
154                       (t 2)))
155            (bottom (save-excursion (goto-char (point-max))
156                                    (forward-line (- height))
157                                    (point)))
158            (window (get-buffer-window (current-buffer))))
159       (when (get-buffer-window gnus-article-buffer)
160         ;; Only do recentering when the article buffer is displayed,
161         ;; Set the window start to either `bottom', which is the biggest
162         ;; possible valid number, or the second line from the top,
163         ;; whichever is the least.
164         (set-window-start
165          window (min bottom (save-excursion (forward-line (- top)) (point)))))
166       ;; Do horizontal recentering while we're at it.
167       (when (and (get-buffer-window (current-buffer) t)
168                  (not (eq gnus-auto-center-summary 'vertical)))
169         (let ((selected (selected-window)))
170           (select-window (get-buffer-window (current-buffer) t))
171           (gnus-summary-position-point)
172           (gnus-horizontal-recenter)
173           (select-window selected))))))
174
175 (defun gnus-xmas-add-hook (hook function &optional append local)
176   (add-hook hook function))
177
178 (defun gnus-xmas-add-text-properties (start end props &optional object)
179   (add-text-properties start end props object)
180   (put-text-property start end 'start-closed nil object))
181
182 (defun gnus-xmas-put-text-property (start end prop value &optional object)
183   (put-text-property start end prop value object)
184   (put-text-property start end 'start-closed nil object))
185
186 (defun gnus-xmas-extent-start-open (point)
187   (map-extents (lambda (extent arg)
188                  (set-extent-property extent 'start-open t))
189                nil point (min (1+ (point)) (point-max))))
190                   
191 (defun gnus-xmas-article-push-button (event)
192   "Check text under the mouse pointer for a callback function.
193 If the text under the mouse pointer has a `gnus-callback' property,
194 call it with the value of the `gnus-data' text property."
195   (interactive "e")
196   (set-buffer (window-buffer (event-window event)))
197   (let* ((pos (event-closest-point event))
198          (data (get-text-property pos 'gnus-data))
199          (fun (get-text-property pos 'gnus-callback)))
200     (when fun
201       (funcall fun data))))
202
203 (defun gnus-xmas-move-overlay (extent start end &optional buffer)
204   (set-extent-endpoints extent start end))
205
206 ;; Fixed by Christopher Davis <ckd@loiosh.kei.com>.
207 (defun gnus-xmas-article-add-button (from to fun &optional data)
208   "Create a button between FROM and TO with callback FUN and data DATA."
209   (when gnus-article-button-face
210     (gnus-overlay-put (gnus-make-overlay from to)
211                       'face gnus-article-button-face))
212   (gnus-add-text-properties 
213    from to
214    (nconc
215     (and gnus-article-mouse-face
216          (list 'mouse-face gnus-article-mouse-face))
217     (list 'gnus-callback fun)
218     (and data (list 'gnus-data data))
219     (list 'highlight t))))
220
221 (defun gnus-xmas-window-top-edge (&optional window)
222   (nth 1 (window-pixel-edges window)))
223
224 (defun gnus-xmas-tree-minimize ()
225   (when (and gnus-tree-minimize-window
226              (not (one-window-p)))
227     (let* ((window-min-height 2)
228            (height (1+ (count-lines (point-min) (point-max))))
229            (min (max (1- window-min-height) height))
230            (tot (if (numberp gnus-tree-minimize-window)
231                     (min gnus-tree-minimize-window min)
232                   min))
233            (win (get-buffer-window (current-buffer)))
234            (wh (and win (1- (window-height win)))))
235       (when (and win
236                  (not (eq tot wh)))
237         (let ((selected (selected-window)))
238           (select-window win)
239           (enlarge-window (- tot wh))
240           (select-window selected))))))
241
242 ;; Select the lowest window on the frame.
243 (defun gnus-xmas-appt-select-lowest-window ()
244   (let* ((lowest-window (selected-window))
245          (bottom-edge (car (cdr (cdr (cdr (window-pixel-edges))))))
246          (last-window (previous-window))
247          (window-search t))
248     (while window-search
249       (let* ((this-window (next-window))
250              (next-bottom-edge (car (cdr (cdr (cdr 
251                                                (window-pixel-edges 
252                                                 this-window)))))))
253         (when (< bottom-edge next-bottom-edge)
254           (setq bottom-edge next-bottom-edge)
255           (setq lowest-window this-window))
256
257         (select-window this-window)
258         (when (eq last-window this-window)
259           (select-window lowest-window)
260           (setq window-search nil))))))
261
262 (defmacro gnus-xmas-menu-add (type &rest menus)
263   `(gnus-xmas-menu-add-1 ',type ',menus))
264 (put 'gnus-xmas-menu-add 'lisp-indent-function 1)
265
266 (defun gnus-xmas-menu-add-1 (type menus)
267   (when (and menu-bar-mode
268              (gnus-visual-p (intern (format "%s-menu" type)) 'menu))
269     (while menus
270       (easy-menu-add (symbol-value (pop menus))))))
271
272 (defun gnus-xmas-group-menu-add ()
273   (gnus-xmas-menu-add group
274     gnus-group-reading-menu gnus-group-group-menu gnus-group-misc-menu))
275
276 (defun gnus-xmas-summary-menu-add ()
277   (gnus-xmas-menu-add summary
278     gnus-summary-misc-menu gnus-summary-kill-menu
279     gnus-summary-article-menu gnus-summary-thread-menu
280     gnus-summary-post-menu ))
281
282 (defun gnus-xmas-article-menu-add ()
283   (gnus-xmas-menu-add article
284     gnus-article-article-menu gnus-article-treatment-menu))
285
286 (defun gnus-xmas-score-menu-add ()
287   (gnus-xmas-menu-add score
288     gnus-score-menu))
289
290 (defun gnus-xmas-pick-menu-add ()
291   (gnus-xmas-menu-add pick
292     gnus-pick-menu))
293
294 (defun gnus-xmas-topic-menu-add ()
295   (gnus-xmas-menu-add topic
296     gnus-topic-menu))
297
298 (defun gnus-xmas-binary-menu-add ()
299   (gnus-xmas-menu-add binary
300     gnus-binary-menu))
301
302 (defun gnus-xmas-tree-menu-add ()
303   (gnus-xmas-menu-add tree
304     gnus-tree-menu))
305
306 (defun gnus-xmas-server-menu-add ()
307   (gnus-xmas-menu-add menu
308     gnus-server-server-menu gnus-server-connections-menu))
309
310 (defun gnus-xmas-browse-menu-add ()
311   (gnus-xmas-menu-add browse
312     gnus-browse-menu))
313
314 (defun gnus-xmas-grouplens-menu-add ()
315   (gnus-xmas-menu-add grouplens
316     gnus-grouplens-menu))
317
318 (defun gnus-xmas-read-event-char ()
319   "Get the next event."
320   (let ((event (next-command-event)))
321     ;; We junk all non-key events.  Is this naughty?
322     (while (not (key-press-event-p event))
323       (setq event (next-command-event)))
324     (cons (and (key-press-event-p event) 
325                (event-to-character event)) 
326           event)))
327
328 (defun gnus-xmas-group-remove-excess-properties ()
329   (let ((end (point))
330         (beg (progn (forward-line -1) (point))))
331     (remove-text-properties (1+ beg) end '(gnus-group nil))
332     (remove-text-properties 
333      beg end 
334      '(gnus-topic nil gnus-topic-level nil gnus-topic-visible nil))
335     (goto-char end)
336     (map-extents 
337      (lambda (e ma)
338        (set-extent-property e 'start-closed t))
339      (current-buffer) beg end)))
340                   
341 (defun gnus-xmas-topic-remove-excess-properties ()
342   (let ((end (point))
343         (beg (progn (forward-line -1) (point))))
344     (remove-text-properties beg end '(gnus-group nil gnus-unread nil))
345     (remove-text-properties (1+ beg) end '(gnus-topic nil))
346     (goto-char end)))
347
348 (defun gnus-xmas-seconds-since-epoch (date)
349   "Return a floating point number that says how many seconds have lapsed between Jan 1 12:00:00 1970 and DATE."
350   (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
351                         (timezone-parse-date date)))
352          (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
353                         (timezone-parse-time
354                          (aref (timezone-parse-date date) 3))))
355          (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
356                         (timezone-parse-date "Jan 1 12:00:00 1970")))
357          (tday (- (timezone-absolute-from-gregorian 
358                    (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
359                   (timezone-absolute-from-gregorian 
360                    (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
361     (+ (nth 2 ttime)
362        (* (nth 1 ttime) 60)
363        (* (float (nth 0 ttime)) 60 60)
364        (* (float tday) 60 60 24))))
365
366 (defun gnus-xmas-define ()
367   (setq gnus-mouse-2 [button2])
368
369   (unless (memq 'underline (face-list))
370     (and (fboundp 'make-face)
371          (funcall (intern "make-face") 'underline)))
372   ;; Must avoid calling set-face-underline-p directly, because it
373   ;; is a defsubst in emacs19, and will make the .elc files non
374   ;; portable!
375   (unless (face-differs-from-default-p 'underline)
376     (funcall (intern "set-face-underline-p") 'underline t))
377
378   (fset 'gnus-make-overlay 'make-extent)
379   (fset 'gnus-overlay-put 'set-extent-property)
380   (fset 'gnus-move-overlay 'gnus-xmas-move-overlay)
381   (fset 'gnus-overlay-end 'extent-end-position)
382   (fset 'gnus-extent-detached-p 'extent-detached-p)
383   (fset 'gnus-add-text-properties 'gnus-xmas-add-text-properties)
384   (fset 'gnus-put-text-property 'gnus-xmas-put-text-property)
385       
386   (require 'text-props)
387   (when (< emacs-minor-version 14)
388     (fset 'gnus-set-text-properties 'gnus-xmas-set-text-properties))
389
390   (unless (boundp 'standard-display-table)
391     (setq standard-display-table nil))
392
393   (defvar gnus-mouse-face-prop 'highlight)
394
395   (unless (fboundp 'encode-time)
396     (defun encode-time (sec minute hour day month year &optional zone)
397       (let ((seconds
398              (gnus-xmas-seconds-since-epoch
399               (timezone-make-arpa-date 
400                year month day (timezone-make-time-string hour minute sec)
401                zone))))
402         (list (floor (/ seconds (expt 2 16)))
403               (round (mod seconds (expt 2 16)))))))
404       
405   (defun gnus-byte-code (func)
406     "Return a form that can be `eval'ed based on FUNC."
407     (let ((fval (symbol-function func)))
408       (if (compiled-function-p fval)
409           (list 'funcall fval)
410         (cons 'progn (cdr (cdr fval))))))
411
412   (fset 'gnus-x-color-values 
413         (if (fboundp 'x-color-values)
414             'x-color-values
415           (lambda (color)
416             (color-instance-rgb-components
417              (make-color-instance color))))))
418
419
420 (defun gnus-xmas-redefine ()
421   "Redefine lots of Gnus functions for XEmacs."
422   (fset 'gnus-summary-make-display-table 'ignore)
423   (fset 'gnus-visual-turn-off-edit-menu 'identity)
424   (fset 'gnus-summary-recenter 'gnus-xmas-summary-recenter)
425   (fset 'gnus-extent-start-open 'gnus-xmas-extent-start-open)
426   (fset 'gnus-article-push-button 'gnus-xmas-article-push-button)
427   (fset 'gnus-article-add-button 'gnus-xmas-article-add-button)
428   (fset 'gnus-window-top-edge 'gnus-xmas-window-top-edge)
429   (fset 'gnus-read-event-char 'gnus-xmas-read-event-char)
430   (fset 'gnus-group-startup-message 'gnus-xmas-group-startup-message)
431   (fset 'gnus-tree-minimize 'gnus-xmas-tree-minimize)
432   (fset 'gnus-appt-select-lowest-window 
433         'gnus-xmas-appt-select-lowest-window)
434   (fset 'gnus-mail-strip-quoted-names 'gnus-xmas-mail-strip-quoted-names)
435   (fset 'gnus-make-local-hook 'make-local-variable)
436   (fset 'gnus-add-hook 'gnus-xmas-add-hook)
437   (fset 'gnus-character-to-event 'character-to-event)
438   (fset 'gnus-article-show-hidden-text 'gnus-xmas-article-show-hidden-text)
439   (fset 'gnus-mode-line-buffer-identification
440         'gnus-xmas-mode-line-buffer-identification)
441
442   (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
443   (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
444   (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add)
445   (add-hook 'gnus-score-mode-hook 'gnus-xmas-score-menu-add)
446
447   (add-hook 'gnus-pick-mode-hook 'gnus-xmas-pick-menu-add)
448   (add-hook 'gnus-topic-mode-hook 'gnus-xmas-topic-menu-add)
449   (add-hook 'gnus-tree-mode-hook 'gnus-xmas-tree-menu-add)
450   (add-hook 'gnus-binary-mode-hook 'gnus-xmas-binary-menu-add)
451   (add-hook 'gnus-grouplens-mode-hook 'gnus-xmas-grouplens-menu-add)
452   (add-hook 'gnus-server-mode-hook 'gnus-xmas-server-menu-add)
453   (add-hook 'gnus-browse-mode-hook 'gnus-xmas-browse-menu-add)
454
455   (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar)
456   (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
457
458   (when (and (<= emacs-major-version 19)
459              (<= emacs-minor-version 13))
460     (setq gnus-article-x-face-too-ugly (when (eq (device-type) 'tty)
461                                          "."))
462     (fset 'gnus-highlight-selected-summary
463           'gnus-xmas-highlight-selected-summary)
464     (fset 'gnus-group-remove-excess-properties
465           'gnus-xmas-group-remove-excess-properties)
466     (fset 'gnus-topic-remove-excess-properties
467           'gnus-xmas-topic-remove-excess-properties)
468     (fset 'gnus-mode-line-buffer-identification 'identity)
469     (unless (boundp 'shell-command-switch)
470       (setq shell-command-switch "-c"))
471     ))
472
473
474 ;;; XEmacs logo and toolbar.
475
476 (defun gnus-xmas-group-startup-message (&optional x y)
477   "Insert startup message in current buffer."
478   ;; Insert the message.
479   (setq gnus-xmas-glyph-directory (message-xmas-find-glyph-directory "gnus"))
480   (erase-buffer)
481   (let ((logo (and gnus-xmas-glyph-directory
482                    (concat 
483                     (file-name-as-directory gnus-xmas-glyph-directory)
484                     "gnus."
485                     (if (featurep 'xpm) "xpm" "xbm"))))
486         (xpm-color-symbols 
487          (and (featurep 'xpm)
488               (append `(("thing" ,(car gnus-xmas-logo-colors))
489                         ("shadow" ,(cadr gnus-xmas-logo-colors)))
490                       xpm-color-symbols))))
491     (if (and (featurep 'xpm)
492              (not (equal (device-type) 'tty))
493              logo
494              (file-exists-p logo))
495         (progn
496           (setq logo (make-glyph logo))
497           (insert " ")
498           (set-extent-begin-glyph (make-extent (point) (point)) logo)
499           (goto-char (point-min))
500           (while (not (eobp))
501             (insert (make-string (/ (max (- (window-width) (or x 35)) 0) 2)
502                                  ? ))
503             (forward-line 1))
504           (goto-char (point-min))
505           (let* ((pheight (+ 20 (count-lines (point-min) (point-max))))
506                  (wheight (window-height))
507                  (rest (- wheight pheight)))
508             (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n))))
509
510       (insert
511        (format "              %s
512           _    ___ _             _      
513           _ ___ __ ___  __    _ ___     
514           __   _     ___    __  ___     
515               _           ___     _     
516              _  _ __             _      
517              ___   __            _      
518                    __           _       
519                     _      _   _        
520                    _      _    _        
521                       _  _    _         
522                   __  ___               
523                  _   _ _     _          
524                 _   _                   
525               _    _                    
526              _    _                     
527             _                         
528           __                             
529
530
531                ""))
532       ;; And then hack it.
533       (gnus-indent-rigidly (point-min) (point-max)
534                            (/ (max (- (window-width) (or x 46)) 0) 2))
535       (goto-char (point-min))
536       (forward-line 1)
537       (let* ((pheight (count-lines (point-min) (point-max)))
538              (wheight (window-height))
539              (rest (- wheight pheight)))
540         (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n))))
541     ;; Fontify some.
542     (goto-char (point-min))
543     (put-text-property (point-min) (point-max) 'face 'gnus-splash-face)
544     (goto-char (point-min))
545     (setq modeline-buffer-identification 
546           (list (concat gnus-version ": *Group*")))
547     (set-buffer-modified-p t)))
548
549
550 ;;; The toolbar.
551
552 (defvar gnus-use-toolbar (if (featurep 'toolbar)
553                              'default-toolbar
554                            nil)
555   "*If nil, do not use a toolbar.
556 If it is non-nil, it must be a toolbar.  The five legal values are
557 `default-toolbar', `top-toolbar', `bottom-toolbar',
558 `right-toolbar', and `left-toolbar'.")
559
560 (defvar gnus-group-toolbar 
561   '([gnus-group-get-new-news gnus-group-get-new-news t "Get new news"]
562     [gnus-group-get-new-news-this-group 
563      gnus-group-get-new-news-this-group t "Get new news in this group"]
564     [gnus-group-catchup-current 
565      gnus-group-catchup-current t "Catchup group"]
566     [gnus-group-describe-group 
567      gnus-group-describe-group t "Describe group"]
568     [gnus-group-unsubscribe gnus-group-unsubscribe t "Unsubscribe group"]
569     [gnus-group-subscribe gnus-group-subscribe t "Subscribe group"]
570     [gnus-group-kill-group gnus-group-kill-group t "Kill group"]
571     [gnus-group-exit gnus-group-exit t "Exit Gnus"]
572     )
573   "The group buffer toolbar.")
574
575 (defvar gnus-summary-toolbar 
576   '([gnus-summary-prev-unread 
577      gnus-summary-prev-unread-article t "Prev unread article"]
578     [gnus-summary-next-unread 
579      gnus-summary-next-unread-article t "Next unread article"]
580     [gnus-summary-post-news 
581      gnus-summary-post-news t "Post an article"]
582     [gnus-summary-followup-with-original
583      gnus-summary-followup-with-original t 
584      "Post a followup and yank the original"]
585     [gnus-summary-followup 
586      gnus-summary-followup t "Post a followup"]
587     [gnus-summary-reply-with-original
588      gnus-summary-reply-with-original t "Mail a reply and yank the original"]
589     [gnus-summary-reply 
590      gnus-summary-reply t "Mail a reply"]
591     [gnus-summary-caesar-message
592      gnus-summary-caesar-message t "Rot 13"]
593     [gnus-uu-decode-uu
594      gnus-uu-decode-uu t "Decode uuencoded articles"]
595     [gnus-summary-save-article-file
596      gnus-summary-save-article-file t "Save article in file"]
597     [gnus-summary-save-article
598      gnus-summary-save-article t "Save article"]
599     [gnus-uu-post-news 
600      gnus-uu-post-news t "Post an uuencoded article"]
601     [gnus-summary-cancel-article
602      gnus-summary-cancel-article t "Cancel article"]
603     [gnus-summary-catchup
604      gnus-summary-catchup t "Catchup"]
605     [gnus-summary-catchup-and-exit
606      gnus-summary-catchup-and-exit t "Catchup and exit"]
607     [gnus-summary-exit gnus-summary-exit t "Exit this summary"]
608     )
609   "The summary buffer toolbar.")
610
611 (defvar gnus-summary-mail-toolbar
612   '(
613     [gnus-summary-prev-unread 
614      gnus-summary-prev-unread-article t "Prev unread article"]
615     [gnus-summary-next-unread 
616      gnus-summary-next-unread-article t "Next unread article"]
617     [gnus-summary-mail-reply gnus-summary-reply t "Reply"]
618 ;    [gnus-summary-mail-get gnus-mail-get t "Message get"]
619     [gnus-summary-mail-originate gnus-summary-post-news t "Originate"]
620     [gnus-summary-mail-save gnus-summary-save-article t "Save"]
621     [gnus-summary-mail-copy gnus-summary-copy-article t "Copy message"]
622 ;    [gnus-summary-mail-delete gnus-summary-delete-article t "Delete message"]
623     [gnus-summary-mail-forward gnus-summary-mail-forward t "Forward message"]
624 ;    [gnus-summary-mail-spell gnus-mail-spell t "Spell"]
625 ;    [gnus-summary-mail-help gnus-mail-help  t "Message help"]
626     [gnus-summary-caesar-message
627      gnus-summary-caesar-message t "Rot 13"]
628     [gnus-uu-decode-uu
629      gnus-uu-decode-uu t "Decode uuencoded articles"]
630     [gnus-summary-save-article-file
631      gnus-summary-save-article-file t "Save article in file"]
632     [gnus-summary-save-article
633      gnus-summary-save-article t "Save article"]
634     [gnus-summary-catchup-and-exit
635      gnus-summary-catchup-and-exit t "Catchup and exit"]
636     [gnus-summary-catchup
637      gnus-summary-catchup t "Catchup"]
638     [gnus-summary-exit gnus-summary-exit t "Exit this summary"]
639     )
640   "The summary buffer mail toolbar.")
641
642 (defun gnus-xmas-setup-group-toolbar ()
643   (and gnus-use-toolbar
644        (message-xmas-setup-toolbar gnus-group-toolbar nil "gnus")
645        (set-specifier (symbol-value gnus-use-toolbar)
646                       (cons (current-buffer) gnus-group-toolbar))))
647
648 (defun gnus-xmas-setup-summary-toolbar ()
649   (let ((bar (if (gnus-news-group-p gnus-newsgroup-name)
650                  gnus-summary-toolbar gnus-summary-mail-toolbar)))
651     (and gnus-use-toolbar
652          (message-xmas-setup-toolbar bar nil "gnus")
653          (set-specifier (symbol-value gnus-use-toolbar)
654                         (cons (current-buffer) bar)))))
655
656 (defun gnus-xmas-mail-strip-quoted-names (address)
657   "Protect mail-strip-quoted-names from NIL input.
658 XEmacs compatibility workaround."
659   (if (null address)
660       nil
661     (mail-strip-quoted-names address)))
662
663 (defun gnus-xmas-call-region (command &rest args)
664   (apply
665    'call-process-region (point-min) (point-max) command t '(t nil) nil
666    args))
667
668 (unless (find-face 'gnus-x-face)
669   (copy-face 'default 'gnus-x-face)
670   (set-face-foreground 'gnus-x-face "black")
671   (set-face-background 'gnus-x-face "white"))
672
673 (defun gnus-xmas-article-display-xface (beg end)
674   "Display any XFace headers in the current article."
675   (save-excursion
676     (let (xface-glyph)
677       (if (featurep 'xface)
678           (setq xface-glyph
679                 (make-glyph (vector 'xface :data 
680                                     (concat "X-Face: "
681                                             (buffer-substring beg end)))))
682         (let ((cur (current-buffer)))
683           (save-excursion
684             (gnus-set-work-buffer)
685             (insert (format "%s" (buffer-substring beg end cur)))
686             (gnus-xmas-call-region "uncompface")
687             (goto-char (point-min))
688             (insert "/* Width=48, Height=48 */\n")
689             (gnus-xmas-call-region "icontopbm")
690             (gnus-xmas-call-region "ppmtoxpm")
691             (setq xface-glyph
692                   (make-glyph
693                    (vector 'xpm :data (buffer-string )))))))
694       (set-glyph-face xface-glyph 'gnus-x-face)
695       (goto-char (point-min))
696       (re-search-forward "^From:" nil t)
697       (set-extent-begin-glyph 
698        (make-extent (point) (1+ (point))) xface-glyph))))
699
700 (defun gnus-xmas-article-show-hidden-text (type &optional hide)
701   "Show all hidden text of type TYPE.
702 If HIDE, hide the text instead."
703   (save-excursion
704     (set-buffer gnus-article-buffer)
705     (let ((buffer-read-only nil)
706           (inhibit-point-motion-hooks t)
707           (beg (point-min)))
708       (while (gnus-goto-char (text-property-any
709                               beg (point-max) 'gnus-type type))
710         (setq beg (point))
711         (forward-char)
712         (if hide
713             (article-hide-text beg (point) gnus-hidden-properties)
714           (article-unhide-text beg (point)))
715         (setq beg (point)))
716       (save-window-excursion
717         (select-window (get-buffer-window (current-buffer)))
718         (recenter))
719       t)))
720
721 (defvar gnus-xmas-pointer-glyph 
722   (progn
723     (setq gnus-xmas-glyph-directory (message-xmas-find-glyph-directory "gnus"))
724     (make-pointer-glyph (concat gnus-xmas-glyph-directory "gnus-pointer."
725                                 (if (featurep 'xpm) "xpm" "xbm")))))
726
727 (defvar gnus-xmas-modeline-left-extent 
728   (let ((ext (copy-extent modeline-buffer-id-left-extent)))
729     ;(set-extent-property ext 'pointer gnus-xmas-pointer-glyph)
730     ext))
731       
732 (defvar gnus-xmas-modeline-right-extent 
733   (let ((ext (copy-extent modeline-buffer-id-right-extent)))
734     ;(set-extent-property ext 'pointer gnus-xmas-pointer-glyph)
735     ext))
736
737 (defvar gnus-xmas-modeline-glyph
738   (progn
739     (setq gnus-xmas-glyph-directory (message-xmas-find-glyph-directory "gnus"))
740     (let* ((file (concat gnus-xmas-glyph-directory "gnus-pointer."
741                          (if (featurep 'xpm) "xpm" "xbm")))
742            (glyph (make-glyph file)))
743       (when (and (featurep 'x)
744                  (file-exists-p file))
745         (set-glyph-face glyph 'modeline-buffer-id))
746       (set-glyph-property glyph 'image (cons 'tty "Gnus:"))
747       glyph)))
748
749 (defun gnus-xmas-mode-line-buffer-identification (line)
750   (let ((line (car line))
751         chop)
752     (if (not (stringp line))
753         (list line)
754       (when (string-match "^Gnus:" line)
755         (setq chop (match-end 0))
756         (list 
757          (if gnus-xmas-modeline-glyph
758              (cons gnus-xmas-modeline-left-extent gnus-xmas-modeline-glyph)
759            (cons gnus-xmas-modeline-left-extent (substring line 0 chop)))
760          (cons gnus-xmas-modeline-right-extent (substring line chop)))))))
761
762 (defun gnus-xmas-splash ()
763   (when (eq (device-type) 'x)
764     (gnus-splash)))
765
766 (provide 'gnus-xmas)
767
768 ;;; gnus-xmas.el ends here