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)
42 (require 'run-at-time)
44 (defgroup gnus-xmas nil
45 "XEmacsoid support for Gnus"
48 (defcustom gnus-xmas-glyph-directory nil
49 "Directory where Gnus logos and icons are located.
50 If this variable is nil, Gnus will try to locate the directory
52 :type '(choice (const :tag "autodetect" nil)
56 (unless gnus-xmas-glyph-directory
57 (unless (setq gnus-xmas-glyph-directory
58 (message-xmas-find-glyph-directory "gnus"))
59 (error "Can't find glyph directory. \
60 Possibly the `etc' directory has not been installed.")))
62 ;;; Internal variables.
64 ;; Don't warn about these undefined variables.
67 (defvar gnus-active-hashtb)
68 (defvar gnus-article-buffer)
69 (defvar gnus-auto-center-summary)
70 (defvar gnus-current-headers)
71 (defvar gnus-level-killed)
72 (defvar gnus-level-zombie)
73 (defvar gnus-newsgroup-bookmarks)
74 (defvar gnus-newsgroup-dependencies)
75 (defvar gnus-newsgroup-selected-overlay)
76 (defvar gnus-newsrc-hashtb)
77 (defvar gnus-read-mark)
78 (defvar gnus-refer-article-method)
79 (defvar gnus-reffed-article-number)
80 (defvar gnus-unread-mark)
82 (defvar gnus-view-pseudos)
83 (defvar gnus-view-pseudos-separately)
85 (defvar gnus-zombie-list)
86 ;;defined in gnus-msg.el
87 (defvar gnus-article-copy)
88 (defvar gnus-check-before-posting)
89 ;;defined in gnus-vis.el
90 (defvar gnus-article-button-face)
91 (defvar gnus-article-mouse-face)
92 (defvar gnus-summary-selected-face)
93 (defvar gnus-group-reading-menu)
94 (defvar gnus-group-group-menu)
95 (defvar gnus-group-misc-menu)
96 (defvar gnus-summary-article-menu)
97 (defvar gnus-summary-thread-menu)
98 (defvar gnus-summary-misc-menu)
99 (defvar gnus-summary-post-menu)
100 (defvar gnus-summary-kill-menu)
101 (defvar gnus-article-article-menu)
102 (defvar gnus-article-treatment-menu)
103 (defvar gnus-mouse-2)
104 (defvar standard-display-table)
105 (defvar gnus-tree-minimize-window)
107 (defun gnus-xmas-highlight-selected-summary ()
108 ;; Highlight selected article in summary buffer
109 (when gnus-summary-selected-face
110 (when gnus-newsgroup-selected-overlay
111 (delete-extent gnus-newsgroup-selected-overlay))
112 (setq gnus-newsgroup-selected-overlay
113 (make-extent (point-at-bol) (point-at-eol)))
114 (set-extent-face gnus-newsgroup-selected-overlay
115 gnus-summary-selected-face)))
117 (defcustom gnus-xmas-force-redisplay nil
118 "*If non-nil, force a redisplay before recentering the summary buffer.
119 This is ugly, but it works around a bug in `window-displayed-height'."
123 (defun gnus-xmas-switch-horizontal-scrollbar-off ()
124 (when (featurep 'scrollbar)
125 (set-specifier scrollbar-height (cons (current-buffer) 0))))
127 (defun gnus-xmas-summary-recenter ()
128 "\"Center\" point in the summary window.
129 If `gnus-auto-center-summary' is nil, or the article buffer isn't
130 displayed, no centering will be performed."
131 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
132 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
133 ;; Force redisplay to get properly computed window height.
134 (when gnus-xmas-force-redisplay
136 (when gnus-auto-center-summary
137 (let* ((height (if (fboundp 'window-displayed-height)
138 (window-displayed-height)
139 (- (window-height) 2)))
140 (top (cond ((< height 4) 0)
142 (t (if (numberp gnus-auto-center-summary)
143 gnus-auto-center-summary
145 (bottom (save-excursion (goto-char (point-max))
146 (forward-line (- height))
148 (window (get-buffer-window (current-buffer))))
149 (when (get-buffer-window gnus-article-buffer)
150 ;; Only do recentering when the article buffer is displayed,
151 ;; Set the window start to either `bottom', which is the biggest
152 ;; possible valid number, or the second line from the top,
153 ;; whichever is the least.
154 ;; NOFORCE parameter suggested by Daniel Pittman <daniel@danann.net>.
156 window (min bottom (save-excursion (forward-line (- top)) (point)))
158 ;; Do horizontal recentering while we're at it.
159 (when (and (get-buffer-window (current-buffer) t)
160 (not (eq gnus-auto-center-summary 'vertical)))
161 (let ((selected (selected-window)))
162 (select-window (get-buffer-window (current-buffer) t))
163 (gnus-summary-position-point)
164 (gnus-horizontal-recenter)
165 (select-window selected))))))
167 (defun gnus-xmas-summary-set-display-table ()
168 ;; Setup the display table -- like `gnus-summary-setup-display-table',
169 ;; but done in an XEmacsish way.
170 (let ((table (make-display-table))
172 ;; Nix out all the control chars...
173 (while (>= (setq i (1- i)) 0)
175 ;; ... but not newline and cr, of course. (cr is necessary for the
176 ;; selective display).
179 ;; We keep TAB as well.
181 ;; We nix out any glyphs over 126 below ctl-arrow.
182 (let ((i (if (integerp ctl-arrow) ctl-arrow 160)))
183 (while (>= (setq i (1- i)) 127)
184 (unless (aref table i)
185 (aset table i [??]))))
186 ;; Can't use `set-specifier' because of a bug in 19.14 and earlier
187 (add-spec-to-specifier current-display-table table (current-buffer) nil)))
189 (defun gnus-xmas-add-text-properties (start end props &optional object)
190 (add-text-properties start end props object)
191 (put-text-property start end 'start-closed nil object))
193 (defun gnus-xmas-put-text-property (start end prop value &optional object)
194 (put-text-property start end prop value object)
195 (put-text-property start end 'start-closed nil object))
197 (defun gnus-xmas-extent-start-open (point)
198 (map-extents (lambda (extent arg)
199 (set-extent-property extent 'start-open t))
200 nil point (min (1+ (point)) (point-max))))
202 (defun gnus-xmas-article-push-button (event)
203 "Check text under the mouse pointer for a callback function.
204 If the text under the mouse pointer has a `gnus-callback' property,
205 call it with the value of the `gnus-data' text property."
207 (set-buffer (window-buffer (event-window event)))
208 (let* ((pos (event-closest-point event))
209 (data (get-text-property pos 'gnus-data))
210 (fun (get-text-property pos 'gnus-callback)))
213 (funcall fun data))))
215 (defun gnus-xmas-move-overlay (extent start end &optional buffer)
216 (set-extent-endpoints extent start end buffer))
218 (defun gnus-xmas-kill-all-overlays ()
219 "Delete all extents in the current buffer."
220 (map-extents (lambda (extent ignore)
221 (delete-extent extent)
224 (defun gnus-xmas-window-top-edge (&optional window)
225 (nth 1 (window-pixel-edges window)))
227 (defun gnus-xmas-tree-minimize ()
228 (when (and gnus-tree-minimize-window
229 (not (one-window-p)))
230 (let* ((window-min-height 2)
231 (height (1+ (count-lines (point-min) (point-max))))
232 (min (max (1- window-min-height) height))
233 (tot (if (numberp gnus-tree-minimize-window)
234 (min gnus-tree-minimize-window min)
236 (win (get-buffer-window (current-buffer)))
237 (wh (and win (1- (window-height win)))))
240 (let ((selected (selected-window)))
242 (enlarge-window (- tot wh))
243 (select-window selected))))))
245 ;; Select the lowest window on the frame.
246 (defun gnus-xmas-appt-select-lowest-window ()
247 (let* ((lowest-window (selected-window))
248 (bottom-edge (car (cdr (cdr (cdr (window-pixel-edges))))))
249 (last-window (previous-window))
252 (let* ((this-window (next-window))
253 (next-bottom-edge (car (cdr (cdr (cdr
256 (when (< bottom-edge next-bottom-edge)
257 (setq bottom-edge next-bottom-edge)
258 (setq lowest-window this-window))
260 (select-window this-window)
261 (when (eq last-window this-window)
262 (select-window lowest-window)
263 (setq window-search nil))))))
265 (defmacro gnus-xmas-menu-add (type &rest menus)
266 `(gnus-xmas-menu-add-1 ',type ',menus))
267 (put 'gnus-xmas-menu-add 'lisp-indent-function 1)
269 (defun gnus-xmas-menu-add-1 (type menus)
270 (when (and menu-bar-mode
271 (gnus-visual-p (intern (format "%s-menu" type)) 'menu))
273 (easy-menu-add (symbol-value (pop menus))))))
275 (defun gnus-xmas-group-menu-add ()
276 (gnus-xmas-menu-add group
277 gnus-group-reading-menu gnus-group-group-menu gnus-group-misc-menu))
279 (defun gnus-xmas-summary-menu-add ()
280 (gnus-xmas-menu-add summary
281 gnus-summary-misc-menu gnus-summary-kill-menu
282 gnus-summary-article-menu gnus-summary-thread-menu
283 gnus-summary-post-menu ))
285 (defun gnus-xmas-article-menu-add ()
286 (gnus-xmas-menu-add article
287 gnus-article-article-menu gnus-article-treatment-menu
288 gnus-article-post-menu gnus-article-commands-menu))
290 (defun gnus-xmas-score-menu-add ()
291 (gnus-xmas-menu-add score
294 (defun gnus-xmas-pick-menu-add ()
295 (gnus-xmas-menu-add pick
298 (defun gnus-xmas-topic-menu-add ()
299 (gnus-xmas-menu-add topic
302 (defun gnus-xmas-binary-menu-add ()
303 (gnus-xmas-menu-add binary
306 (defun gnus-xmas-agent-summary-menu-add ()
307 (gnus-xmas-menu-add agent-summary
308 gnus-agent-summary-menu))
310 (defun gnus-xmas-agent-group-menu-add ()
311 (gnus-xmas-menu-add agent-group
312 gnus-agent-group-menu))
314 (defun gnus-xmas-agent-server-menu-add ()
315 (gnus-xmas-menu-add agent-server
316 gnus-agent-server-menu))
318 (defun gnus-xmas-tree-menu-add ()
319 (gnus-xmas-menu-add tree
322 (defun gnus-xmas-draft-menu-add ()
323 (gnus-xmas-menu-add draft
326 (defun gnus-xmas-server-menu-add ()
327 (gnus-xmas-menu-add menu
328 gnus-server-server-menu gnus-server-connections-menu))
330 (defun gnus-xmas-browse-menu-add ()
331 (gnus-xmas-menu-add browse
334 (defun gnus-xmas-grouplens-menu-add ()
335 (gnus-xmas-menu-add grouplens
336 gnus-grouplens-menu))
338 (defun gnus-xmas-read-event-char (&optional prompt)
339 "Get the next event."
341 (message "%s" prompt))
342 (let ((event (next-command-event)))
344 ;; We junk all non-key events. Is this naughty?
345 (while (not (or (key-press-event-p event)
346 (button-press-event-p event)))
347 (dispatch-event event)
348 (setq event (next-command-event)))
349 (cons (and (key-press-event-p event)
350 (event-to-character event))
353 (defun gnus-xmas-define ()
354 (setq gnus-mouse-2 [button2])
355 (setq gnus-mouse-3 [button3])
356 (setq gnus-widget-button-keymap widget-button-keymap)
358 (unless (memq 'underline (face-list))
359 (and (fboundp 'make-face)
360 (funcall (intern "make-face") 'underline)))
361 ;; Must avoid calling set-face-underline-p directly, because it
362 ;; is a defsubst in emacs19, and will make the .elc files non
364 (unless (face-differs-from-default-p 'underline)
365 (funcall (intern "set-face-underline-p") 'underline t))
368 ((fboundp 'char-or-char-int-p)
369 ;; Handle both types of marks for XEmacs-20.x.
370 (defalias 'gnus-characterp 'char-or-char-int-p))
371 ;; V19 of XEmacs, probably.
373 (defalias 'gnus-characterp 'characterp)))
375 (defalias 'gnus-make-overlay 'make-extent)
376 (defalias 'gnus-delete-overlay 'delete-extent)
377 (defalias 'gnus-overlay-put 'set-extent-property)
378 (defalias 'gnus-move-overlay 'gnus-xmas-move-overlay)
379 (defalias 'gnus-overlay-buffer 'extent-object)
380 (defalias 'gnus-overlay-start 'extent-start-position)
381 (defalias 'gnus-overlay-end 'extent-end-position)
382 (defalias 'gnus-kill-all-overlays 'gnus-xmas-kill-all-overlays)
383 (defalias 'gnus-extent-detached-p 'extent-detached-p)
384 (defalias 'gnus-add-text-properties 'gnus-xmas-add-text-properties)
385 (defalias 'gnus-put-text-property 'gnus-xmas-put-text-property)
386 (defalias 'gnus-deactivate-mark 'ignore)
387 (defalias 'gnus-window-edges 'window-pixel-edges)
388 (defalias 'gnus-assq-delete-all 'gnus-xmas-assq-delete-all)
390 (unless (boundp 'standard-display-table)
391 (setq standard-display-table nil))
393 (defvar gnus-mouse-face-prop 'highlight)
395 (defun gnus-byte-code (func)
396 "Return a form that can be `eval'ed based on FUNC."
397 (let ((fval (indirect-function func)))
398 (if (compiled-function-p fval)
400 (cons 'progn (cdr (cdr fval))))))
402 (unless (fboundp 'match-string-no-properties)
403 (defalias 'match-string-no-properties 'match-string))
405 (defalias 'gnus-x-color-values
406 (if (fboundp 'x-color-values)
409 (color-instance-rgb-components
410 (make-color-instance color)))))
412 (unless (fboundp 'char-width)
413 (defalias 'char-width (lambda (ch) 1))))
415 (defun gnus-xmas-redefine ()
416 "Redefine lots of Gnus functions for XEmacs."
417 (defalias 'gnus-summary-set-display-table 'gnus-xmas-summary-set-display-table)
418 (defalias 'gnus-visual-turn-off-edit-menu 'identity)
419 (defalias 'gnus-summary-recenter 'gnus-xmas-summary-recenter)
420 (defalias 'gnus-extent-start-open 'gnus-xmas-extent-start-open)
421 (defalias 'gnus-article-push-button 'gnus-xmas-article-push-button)
422 (defalias 'gnus-window-top-edge 'gnus-xmas-window-top-edge)
423 (defalias 'gnus-read-event-char 'gnus-xmas-read-event-char)
424 (defalias 'gnus-group-startup-message 'gnus-xmas-group-startup-message)
425 (defalias 'gnus-tree-minimize 'gnus-xmas-tree-minimize)
426 (defalias 'gnus-appt-select-lowest-window
427 'gnus-xmas-appt-select-lowest-window)
428 (defalias 'gnus-mail-strip-quoted-names 'gnus-xmas-mail-strip-quoted-names)
429 (defalias 'gnus-character-to-event 'character-to-event)
430 (defalias 'gnus-mode-line-buffer-identification
431 'gnus-xmas-mode-line-buffer-identification)
432 (defalias 'gnus-key-press-event-p 'key-press-event-p)
433 (defalias 'gnus-region-active-p 'region-active-p)
434 (defalias 'gnus-mark-active-p 'region-exists-p)
435 (defalias 'gnus-annotation-in-region-p 'gnus-xmas-annotation-in-region-p)
436 (defalias 'gnus-mime-button-menu 'gnus-xmas-mime-button-menu)
437 (defalias 'gnus-image-type-available-p 'gnus-xmas-image-type-available-p)
438 (defalias 'gnus-put-image 'gnus-xmas-put-image)
439 (defalias 'gnus-create-image 'gnus-xmas-create-image)
440 (defalias 'gnus-remove-image 'gnus-xmas-remove-image)
442 ;; These ones are not defcutom'ed, sometimes not even defvar'ed. They
443 ;; probably should. If that is done, the code below should then be moved
444 ;; where each variable is defined, in order not to mess with user settings.
446 (add-hook 'gnus-score-mode-hook 'gnus-xmas-score-menu-add)
447 (add-hook 'gnus-binary-mode-hook 'gnus-xmas-binary-menu-add)
448 (add-hook 'gnus-grouplens-mode-hook 'gnus-xmas-grouplens-menu-add)
449 (add-hook 'gnus-server-mode-hook 'gnus-xmas-server-menu-add)
450 (add-hook 'gnus-browse-mode-hook 'gnus-xmas-browse-menu-add)
451 (add-hook 'gnus-draft-mode-hook 'gnus-xmas-draft-menu-add)
452 (add-hook 'gnus-mailing-list-mode-hook 'gnus-xmas-mailing-list-menu-add))
455 ;;; XEmacs logo and toolbar.
457 (defun gnus-xmas-group-startup-message (&optional x y)
458 "Insert startup message in current buffer."
459 ;; Insert the message.
462 ((and (console-on-window-system-p)
465 (let* ((logo-xpm (expand-file-name "gnus.xpm" gnus-xmas-glyph-directory))
466 (logo-xbm (expand-file-name "gnus.xbm" gnus-xmas-glyph-directory))
468 (cond ((featurep 'xpm)
472 (("thing" . ,(car gnus-logo-colors))
473 ("shadow" . ,(cadr gnus-logo-colors))
475 ("background" . ,(face-background 'default)))])
477 `[xbm :file ,logo-xbm])
480 (set-extent-begin-glyph (make-extent (point) (point)) glyph)
481 (goto-char (point-min))
483 (insert (make-string (/ (max (- (window-width) (or x 35)) 0) 2)
486 (setq gnus-simple-splash nil))
487 (goto-char (point-min))
488 (let* ((pheight (+ 20 (count-lines (point-min) (point-max))))
489 (wheight (window-height))
490 (rest (- wheight pheight)))
491 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n))))
496 _ ___ __ ___ __ _ ___
516 (gnus-indent-rigidly (point-min) (point-max)
517 (/ (max (- (window-width) (or x 46)) 0) 2))
518 (goto-char (point-min))
520 (let* ((pheight (count-lines (point-min) (point-max)))
521 (wheight (window-height))
522 (rest (- wheight pheight)))
523 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
525 (put-text-property (point-min) (point-max) 'face 'gnus-splash-face)))
526 (setq modeline-buffer-identification
527 (list (concat gnus-version ": *Group*")))
528 (set-buffer-modified-p t))
533 (defcustom gnus-use-toolbar (if (featurep 'toolbar)
536 "*If nil, do not use a toolbar.
537 If it is non-nil, it must be a toolbar. The five valid values are
538 `default-toolbar', `top-toolbar', `bottom-toolbar',
539 `right-toolbar', and `left-toolbar'."
540 :type '(choice (const default-toolbar)
541 (const top-toolbar) (const bottom-toolbar)
542 (const left-toolbar) (const right-toolbar)
543 (const :tag "no toolbar" nil))
546 (defvar gnus-group-toolbar
547 '([gnus-group-get-new-news gnus-group-get-new-news t "Get new news"]
548 [gnus-group-get-new-news-this-group
549 gnus-group-get-new-news-this-group t "Get new news in this group"]
550 [gnus-group-catchup-current
551 gnus-group-catchup-current t "Catchup group"]
552 [gnus-group-describe-group
553 gnus-group-describe-group t "Describe group"]
554 [gnus-group-unsubscribe gnus-group-unsubscribe t "Unsubscribe group"]
555 [gnus-group-subscribe gnus-group-subscribe t "Subscribe group"]
556 [gnus-group-kill-group gnus-group-kill-group t "Kill group"]
557 [gnus-summary-mail-save
558 gnus-group-save-newsrc t "Save .newsrc files"] ; borrowed icon.
559 [gnus-group-exit gnus-group-exit t "Exit Gnus"])
560 "The group buffer toolbar.")
562 (defvar gnus-summary-toolbar
563 '([gnus-summary-prev-unread
564 gnus-summary-prev-page-or-article t "Page up"]
565 [gnus-summary-next-unread
566 gnus-summary-next-page t "Page down"]
567 [gnus-summary-post-news
568 gnus-summary-post-news t "Post an article"]
569 [gnus-summary-followup-with-original
570 gnus-summary-followup-with-original t
571 "Post a followup and yank the original"]
572 [gnus-summary-followup
573 gnus-summary-followup t "Post a followup"]
574 [gnus-summary-reply-with-original
575 gnus-summary-reply-with-original t "Mail a reply and yank the original"]
577 gnus-summary-reply t "Mail a reply"]
578 [gnus-summary-caesar-message
579 gnus-summary-caesar-message t "Rot 13"]
581 gnus-uu-decode-uu t "Decode uuencoded articles"]
582 [gnus-summary-save-article-file
583 gnus-summary-save-article-file t "Save article in file"]
584 [gnus-summary-save-article
585 gnus-summary-save-article t "Save article"]
587 gnus-uu-post-news t "Post a uuencoded article"]
588 [gnus-summary-cancel-article
589 gnus-summary-cancel-article t "Cancel article"]
590 [gnus-summary-catchup
591 gnus-summary-catchup t "Catchup"]
592 [gnus-summary-catchup-and-exit
593 gnus-summary-catchup-and-exit t "Catchup and exit"]
594 [gnus-summary-exit gnus-summary-exit t "Exit this summary"])
595 "The summary buffer toolbar.")
597 (defvar gnus-summary-mail-toolbar
599 [gnus-summary-prev-unread
600 gnus-summary-prev-unread-article t "Prev unread article"]
601 [gnus-summary-next-unread
602 gnus-summary-next-unread-article t "Next unread article"]
603 [gnus-summary-mail-reply gnus-summary-reply t "Reply"]
604 [gnus-summary-mail-originate gnus-summary-post-news t "Originate"]
605 [gnus-summary-mail-save gnus-summary-save-article t "Save"]
606 [gnus-summary-mail-copy gnus-summary-copy-article t "Copy message"]
607 [gnus-summary-mail-forward gnus-summary-mail-forward t "Forward message"]
608 [gnus-summary-caesar-message
609 gnus-summary-caesar-message t "Rot 13"]
611 gnus-uu-decode-uu t "Decode uuencoded articles"]
612 [gnus-summary-save-article-file
613 gnus-summary-save-article-file t "Save article in file"]
614 [gnus-summary-save-article
615 gnus-summary-save-article t "Save article"]
616 [gnus-summary-cancel-article ; usenet : cancellation :: mail : deletion.
617 gnus-summary-delete-article t "Delete message"]
618 [gnus-summary-catchup
619 gnus-summary-catchup t "Catchup"]
620 [gnus-summary-catchup-and-exit
621 gnus-summary-catchup-and-exit t "Catchup and exit"]
622 [gnus-summary-exit gnus-summary-exit t "Exit this summary"])
623 "The summary buffer mail toolbar.")
625 (defun gnus-xmas-setup-group-toolbar ()
626 (and gnus-use-toolbar
627 (message-xmas-setup-toolbar gnus-group-toolbar nil "gnus")
628 (set-specifier (symbol-value gnus-use-toolbar)
629 (cons (current-buffer) gnus-group-toolbar))))
631 (defun gnus-xmas-setup-summary-toolbar ()
632 (let ((bar (if (gnus-news-group-p gnus-newsgroup-name)
633 gnus-summary-toolbar gnus-summary-mail-toolbar)))
634 (and gnus-use-toolbar
635 (message-xmas-setup-toolbar bar nil "gnus")
636 (set-specifier (symbol-value gnus-use-toolbar)
637 (cons (current-buffer) bar)))))
639 (defun gnus-xmas-mail-strip-quoted-names (address)
640 "Protect mail-strip-quoted-names from nil input.
641 XEmacs compatibility workaround."
644 (mail-strip-quoted-names address)))
646 (defun gnus-xmas-call-region (command &rest args)
648 'call-process-region (point-min) (point-max) command t '(t nil) nil
651 (defvar gnus-xmas-modeline-left-extent
652 (let ((ext (copy-extent modeline-buffer-id-left-extent)))
655 (defvar gnus-xmas-modeline-right-extent
656 (let ((ext (copy-extent modeline-buffer-id-right-extent)))
659 (defvar gnus-xmas-modeline-glyph
661 (let* ((file-xpm (expand-file-name "gnus-pointer.xpm"
662 gnus-xmas-glyph-directory))
663 (file-xbm (expand-file-name "gnus-pointer.xbm"
664 gnus-xmas-glyph-directory))
667 (cond ((featurep 'xpm)
668 ;; Let's try a nifty XPM
669 `[xpm :file ,file-xpm])
671 ;; Then a not-so-nifty XBM
672 `[xbm :file ,file-xbm])
673 ;; Then the simple string
674 (t [string :data "Gnus:"])))))
675 (set-glyph-face glyph 'modeline-buffer-id)
678 (defun gnus-xmas-mode-line-buffer-identification (line)
679 (let ((line (car line))
682 ;; This is some weird type of id.
683 ((not (stringp line))
685 ;; This is non-standard, so we just pass it through.
686 ((not (string-match "^Gnus:" line))
688 ;; We have a standard line, so we colorize and glyphize it a bit.
690 (setq chop (match-end 0))
692 (if gnus-xmas-modeline-glyph
693 (cons gnus-xmas-modeline-left-extent gnus-xmas-modeline-glyph)
694 (cons gnus-xmas-modeline-left-extent (substring line 0 chop)))
695 (cons gnus-xmas-modeline-right-extent (substring line chop)))))))
697 (defun gnus-xmas-splash ()
698 (when (eq (device-type) 'x)
701 (defun gnus-xmas-annotation-in-region-p (b e)
702 (or (map-extents (lambda (e u) t) nil b e nil nil 'mm t)
704 (eq (cadr (memq 'gnus-undeletable (text-properties-at b))) t)
705 (text-property-any b e 'gnus-undeletable t))))
707 (defun gnus-xmas-mime-button-menu (event prefix)
708 "Construct a context-sensitive menu of MIME commands."
710 (let ((response (get-popup-menu-response
712 ,@(mapcar (lambda (c) `[,(caddr c) ,(car c) t])
713 gnus-mime-button-commands)))))
714 (set-buffer (event-buffer event))
715 (goto-char (event-point event))
716 (funcall (event-function response) (event-object response))))
718 (defun gnus-group-add-icon ()
719 "Add an icon to the current line according to `gnus-group-icon-list'."
722 ;; now find out where the line starts and leave point there.
723 (beg (progn (beginning-of-line) (point))))
725 (narrow-to-region beg end)
727 (when (search-forward "==&&==" nil t)
728 (let* ((group (gnus-group-group-name))
729 (entry (gnus-group-entry group))
730 (unread (if (numberp (car entry)) (car entry) 0))
731 (active (gnus-active group))
732 (total (if active (1+ (- (cdr active) (car active))) 0))
734 (method (gnus-server-get-method group (gnus-info-method info)))
735 (marked (gnus-info-marks info))
736 (mailp (memq 'mail (assoc (symbol-name
737 (car (or method gnus-select-method)))
738 gnus-valid-select-methods)))
739 (level (or (gnus-info-level info) gnus-level-killed))
740 (score (or (gnus-info-score info) 0))
741 (ticked (gnus-range-length (cdr (assq 'tick marked))))
742 (group-age (gnus-group-timestamp-delta group))
743 (inhibit-read-only t)
744 (list gnus-group-icon-list)
745 (mystart (match-beginning 0))
746 (myend (match-end 0)))
747 (goto-char (point-min))
749 (not (eval (caar list))))
750 (setq list (cdr list)))
752 (let* ((file (cdar list))
753 (glyph (gnus-group-icon-create-glyph
754 (buffer-substring mystart myend)
758 (mapcar 'delete-annotation (annotations-at myend))
759 (let ((ext (make-extent mystart myend))
760 (ant (make-annotation glyph myend 'text)))
761 ;; set text extent params
762 (set-extent-property ext 'end-open t)
763 (set-extent-property ext 'start-open t)
764 (set-extent-property ext 'invisible t)))
765 (delete-region mystart myend)))
766 (delete-region mystart myend))))
770 (defun gnus-group-icon-create-glyph (substring pixmap)
771 "Create a glyph for insertion into a group line."
773 (cdr-safe (assoc pixmap gnus-group-icon-cache))
774 (let* ((glyph (make-glyph
777 (expand-file-name pixmap gnus-xmas-glyph-directory))
779 (expand-file-name pixmap gnus-xmas-glyph-directory))
780 (cons 'tty substring)))))
781 (setq gnus-group-icon-cache
782 (cons (cons pixmap glyph) gnus-group-icon-cache))
783 (set-glyph-face glyph 'default)
786 (defun gnus-xmas-mailing-list-menu-add ()
787 (gnus-xmas-menu-add mailing-list
788 gnus-mailing-list-menu))
790 (defun gnus-xmas-image-type-available-p (type)
792 (featurep (if (eq type 'pbm) 'xbm type))))
794 (defun gnus-xmas-create-image (file &optional type data-p &rest props)
797 (car (last (split-string file "[.]")))))
798 (face (plist-get props :face))
800 (when (equal type "pbm")
804 (insert-file-contents-literally file))
805 (shell-command-on-region (point-min) (point-max)
806 "ppmtoxpm 2>/dev/null" t)
807 (setq file (buffer-string)
811 (if (equal type "xbm")
812 (make-glyph (list (cons 'x file)))
816 (insert-file-contents-literally file))
820 (mm-image-type-from-buffer))
821 :data (buffer-string))))))
823 (set-glyph-face glyph face))
826 (defun gnus-xmas-put-image (glyph &optional string category)
827 "Insert STRING, but display GLYPH.
828 Warning: Don't insert text immediately after the image."
829 (let ((begin (point))
831 (if (and (bobp) (not string))
835 (setq begin (1- begin)))
836 (setq extent (make-extent begin (point)))
837 (set-extent-property extent 'gnus-image category)
838 (set-extent-property extent 'duplicable t)
840 (set-extent-property extent 'invisible t))
841 (set-extent-property extent 'end-glyph glyph))
844 (defun gnus-xmas-remove-image (image &optional category)
847 (when (equal (extent-end-glyph ext) image)
848 (set-extent-property ext 'invisible nil)
849 (set-extent-property ext 'end-glyph nil))
851 nil nil nil nil nil 'gnus-image category))
853 (defun gnus-xmas-assq-delete-all (key alist)
855 (while (setq elem (assq key alist))
856 (setq alist (delq elem alist)))
861 ;;; gnus-xmas.el ends here