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 (autoload 'gnus-active "gnus" nil nil 'macro)
32 (autoload 'gnus-group-entry "gnus" nil nil 'macro)
33 (autoload 'gnus-info-level "gnus" nil nil 'macro)
34 (autoload 'gnus-info-marks "gnus" nil nil 'macro)
35 (autoload 'gnus-info-method "gnus" nil nil 'macro)
36 (autoload 'gnus-info-score "gnus" nil nil 'macro))
39 (defvar menu-bar-mode (featurep 'menubar))
40 (require 'messagexmas)
43 (defgroup gnus-xmas nil
44 "XEmacsoid support for Gnus"
47 (defcustom gnus-xmas-glyph-directory nil
48 "Directory where Gnus logos and icons are located.
49 If this variable is nil, Gnus will try to locate the directory
51 :type '(choice (const :tag "autodetect" nil)
55 (unless gnus-xmas-glyph-directory
56 (unless (setq gnus-xmas-glyph-directory
57 (message-xmas-find-glyph-directory "gnus"))
58 (error "Can't find glyph directory. \
59 Possibly the `etc' directory has not been installed.")))
61 ;;; Internal variables.
63 ;; Don't warn about these undefined variables.
66 (defvar gnus-active-hashtb)
67 (defvar gnus-article-buffer)
68 (defvar gnus-auto-center-summary)
69 (defvar gnus-current-headers)
70 (defvar gnus-level-killed)
71 (defvar gnus-level-zombie)
72 (defvar gnus-newsgroup-bookmarks)
73 (defvar gnus-newsgroup-dependencies)
74 (defvar gnus-newsgroup-selected-overlay)
75 (defvar gnus-newsrc-hashtb)
76 (defvar gnus-read-mark)
77 (defvar gnus-refer-article-method)
78 (defvar gnus-reffed-article-number)
79 (defvar gnus-unread-mark)
81 (defvar gnus-view-pseudos)
82 (defvar gnus-view-pseudos-separately)
84 (defvar gnus-zombie-list)
85 ;;defined in gnus-msg.el
86 (defvar gnus-article-copy)
87 (defvar gnus-check-before-posting)
88 ;;defined in gnus-vis.el
89 (defvar gnus-article-button-face)
90 (defvar gnus-article-mouse-face)
91 (defvar gnus-summary-selected-face)
92 (defvar gnus-group-reading-menu)
93 (defvar gnus-group-group-menu)
94 (defvar gnus-group-misc-menu)
95 (defvar gnus-summary-article-menu)
96 (defvar gnus-summary-thread-menu)
97 (defvar gnus-summary-misc-menu)
98 (defvar gnus-summary-post-menu)
99 (defvar gnus-summary-kill-menu)
100 (defvar gnus-article-article-menu)
101 (defvar gnus-article-treatment-menu)
102 (defvar gnus-mouse-2)
103 (defvar standard-display-table)
104 (defvar gnus-tree-minimize-window)
106 (defun gnus-xmas-highlight-selected-summary ()
107 ;; Highlight selected article in summary buffer
108 (when gnus-summary-selected-face
109 (when gnus-newsgroup-selected-overlay
110 (delete-extent gnus-newsgroup-selected-overlay))
111 (setq gnus-newsgroup-selected-overlay
112 (make-extent (point-at-bol) (point-at-eol)))
113 (set-extent-face gnus-newsgroup-selected-overlay
114 gnus-summary-selected-face)))
116 (defcustom gnus-xmas-force-redisplay nil
117 "*If non-nil, force a redisplay before recentering the summary buffer.
118 This is ugly, but it works around a bug in `window-displayed-height'."
122 (defun gnus-xmas-switch-horizontal-scrollbar-off ()
123 (when (featurep 'scrollbar)
124 (set-specifier scrollbar-height (cons (current-buffer) 0))))
126 (defun gnus-xmas-summary-recenter ()
127 "\"Center\" point in the summary window.
128 If `gnus-auto-center-summary' is nil, or the article buffer isn't
129 displayed, no centering will be performed."
130 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
131 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
132 ;; Force redisplay to get properly computed window height.
133 (when gnus-xmas-force-redisplay
135 (when gnus-auto-center-summary
136 (let* ((height (if (fboundp 'window-displayed-height)
137 (window-displayed-height)
138 (- (window-height) 2)))
139 (top (cond ((< height 4) 0)
141 (t (if (numberp gnus-auto-center-summary)
142 gnus-auto-center-summary
144 (bottom (save-excursion (goto-char (point-max))
145 (forward-line (- height))
147 (window (get-buffer-window (current-buffer))))
148 (when (get-buffer-window gnus-article-buffer)
149 ;; Only do recentering when the article buffer is displayed,
150 ;; Set the window start to either `bottom', which is the biggest
151 ;; possible valid number, or the second line from the top,
152 ;; whichever is the least.
153 ;; NOFORCE parameter suggested by Daniel Pittman <daniel@danann.net>.
155 window (min bottom (save-excursion (forward-line (- top)) (point)))
157 ;; Do horizontal recentering while we're at it.
158 (when (and (get-buffer-window (current-buffer) t)
159 (not (eq gnus-auto-center-summary 'vertical)))
160 (let ((selected (selected-window)))
161 (select-window (get-buffer-window (current-buffer) t))
162 (gnus-summary-position-point)
163 (gnus-horizontal-recenter)
164 (select-window selected))))))
166 (defun gnus-xmas-summary-set-display-table ()
167 ;; Setup the display table -- like `gnus-summary-setup-display-table',
168 ;; but done in an XEmacsish way.
169 (let ((table (make-display-table))
171 ;; Nix out all the control chars...
172 (while (>= (setq i (1- i)) 0)
174 ;; ... but not newline and cr, of course. (cr is necessary for the
175 ;; selective display).
178 ;; We keep TAB as well.
180 ;; We nix out any glyphs over 126 below ctl-arrow.
181 (let ((i (if (integerp ctl-arrow) ctl-arrow 160)))
182 (while (>= (setq i (1- i)) 127)
183 (unless (aref table i)
184 (aset table i [??]))))
185 ;; Can't use `set-specifier' because of a bug in 19.14 and earlier
186 (add-spec-to-specifier current-display-table table (current-buffer) nil)))
188 (defun gnus-xmas-add-text-properties (start end props &optional object)
189 (add-text-properties start end props object)
190 (put-text-property start end 'start-closed nil object))
192 (defun gnus-xmas-put-text-property (start end prop value &optional object)
193 (put-text-property start end prop value object)
194 (put-text-property start end 'start-closed nil object))
196 (defun gnus-xmas-extent-start-open (point)
197 (map-extents (lambda (extent arg)
198 (set-extent-property extent 'start-open t))
199 nil point (min (1+ (point)) (point-max))))
201 (defun gnus-xmas-article-push-button (event)
202 "Check text under the mouse pointer for a callback function.
203 If the text under the mouse pointer has a `gnus-callback' property,
204 call it with the value of the `gnus-data' text property."
206 (set-buffer (window-buffer (event-window event)))
207 (let* ((pos (event-closest-point event))
208 (data (get-text-property pos 'gnus-data))
209 (fun (get-text-property pos 'gnus-callback)))
212 (funcall fun data))))
214 (defun gnus-xmas-move-overlay (extent start end &optional buffer)
215 (set-extent-endpoints extent start end buffer))
217 (defun gnus-xmas-kill-all-overlays ()
218 "Delete all extents in the current buffer."
219 (map-extents (lambda (extent ignore)
220 (delete-extent extent)
223 (defun gnus-xmas-window-top-edge (&optional window)
224 (nth 1 (window-pixel-edges window)))
226 (defun gnus-xmas-tree-minimize ()
227 (when (and gnus-tree-minimize-window
228 (not (one-window-p)))
229 (let* ((window-min-height 2)
230 (height (1+ (count-lines (point-min) (point-max))))
231 (min (max (1- window-min-height) height))
232 (tot (if (numberp gnus-tree-minimize-window)
233 (min gnus-tree-minimize-window min)
235 (win (get-buffer-window (current-buffer)))
236 (wh (and win (1- (window-height win)))))
239 (let ((selected (selected-window)))
241 (enlarge-window (- tot wh))
242 (select-window selected))))))
244 ;; Select the lowest window on the frame.
245 (defun gnus-xmas-appt-select-lowest-window ()
246 (let* ((lowest-window (selected-window))
247 (bottom-edge (car (cdr (cdr (cdr (window-pixel-edges))))))
248 (last-window (previous-window))
251 (let* ((this-window (next-window))
252 (next-bottom-edge (car (cdr (cdr (cdr
255 (when (< bottom-edge next-bottom-edge)
256 (setq bottom-edge next-bottom-edge)
257 (setq lowest-window this-window))
259 (select-window this-window)
260 (when (eq last-window this-window)
261 (select-window lowest-window)
262 (setq window-search nil))))))
264 (defmacro gnus-xmas-menu-add (type &rest menus)
265 `(gnus-xmas-menu-add-1 ',type ',menus))
266 (put 'gnus-xmas-menu-add 'lisp-indent-function 1)
268 (defun gnus-xmas-menu-add-1 (type menus)
269 (when (and menu-bar-mode
270 (gnus-visual-p (intern (format "%s-menu" type)) 'menu))
272 (easy-menu-add (symbol-value (pop menus))))))
274 (defun gnus-xmas-group-menu-add ()
275 (gnus-xmas-menu-add group
276 gnus-group-reading-menu gnus-group-group-menu gnus-group-misc-menu))
278 (defun gnus-xmas-summary-menu-add ()
279 (gnus-xmas-menu-add summary
280 gnus-summary-misc-menu gnus-summary-kill-menu
281 gnus-summary-article-menu gnus-summary-thread-menu
282 gnus-summary-post-menu ))
284 (defun gnus-xmas-article-menu-add ()
285 (gnus-xmas-menu-add article
286 gnus-article-article-menu gnus-article-treatment-menu
287 gnus-article-post-menu gnus-article-commands-menu))
289 (defun gnus-xmas-score-menu-add ()
290 (gnus-xmas-menu-add score
293 (defun gnus-xmas-pick-menu-add ()
294 (gnus-xmas-menu-add pick
297 (defun gnus-xmas-topic-menu-add ()
298 (gnus-xmas-menu-add topic
301 (defun gnus-xmas-binary-menu-add ()
302 (gnus-xmas-menu-add binary
305 (defun gnus-xmas-agent-summary-menu-add ()
306 (gnus-xmas-menu-add agent-summary
307 gnus-agent-summary-menu))
309 (defun gnus-xmas-agent-group-menu-add ()
310 (gnus-xmas-menu-add agent-group
311 gnus-agent-group-menu))
313 (defun gnus-xmas-agent-server-menu-add ()
314 (gnus-xmas-menu-add agent-server
315 gnus-agent-server-menu))
317 (defun gnus-xmas-tree-menu-add ()
318 (gnus-xmas-menu-add tree
321 (defun gnus-xmas-draft-menu-add ()
322 (gnus-xmas-menu-add draft
325 (defun gnus-xmas-server-menu-add ()
326 (gnus-xmas-menu-add menu
327 gnus-server-server-menu gnus-server-connections-menu))
329 (defun gnus-xmas-browse-menu-add ()
330 (gnus-xmas-menu-add browse
333 (defun gnus-xmas-grouplens-menu-add ()
334 (gnus-xmas-menu-add grouplens
335 gnus-grouplens-menu))
337 (defun gnus-xmas-read-event-char (&optional prompt)
338 "Get the next event."
340 (message "%s" prompt))
341 (let ((event (next-command-event)))
343 ;; We junk all non-key events. Is this naughty?
344 (while (not (or (key-press-event-p event)
345 (button-press-event-p event)))
346 (dispatch-event event)
347 (setq event (next-command-event)))
348 (cons (and (key-press-event-p event)
349 (event-to-character event))
352 (defun gnus-xmas-define ()
353 (setq gnus-mouse-2 [button2])
354 (setq gnus-mouse-3 [button3])
355 (setq gnus-widget-button-keymap widget-button-keymap)
357 (unless (memq 'underline (face-list))
358 (and (fboundp 'make-face)
359 (funcall (intern "make-face") 'underline)))
360 ;; Must avoid calling set-face-underline-p directly, because it
361 ;; is a defsubst in emacs19, and will make the .elc files non
363 (unless (face-differs-from-default-p 'underline)
364 (funcall (intern "set-face-underline-p") 'underline t))
367 ((fboundp 'char-or-char-int-p)
368 ;; Handle both types of marks for XEmacs-20.x.
369 (defalias 'gnus-characterp 'char-or-char-int-p))
370 ;; V19 of XEmacs, probably.
372 (defalias 'gnus-characterp 'characterp)))
374 (defalias 'gnus-make-overlay 'make-extent)
375 (defalias 'gnus-delete-overlay 'delete-extent)
376 (defalias 'gnus-overlay-put 'set-extent-property)
377 (defalias 'gnus-move-overlay 'gnus-xmas-move-overlay)
378 (defalias 'gnus-overlay-buffer 'extent-object)
379 (defalias 'gnus-overlay-start 'extent-start-position)
380 (defalias 'gnus-overlay-end 'extent-end-position)
381 (defalias 'gnus-kill-all-overlays 'gnus-xmas-kill-all-overlays)
382 (defalias 'gnus-extent-detached-p 'extent-detached-p)
383 (defalias 'gnus-add-text-properties 'gnus-xmas-add-text-properties)
384 (defalias 'gnus-put-text-property 'gnus-xmas-put-text-property)
385 (defalias 'gnus-deactivate-mark 'ignore)
386 (defalias 'gnus-window-edges 'window-pixel-edges)
387 (defalias 'gnus-assq-delete-all 'gnus-xmas-assq-delete-all)
389 (unless (boundp 'standard-display-table)
390 (setq standard-display-table nil))
392 (defvar gnus-mouse-face-prop 'highlight)
394 (defun gnus-byte-code (func)
395 "Return a form that can be `eval'ed based on FUNC."
396 (let ((fval (indirect-function func)))
397 (if (compiled-function-p fval)
399 (cons 'progn (cdr (cdr fval))))))
401 (unless (fboundp 'match-string-no-properties)
402 (defalias 'match-string-no-properties 'match-string))
404 (defalias 'gnus-x-color-values
405 (if (fboundp 'x-color-values)
408 (color-instance-rgb-components
409 (make-color-instance color)))))
411 (unless (fboundp 'char-width)
412 (defalias 'char-width (lambda (ch) 1))))
414 (defun gnus-xmas-redefine ()
415 "Redefine lots of Gnus functions for XEmacs."
416 (defalias 'gnus-summary-set-display-table 'gnus-xmas-summary-set-display-table)
417 (defalias 'gnus-visual-turn-off-edit-menu 'identity)
418 (defalias 'gnus-summary-recenter 'gnus-xmas-summary-recenter)
419 (defalias 'gnus-extent-start-open 'gnus-xmas-extent-start-open)
420 (defalias 'gnus-article-push-button 'gnus-xmas-article-push-button)
421 (defalias 'gnus-window-top-edge 'gnus-xmas-window-top-edge)
422 (defalias 'gnus-read-event-char 'gnus-xmas-read-event-char)
423 (defalias 'gnus-group-startup-message 'gnus-xmas-group-startup-message)
424 (defalias 'gnus-tree-minimize 'gnus-xmas-tree-minimize)
425 (defalias 'gnus-appt-select-lowest-window
426 'gnus-xmas-appt-select-lowest-window)
427 (defalias 'gnus-mail-strip-quoted-names 'gnus-xmas-mail-strip-quoted-names)
428 (defalias 'gnus-character-to-event 'character-to-event)
429 (defalias 'gnus-mode-line-buffer-identification
430 'gnus-xmas-mode-line-buffer-identification)
431 (defalias 'gnus-key-press-event-p 'key-press-event-p)
432 (defalias 'gnus-region-active-p 'region-active-p)
433 (defalias 'gnus-mark-active-p 'region-exists-p)
434 (defalias 'gnus-annotation-in-region-p 'gnus-xmas-annotation-in-region-p)
435 (defalias 'gnus-mime-button-menu 'gnus-xmas-mime-button-menu)
436 (defalias 'gnus-image-type-available-p 'gnus-xmas-image-type-available-p)
437 (defalias 'gnus-put-image 'gnus-xmas-put-image)
438 (defalias 'gnus-create-image 'gnus-xmas-create-image)
439 (defalias 'gnus-remove-image 'gnus-xmas-remove-image)
441 ;; These ones are not defcutom'ed, sometimes not even defvar'ed. They
442 ;; probably should. If that is done, the code below should then be moved
443 ;; where each variable is defined, in order not to mess with user settings.
445 (add-hook 'gnus-score-mode-hook 'gnus-xmas-score-menu-add)
446 (add-hook 'gnus-binary-mode-hook 'gnus-xmas-binary-menu-add)
447 (add-hook 'gnus-grouplens-mode-hook 'gnus-xmas-grouplens-menu-add)
448 (add-hook 'gnus-server-mode-hook 'gnus-xmas-server-menu-add)
449 (add-hook 'gnus-browse-mode-hook 'gnus-xmas-browse-menu-add)
450 (add-hook 'gnus-draft-mode-hook 'gnus-xmas-draft-menu-add)
451 (add-hook 'gnus-mailing-list-mode-hook 'gnus-xmas-mailing-list-menu-add))
454 ;;; XEmacs logo and toolbar.
456 (defun gnus-xmas-group-startup-message (&optional x y)
457 "Insert startup message in current buffer."
458 ;; Insert the message.
461 ((and (console-on-window-system-p)
464 (let* ((logo-xpm (expand-file-name "gnus.xpm" gnus-xmas-glyph-directory))
465 (logo-xbm (expand-file-name "gnus.xbm" gnus-xmas-glyph-directory))
467 (cond ((featurep 'xpm)
471 (("thing" . ,(car gnus-logo-colors))
472 ("shadow" . ,(cadr gnus-logo-colors))
474 ("background" . ,(face-background 'default)))])
476 `[xbm :file ,logo-xbm])
479 (set-extent-begin-glyph (make-extent (point) (point)) glyph)
480 (goto-char (point-min))
482 (insert (make-string (/ (max (- (window-width) (or x 35)) 0) 2)
485 (setq gnus-simple-splash nil))
486 (goto-char (point-min))
487 (let* ((pheight (+ 20 (count-lines (point-min) (point-max))))
488 (wheight (window-height))
489 (rest (- wheight pheight)))
490 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n))))
495 _ ___ __ ___ __ _ ___
515 (gnus-indent-rigidly (point-min) (point-max)
516 (/ (max (- (window-width) (or x 46)) 0) 2))
517 (goto-char (point-min))
519 (let* ((pheight (count-lines (point-min) (point-max)))
520 (wheight (window-height))
521 (rest (- wheight pheight)))
522 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
524 (put-text-property (point-min) (point-max) 'face 'gnus-splash-face)))
525 (setq modeline-buffer-identification
526 (list (concat gnus-version ": *Group*")))
527 (set-buffer-modified-p t))
532 (defcustom gnus-use-toolbar (if (featurep 'toolbar)
535 "*If nil, do not use a toolbar.
536 If it is non-nil, it must be a toolbar. The five valid values are
537 `default-toolbar', `top-toolbar', `bottom-toolbar',
538 `right-toolbar', and `left-toolbar'."
539 :type '(choice (const default-toolbar)
540 (const top-toolbar) (const bottom-toolbar)
541 (const left-toolbar) (const right-toolbar)
542 (const :tag "no toolbar" nil))
545 (defvar gnus-group-toolbar
546 '([gnus-group-get-new-news gnus-group-get-new-news t "Get new news"]
547 [gnus-group-get-new-news-this-group
548 gnus-group-get-new-news-this-group t "Get new news in this group"]
549 [gnus-group-catchup-current
550 gnus-group-catchup-current t "Catchup group"]
551 [gnus-group-describe-group
552 gnus-group-describe-group t "Describe group"]
553 [gnus-group-unsubscribe gnus-group-unsubscribe t "Unsubscribe group"]
554 [gnus-group-subscribe gnus-group-subscribe t "Subscribe group"]
555 [gnus-group-kill-group gnus-group-kill-group t "Kill group"]
556 [gnus-summary-mail-save
557 gnus-group-save-newsrc t "Save .newsrc files"] ; borrowed icon.
558 [gnus-group-exit gnus-group-exit t "Exit Gnus"])
559 "The group buffer toolbar.")
561 (defvar gnus-summary-toolbar
562 '([gnus-summary-prev-unread
563 gnus-summary-prev-page-or-article t "Page up"]
564 [gnus-summary-next-unread
565 gnus-summary-next-page t "Page down"]
566 [gnus-summary-post-news
567 gnus-summary-post-news t "Post an article"]
568 [gnus-summary-followup-with-original
569 gnus-summary-followup-with-original t
570 "Post a followup and yank the original"]
571 [gnus-summary-followup
572 gnus-summary-followup t "Post a followup"]
573 [gnus-summary-reply-with-original
574 gnus-summary-reply-with-original t "Mail a reply and yank the original"]
576 gnus-summary-reply t "Mail a reply"]
577 [gnus-summary-caesar-message
578 gnus-summary-caesar-message t "Rot 13"]
580 gnus-uu-decode-uu t "Decode uuencoded articles"]
581 [gnus-summary-save-article-file
582 gnus-summary-save-article-file t "Save article in file"]
583 [gnus-summary-save-article
584 gnus-summary-save-article t "Save article"]
586 gnus-uu-post-news t "Post a uuencoded article"]
587 [gnus-summary-cancel-article
588 gnus-summary-cancel-article t "Cancel article"]
589 [gnus-summary-catchup
590 gnus-summary-catchup t "Catchup"]
591 [gnus-summary-catchup-and-exit
592 gnus-summary-catchup-and-exit t "Catchup and exit"]
593 [gnus-summary-exit gnus-summary-exit t "Exit this summary"])
594 "The summary buffer toolbar.")
596 (defvar gnus-summary-mail-toolbar
598 [gnus-summary-prev-unread
599 gnus-summary-prev-unread-article t "Prev unread article"]
600 [gnus-summary-next-unread
601 gnus-summary-next-unread-article t "Next unread article"]
602 [gnus-summary-mail-reply gnus-summary-reply t "Reply"]
603 [gnus-summary-mail-originate gnus-summary-post-news t "Originate"]
604 [gnus-summary-mail-save gnus-summary-save-article t "Save"]
605 [gnus-summary-mail-copy gnus-summary-copy-article t "Copy message"]
606 [gnus-summary-mail-forward gnus-summary-mail-forward t "Forward message"]
607 [gnus-summary-caesar-message
608 gnus-summary-caesar-message t "Rot 13"]
610 gnus-uu-decode-uu t "Decode uuencoded articles"]
611 [gnus-summary-save-article-file
612 gnus-summary-save-article-file t "Save article in file"]
613 [gnus-summary-save-article
614 gnus-summary-save-article t "Save article"]
615 [gnus-summary-cancel-article ; usenet : cancellation :: mail : deletion.
616 gnus-summary-delete-article t "Delete message"]
617 [gnus-summary-catchup
618 gnus-summary-catchup t "Catchup"]
619 [gnus-summary-catchup-and-exit
620 gnus-summary-catchup-and-exit t "Catchup and exit"]
621 [gnus-summary-exit gnus-summary-exit t "Exit this summary"])
622 "The summary buffer mail toolbar.")
624 (defun gnus-xmas-setup-group-toolbar ()
625 (and gnus-use-toolbar
626 (message-xmas-setup-toolbar gnus-group-toolbar nil "gnus")
627 (set-specifier (symbol-value gnus-use-toolbar)
628 (cons (current-buffer) gnus-group-toolbar))))
630 (defun gnus-xmas-setup-summary-toolbar ()
631 (let ((bar (if (gnus-news-group-p gnus-newsgroup-name)
632 gnus-summary-toolbar gnus-summary-mail-toolbar)))
633 (and gnus-use-toolbar
634 (message-xmas-setup-toolbar bar nil "gnus")
635 (set-specifier (symbol-value gnus-use-toolbar)
636 (cons (current-buffer) bar)))))
638 (defun gnus-xmas-mail-strip-quoted-names (address)
639 "Protect mail-strip-quoted-names from nil input.
640 XEmacs compatibility workaround."
643 (mail-strip-quoted-names address)))
645 (defun gnus-xmas-call-region (command &rest args)
647 'call-process-region (point-min) (point-max) command t '(t nil) nil
650 (defvar gnus-xmas-modeline-left-extent
651 (let ((ext (copy-extent modeline-buffer-id-left-extent)))
654 (defvar gnus-xmas-modeline-right-extent
655 (let ((ext (copy-extent modeline-buffer-id-right-extent)))
658 (defvar gnus-xmas-modeline-glyph
660 (let* ((file-xpm (expand-file-name "gnus-pointer.xpm"
661 gnus-xmas-glyph-directory))
662 (file-xbm (expand-file-name "gnus-pointer.xbm"
663 gnus-xmas-glyph-directory))
666 (cond ((featurep 'xpm)
667 ;; Let's try a nifty XPM
668 `[xpm :file ,file-xpm])
670 ;; Then a not-so-nifty XBM
671 `[xbm :file ,file-xbm])
672 ;; Then the simple string
673 (t [string :data "Gnus:"])))))
674 (set-glyph-face glyph 'modeline-buffer-id)
677 (defun gnus-xmas-mode-line-buffer-identification (line)
678 (let ((line (car line))
681 ;; This is some weird type of id.
682 ((not (stringp line))
684 ;; This is non-standard, so we just pass it through.
685 ((not (string-match "^Gnus:" line))
687 ;; We have a standard line, so we colorize and glyphize it a bit.
689 (setq chop (match-end 0))
691 (if gnus-xmas-modeline-glyph
692 (cons gnus-xmas-modeline-left-extent gnus-xmas-modeline-glyph)
693 (cons gnus-xmas-modeline-left-extent (substring line 0 chop)))
694 (cons gnus-xmas-modeline-right-extent (substring line chop)))))))
696 (defun gnus-xmas-splash ()
697 (when (eq (device-type) 'x)
700 (defun gnus-xmas-annotation-in-region-p (b e)
701 (or (map-extents (lambda (e u) t) nil b e nil nil 'mm t)
703 (eq (cadr (memq 'gnus-undeletable (text-properties-at b))) t)
704 (text-property-any b e 'gnus-undeletable t))))
706 (defun gnus-xmas-mime-button-menu (event prefix)
707 "Construct a context-sensitive menu of MIME commands."
709 (let ((response (get-popup-menu-response
711 ,@(mapcar (lambda (c) `[,(caddr c) ,(car c) t])
712 gnus-mime-button-commands)))))
713 (set-buffer (event-buffer event))
714 (goto-char (event-point event))
715 (funcall (event-function response) (event-object response))))
717 (defun gnus-group-add-icon ()
718 "Add an icon to the current line according to `gnus-group-icon-list'."
721 ;; now find out where the line starts and leave point there.
722 (beg (progn (beginning-of-line) (point))))
724 (narrow-to-region beg end)
726 (when (search-forward "==&&==" nil t)
727 (let* ((group (gnus-group-group-name))
728 (entry (gnus-group-entry group))
729 (unread (if (numberp (car entry)) (car entry) 0))
730 (active (gnus-active group))
731 (total (if active (1+ (- (cdr active) (car active))) 0))
733 (method (gnus-server-get-method group (gnus-info-method info)))
734 (marked (gnus-info-marks info))
735 (mailp (memq 'mail (assoc (symbol-name
736 (car (or method gnus-select-method)))
737 gnus-valid-select-methods)))
738 (level (or (gnus-info-level info) gnus-level-killed))
739 (score (or (gnus-info-score info) 0))
740 (ticked (gnus-range-length (cdr (assq 'tick marked))))
741 (group-age (gnus-group-timestamp-delta group))
742 (inhibit-read-only t)
743 (list gnus-group-icon-list)
744 (mystart (match-beginning 0))
745 (myend (match-end 0)))
746 (goto-char (point-min))
748 (not (eval (caar list))))
749 (setq list (cdr list)))
751 (let* ((file (cdar list))
752 (glyph (gnus-group-icon-create-glyph
753 (buffer-substring mystart myend)
757 (mapcar 'delete-annotation (annotations-at myend))
758 (let ((ext (make-extent mystart myend))
759 (ant (make-annotation glyph myend 'text)))
760 ;; set text extent params
761 (set-extent-property ext 'end-open t)
762 (set-extent-property ext 'start-open t)
763 (set-extent-property ext 'invisible t)))
764 (delete-region mystart myend)))
765 (delete-region mystart myend))))
769 (defun gnus-group-icon-create-glyph (substring pixmap)
770 "Create a glyph for insertion into a group line."
772 (cdr-safe (assoc pixmap gnus-group-icon-cache))
773 (let* ((glyph (make-glyph
776 (expand-file-name pixmap gnus-xmas-glyph-directory))
778 (expand-file-name pixmap gnus-xmas-glyph-directory))
779 (cons 'tty substring)))))
780 (setq gnus-group-icon-cache
781 (cons (cons pixmap glyph) gnus-group-icon-cache))
782 (set-glyph-face glyph 'default)
785 (defun gnus-xmas-mailing-list-menu-add ()
786 (gnus-xmas-menu-add mailing-list
787 gnus-mailing-list-menu))
789 (defun gnus-xmas-image-type-available-p (type)
791 (featurep (if (eq type 'pbm) 'xbm type))))
793 (defun gnus-xmas-create-image (file &optional type data-p &rest props)
796 (car (last (split-string file "[.]")))))
797 (face (plist-get props :face))
799 (when (equal type "pbm")
803 (insert-file-contents-literally file))
804 (shell-command-on-region (point-min) (point-max)
805 "ppmtoxpm 2>/dev/null" t)
806 (setq file (buffer-string)
810 (if (equal type "xbm")
811 (make-glyph (list (cons 'x file)))
815 (insert-file-contents-literally file))
819 (mm-image-type-from-buffer))
820 :data (buffer-string))))))
822 (set-glyph-face glyph face))
825 (defun gnus-xmas-put-image (glyph &optional string category)
826 "Insert STRING, but display GLYPH.
827 Warning: Don't insert text immediately after the image."
828 (let ((begin (point))
830 (if (and (bobp) (not string))
834 (setq begin (1- begin)))
835 (setq extent (make-extent begin (point)))
836 (set-extent-property extent 'gnus-image category)
837 (set-extent-property extent 'duplicable t)
839 (set-extent-property extent 'invisible t))
840 (set-extent-property extent 'end-glyph glyph))
843 (defun gnus-xmas-remove-image (image &optional category)
846 (when (equal (extent-end-glyph ext) image)
847 (set-extent-property ext 'invisible nil)
848 (set-extent-property ext 'end-glyph nil))
850 nil nil nil nil nil 'gnus-image category))
852 (defun gnus-xmas-assq-delete-all (key alist)
854 (while (setq elem (assq key alist))
855 (setq alist (delq elem alist)))
860 ;;; gnus-xmas.el ends here