1 ;;; gnus-xmas.el --- Gnus functions for XEmacs
3 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4 ;; Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
31 (defvar menu-bar-mode (featurep 'menubar))
32 (require 'messagexmas)
35 (defgroup gnus-xmas nil
36 "XEmacsoid support for Gnus"
39 (defcustom gnus-xmas-glyph-directory nil
40 "Directory where Gnus logos and icons are located.
41 If this variable is nil, Gnus will try to locate the directory
43 :type '(choice (const :tag "autodetect" nil)
47 (unless gnus-xmas-glyph-directory
48 (unless (setq gnus-xmas-glyph-directory
49 (message-xmas-find-glyph-directory "gnus"))
50 (error "Can't find glyph directory. \
51 Possibly the `etc' directory has not been installed.")))
53 ;;; Internal variables.
55 ;; Don't warn about these undefined variables.
58 (defvar gnus-active-hashtb)
59 (defvar gnus-article-buffer)
60 (defvar gnus-auto-center-summary)
61 (defvar gnus-current-headers)
62 (defvar gnus-level-killed)
63 (defvar gnus-level-zombie)
64 (defvar gnus-newsgroup-bookmarks)
65 (defvar gnus-newsgroup-dependencies)
66 (defvar gnus-newsgroup-selected-overlay)
67 (defvar gnus-newsrc-hashtb)
68 (defvar gnus-read-mark)
69 (defvar gnus-refer-article-method)
70 (defvar gnus-reffed-article-number)
71 (defvar gnus-unread-mark)
73 (defvar gnus-view-pseudos)
74 (defvar gnus-view-pseudos-separately)
76 (defvar gnus-zombie-list)
77 ;;defined in gnus-msg.el
78 (defvar gnus-article-copy)
79 (defvar gnus-check-before-posting)
80 ;;defined in gnus-vis.el
81 (defvar gnus-article-button-face)
82 (defvar gnus-article-mouse-face)
83 (defvar gnus-summary-selected-face)
84 (defvar gnus-group-reading-menu)
85 (defvar gnus-group-group-menu)
86 (defvar gnus-group-misc-menu)
87 (defvar gnus-summary-article-menu)
88 (defvar gnus-summary-thread-menu)
89 (defvar gnus-summary-misc-menu)
90 (defvar gnus-summary-post-menu)
91 (defvar gnus-summary-kill-menu)
92 (defvar gnus-article-article-menu)
93 (defvar gnus-article-treatment-menu)
95 (defvar standard-display-table)
96 (defvar gnus-tree-minimize-window)
98 (defun gnus-xmas-set-text-properties (start end props &optional buffer)
99 "You should NEVER use this function. It is ideologically blasphemous.
100 It is provided only to ease porting of broken FSF Emacs programs."
103 (map-extents (lambda (extent ignored)
104 (remove-text-properties
106 (list (extent-property extent 'text-prop) nil)
109 buffer start end nil nil 'text-prop)
110 (gnus-add-text-properties start end props buffer)))
112 (defun gnus-xmas-highlight-selected-summary ()
113 ;; Highlight selected article in summary buffer
114 (when gnus-summary-selected-face
115 (when gnus-newsgroup-selected-overlay
116 (delete-extent gnus-newsgroup-selected-overlay))
117 (setq gnus-newsgroup-selected-overlay
118 (make-extent (gnus-point-at-bol) (gnus-point-at-eol)))
119 (set-extent-face gnus-newsgroup-selected-overlay
120 gnus-summary-selected-face)))
122 (defcustom gnus-xmas-force-redisplay nil
123 "*If non-nil, force a redisplay before recentering the summary buffer.
124 This is ugly, but it works around a bug in `window-displayed-height'."
128 (defun gnus-xmas-switch-horizontal-scrollbar-off ()
129 (when (featurep 'scrollbar)
130 (set-specifier scrollbar-height (cons (current-buffer) 0))))
132 (defun gnus-xmas-summary-recenter ()
133 "\"Center\" point in the summary window.
134 If `gnus-auto-center-summary' is nil, or the article buffer isn't
135 displayed, no centering will be performed."
136 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
137 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
138 ;; Force redisplay to get properly computed window height.
139 (when gnus-xmas-force-redisplay
141 (when gnus-auto-center-summary
142 (let* ((height (if (fboundp 'window-displayed-height)
143 (window-displayed-height)
144 (- (window-height) 2)))
145 (top (cond ((< height 4) 0)
147 (t (if (numberp gnus-auto-center-summary)
148 gnus-auto-center-summary
150 (bottom (save-excursion (goto-char (point-max))
151 (forward-line (- height))
153 (window (get-buffer-window (current-buffer))))
154 (when (get-buffer-window gnus-article-buffer)
155 ;; Only do recentering when the article buffer is displayed,
156 ;; Set the window start to either `bottom', which is the biggest
157 ;; possible valid number, or the second line from the top,
158 ;; whichever is the least.
159 ;; NOFORCE parameter suggested by Daniel Pittman <daniel@danann.net>.
161 window (min bottom (save-excursion (forward-line (- top)) (point)))
163 ;; Do horizontal recentering while we're at it.
164 (when (and (get-buffer-window (current-buffer) t)
165 (not (eq gnus-auto-center-summary 'vertical)))
166 (let ((selected (selected-window)))
167 (select-window (get-buffer-window (current-buffer) t))
168 (gnus-summary-position-point)
169 (gnus-horizontal-recenter)
170 (select-window selected))))))
172 (defun gnus-xmas-summary-set-display-table ()
173 ;; Setup the display table -- like `gnus-summary-setup-display-table',
174 ;; but done in an XEmacsish way.
175 (let ((table (make-display-table))
177 ;; Nix out all the control chars...
178 (while (>= (setq i (1- i)) 0)
180 ;; ... but not newline and cr, of course. (cr is necessary for the
181 ;; selective display).
184 ;; We keep TAB as well.
186 ;; We nix out any glyphs over 126 below ctl-arrow.
187 (let ((i (if (integerp ctl-arrow) ctl-arrow 160)))
188 (while (>= (setq i (1- i)) 127)
189 (unless (aref table i)
190 (aset table i [??]))))
191 ;; Can't use `set-specifier' because of a bug in 19.14 and earlier
192 (add-spec-to-specifier current-display-table table (current-buffer) nil)))
194 (defun gnus-xmas-add-text-properties (start end props &optional object)
195 (add-text-properties start end props object)
196 (put-text-property start end 'start-closed nil object))
198 (defun gnus-xmas-put-text-property (start end prop value &optional object)
199 (put-text-property start end prop value object)
200 (put-text-property start end 'start-closed nil object))
202 (defun gnus-xmas-extent-start-open (point)
203 (map-extents (lambda (extent arg)
204 (set-extent-property extent 'start-open t))
205 nil point (min (1+ (point)) (point-max))))
207 (defun gnus-xmas-article-push-button (event)
208 "Check text under the mouse pointer for a callback function.
209 If the text under the mouse pointer has a `gnus-callback' property,
210 call it with the value of the `gnus-data' text property."
212 (set-buffer (window-buffer (event-window event)))
213 (let* ((pos (event-closest-point event))
214 (data (get-text-property pos 'gnus-data))
215 (fun (get-text-property pos 'gnus-callback)))
218 (funcall fun data))))
220 (defun gnus-xmas-move-overlay (extent start end &optional buffer)
221 (set-extent-endpoints extent start end buffer))
223 (defun gnus-xmas-kill-all-overlays ()
224 "Delete all extents in the current buffer."
225 (map-extents (lambda (extent ignore)
226 (delete-extent extent)
229 (defun gnus-xmas-window-top-edge (&optional window)
230 (nth 1 (window-pixel-edges window)))
232 (defun gnus-xmas-tree-minimize ()
233 (when (and gnus-tree-minimize-window
234 (not (one-window-p)))
235 (let* ((window-min-height 2)
236 (height (1+ (count-lines (point-min) (point-max))))
237 (min (max (1- window-min-height) height))
238 (tot (if (numberp gnus-tree-minimize-window)
239 (min gnus-tree-minimize-window min)
241 (win (get-buffer-window (current-buffer)))
242 (wh (and win (1- (window-height win)))))
245 (let ((selected (selected-window)))
247 (enlarge-window (- tot wh))
248 (select-window selected))))))
250 ;; Select the lowest window on the frame.
251 (defun gnus-xmas-appt-select-lowest-window ()
252 (let* ((lowest-window (selected-window))
253 (bottom-edge (car (cdr (cdr (cdr (window-pixel-edges))))))
254 (last-window (previous-window))
257 (let* ((this-window (next-window))
258 (next-bottom-edge (car (cdr (cdr (cdr
261 (when (< bottom-edge next-bottom-edge)
262 (setq bottom-edge next-bottom-edge)
263 (setq lowest-window this-window))
265 (select-window this-window)
266 (when (eq last-window this-window)
267 (select-window lowest-window)
268 (setq window-search nil))))))
270 (defmacro gnus-xmas-menu-add (type &rest menus)
271 `(gnus-xmas-menu-add-1 ',type ',menus))
272 (put 'gnus-xmas-menu-add 'lisp-indent-function 1)
274 (defun gnus-xmas-menu-add-1 (type menus)
275 (when (and menu-bar-mode
276 (gnus-visual-p (intern (format "%s-menu" type)) 'menu))
278 (easy-menu-add (symbol-value (pop menus))))))
280 (defun gnus-xmas-group-menu-add ()
281 (gnus-xmas-menu-add group
282 gnus-group-reading-menu gnus-group-group-menu gnus-group-misc-menu))
284 (defun gnus-xmas-summary-menu-add ()
285 (gnus-xmas-menu-add summary
286 gnus-summary-misc-menu gnus-summary-kill-menu
287 gnus-summary-article-menu gnus-summary-thread-menu
288 gnus-summary-post-menu ))
290 (defun gnus-xmas-article-menu-add ()
291 (gnus-xmas-menu-add article
292 gnus-article-article-menu gnus-article-treatment-menu
293 gnus-article-post-menu gnus-article-commands-menu))
295 (defun gnus-xmas-score-menu-add ()
296 (gnus-xmas-menu-add score
299 (defun gnus-xmas-pick-menu-add ()
300 (gnus-xmas-menu-add pick
303 (defun gnus-xmas-topic-menu-add ()
304 (gnus-xmas-menu-add topic
307 (defun gnus-xmas-binary-menu-add ()
308 (gnus-xmas-menu-add binary
311 (defun gnus-xmas-agent-summary-menu-add ()
312 (gnus-xmas-menu-add agent-summary
313 gnus-agent-summary-menu))
315 (defun gnus-xmas-agent-group-menu-add ()
316 (gnus-xmas-menu-add agent-group
317 gnus-agent-group-menu))
319 (defun gnus-xmas-agent-server-menu-add ()
320 (gnus-xmas-menu-add agent-server
321 gnus-agent-server-menu))
323 (defun gnus-xmas-tree-menu-add ()
324 (gnus-xmas-menu-add tree
327 (defun gnus-xmas-draft-menu-add ()
328 (gnus-xmas-menu-add draft
331 (defun gnus-xmas-server-menu-add ()
332 (gnus-xmas-menu-add menu
333 gnus-server-server-menu gnus-server-connections-menu))
335 (defun gnus-xmas-browse-menu-add ()
336 (gnus-xmas-menu-add browse
339 (defun gnus-xmas-grouplens-menu-add ()
340 (gnus-xmas-menu-add grouplens
341 gnus-grouplens-menu))
343 (defun gnus-xmas-read-event-char (&optional prompt)
344 "Get the next event."
346 (message "%s" prompt))
347 (let ((event (next-command-event)))
349 ;; We junk all non-key events. Is this naughty?
350 (while (not (or (key-press-event-p event)
351 (button-press-event-p event)))
352 (dispatch-event event)
353 (setq event (next-command-event)))
354 (cons (and (key-press-event-p event)
355 (event-to-character event))
358 (defun gnus-xmas-define ()
359 (setq gnus-mouse-2 [button2])
360 (setq gnus-mouse-3 [button3])
361 (setq gnus-widget-button-keymap widget-button-keymap)
363 (unless (memq 'underline (face-list))
364 (and (fboundp 'make-face)
365 (funcall (intern "make-face") 'underline)))
366 ;; Must avoid calling set-face-underline-p directly, because it
367 ;; is a defsubst in emacs19, and will make the .elc files non
369 (unless (face-differs-from-default-p 'underline)
370 (funcall (intern "set-face-underline-p") 'underline t))
373 ((fboundp 'char-or-char-int-p)
374 ;; Handle both types of marks for XEmacs-20.x.
375 (defalias 'gnus-characterp 'char-or-char-int-p))
376 ;; V19 of XEmacs, probably.
378 (defalias 'gnus-characterp 'characterp)))
380 (defalias 'gnus-make-overlay 'make-extent)
381 (defalias 'gnus-delete-overlay 'delete-extent)
382 (defalias 'gnus-overlay-put 'set-extent-property)
383 (defalias 'gnus-move-overlay 'gnus-xmas-move-overlay)
384 (defalias 'gnus-overlay-buffer 'extent-object)
385 (defalias 'gnus-overlay-start 'extent-start-position)
386 (defalias 'gnus-overlay-end 'extent-end-position)
387 (defalias 'gnus-kill-all-overlays 'gnus-xmas-kill-all-overlays)
388 (defalias 'gnus-extent-detached-p 'extent-detached-p)
389 (defalias 'gnus-add-text-properties 'gnus-xmas-add-text-properties)
390 (defalias 'gnus-put-text-property 'gnus-xmas-put-text-property)
391 (defalias 'gnus-deactivate-mark 'ignore)
392 (defalias 'gnus-window-edges 'window-pixel-edges)
394 (if (and (<= emacs-major-version 19)
395 (< emacs-minor-version 14))
396 (defalias 'gnus-set-text-properties 'gnus-xmas-set-text-properties))
398 (unless (boundp 'standard-display-table)
399 (setq standard-display-table nil))
401 (defvar gnus-mouse-face-prop 'highlight)
403 (defun gnus-byte-code (func)
404 "Return a form that can be `eval'ed based on FUNC."
405 (let ((fval (indirect-function func)))
406 (if (compiled-function-p fval)
408 (cons 'progn (cdr (cdr fval))))))
410 (unless (fboundp 'match-string-no-properties)
411 (defalias 'match-string-no-properties 'match-string))
413 (defalias 'gnus-x-color-values
414 (if (fboundp 'x-color-values)
417 (color-instance-rgb-components
418 (make-color-instance color))))))
420 (defun gnus-xmas-redefine ()
421 "Redefine lots of Gnus functions for XEmacs."
422 (defalias 'gnus-summary-set-display-table 'gnus-xmas-summary-set-display-table)
423 (defalias 'gnus-visual-turn-off-edit-menu 'identity)
424 (defalias 'gnus-summary-recenter 'gnus-xmas-summary-recenter)
425 (defalias 'gnus-extent-start-open 'gnus-xmas-extent-start-open)
426 (defalias 'gnus-article-push-button 'gnus-xmas-article-push-button)
427 (defalias 'gnus-window-top-edge 'gnus-xmas-window-top-edge)
428 (defalias 'gnus-read-event-char 'gnus-xmas-read-event-char)
429 (defalias 'gnus-group-startup-message 'gnus-xmas-group-startup-message)
430 (defalias 'gnus-tree-minimize 'gnus-xmas-tree-minimize)
431 (defalias 'gnus-appt-select-lowest-window
432 'gnus-xmas-appt-select-lowest-window)
433 (defalias 'gnus-mail-strip-quoted-names 'gnus-xmas-mail-strip-quoted-names)
434 (defalias 'gnus-character-to-event 'character-to-event)
435 (defalias 'gnus-mode-line-buffer-identification
436 'gnus-xmas-mode-line-buffer-identification)
437 (defalias 'gnus-key-press-event-p 'key-press-event-p)
438 (defalias 'gnus-region-active-p 'region-active-p)
439 (defalias 'gnus-mark-active-p 'region-exists-p)
440 (defalias 'gnus-annotation-in-region-p 'gnus-xmas-annotation-in-region-p)
441 (defalias 'gnus-mime-button-menu 'gnus-xmas-mime-button-menu)
442 (defalias 'gnus-image-type-available-p 'gnus-xmas-image-type-available-p)
443 (defalias 'gnus-put-image 'gnus-xmas-put-image)
444 (defalias 'gnus-create-image 'gnus-xmas-create-image)
445 (defalias 'gnus-remove-image 'gnus-xmas-remove-image)
447 (when (or (< emacs-major-version 21)
448 (and (= emacs-major-version 21)
449 (< emacs-minor-version 3)))
450 (defalias 'gnus-completing-read 'gnus-xmas-completing-read))
452 ;; These ones are not defcutom'ed, sometimes not even defvar'ed. They
453 ;; probably should. If that is done, the code below should then be moved
454 ;; where each variable is defined, in order not to mess with user settings.
456 (add-hook 'gnus-score-mode-hook 'gnus-xmas-score-menu-add)
457 (add-hook 'gnus-binary-mode-hook 'gnus-xmas-binary-menu-add)
458 (add-hook 'gnus-grouplens-mode-hook 'gnus-xmas-grouplens-menu-add)
459 (add-hook 'gnus-server-mode-hook 'gnus-xmas-server-menu-add)
460 (add-hook 'gnus-browse-mode-hook 'gnus-xmas-browse-menu-add)
461 (add-hook 'gnus-draft-mode-hook 'gnus-xmas-draft-menu-add)
462 (add-hook 'gnus-mailing-list-mode-hook 'gnus-xmas-mailing-list-menu-add))
465 ;;; XEmacs logo and toolbar.
467 (defun gnus-xmas-group-startup-message (&optional x y)
468 "Insert startup message in current buffer."
469 ;; Insert the message.
472 ((and (console-on-window-system-p)
475 (let* ((logo-xpm (expand-file-name "gnus.xpm" gnus-xmas-glyph-directory))
476 (logo-xbm (expand-file-name "gnus.xbm" gnus-xmas-glyph-directory))
478 (cond ((featurep 'xpm)
482 (("thing" . ,(car gnus-logo-colors))
483 ("shadow" . ,(cadr gnus-logo-colors))
485 ("background" . ,(face-background 'default)))])
487 `[xbm :file ,logo-xbm])
490 (set-extent-begin-glyph (make-extent (point) (point)) glyph)
491 (goto-char (point-min))
493 (insert (make-string (/ (max (- (window-width) (or x 35)) 0) 2)
496 (setq gnus-simple-splash nil))
497 (goto-char (point-min))
498 (let* ((pheight (+ 20 (count-lines (point-min) (point-max))))
499 (wheight (window-height))
500 (rest (- wheight pheight)))
501 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n))))
506 _ ___ __ ___ __ _ ___
526 (gnus-indent-rigidly (point-min) (point-max)
527 (/ (max (- (window-width) (or x 46)) 0) 2))
528 (goto-char (point-min))
530 (let* ((pheight (count-lines (point-min) (point-max)))
531 (wheight (window-height))
532 (rest (- wheight pheight)))
533 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
535 (put-text-property (point-min) (point-max) 'face 'gnus-splash-face)))
536 (setq modeline-buffer-identification
537 (list (concat gnus-version ": *Group*")))
538 (set-buffer-modified-p t))
543 (defcustom gnus-use-toolbar (if (featurep 'toolbar)
546 "*If nil, do not use a toolbar.
547 If it is non-nil, it must be a toolbar. The five valid values are
548 `default-toolbar', `top-toolbar', `bottom-toolbar',
549 `right-toolbar', and `left-toolbar'."
550 :type '(choice (const default-toolbar)
551 (const top-toolbar) (const bottom-toolbar)
552 (const left-toolbar) (const right-toolbar)
553 (const :tag "no toolbar" nil))
556 (defvar gnus-group-toolbar
557 '([gnus-group-get-new-news gnus-group-get-new-news t "Get new news"]
558 [gnus-group-get-new-news-this-group
559 gnus-group-get-new-news-this-group t "Get new news in this group"]
560 [gnus-group-catchup-current
561 gnus-group-catchup-current t "Catchup group"]
562 [gnus-group-describe-group
563 gnus-group-describe-group t "Describe group"]
564 [gnus-group-unsubscribe gnus-group-unsubscribe t "Unsubscribe group"]
565 [gnus-group-subscribe gnus-group-subscribe t "Subscribe group"]
566 [gnus-group-kill-group gnus-group-kill-group t "Kill group"]
567 [gnus-summary-mail-save
568 gnus-group-save-newsrc t "Save .newsrc files"] ; borrowed icon.
569 [gnus-group-exit gnus-group-exit t "Exit Gnus"])
570 "The group buffer toolbar.")
572 (defvar gnus-summary-toolbar
573 '([gnus-summary-prev-unread
574 gnus-summary-prev-page-or-article t "Page up"]
575 [gnus-summary-next-unread
576 gnus-summary-next-page t "Page down"]
577 [gnus-summary-post-news
578 gnus-summary-post-news t "Post an article"]
579 [gnus-summary-followup-with-original
580 gnus-summary-followup-with-original t
581 "Post a followup and yank the original"]
582 [gnus-summary-followup
583 gnus-summary-followup t "Post a followup"]
584 [gnus-summary-reply-with-original
585 gnus-summary-reply-with-original t "Mail a reply and yank the original"]
587 gnus-summary-reply t "Mail a reply"]
588 [gnus-summary-caesar-message
589 gnus-summary-caesar-message t "Rot 13"]
591 gnus-uu-decode-uu t "Decode uuencoded articles"]
592 [gnus-summary-save-article-file
593 gnus-summary-save-article-file t "Save article in file"]
594 [gnus-summary-save-article
595 gnus-summary-save-article t "Save article"]
597 gnus-uu-post-news t "Post a uuencoded article"]
598 [gnus-summary-cancel-article
599 gnus-summary-cancel-article t "Cancel article"]
600 [gnus-summary-catchup
601 gnus-summary-catchup t "Catchup"]
602 [gnus-summary-catchup-and-exit
603 gnus-summary-catchup-and-exit t "Catchup and exit"]
604 [gnus-summary-exit gnus-summary-exit t "Exit this summary"])
605 "The summary buffer toolbar.")
607 (defvar gnus-summary-mail-toolbar
609 [gnus-summary-prev-unread
610 gnus-summary-prev-unread-article t "Prev unread article"]
611 [gnus-summary-next-unread
612 gnus-summary-next-unread-article t "Next unread article"]
613 [gnus-summary-mail-reply gnus-summary-reply t "Reply"]
614 [gnus-summary-mail-originate gnus-summary-post-news t "Originate"]
615 [gnus-summary-mail-save gnus-summary-save-article t "Save"]
616 [gnus-summary-mail-copy gnus-summary-copy-article t "Copy message"]
617 [gnus-summary-mail-forward gnus-summary-mail-forward t "Forward message"]
618 [gnus-summary-caesar-message
619 gnus-summary-caesar-message t "Rot 13"]
621 gnus-uu-decode-uu t "Decode uuencoded articles"]
622 [gnus-summary-save-article-file
623 gnus-summary-save-article-file t "Save article in file"]
624 [gnus-summary-save-article
625 gnus-summary-save-article t "Save article"]
626 [gnus-summary-cancel-article ; usenet : cancellation :: mail : deletion.
627 gnus-summary-delete-article t "Delete message"]
628 [gnus-summary-catchup
629 gnus-summary-catchup t "Catchup"]
630 [gnus-summary-catchup-and-exit
631 gnus-summary-catchup-and-exit t "Catchup and exit"]
632 [gnus-summary-exit gnus-summary-exit t "Exit this summary"])
633 "The summary buffer mail toolbar.")
635 (defun gnus-xmas-setup-group-toolbar ()
636 (and gnus-use-toolbar
637 (message-xmas-setup-toolbar gnus-group-toolbar nil "gnus")
638 (set-specifier (symbol-value gnus-use-toolbar)
639 (cons (current-buffer) gnus-group-toolbar))))
641 (defun gnus-xmas-setup-summary-toolbar ()
642 (let ((bar (if (gnus-news-group-p gnus-newsgroup-name)
643 gnus-summary-toolbar gnus-summary-mail-toolbar)))
644 (and gnus-use-toolbar
645 (message-xmas-setup-toolbar bar nil "gnus")
646 (set-specifier (symbol-value gnus-use-toolbar)
647 (cons (current-buffer) bar)))))
649 (defun gnus-xmas-mail-strip-quoted-names (address)
650 "Protect mail-strip-quoted-names from nil input.
651 XEmacs compatibility workaround."
654 (mail-strip-quoted-names address)))
656 (defun gnus-xmas-call-region (command &rest args)
658 'call-process-region (point-min) (point-max) command t '(t nil) nil
661 (defvar gnus-xmas-modeline-left-extent
662 (let ((ext (copy-extent modeline-buffer-id-left-extent)))
665 (defvar gnus-xmas-modeline-right-extent
666 (let ((ext (copy-extent modeline-buffer-id-right-extent)))
669 (defvar gnus-xmas-modeline-glyph
671 (let* ((file-xpm (expand-file-name "gnus-pointer.xpm"
672 gnus-xmas-glyph-directory))
673 (file-xbm (expand-file-name "gnus-pointer.xbm"
674 gnus-xmas-glyph-directory))
677 (cond ((featurep 'xpm)
678 ;; Let's try a nifty XPM
679 `[xpm :file ,file-xpm])
681 ;; Then a not-so-nifty XBM
682 `[xbm :file ,file-xbm])
683 ;; Then the simple string
684 (t [string :data "Gnus:"])))))
685 (set-glyph-face glyph 'modeline-buffer-id)
688 (defun gnus-xmas-mode-line-buffer-identification (line)
689 (let ((line (car line))
692 ;; This is some weird type of id.
693 ((not (stringp line))
695 ;; This is non-standard, so we just pass it through.
696 ((not (string-match "^Gnus:" line))
698 ;; We have a standard line, so we colorize and glyphize it a bit.
700 (setq chop (match-end 0))
702 (if gnus-xmas-modeline-glyph
703 (cons gnus-xmas-modeline-left-extent gnus-xmas-modeline-glyph)
704 (cons gnus-xmas-modeline-left-extent (substring line 0 chop)))
705 (cons gnus-xmas-modeline-right-extent (substring line chop)))))))
707 (defun gnus-xmas-splash ()
708 (when (eq (device-type) 'x)
711 (defun gnus-xmas-annotation-in-region-p (b e)
712 (or (map-extents (lambda (e u) t) nil b e nil nil 'mm t)
714 (eq (cadr (memq 'gnus-undeletable (text-properties-at b))) t)
715 (text-property-any b e 'gnus-undeletable t))))
717 (defun gnus-xmas-mime-button-menu (event)
718 "Construct a context-sensitive menu of MIME commands."
720 (let ((response (get-popup-menu-response
722 ,@(mapcar (lambda (c) `[,(caddr c) ,(car c) t])
723 gnus-mime-button-commands)))))
724 (set-buffer (event-buffer event))
725 (goto-char (event-point event))
726 (funcall (event-function response) (event-object response))))
728 (defun gnus-group-add-icon ()
729 "Add an icon to the current line according to `gnus-group-icon-list'."
731 (end (progn (end-of-line) (point)))
732 ;; now find out where the line starts and leave point there.
733 (beg (progn (beginning-of-line) (point))))
735 (narrow-to-region beg end)
737 (when (search-forward "==&&==" nil t)
738 (let* ((group (gnus-group-group-name))
739 (entry (gnus-group-entry group))
740 (unread (if (numberp (car entry)) (car entry) 0))
741 (active (gnus-active group))
742 (total (if active (1+ (- (cdr active) (car active))) 0))
744 (method (gnus-server-get-method group (gnus-info-method info)))
745 (marked (gnus-info-marks info))
746 (mailp (memq 'mail (assoc (symbol-name
747 (car (or method gnus-select-method)))
748 gnus-valid-select-methods)))
749 (level (or (gnus-info-level info) gnus-level-killed))
750 (score (or (gnus-info-score info) 0))
751 (ticked (gnus-range-length (cdr (assq 'tick marked))))
752 (group-age (gnus-group-timestamp-delta group))
753 (inhibit-read-only t)
754 (list gnus-group-icon-list)
755 (mystart (match-beginning 0))
756 (myend (match-end 0)))
757 (goto-char (point-min))
759 (not (eval (caar list))))
760 (setq list (cdr list)))
762 (let* ((file (cdar list))
763 (glyph (gnus-group-icon-create-glyph
764 (buffer-substring mystart myend)
768 (mapcar 'delete-annotation (annotations-at myend))
769 (let ((ext (make-extent mystart myend))
770 (ant (make-annotation glyph myend 'text)))
771 ;; set text extent params
772 (set-extent-property ext 'end-open t)
773 (set-extent-property ext 'start-open t)
774 (set-extent-property ext 'invisible t)))
775 (delete-region mystart myend)))
776 (delete-region mystart myend))))
780 (defun gnus-group-icon-create-glyph (substring pixmap)
781 "Create a glyph for insertion into a group line."
783 (cdr-safe (assoc pixmap gnus-group-icon-cache))
784 (let* ((glyph (make-glyph
787 (expand-file-name pixmap gnus-xmas-glyph-directory))
789 (expand-file-name pixmap gnus-xmas-glyph-directory))
790 (cons 'tty substring)))))
791 (setq gnus-group-icon-cache
792 (cons (cons pixmap glyph) gnus-group-icon-cache))
793 (set-glyph-face glyph 'default)
796 (defun gnus-xmas-mailing-list-menu-add ()
797 (gnus-xmas-menu-add mailing-list
798 gnus-mailing-list-menu))
800 (defun gnus-xmas-image-type-available-p (type)
802 (featurep (if (eq type 'pbm) 'xbm type))))
804 (defun gnus-xmas-create-image (file &optional type data-p &rest props)
807 (car (last (split-string file "[.]")))))
808 (face (plist-get props :face))
810 (when (equal type "pbm")
814 (insert-file-contents file))
815 (shell-command-on-region (point-min) (point-max)
816 "ppmtoxpm 2>/dev/null" t)
817 (setq file (buffer-string)
821 (if (equal type "xbm")
822 (make-glyph (list (cons 'x file)))
826 (insert-file-contents file))
830 (mm-image-type-from-buffer))
831 :data (buffer-string))))))
833 (set-glyph-face glyph face))
836 (defun gnus-xmas-put-image (glyph &optional string)
837 "Insert STRING, but display GLYPH.
838 Warning: Don't insert text immediately after the image."
839 (let ((begin (point))
841 (if (and (bobp) (not string))
845 (setq begin (1- begin)))
846 (setq extent (make-extent begin (point)))
847 (set-extent-property extent 'gnus-image t)
848 (set-extent-property extent 'duplicable t)
850 (set-extent-property extent 'invisible t))
851 (set-extent-property extent 'end-glyph glyph))
854 (defun gnus-xmas-remove-image (image)
857 (when (equal (extent-end-glyph ext) image)
858 (set-extent-property ext 'invisible nil)
859 (set-extent-property ext 'end-glyph nil))
861 nil nil nil nil nil 'gnus-image))
863 (defun gnus-xmas-completing-read (prompt table &optional
864 predicate require-match history)
866 (not (boundp history)))
869 (if (symbol-value history)
870 (concat prompt " (" (car (symbol-value history)) "): ")
871 (concat prompt ": "))
880 ;;; gnus-xmas.el ends here