1 ;;; gnus-xmas.el --- Gnus functions for XEmacs
2 ;; Copyright (C) 1995,96,97,98,99 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 | ee -")
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)
185 (t (if (numberp gnus-auto-center-summary)
186 gnus-auto-center-summary
188 (bottom (save-excursion (goto-char (point-max))
189 (forward-line (- height))
191 (window (get-buffer-window (current-buffer))))
192 (when (get-buffer-window gnus-article-buffer)
193 ;; Only do recentering when the article buffer is displayed,
194 ;; Set the window start to either `bottom', which is the biggest
195 ;; possible valid number, or the second line from the top,
196 ;; whichever is the least.
198 window (min bottom (save-excursion (forward-line (- top)) (point)))))
199 ;; Do horizontal recentering while we're at it.
200 (when (and (get-buffer-window (current-buffer) t)
201 (not (eq gnus-auto-center-summary 'vertical)))
202 (let ((selected (selected-window)))
203 (select-window (get-buffer-window (current-buffer) t))
204 (gnus-summary-position-point)
205 (gnus-horizontal-recenter)
206 (select-window selected))))))
208 (defun gnus-xmas-summary-set-display-table ()
209 ;; Setup the display table -- like `gnus-summary-setup-display-table',
210 ;; but done in an XEmacsish way.
211 (let ((table (make-display-table))
213 ;; Nix out all the control chars...
214 (while (>= (setq i (1- i)) 0)
216 ;; ... but not newline and cr, of course. (cr is necessary for the
217 ;; selective display).
220 ;; We keep TAB as well.
222 ;; We nix out any glyphs over 126 below ctl-arrow.
223 (let ((i (if (integerp ctl-arrow) ctl-arrow 160)))
224 (while (>= (setq i (1- i)) 127)
225 (unless (aref table i)
226 (aset table i [??]))))
227 ;; Can't use `set-specifier' because of a bug in 19.14 and earlier
228 (add-spec-to-specifier current-display-table table (current-buffer) nil)))
230 (defun gnus-xmas-add-text-properties (start end props &optional object)
231 (add-text-properties start end props object)
232 (put-text-property start end 'start-closed nil object))
234 (defun gnus-xmas-put-text-property (start end prop value &optional object)
235 (put-text-property start end prop value object)
236 (put-text-property start end 'start-closed nil object))
238 (defun gnus-xmas-extent-start-open (point)
239 (map-extents (lambda (extent arg)
240 (set-extent-property extent 'start-open t))
241 nil point (min (1+ (point)) (point-max))))
243 (defun gnus-xmas-article-push-button (event)
244 "Check text under the mouse pointer for a callback function.
245 If the text under the mouse pointer has a `gnus-callback' property,
246 call it with the value of the `gnus-data' text property."
248 (set-buffer (window-buffer (event-window event)))
249 (let* ((pos (event-closest-point event))
250 (data (get-text-property pos 'gnus-data))
251 (fun (get-text-property pos 'gnus-callback)))
254 (funcall fun data))))
256 (defun gnus-xmas-move-overlay (extent start end &optional buffer)
257 (set-extent-endpoints extent start end buffer))
259 (defun gnus-xmas-kill-all-overlays ()
260 "Delete all extents in the current buffer."
261 (map-extents (lambda (extent ignore)
262 (delete-extent extent)
265 (defun gnus-xmas-window-top-edge (&optional window)
266 (nth 1 (window-pixel-edges window)))
268 (defun gnus-xmas-tree-minimize ()
269 (when (and gnus-tree-minimize-window
270 (not (one-window-p)))
271 (let* ((window-min-height 2)
272 (height (1+ (count-lines (point-min) (point-max))))
273 (min (max (1- window-min-height) height))
274 (tot (if (numberp gnus-tree-minimize-window)
275 (min gnus-tree-minimize-window min)
277 (win (get-buffer-window (current-buffer)))
278 (wh (and win (1- (window-height win)))))
281 (let ((selected (selected-window)))
283 (enlarge-window (- tot wh))
284 (select-window selected))))))
286 ;; Select the lowest window on the frame.
287 (defun gnus-xmas-appt-select-lowest-window ()
288 (let* ((lowest-window (selected-window))
289 (bottom-edge (car (cdr (cdr (cdr (window-pixel-edges))))))
290 (last-window (previous-window))
293 (let* ((this-window (next-window))
294 (next-bottom-edge (car (cdr (cdr (cdr
297 (when (< bottom-edge next-bottom-edge)
298 (setq bottom-edge next-bottom-edge)
299 (setq lowest-window this-window))
301 (select-window this-window)
302 (when (eq last-window this-window)
303 (select-window lowest-window)
304 (setq window-search nil))))))
306 (defmacro gnus-xmas-menu-add (type &rest menus)
307 `(gnus-xmas-menu-add-1 ',type ',menus))
308 (put 'gnus-xmas-menu-add 'lisp-indent-function 1)
310 (defun gnus-xmas-menu-add-1 (type menus)
311 (when (and menu-bar-mode
312 (gnus-visual-p (intern (format "%s-menu" type)) 'menu))
314 (easy-menu-add (symbol-value (pop menus))))))
316 (defun gnus-xmas-group-menu-add ()
317 (gnus-xmas-menu-add group
318 gnus-group-reading-menu gnus-group-group-menu gnus-group-misc-menu))
320 (defun gnus-xmas-summary-menu-add ()
321 (gnus-xmas-menu-add summary
322 gnus-summary-misc-menu gnus-summary-kill-menu
323 gnus-summary-article-menu gnus-summary-thread-menu
324 gnus-summary-post-menu ))
326 (defun gnus-xmas-article-menu-add ()
327 (gnus-xmas-menu-add article
328 gnus-article-article-menu gnus-article-treatment-menu))
330 (defun gnus-xmas-score-menu-add ()
331 (gnus-xmas-menu-add score
334 (defun gnus-xmas-pick-menu-add ()
335 (gnus-xmas-menu-add pick
338 (defun gnus-xmas-topic-menu-add ()
339 (gnus-xmas-menu-add topic
342 (defun gnus-xmas-binary-menu-add ()
343 (gnus-xmas-menu-add binary
346 (defun gnus-xmas-agent-summary-menu-add ()
347 (gnus-xmas-menu-add agent-summary
348 gnus-agent-summary-menu))
350 (defun gnus-xmas-agent-group-menu-add ()
351 (gnus-xmas-menu-add agent-group
352 gnus-agent-group-menu))
354 (defun gnus-xmas-agent-server-menu-add ()
355 (gnus-xmas-menu-add agent-server
356 gnus-agent-server-menu))
358 (defun gnus-xmas-tree-menu-add ()
359 (gnus-xmas-menu-add tree
362 (defun gnus-xmas-draft-menu-add ()
363 (gnus-xmas-menu-add draft
366 (defun gnus-xmas-server-menu-add ()
367 (gnus-xmas-menu-add menu
368 gnus-server-server-menu gnus-server-connections-menu))
370 (defun gnus-xmas-browse-menu-add ()
371 (gnus-xmas-menu-add browse
374 (defun gnus-xmas-grouplens-menu-add ()
375 (gnus-xmas-menu-add grouplens
376 gnus-grouplens-menu))
378 (defun gnus-xmas-read-event-char ()
379 "Get the next event."
380 (let ((event (next-command-event)))
382 ;; We junk all non-key events. Is this naughty?
383 (while (not (or (key-press-event-p event)
384 (button-press-event-p event)))
385 (dispatch-event event)
386 (setq event (next-command-event)))
387 (cons (and (key-press-event-p event)
388 (event-to-character event))
391 (defun gnus-xmas-define ()
392 (setq gnus-mouse-2 [button2])
393 (setq gnus-mouse-3 [button3])
394 (setq gnus-widget-button-keymap widget-button-keymap)
396 (unless (memq 'underline (face-list))
397 (and (fboundp 'make-face)
398 (funcall (intern "make-face") 'underline)))
399 ;; Must avoid calling set-face-underline-p directly, because it
400 ;; is a defsubst in emacs19, and will make the .elc files non
402 (unless (face-differs-from-default-p 'underline)
403 (funcall (intern "set-face-underline-p") 'underline t))
406 ((fboundp 'char-or-char-int-p)
407 ;; Handle both types of marks for XEmacs-20.x.
408 (fset 'gnus-characterp 'char-or-char-int-p))
409 ;; V19 of XEmacs, probably.
411 (fset 'gnus-characterp 'characterp)))
413 (fset 'gnus-make-overlay 'make-extent)
414 (fset 'gnus-delete-overlay 'delete-extent)
415 (fset 'gnus-overlay-put 'set-extent-property)
416 (fset 'gnus-move-overlay 'gnus-xmas-move-overlay)
417 (fset 'gnus-overlay-end 'extent-end-position)
418 (fset 'gnus-kill-all-overlays 'gnus-xmas-kill-all-overlays)
419 (fset 'gnus-extent-detached-p 'extent-detached-p)
420 (fset 'gnus-add-text-properties 'gnus-xmas-add-text-properties)
421 (fset 'gnus-put-text-property 'gnus-xmas-put-text-property)
422 (fset 'gnus-deactivate-mark 'ignore)
423 (fset 'gnus-window-edges 'window-pixel-edges)
425 (if (and (<= emacs-major-version 19)
426 (< emacs-minor-version 14))
427 (fset 'gnus-set-text-properties 'gnus-xmas-set-text-properties))
429 (when (fboundp 'turn-off-scroll-in-place)
430 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
432 (unless (boundp 'standard-display-table)
433 (setq standard-display-table nil))
435 (defvar gnus-mouse-face-prop 'highlight)
437 (defun gnus-byte-code (func)
438 "Return a form that can be `eval'ed based on FUNC."
439 (let ((fval (indirect-function func)))
440 (if (compiled-function-p fval)
442 (cons 'progn (cdr (cdr fval))))))
444 (fset 'gnus-x-color-values
445 (if (fboundp 'x-color-values)
448 (color-instance-rgb-components
449 (make-color-instance color))))))
451 (defun gnus-xmas-redefine ()
452 "Redefine lots of Gnus functions for XEmacs."
453 (fset 'gnus-summary-set-display-table 'gnus-xmas-summary-set-display-table)
454 (fset 'gnus-visual-turn-off-edit-menu 'identity)
455 (fset 'gnus-summary-recenter 'gnus-xmas-summary-recenter)
456 (fset 'gnus-extent-start-open 'gnus-xmas-extent-start-open)
457 (fset 'gnus-article-push-button 'gnus-xmas-article-push-button)
458 (fset 'gnus-window-top-edge 'gnus-xmas-window-top-edge)
459 (fset 'gnus-read-event-char 'gnus-xmas-read-event-char)
460 (fset 'gnus-group-startup-message 'gnus-xmas-group-startup-message)
461 (fset 'gnus-tree-minimize 'gnus-xmas-tree-minimize)
462 (fset 'gnus-appt-select-lowest-window
463 'gnus-xmas-appt-select-lowest-window)
464 (fset 'gnus-mail-strip-quoted-names 'gnus-xmas-mail-strip-quoted-names)
465 (fset 'gnus-character-to-event 'character-to-event)
466 (fset 'gnus-mode-line-buffer-identification
467 'gnus-xmas-mode-line-buffer-identification)
468 (fset 'gnus-key-press-event-p 'key-press-event-p)
469 (fset 'gnus-region-active-p 'region-active-p)
470 (fset 'gnus-annotation-in-region-p 'gnus-xmas-annotation-in-region-p)
471 (fset 'gnus-mime-button-menu 'gnus-xmas-mime-button-menu)
473 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
474 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
475 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add)
476 (add-hook 'gnus-score-mode-hook 'gnus-xmas-score-menu-add)
478 (add-hook 'gnus-pick-mode-hook 'gnus-xmas-pick-menu-add)
479 (add-hook 'gnus-topic-mode-hook 'gnus-xmas-topic-menu-add)
480 (add-hook 'gnus-tree-mode-hook 'gnus-xmas-tree-menu-add)
481 (add-hook 'gnus-binary-mode-hook 'gnus-xmas-binary-menu-add)
482 (add-hook 'gnus-grouplens-mode-hook 'gnus-xmas-grouplens-menu-add)
483 (add-hook 'gnus-server-mode-hook 'gnus-xmas-server-menu-add)
484 (add-hook 'gnus-browse-mode-hook 'gnus-xmas-browse-menu-add)
486 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar)
487 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
489 (add-hook 'gnus-agent-summary-mode-hook 'gnus-xmas-agent-summary-menu-add)
490 (add-hook 'gnus-agent-group-mode-hook 'gnus-xmas-agent-group-menu-add)
491 (add-hook 'gnus-agent-server-mode-hook 'gnus-xmas-agent-server-menu-add)
493 (add-hook 'gnus-draft-mode-hook 'gnus-xmas-draft-menu-add)
494 (add-hook 'gnus-summary-mode-hook
495 'gnus-xmas-switch-horizontal-scrollbar-off)
496 (add-hook 'gnus-tree-mode-hook 'gnus-xmas-switch-horizontal-scrollbar-off)
498 (when (featurep 'mule)
499 (defun gnus-truncate-string (str end-column &optional start-column padding)
500 "Truncate string STR to end at column END-COLUMN.
501 The optional 2nd arg START-COLUMN, if non-nil, specifies
502 the starting column; that means to return the characters occupying
503 columns START-COLUMN ... END-COLUMN of STR.
505 The optional 3rd arg PADDING, if non-nil, specifies a padding character
506 to add at the end of the result if STR doesn't reach column END-COLUMN,
507 or if END-COLUMN comes in the middle of a character in STR.
508 PADDING is also added at the beginning of the result
509 if column START-COLUMN appears in the middle of a character in STR.
511 If PADDING is nil, no padding is added in these cases, so
512 the resulting string may be narrower than END-COLUMN.
513 \[Emacs 20.3 emulating function]"
515 (setq start-column 0))
516 (let ((len (length str))
519 (head-padding "") (tail-padding "")
520 ch last-column last-idx from-idx)
522 (while (< column start-column)
523 (setq ch (aref str idx)
524 column (+ column (char-width ch))
526 (args-out-of-range (setq idx len)))
527 (if (< column start-column)
528 (if padding (make-string end-column padding) "")
529 (if (and padding (> column start-column))
531 (make-string (- column start-column) padding)))
533 (if (< end-column column)
536 (while (< column end-column)
537 (setq last-column column
540 column (+ column (char-width ch))
542 (args-out-of-range (setq idx len)))
543 (if (> column end-column)
544 (setq column last-column idx last-idx))
545 (if (and padding (< column end-column))
547 (make-string (- end-column column) padding))))
548 (setq str (substring str from-idx idx))
550 (concat head-padding str tail-padding)
553 (defun gnus-tilde-pad-form (el pad-width)
554 "Return a form that pads EL to PAD-WIDTH."
555 (let ((pad (abs pad-width)))
558 `(let ((val (format "%s" ,el)))
559 (concat val (make-string
560 (max 0 (- ,pad (string-width val))) ?\ )))
561 `(let ((val (format "%s" ,el)))
563 (max 0 (- ,pad (string-width val))) ?\ )
566 `(let ((val (eval ,el)))
567 (concat val (make-string
568 (max 0 (- ,pad (string-width val))) ?\ )))
569 `(let ((val (eval ,el)))
571 (max 0 (- ,pad (string-width val))) ?\ )
574 (defun gnus-tilde-max-form (el max-width)
575 "Return a form that limits EL to MAX-WIDTH."
576 (let ((max (abs max-width)))
579 `(let ((width (string-width ,el)))
580 (gnus-truncate-string ,el width (- width ,max)))
581 `(gnus-truncate-string ,el ,max))
583 `(let* ((val (eval ,el))
584 (width (string-width val)))
585 (gnus-truncate-string val width (- width ,max)))
586 `(let ((val (eval ,el)))
587 (gnus-truncate-string val ,max))))))
589 (defun gnus-tilde-cut-form (el cut-width)
590 "Return a form that cuts CUT-WIDTH off of EL."
591 (let ((cut (abs cut-width)))
594 `(gnus-truncate-string ,el (- (string-width ,el) ,cut))
595 `(gnus-truncate-string ,el (string-width ,el) ,cut))
597 `(let ((val (eval ,el)))
598 (gnus-truncate-string val (- (string-width val) ,cut)))
599 `(let ((val (eval ,el)))
600 (gnus-truncate-string val (string-width val) ,cut))))))
603 ;;; XEmacs logo and toolbar.
605 (defun gnus-xmas-group-startup-message (&optional x y)
606 "Insert startup message in current buffer."
607 ;; Insert the message.
608 (setq gnus-xmas-glyph-directory (message-xmas-find-glyph-directory "gnus"))
611 ((and (console-on-window-system-p)
614 (let* ((logo-xpm (expand-file-name "gnus.xpm" gnus-xmas-glyph-directory))
615 (logo-xbm (expand-file-name "gnus.xbm" gnus-xmas-glyph-directory))
617 (cond ((featurep 'xpm)
621 (("thing" . ,(car gnus-xmas-logo-colors))
622 ("shadow" . ,(cadr gnus-xmas-logo-colors))
623 ("background" . ,(face-background 'default)))])
625 `[xbm :file ,logo-xbm])
628 (set-extent-begin-glyph (make-extent (point) (point)) glyph)
629 (goto-char (point-min))
631 (insert (make-string (/ (max (- (window-width) (or x 35)) 0) 2)
634 (setq gnus-simple-splash nil))
635 (goto-char (point-min))
636 (let* ((pheight (+ 20 (count-lines (point-min) (point-max))))
637 (wheight (window-height))
638 (rest (- wheight pheight)))
639 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n))))
644 _ ___ __ ___ __ _ ___
664 (gnus-indent-rigidly (point-min) (point-max)
665 (/ (max (- (window-width) (or x 46)) 0) 2))
666 (goto-char (point-min))
668 (let* ((pheight (count-lines (point-min) (point-max)))
669 (wheight (window-height))
670 (rest (- wheight pheight)))
671 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
673 (put-text-property (point-min) (point-max) 'face 'gnus-splash-face)))
674 (setq modeline-buffer-identification
675 (list (concat gnus-version ": *Group*")))
676 (set-buffer-modified-p t))
681 (defcustom gnus-use-toolbar (if (featurep 'toolbar)
684 "*If nil, do not use a toolbar.
685 If it is non-nil, it must be a toolbar. The five valid values are
686 `default-toolbar', `top-toolbar', `bottom-toolbar',
687 `right-toolbar', and `left-toolbar'."
688 :type '(choice (const default-toolbar)
689 (const top-toolbar) (const bottom-toolbar)
690 (const left-toolbar) (const right-toolbar)
691 (const :tag "no toolbar" nil))
694 (defvar gnus-group-toolbar
695 '([gnus-group-get-new-news gnus-group-get-new-news t "Get new news"]
696 [gnus-group-get-new-news-this-group
697 gnus-group-get-new-news-this-group t "Get new news in this group"]
698 [gnus-group-catchup-current
699 gnus-group-catchup-current t "Catchup group"]
700 [gnus-group-describe-group
701 gnus-group-describe-group t "Describe group"]
702 [gnus-group-unsubscribe gnus-group-unsubscribe t "Unsubscribe group"]
703 [gnus-group-subscribe gnus-group-subscribe t "Subscribe group"]
704 [gnus-group-kill-group gnus-group-kill-group t "Kill group"]
705 [gnus-group-exit gnus-group-exit t "Exit Gnus"])
706 "The group buffer toolbar.")
708 (defvar gnus-summary-toolbar
709 '([gnus-summary-prev-unread
710 gnus-summary-prev-page-or-article t "Page up"]
711 [gnus-summary-next-unread
712 gnus-summary-next-page t "Page down"]
713 [gnus-summary-post-news
714 gnus-summary-post-news t "Post an article"]
715 [gnus-summary-followup-with-original
716 gnus-summary-followup-with-original t
717 "Post a followup and yank the original"]
718 [gnus-summary-followup
719 gnus-summary-followup t "Post a followup"]
720 [gnus-summary-reply-with-original
721 gnus-summary-reply-with-original t "Mail a reply and yank the original"]
723 gnus-summary-reply t "Mail a reply"]
724 [gnus-summary-caesar-message
725 gnus-summary-caesar-message t "Rot 13"]
727 gnus-uu-decode-uu t "Decode uuencoded articles"]
728 [gnus-summary-save-article-file
729 gnus-summary-save-article-file t "Save article in file"]
730 [gnus-summary-save-article
731 gnus-summary-save-article t "Save article"]
733 gnus-uu-post-news t "Post a uuencoded article"]
734 [gnus-summary-cancel-article
735 gnus-summary-cancel-article t "Cancel article"]
736 [gnus-summary-catchup
737 gnus-summary-catchup t "Catchup"]
738 [gnus-summary-catchup-and-exit
739 gnus-summary-catchup-and-exit t "Catchup and exit"]
740 [gnus-summary-exit gnus-summary-exit t "Exit this summary"]
742 "The summary buffer toolbar.")
744 (defvar gnus-summary-mail-toolbar
746 [gnus-summary-prev-unread
747 gnus-summary-prev-unread-article t "Prev unread article"]
748 [gnus-summary-next-unread
749 gnus-summary-next-unread-article t "Next unread article"]
750 [gnus-summary-mail-reply gnus-summary-reply t "Reply"]
751 ; [gnus-summary-mail-get gnus-mail-get t "Message get"]
752 [gnus-summary-mail-originate gnus-summary-post-news t "Originate"]
753 [gnus-summary-mail-save gnus-summary-save-article t "Save"]
754 [gnus-summary-mail-copy gnus-summary-copy-article t "Copy message"]
755 ; [gnus-summary-mail-delete gnus-summary-delete-article t "Delete message"]
756 [gnus-summary-mail-forward gnus-summary-mail-forward t "Forward message"]
757 ; [gnus-summary-mail-spell gnus-mail-spell t "Spell"]
758 ; [gnus-summary-mail-help gnus-mail-help t "Message help"]
759 [gnus-summary-caesar-message
760 gnus-summary-caesar-message t "Rot 13"]
762 gnus-uu-decode-uu t "Decode uuencoded articles"]
763 [gnus-summary-save-article-file
764 gnus-summary-save-article-file t "Save article in file"]
765 [gnus-summary-save-article
766 gnus-summary-save-article t "Save article"]
767 [gnus-summary-catchup
768 gnus-summary-catchup t "Catchup"]
769 [gnus-summary-catchup-and-exit
770 gnus-summary-catchup-and-exit t "Catchup and exit"]
771 [gnus-summary-exit gnus-summary-exit t "Exit this summary"]
773 "The summary buffer mail toolbar.")
775 (defun gnus-xmas-setup-group-toolbar ()
776 (and gnus-use-toolbar
777 (message-xmas-setup-toolbar gnus-group-toolbar nil "gnus")
778 (set-specifier (symbol-value gnus-use-toolbar)
779 (cons (current-buffer) gnus-group-toolbar))))
781 (defun gnus-xmas-setup-summary-toolbar ()
782 (let ((bar (if (gnus-news-group-p gnus-newsgroup-name)
783 gnus-summary-toolbar gnus-summary-mail-toolbar)))
784 (and gnus-use-toolbar
785 (message-xmas-setup-toolbar bar nil "gnus")
786 (set-specifier (symbol-value gnus-use-toolbar)
787 (cons (current-buffer) bar)))))
789 (defun gnus-xmas-mail-strip-quoted-names (address)
790 "Protect mail-strip-quoted-names from NIL input.
791 XEmacs compatibility workaround."
794 (mail-strip-quoted-names address)))
796 (defun gnus-xmas-call-region (command &rest args)
798 'call-process-region (point-min) (point-max) command t '(t nil) nil
801 (defface gnus-x-face '((t (:foreground "black" :background "white")))
802 "Face to show X face"
805 (defun gnus-xmas-article-display-xface (beg end)
806 "Display any XFace headers in the current article."
811 (make-glyph (vector 'xface :data
813 (buffer-substring beg end)))))
815 (let ((cur (current-buffer)))
817 (gnus-set-work-buffer)
818 (insert (format "%s" (buffer-substring beg end cur)))
819 (gnus-xmas-call-region "uncompface")
820 (goto-char (point-min))
821 (insert "/* Width=48, Height=48 */\n")
822 (gnus-xmas-call-region "icontopbm")
823 (gnus-xmas-call-region "ppmtoxpm")
825 (vector 'xpm :data (buffer-string))))))
827 (make-glyph [nothing]))))
828 (ext (make-extent (progn
829 (goto-char (point-min))
830 (re-search-forward "^From:" nil t)
833 (set-glyph-face xface-glyph 'gnus-x-face)
834 (set-extent-begin-glyph ext xface-glyph)
835 (set-extent-property ext 'duplicable t))))
837 (defvar gnus-xmas-modeline-left-extent
838 (let ((ext (copy-extent modeline-buffer-id-left-extent)))
841 (defvar gnus-xmas-modeline-right-extent
842 (let ((ext (copy-extent modeline-buffer-id-right-extent)))
845 (defvar gnus-xmas-modeline-glyph
847 (setq gnus-xmas-glyph-directory (message-xmas-find-glyph-directory "gnus"))
848 (let* ((file-xpm (expand-file-name "gnus-pointer.xpm"
849 gnus-xmas-glyph-directory))
850 (file-xbm (expand-file-name "gnus-pointer.xbm"
851 gnus-xmas-glyph-directory))
854 (cond ((featurep 'xpm)
855 ;; Let's try a nifty XPM
856 `[xpm :file ,file-xpm])
858 ;; Then a not-so-nifty XBM
859 `[xbm :file ,file-xbm])
860 ;; Then the simple string
861 (t [string :data "Gnus:"])))))
862 (set-glyph-face glyph 'modeline-buffer-id)
865 (defun gnus-xmas-mode-line-buffer-identification (line)
866 (let ((line (car line))
869 ;; This is some weird type of id.
870 ((not (stringp line))
872 ;; This is non-standard, so we just pass it through.
873 ((not (string-match "^Gnus:" line))
875 ;; We have a standard line, so we colorize and glyphize it a bit.
877 (setq chop (match-end 0))
879 (if gnus-xmas-modeline-glyph
880 (cons gnus-xmas-modeline-left-extent gnus-xmas-modeline-glyph)
881 (cons gnus-xmas-modeline-left-extent (substring line 0 chop)))
882 (cons gnus-xmas-modeline-right-extent (substring line chop)))))))
884 (defun gnus-xmas-splash ()
885 (when (eq (device-type) 'x)
888 (defun gnus-xmas-annotation-in-region-p (b e)
889 (or (map-extents (lambda (e u) t) nil b e nil nil 'mm t)
891 (eq (cadr (memq 'gnus-undeletable (text-properties-at b))) t)
892 (text-property-any b e 'gnus-undeletable t))))
894 (defun gnus-xmas-mime-button-menu (event)
895 "Construct a context-sensitive menu of MIME commands."
897 (let ((response (get-popup-menu-response
899 ,@(mapcar (lambda (c) `[,(caddr c) ,(car c) t])
900 gnus-mime-button-commands)))))
901 (set-buffer (event-buffer event))
902 (goto-char (event-point event))
903 (funcall (event-function response) (event-object response))))
907 ;;; gnus-xmas.el ends here