1 ;;; gnus-xmas.el --- Gnus functions for XEmacs
2 ;; Copyright (C) 1995,96,97,98 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
30 (defvar menu-bar-mode (featurep 'menubar))
31 (require 'messagexmas)
34 (defgroup gnus-xmas nil
35 "XEmacsoid support for Gnus"
38 (defcustom gnus-xmas-glyph-directory nil
39 "Directory where Gnus logos and icons are located.
40 If this variable is nil, Gnus will try to locate the directory
42 :type '(choice (const :tag "autodetect" nil)
46 ;;(format "%02x%02x%02x" 114 66 20) "724214"
48 (defvar gnus-xmas-logo-color-alist
49 '((flame "#cc3300" "#ff2200")
50 (pine "#c0cc93" "#f8ffb8")
51 (moss "#a1cc93" "#d2ffb8")
52 (irish "#04cc90" "#05ff97")
53 (sky "#049acc" "#05deff")
54 (tin "#6886cc" "#82b6ff")
55 (velvet "#7c68cc" "#8c82ff")
56 (grape "#b264cc" "#cf7df")
57 (labia "#cc64c2" "#fd7dff")
58 (berry "#cc6485" "#ff7db5")
59 (dino "#724214" "#1e3f03")
60 (neutral "#b4b4b4" "#878787")
61 (september "#bf9900" "#ffcc00"))
62 "Color alist used for the Gnus logo.")
64 (defcustom gnus-xmas-logo-color-style 'dino
65 "*Color styles used for the Gnus logo."
66 :type '(choice (const flame) (const pine) (const moss)
67 (const irish) (const sky) (const tin)
68 (const velvet) (const grape) (const labia)
69 (const berry) (const neutral) (const september)
73 (defvar gnus-xmas-logo-colors
74 (cdr (assq gnus-xmas-logo-color-style gnus-xmas-logo-color-alist))
75 "Colors used for the Gnus logo.")
77 (defcustom gnus-article-x-face-command
78 (if (or (featurep 'xface)
80 'gnus-xmas-article-display-xface
81 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -")
82 "*String or function to be executed to display an X-Face header.
83 If it is a string, the command will be executed in a sub-shell
84 asynchronously. The compressed face will be piped to this command."
85 :type '(choice string function))
87 ;;; Internal variables.
89 ;; Don't warn about these undefined variables.
91 (defvar gnus-group-mode-hook)
92 (defvar gnus-summary-mode-hook)
93 (defvar gnus-article-mode-hook)
96 (defvar gnus-active-hashtb)
97 (defvar gnus-article-buffer)
98 (defvar gnus-auto-center-summary)
99 (defvar gnus-current-headers)
100 (defvar gnus-level-killed)
101 (defvar gnus-level-zombie)
102 (defvar gnus-newsgroup-bookmarks)
103 (defvar gnus-newsgroup-dependencies)
104 (defvar gnus-newsgroup-selected-overlay)
105 (defvar gnus-newsrc-hashtb)
106 (defvar gnus-read-mark)
107 (defvar gnus-refer-article-method)
108 (defvar gnus-reffed-article-number)
109 (defvar gnus-unread-mark)
110 (defvar gnus-version)
111 (defvar gnus-view-pseudos)
112 (defvar gnus-view-pseudos-separately)
114 (defvar gnus-zombie-list)
115 ;;defined in gnus-msg.el
116 (defvar gnus-article-copy)
117 (defvar gnus-check-before-posting)
118 ;;defined in gnus-vis.el
119 (defvar gnus-article-button-face)
120 (defvar gnus-article-mouse-face)
121 (defvar gnus-summary-selected-face)
122 (defvar gnus-group-reading-menu)
123 (defvar gnus-group-group-menu)
124 (defvar gnus-group-misc-menu)
125 (defvar gnus-summary-article-menu)
126 (defvar gnus-summary-thread-menu)
127 (defvar gnus-summary-misc-menu)
128 (defvar gnus-summary-post-menu)
129 (defvar gnus-summary-kill-menu)
130 (defvar gnus-article-article-menu)
131 (defvar gnus-article-treatment-menu)
132 (defvar gnus-mouse-2)
133 (defvar standard-display-table)
134 (defvar gnus-tree-minimize-window)
136 (defun gnus-xmas-set-text-properties (start end props &optional buffer)
137 "You should NEVER use this function. It is ideologically blasphemous.
138 It is provided only to ease porting of broken FSF Emacs programs."
141 (map-extents (lambda (extent ignored)
142 (remove-text-properties
144 (list (extent-property extent 'text-prop) nil)
147 buffer start end nil nil 'text-prop)
148 (gnus-add-text-properties start end props buffer)))
150 (defun gnus-xmas-highlight-selected-summary ()
151 ;; Highlight selected article in summary buffer
152 (when gnus-summary-selected-face
153 (when gnus-newsgroup-selected-overlay
154 (delete-extent gnus-newsgroup-selected-overlay))
155 (setq gnus-newsgroup-selected-overlay
156 (make-extent (gnus-point-at-bol) (gnus-point-at-eol)))
157 (set-extent-face gnus-newsgroup-selected-overlay
158 gnus-summary-selected-face)))
160 (defcustom gnus-xmas-force-redisplay nil
161 "*If non-nil, force a redisplay before recentering the summary buffer.
162 This is ugly, but it works around a bug in `window-displayed-height'."
166 (defun gnus-xmas-switch-horizontal-scrollbar-off ()
167 (when (featurep 'scrollbar)
168 (set-specifier scrollbar-height (cons (current-buffer) 0))))
170 (defun gnus-xmas-summary-recenter ()
171 "\"Center\" point in the summary window.
172 If `gnus-auto-center-summary' is nil, or the article buffer isn't
173 displayed, no centering will be performed."
174 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
175 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
176 ;; Force redisplay to get properly computed window height.
177 (when gnus-xmas-force-redisplay
179 (when gnus-auto-center-summary
180 (let* ((height (if (fboundp 'window-displayed-height)
181 (window-displayed-height)
182 (- (window-height) 2)))
183 (top (cond ((< height 4) 0)
186 (bottom (save-excursion (goto-char (point-max))
187 (forward-line (- height))
189 (window (get-buffer-window (current-buffer))))
190 (when (get-buffer-window gnus-article-buffer)
191 ;; Only do recentering when the article buffer is displayed,
192 ;; Set the window start to either `bottom', which is the biggest
193 ;; possible valid number, or the second line from the top,
194 ;; whichever is the least.
196 window (min bottom (save-excursion (forward-line (- top)) (point)))))
197 ;; Do horizontal recentering while we're at it.
198 (when (and (get-buffer-window (current-buffer) t)
199 (not (eq gnus-auto-center-summary 'vertical)))
200 (let ((selected (selected-window)))
201 (select-window (get-buffer-window (current-buffer) t))
202 (gnus-summary-position-point)
203 (gnus-horizontal-recenter)
204 (select-window selected))))))
206 (defun gnus-xmas-summary-set-display-table ()
207 ;; Setup the display table -- like `gnus-summary-setup-display-table',
208 ;; but done in an XEmacsish way.
209 (let ((table (make-display-table))
211 ;; Nix out all the control chars...
212 (while (>= (setq i (1- i)) 0)
214 ;; ... but not newline and cr, of course. (cr is necessary for the
215 ;; selective display).
218 ;; We keep TAB as well.
220 ;; We nix out any glyphs over 126 below ctl-arrow.
221 (let ((i (if (integerp ctl-arrow) ctl-arrow 160)))
222 (while (>= (setq i (1- i)) 127)
223 (unless (aref table i)
224 (aset table i [??]))))
225 ;; Can't use `set-specifier' because of a bug in 19.14 and earlier
226 (add-spec-to-specifier current-display-table table (current-buffer) nil)))
228 (defun gnus-xmas-add-text-properties (start end props &optional object)
229 (add-text-properties start end props object)
230 (put-text-property start end 'start-closed nil object))
232 (defun gnus-xmas-put-text-property (start end prop value &optional object)
233 (put-text-property start end prop value object)
234 (put-text-property start end 'start-closed nil object))
236 (defun gnus-xmas-extent-start-open (point)
237 (map-extents (lambda (extent arg)
238 (set-extent-property extent 'start-open t))
239 nil point (min (1+ (point)) (point-max))))
241 (defun gnus-xmas-article-push-button (event)
242 "Check text under the mouse pointer for a callback function.
243 If the text under the mouse pointer has a `gnus-callback' property,
244 call it with the value of the `gnus-data' text property."
246 (set-buffer (window-buffer (event-window event)))
247 (let* ((pos (event-closest-point event))
248 (data (get-text-property pos 'gnus-data))
249 (fun (get-text-property pos 'gnus-callback)))
251 (funcall fun data))))
253 (defun gnus-xmas-move-overlay (extent start end &optional buffer)
254 (set-extent-endpoints extent start end buffer))
256 (defun gnus-xmas-kill-all-overlays ()
257 "Delete all extents in the current buffer."
258 (map-extents (lambda (extent ignore)
259 (delete-extent extent)
262 (defun gnus-xmas-window-top-edge (&optional window)
263 (nth 1 (window-pixel-edges window)))
265 (defun gnus-xmas-tree-minimize ()
266 (when (and gnus-tree-minimize-window
267 (not (one-window-p)))
268 (let* ((window-min-height 2)
269 (height (1+ (count-lines (point-min) (point-max))))
270 (min (max (1- window-min-height) height))
271 (tot (if (numberp gnus-tree-minimize-window)
272 (min gnus-tree-minimize-window min)
274 (win (get-buffer-window (current-buffer)))
275 (wh (and win (1- (window-height win)))))
278 (let ((selected (selected-window)))
280 (enlarge-window (- tot wh))
281 (select-window selected))))))
283 ;; Select the lowest window on the frame.
284 (defun gnus-xmas-appt-select-lowest-window ()
285 (let* ((lowest-window (selected-window))
286 (bottom-edge (car (cdr (cdr (cdr (window-pixel-edges))))))
287 (last-window (previous-window))
290 (let* ((this-window (next-window))
291 (next-bottom-edge (car (cdr (cdr (cdr
294 (when (< bottom-edge next-bottom-edge)
295 (setq bottom-edge next-bottom-edge)
296 (setq lowest-window this-window))
298 (select-window this-window)
299 (when (eq last-window this-window)
300 (select-window lowest-window)
301 (setq window-search nil))))))
303 (defmacro gnus-xmas-menu-add (type &rest menus)
304 `(gnus-xmas-menu-add-1 ',type ',menus))
305 (put 'gnus-xmas-menu-add 'lisp-indent-function 1)
307 (defun gnus-xmas-menu-add-1 (type menus)
308 (when (and menu-bar-mode
309 (gnus-visual-p (intern (format "%s-menu" type)) 'menu))
311 (easy-menu-add (symbol-value (pop menus))))))
313 (defun gnus-xmas-group-menu-add ()
314 (gnus-xmas-menu-add group
315 gnus-group-reading-menu gnus-group-group-menu gnus-group-misc-menu))
317 (defun gnus-xmas-summary-menu-add ()
318 (gnus-xmas-menu-add summary
319 gnus-summary-misc-menu gnus-summary-kill-menu
320 gnus-summary-article-menu gnus-summary-thread-menu
321 gnus-summary-post-menu ))
323 (defun gnus-xmas-article-menu-add ()
324 (gnus-xmas-menu-add article
325 gnus-article-article-menu gnus-article-treatment-menu))
327 (defun gnus-xmas-score-menu-add ()
328 (gnus-xmas-menu-add score
331 (defun gnus-xmas-pick-menu-add ()
332 (gnus-xmas-menu-add pick
335 (defun gnus-xmas-topic-menu-add ()
336 (gnus-xmas-menu-add topic
339 (defun gnus-xmas-binary-menu-add ()
340 (gnus-xmas-menu-add binary
343 (defun gnus-xmas-agent-summary-menu-add ()
344 (gnus-xmas-menu-add agent-summary
345 gnus-agent-summary-menu))
347 (defun gnus-xmas-agent-group-menu-add ()
348 (gnus-xmas-menu-add agent-group
349 gnus-agent-group-menu))
351 (defun gnus-xmas-agent-server-menu-add ()
352 (gnus-xmas-menu-add agent-server
353 gnus-agent-server-menu))
355 (defun gnus-xmas-tree-menu-add ()
356 (gnus-xmas-menu-add tree
359 (defun gnus-xmas-draft-menu-add ()
360 (gnus-xmas-menu-add draft
363 (defun gnus-xmas-server-menu-add ()
364 (gnus-xmas-menu-add menu
365 gnus-server-server-menu gnus-server-connections-menu))
367 (defun gnus-xmas-browse-menu-add ()
368 (gnus-xmas-menu-add browse
371 (defun gnus-xmas-grouplens-menu-add ()
372 (gnus-xmas-menu-add grouplens
373 gnus-grouplens-menu))
375 (defun gnus-xmas-read-event-char ()
376 "Get the next event."
377 (let ((event (next-command-event)))
379 ;; We junk all non-key events. Is this naughty?
380 (while (not (or (key-press-event-p event)
381 (button-press-event-p event)))
382 (dispatch-event event)
383 (setq event (next-command-event)))
384 (cons (and (key-press-event-p event)
385 (event-to-character event))
388 (defun gnus-xmas-define ()
389 (setq gnus-mouse-2 [button2])
390 (setq gnus-mouse-3 [button3])
391 (setq gnus-widget-button-keymap widget-button-keymap)
393 (unless (memq 'underline (face-list))
394 (and (fboundp 'make-face)
395 (funcall (intern "make-face") 'underline)))
396 ;; Must avoid calling set-face-underline-p directly, because it
397 ;; is a defsubst in emacs19, and will make the .elc files non
399 (unless (face-differs-from-default-p 'underline)
400 (funcall (intern "set-face-underline-p") 'underline t))
403 ((fboundp 'char-or-char-int-p)
404 ;; Handle both types of marks for XEmacs-20.x.
405 (fset 'gnus-characterp 'char-or-char-int-p))
406 ;; V19 of XEmacs, probably.
408 (fset 'gnus-characterp 'characterp)))
410 (fset 'gnus-make-overlay 'make-extent)
411 (fset 'gnus-delete-overlay 'delete-extent)
412 (fset 'gnus-overlay-put 'set-extent-property)
413 (fset 'gnus-move-overlay 'gnus-xmas-move-overlay)
414 (fset 'gnus-overlay-end 'extent-end-position)
415 (fset 'gnus-kill-all-overlays 'gnus-xmas-kill-all-overlays)
416 (fset 'gnus-extent-detached-p 'extent-detached-p)
417 (fset 'gnus-add-text-properties 'gnus-xmas-add-text-properties)
418 (fset 'gnus-put-text-property 'gnus-xmas-put-text-property)
419 (fset 'gnus-deactivate-mark 'ignore)
420 (fset 'gnus-window-edges 'window-pixel-edges)
422 (if (and (<= emacs-major-version 19)
423 (< emacs-minor-version 14))
424 (fset 'gnus-set-text-properties 'gnus-xmas-set-text-properties))
426 (when (fboundp 'turn-off-scroll-in-place)
427 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
429 (unless (boundp 'standard-display-table)
430 (setq standard-display-table nil))
432 (defvar gnus-mouse-face-prop 'highlight)
434 (defun gnus-byte-code (func)
435 "Return a form that can be `eval'ed based on FUNC."
436 (let ((fval (indirect-function func)))
437 (if (compiled-function-p fval)
439 (cons 'progn (cdr (cdr fval))))))
441 (fset 'gnus-x-color-values
442 (if (fboundp 'x-color-values)
445 (color-instance-rgb-components
446 (make-color-instance color))))))
448 (defun gnus-xmas-redefine ()
449 "Redefine lots of Gnus functions for XEmacs."
450 (fset 'gnus-summary-set-display-table 'gnus-xmas-summary-set-display-table)
451 (fset 'gnus-visual-turn-off-edit-menu 'identity)
452 (fset 'gnus-summary-recenter 'gnus-xmas-summary-recenter)
453 (fset 'gnus-extent-start-open 'gnus-xmas-extent-start-open)
454 (fset 'gnus-article-push-button 'gnus-xmas-article-push-button)
455 (fset 'gnus-window-top-edge 'gnus-xmas-window-top-edge)
456 (fset 'gnus-read-event-char 'gnus-xmas-read-event-char)
457 (fset 'gnus-group-startup-message 'gnus-xmas-group-startup-message)
458 (fset 'gnus-tree-minimize 'gnus-xmas-tree-minimize)
459 (fset 'gnus-appt-select-lowest-window
460 'gnus-xmas-appt-select-lowest-window)
461 (fset 'gnus-mail-strip-quoted-names 'gnus-xmas-mail-strip-quoted-names)
462 (fset 'gnus-character-to-event 'character-to-event)
463 (fset 'gnus-mode-line-buffer-identification
464 'gnus-xmas-mode-line-buffer-identification)
465 (fset 'gnus-key-press-event-p 'key-press-event-p)
466 (fset 'gnus-region-active-p 'region-active-p)
467 (fset 'gnus-annotation-in-region-p 'gnus-xmas-annotation-in-region-p)
468 (fset 'gnus-mime-button-menu 'gnus-xmas-mime-button-menu)
470 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
471 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
472 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add)
473 (add-hook 'gnus-score-mode-hook 'gnus-xmas-score-menu-add)
475 (add-hook 'gnus-pick-mode-hook 'gnus-xmas-pick-menu-add)
476 (add-hook 'gnus-topic-mode-hook 'gnus-xmas-topic-menu-add)
477 (add-hook 'gnus-tree-mode-hook 'gnus-xmas-tree-menu-add)
478 (add-hook 'gnus-binary-mode-hook 'gnus-xmas-binary-menu-add)
479 (add-hook 'gnus-grouplens-mode-hook 'gnus-xmas-grouplens-menu-add)
480 (add-hook 'gnus-server-mode-hook 'gnus-xmas-server-menu-add)
481 (add-hook 'gnus-browse-mode-hook 'gnus-xmas-browse-menu-add)
483 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar)
484 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
486 (add-hook 'gnus-agent-summary-mode-hook 'gnus-xmas-agent-summary-menu-add)
487 (add-hook 'gnus-agent-group-mode-hook 'gnus-xmas-agent-group-menu-add)
488 (add-hook 'gnus-agent-server-mode-hook 'gnus-xmas-agent-server-menu-add)
490 (add-hook 'gnus-draft-mode-hook 'gnus-xmas-draft-menu-add)
491 (add-hook 'gnus-summary-mode-hook
492 'gnus-xmas-switch-horizontal-scrollbar-off)
493 (add-hook 'gnus-tree-mode-hook 'gnus-xmas-switch-horizontal-scrollbar-off)
495 (when (featurep 'mule)
496 (defun gnus-truncate-string (str end-column &optional start-column padding)
497 "Truncate string STR to end at column END-COLUMN.
498 The optional 2nd arg START-COLUMN, if non-nil, specifies
499 the starting column; that means to return the characters occupying
500 columns START-COLUMN ... END-COLUMN of STR.
502 The optional 3rd arg PADDING, if non-nil, specifies a padding character
503 to add at the end of the result if STR doesn't reach column END-COLUMN,
504 or if END-COLUMN comes in the middle of a character in STR.
505 PADDING is also added at the beginning of the result
506 if column START-COLUMN appears in the middle of a character in STR.
508 If PADDING is nil, no padding is added in these cases, so
509 the resulting string may be narrower than END-COLUMN.
510 \[Emacs 20.3 emulating function]"
512 (setq start-column 0))
513 (let ((len (length str))
516 (head-padding "") (tail-padding "")
517 ch last-column last-idx from-idx)
519 (while (< column start-column)
520 (setq ch (aref str idx)
521 column (+ column (char-width ch))
523 (args-out-of-range (setq idx len)))
524 (if (< column start-column)
525 (if padding (make-string end-column padding) "")
526 (if (and padding (> column start-column))
528 (make-string (- column start-column) padding)))
530 (if (< end-column column)
533 (while (< column end-column)
534 (setq last-column column
537 column (+ column (char-width ch))
539 (args-out-of-range (setq idx len)))
540 (if (> column end-column)
541 (setq column last-column idx last-idx))
542 (if (and padding (< column end-column))
544 (make-string (- end-column column) padding))))
545 (setq str (substring str from-idx idx))
547 (concat head-padding str tail-padding)
550 (defun gnus-tilde-pad-form (el pad-width)
551 "Return a form that pads EL to PAD-WIDTH."
552 (let ((pad (abs pad-width)))
555 `(let ((val (format "%s" ,el)))
556 (concat val (make-string
557 (max 0 (- ,pad (string-width val))) ?\ )))
558 `(let ((val (format "%s" ,el)))
560 (max 0 (- ,pad (string-width val))) ?\ )
563 `(let ((val (eval ,el)))
564 (concat val (make-string
565 (max 0 (- ,pad (string-width val))) ?\ )))
566 `(let ((val (eval ,el)))
568 (max 0 (- ,pad (string-width val))) ?\ )
571 (defun gnus-tilde-max-form (el max-width)
572 "Return a form that limits EL to MAX-WIDTH."
573 (let ((max (abs max-width)))
576 `(let ((width (string-width ,el)))
577 (gnus-truncate-string ,el width (- width ,max)))
578 `(gnus-truncate-string ,el ,max))
580 `(let* ((val (eval ,el))
581 (width (string-width val)))
582 (gnus-truncate-string val width (- width ,max)))
583 `(let ((val (eval ,el)))
584 (gnus-truncate-string val ,max))))))
586 (defun gnus-tilde-cut-form (el cut-width)
587 "Return a form that cuts CUT-WIDTH off of EL."
588 (let ((cut (abs cut-width)))
591 `(gnus-truncate-string ,el (- (string-width ,el) ,cut))
592 `(gnus-truncate-string ,el (string-width ,el) ,cut))
594 `(let ((val (eval ,el)))
595 (gnus-truncate-string val (- (string-width val) ,cut)))
596 `(let ((val (eval ,el)))
597 (gnus-truncate-string val (string-width val) ,cut))))))
600 ;;; XEmacs logo and toolbar.
602 (defun gnus-xmas-group-startup-message (&optional x y)
603 "Insert startup message in current buffer."
604 ;; Insert the message.
605 (setq gnus-xmas-glyph-directory (message-xmas-find-glyph-directory "gnus"))
608 ((and (console-on-window-system-p)
611 (let* ((logo-xpm (expand-file-name "gnus.xpm" gnus-xmas-glyph-directory))
612 (logo-xbm (expand-file-name "gnus.xbm" gnus-xmas-glyph-directory))
614 (cond ((featurep 'xpm)
618 (("thing" . ,(car gnus-xmas-logo-colors))
619 ("shadow" . ,(cadr gnus-xmas-logo-colors))
620 ("background" . ,(face-background 'default)))])
622 `[xbm :file ,logo-xbm])
625 (set-extent-begin-glyph (make-extent (point) (point)) glyph)
626 (goto-char (point-min))
628 (insert (make-string (/ (max (- (window-width) (or x 35)) 0) 2)
631 (setq gnus-simple-splash nil))
632 (goto-char (point-min))
633 (let* ((pheight (+ 20 (count-lines (point-min) (point-max))))
634 (wheight (window-height))
635 (rest (- wheight pheight)))
636 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n))))
641 _ ___ __ ___ __ _ ___
661 (gnus-indent-rigidly (point-min) (point-max)
662 (/ (max (- (window-width) (or x 46)) 0) 2))
663 (goto-char (point-min))
665 (let* ((pheight (count-lines (point-min) (point-max)))
666 (wheight (window-height))
667 (rest (- wheight pheight)))
668 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
670 (put-text-property (point-min) (point-max) 'face 'gnus-splash-face)))
671 (setq modeline-buffer-identification
672 (list (concat gnus-version ": *Group*")))
673 (set-buffer-modified-p t))
678 (defcustom gnus-use-toolbar (if (featurep 'toolbar)
681 "*If nil, do not use a toolbar.
682 If it is non-nil, it must be a toolbar. The five legal values are
683 `default-toolbar', `top-toolbar', `bottom-toolbar',
684 `right-toolbar', and `left-toolbar'."
685 :type '(choice (const default-toolbar)
686 (const top-toolbar) (const bottom-toolbar)
687 (const left-toolbar) (const right-toolbar)
688 (const :tag "no toolbar" nil))
691 (defvar gnus-group-toolbar
692 '([gnus-group-get-new-news gnus-group-get-new-news t "Get new news"]
693 [gnus-group-get-new-news-this-group
694 gnus-group-get-new-news-this-group t "Get new news in this group"]
695 [gnus-group-catchup-current
696 gnus-group-catchup-current t "Catchup group"]
697 [gnus-group-describe-group
698 gnus-group-describe-group t "Describe group"]
699 [gnus-group-unsubscribe gnus-group-unsubscribe t "Unsubscribe group"]
700 [gnus-group-subscribe gnus-group-subscribe t "Subscribe group"]
701 [gnus-group-kill-group gnus-group-kill-group t "Kill group"]
702 [gnus-group-exit gnus-group-exit t "Exit Gnus"]
704 "The group buffer toolbar.")
706 (defvar gnus-summary-toolbar
707 '([gnus-summary-prev-unread
708 gnus-summary-prev-page-or-article t "Page up"]
709 [gnus-summary-next-unread
710 gnus-summary-next-page t "Page down"]
711 [gnus-summary-post-news
712 gnus-summary-post-news t "Post an article"]
713 [gnus-summary-followup-with-original
714 gnus-summary-followup-with-original t
715 "Post a followup and yank the original"]
716 [gnus-summary-followup
717 gnus-summary-followup t "Post a followup"]
718 [gnus-summary-reply-with-original
719 gnus-summary-reply-with-original t "Mail a reply and yank the original"]
721 gnus-summary-reply t "Mail a reply"]
722 [gnus-summary-caesar-message
723 gnus-summary-caesar-message t "Rot 13"]
725 gnus-uu-decode-uu t "Decode uuencoded articles"]
726 [gnus-summary-save-article-file
727 gnus-summary-save-article-file t "Save article in file"]
728 [gnus-summary-save-article
729 gnus-summary-save-article t "Save article"]
731 gnus-uu-post-news t "Post a uuencoded article"]
732 [gnus-summary-cancel-article
733 gnus-summary-cancel-article t "Cancel article"]
734 [gnus-summary-catchup
735 gnus-summary-catchup t "Catchup"]
736 [gnus-summary-catchup-and-exit
737 gnus-summary-catchup-and-exit t "Catchup and exit"]
738 [gnus-summary-exit gnus-summary-exit t "Exit this summary"]
740 "The summary buffer toolbar.")
742 (defvar gnus-summary-mail-toolbar
744 [gnus-summary-prev-unread
745 gnus-summary-prev-unread-article t "Prev unread article"]
746 [gnus-summary-next-unread
747 gnus-summary-next-unread-article t "Next unread article"]
748 [gnus-summary-mail-reply gnus-summary-reply t "Reply"]
749 ; [gnus-summary-mail-get gnus-mail-get t "Message get"]
750 [gnus-summary-mail-originate gnus-summary-post-news t "Originate"]
751 [gnus-summary-mail-save gnus-summary-save-article t "Save"]
752 [gnus-summary-mail-copy gnus-summary-copy-article t "Copy message"]
753 ; [gnus-summary-mail-delete gnus-summary-delete-article t "Delete message"]
754 [gnus-summary-mail-forward gnus-summary-mail-forward t "Forward message"]
755 ; [gnus-summary-mail-spell gnus-mail-spell t "Spell"]
756 ; [gnus-summary-mail-help gnus-mail-help t "Message help"]
757 [gnus-summary-caesar-message
758 gnus-summary-caesar-message t "Rot 13"]
760 gnus-uu-decode-uu t "Decode uuencoded articles"]
761 [gnus-summary-save-article-file
762 gnus-summary-save-article-file t "Save article in file"]
763 [gnus-summary-save-article
764 gnus-summary-save-article t "Save article"]
765 [gnus-summary-catchup
766 gnus-summary-catchup t "Catchup"]
767 [gnus-summary-catchup-and-exit
768 gnus-summary-catchup-and-exit t "Catchup and exit"]
769 [gnus-summary-exit gnus-summary-exit t "Exit this summary"]
771 "The summary buffer mail toolbar.")
773 (defun gnus-xmas-setup-group-toolbar ()
774 (and gnus-use-toolbar
775 (message-xmas-setup-toolbar gnus-group-toolbar nil "gnus")
776 (set-specifier (symbol-value gnus-use-toolbar)
777 (cons (current-buffer) gnus-group-toolbar))))
779 (defun gnus-xmas-setup-summary-toolbar ()
780 (let ((bar (if (gnus-news-group-p gnus-newsgroup-name)
781 gnus-summary-toolbar gnus-summary-mail-toolbar)))
782 (and gnus-use-toolbar
783 (message-xmas-setup-toolbar bar nil "gnus")
784 (set-specifier (symbol-value gnus-use-toolbar)
785 (cons (current-buffer) bar)))))
787 (defun gnus-xmas-mail-strip-quoted-names (address)
788 "Protect mail-strip-quoted-names from NIL input.
789 XEmacs compatibility workaround."
792 (mail-strip-quoted-names address)))
794 (defun gnus-xmas-call-region (command &rest args)
796 'call-process-region (point-min) (point-max) command t '(t nil) nil
799 (defface gnus-x-face '((t (:foreground "black" :background "white")))
800 "Face to show X face"
803 (defun gnus-xmas-article-display-xface (beg end)
804 "Display any XFace headers in the current article."
807 (cond ((featurep 'xface)
808 (make-glyph (vector 'xface :data
810 (buffer-substring beg end)))))
812 (let ((cur (current-buffer)))
814 (gnus-set-work-buffer)
815 (insert (format "%s" (buffer-substring beg end cur)))
816 (gnus-xmas-call-region "uncompface")
817 (goto-char (point-min))
818 (insert "/* Width=48, Height=48 */\n")
819 (gnus-xmas-call-region "icontopbm")
820 (gnus-xmas-call-region "ppmtoxpm")
822 (vector 'xpm :data (buffer-string))))))
824 (make-glyph [nothing]))))
825 (ext (make-extent (progn
826 (goto-char (point-min))
827 (re-search-forward "^From:" nil t)
830 (set-glyph-face xface-glyph 'gnus-x-face)
831 (set-extent-begin-glyph ext xface-glyph)
832 (set-extent-property ext 'duplicable t))))
834 ;;(defvar gnus-xmas-pointer-glyph
836 ;; (setq gnus-xmas-glyph-directory (message-xmas-find-glyph-directory
838 ;; (let ((file-xpm (expand-file-name "gnus-pointer.xpm"
839 ;; gnus-xmas-glyph-directory))
840 ;; (file-xbm (expand-file-name "gnus-pointer.xbm"
841 ;; gnus-xmas-glyph-directory)))
842 ;; (make-pointer-glyph
843 ;; (list (vector 'xpm ':file file-xpm)
844 ;; (vector 'xbm ':file file-xbm))))))
846 (defvar gnus-xmas-modeline-left-extent
847 (let ((ext (copy-extent modeline-buffer-id-left-extent)))
848 ; (set-extent-property ext 'pointer gnus-xmas-pointer-glyph)
851 (defvar gnus-xmas-modeline-right-extent
852 (let ((ext (copy-extent modeline-buffer-id-right-extent)))
853 ; (set-extent-property ext 'pointer gnus-xmas-pointer-glyph)
856 (defvar gnus-xmas-modeline-glyph
858 (setq gnus-xmas-glyph-directory (message-xmas-find-glyph-directory "gnus"))
859 (let* ((file-xpm (expand-file-name "gnus-pointer.xpm"
860 gnus-xmas-glyph-directory))
861 (file-xbm (expand-file-name "gnus-pointer.xbm"
862 gnus-xmas-glyph-directory))
865 (cond ((featurep 'xpm)
866 ;; Let's try a nifty XPM
867 `[xpm :file ,file-xpm])
869 ;; Then a not-so-nifty XBM
870 [xbm :file ,file-xbm])
871 ;; Then the simple string
872 (t [string :data "Gnus:"])))))
873 (set-glyph-face glyph 'modeline-buffer-id)
876 (defun gnus-xmas-mode-line-buffer-identification (line)
877 (let ((line (car line))
880 ;; This is some weird type of id.
881 ((not (stringp line))
883 ;; This is non-standard, so we just pass it through.
884 ((not (string-match "^Gnus:" line))
886 ;; We have a standard line, so we colorize and glyphize it a bit.
888 (setq chop (match-end 0))
890 (if gnus-xmas-modeline-glyph
891 (cons gnus-xmas-modeline-left-extent gnus-xmas-modeline-glyph)
892 (cons gnus-xmas-modeline-left-extent (substring line 0 chop)))
893 (cons gnus-xmas-modeline-right-extent (substring line chop)))))))
895 (defun gnus-xmas-splash ()
896 (when (eq (device-type) 'x)
899 (defun gnus-xmas-annotation-in-region-p (b e)
900 (map-extents (lambda (e u) t) nil b e nil nil 'mm t))
902 (defun gnus-xmas-mime-button-menu (event)
903 "Construct a context-sensitive menu of MIME commands."
905 (let ((response (get-popup-menu-response
907 ,@(mapcar (lambda (c) `[,(caddr c) ,(car c) t])
908 gnus-mime-button-commands)))))
909 (set-buffer (event-buffer event))
910 (goto-char (event-point event))
911 (funcall (event-function response) (event-object response))))
916 ;;; gnus-xmas.el ends here