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-set-text-properties (start end props &optional buffer)
107 "You should NEVER use this function. It is ideologically blasphemous.
108 It is provided only to ease porting of broken FSF Emacs programs."
111 (map-extents (lambda (extent ignored)
112 (remove-text-properties
114 (list (extent-property extent 'text-prop) nil)
117 buffer start end nil nil 'text-prop)
118 (gnus-add-text-properties start end props buffer)))
120 (defun gnus-xmas-highlight-selected-summary ()
121 ;; Highlight selected article in summary buffer
122 (when gnus-summary-selected-face
123 (when gnus-newsgroup-selected-overlay
124 (delete-extent gnus-newsgroup-selected-overlay))
125 (setq gnus-newsgroup-selected-overlay
126 (make-extent (point-at-bol) (point-at-eol)))
127 (set-extent-face gnus-newsgroup-selected-overlay
128 gnus-summary-selected-face)))
130 (defcustom gnus-xmas-force-redisplay nil
131 "*If non-nil, force a redisplay before recentering the summary buffer.
132 This is ugly, but it works around a bug in `window-displayed-height'."
136 (defun gnus-xmas-switch-horizontal-scrollbar-off ()
137 (when (featurep 'scrollbar)
138 (set-specifier scrollbar-height (cons (current-buffer) 0))))
140 (defun gnus-xmas-summary-recenter ()
141 "\"Center\" point in the summary window.
142 If `gnus-auto-center-summary' is nil, or the article buffer isn't
143 displayed, no centering will be performed."
144 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
145 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
146 ;; Force redisplay to get properly computed window height.
147 (when gnus-xmas-force-redisplay
149 (when gnus-auto-center-summary
150 (let* ((height (if (fboundp 'window-displayed-height)
151 (window-displayed-height)
152 (- (window-height) 2)))
153 (top (cond ((< height 4) 0)
155 (t (if (numberp gnus-auto-center-summary)
156 gnus-auto-center-summary
158 (bottom (save-excursion (goto-char (point-max))
159 (forward-line (- height))
161 (window (get-buffer-window (current-buffer))))
162 (when (get-buffer-window gnus-article-buffer)
163 ;; Only do recentering when the article buffer is displayed,
164 ;; Set the window start to either `bottom', which is the biggest
165 ;; possible valid number, or the second line from the top,
166 ;; whichever is the least.
167 ;; NOFORCE parameter suggested by Daniel Pittman <daniel@danann.net>.
169 window (min bottom (save-excursion (forward-line (- top)) (point)))
171 ;; Do horizontal recentering while we're at it.
172 (when (and (get-buffer-window (current-buffer) t)
173 (not (eq gnus-auto-center-summary 'vertical)))
174 (let ((selected (selected-window)))
175 (select-window (get-buffer-window (current-buffer) t))
176 (gnus-summary-position-point)
177 (gnus-horizontal-recenter)
178 (select-window selected))))))
180 (defun gnus-xmas-summary-set-display-table ()
181 ;; Setup the display table -- like `gnus-summary-setup-display-table',
182 ;; but done in an XEmacsish way.
183 (let ((table (make-display-table))
185 ;; Nix out all the control chars...
186 (while (>= (setq i (1- i)) 0)
188 ;; ... but not newline and cr, of course. (cr is necessary for the
189 ;; selective display).
192 ;; We keep TAB as well.
194 ;; We nix out any glyphs over 126 below ctl-arrow.
195 (let ((i (if (integerp ctl-arrow) ctl-arrow 160)))
196 (while (>= (setq i (1- i)) 127)
197 (unless (aref table i)
198 (aset table i [??]))))
199 ;; Can't use `set-specifier' because of a bug in 19.14 and earlier
200 (add-spec-to-specifier current-display-table table (current-buffer) nil)))
202 (defun gnus-xmas-add-text-properties (start end props &optional object)
203 (add-text-properties start end props object)
204 (put-text-property start end 'start-closed nil object))
206 (defun gnus-xmas-put-text-property (start end prop value &optional object)
207 (put-text-property start end prop value object)
208 (put-text-property start end 'start-closed nil object))
210 (defun gnus-xmas-extent-start-open (point)
211 (map-extents (lambda (extent arg)
212 (set-extent-property extent 'start-open t))
213 nil point (min (1+ (point)) (point-max))))
215 (defun gnus-xmas-article-push-button (event)
216 "Check text under the mouse pointer for a callback function.
217 If the text under the mouse pointer has a `gnus-callback' property,
218 call it with the value of the `gnus-data' text property."
220 (set-buffer (window-buffer (event-window event)))
221 (let* ((pos (event-closest-point event))
222 (data (get-text-property pos 'gnus-data))
223 (fun (get-text-property pos 'gnus-callback)))
226 (funcall fun data))))
228 (defun gnus-xmas-move-overlay (extent start end &optional buffer)
229 (set-extent-endpoints extent start end buffer))
231 (defun gnus-xmas-kill-all-overlays ()
232 "Delete all extents in the current buffer."
233 (map-extents (lambda (extent ignore)
234 (delete-extent extent)
237 (defun gnus-xmas-window-top-edge (&optional window)
238 (nth 1 (window-pixel-edges window)))
240 (defun gnus-xmas-tree-minimize ()
241 (when (and gnus-tree-minimize-window
242 (not (one-window-p)))
243 (let* ((window-min-height 2)
244 (height (1+ (count-lines (point-min) (point-max))))
245 (min (max (1- window-min-height) height))
246 (tot (if (numberp gnus-tree-minimize-window)
247 (min gnus-tree-minimize-window min)
249 (win (get-buffer-window (current-buffer)))
250 (wh (and win (1- (window-height win)))))
253 (let ((selected (selected-window)))
255 (enlarge-window (- tot wh))
256 (select-window selected))))))
258 ;; Select the lowest window on the frame.
259 (defun gnus-xmas-appt-select-lowest-window ()
260 (let* ((lowest-window (selected-window))
261 (bottom-edge (car (cdr (cdr (cdr (window-pixel-edges))))))
262 (last-window (previous-window))
265 (let* ((this-window (next-window))
266 (next-bottom-edge (car (cdr (cdr (cdr
269 (when (< bottom-edge next-bottom-edge)
270 (setq bottom-edge next-bottom-edge)
271 (setq lowest-window this-window))
273 (select-window this-window)
274 (when (eq last-window this-window)
275 (select-window lowest-window)
276 (setq window-search nil))))))
278 (defmacro gnus-xmas-menu-add (type &rest menus)
279 `(gnus-xmas-menu-add-1 ',type ',menus))
280 (put 'gnus-xmas-menu-add 'lisp-indent-function 1)
282 (defun gnus-xmas-menu-add-1 (type menus)
283 (when (and menu-bar-mode
284 (gnus-visual-p (intern (format "%s-menu" type)) 'menu))
286 (easy-menu-add (symbol-value (pop menus))))))
288 (defun gnus-xmas-group-menu-add ()
289 (gnus-xmas-menu-add group
290 gnus-group-reading-menu gnus-group-group-menu gnus-group-misc-menu))
292 (defun gnus-xmas-summary-menu-add ()
293 (gnus-xmas-menu-add summary
294 gnus-summary-misc-menu gnus-summary-kill-menu
295 gnus-summary-article-menu gnus-summary-thread-menu
296 gnus-summary-post-menu ))
298 (defun gnus-xmas-article-menu-add ()
299 (gnus-xmas-menu-add article
300 gnus-article-article-menu gnus-article-treatment-menu
301 gnus-article-post-menu gnus-article-commands-menu))
303 (defun gnus-xmas-score-menu-add ()
304 (gnus-xmas-menu-add score
307 (defun gnus-xmas-pick-menu-add ()
308 (gnus-xmas-menu-add pick
311 (defun gnus-xmas-topic-menu-add ()
312 (gnus-xmas-menu-add topic
315 (defun gnus-xmas-binary-menu-add ()
316 (gnus-xmas-menu-add binary
319 (defun gnus-xmas-agent-summary-menu-add ()
320 (gnus-xmas-menu-add agent-summary
321 gnus-agent-summary-menu))
323 (defun gnus-xmas-agent-group-menu-add ()
324 (gnus-xmas-menu-add agent-group
325 gnus-agent-group-menu))
327 (defun gnus-xmas-agent-server-menu-add ()
328 (gnus-xmas-menu-add agent-server
329 gnus-agent-server-menu))
331 (defun gnus-xmas-tree-menu-add ()
332 (gnus-xmas-menu-add tree
335 (defun gnus-xmas-draft-menu-add ()
336 (gnus-xmas-menu-add draft
339 (defun gnus-xmas-server-menu-add ()
340 (gnus-xmas-menu-add menu
341 gnus-server-server-menu gnus-server-connections-menu))
343 (defun gnus-xmas-browse-menu-add ()
344 (gnus-xmas-menu-add browse
347 (defun gnus-xmas-grouplens-menu-add ()
348 (gnus-xmas-menu-add grouplens
349 gnus-grouplens-menu))
351 (defun gnus-xmas-read-event-char (&optional prompt)
352 "Get the next event."
354 (message "%s" prompt))
355 (let ((event (next-command-event)))
357 ;; We junk all non-key events. Is this naughty?
358 (while (not (or (key-press-event-p event)
359 (button-press-event-p event)))
360 (dispatch-event event)
361 (setq event (next-command-event)))
362 (cons (and (key-press-event-p event)
363 (event-to-character event))
366 (defun gnus-xmas-define ()
367 (setq gnus-mouse-2 [button2])
368 (setq gnus-mouse-3 [button3])
369 (setq gnus-widget-button-keymap widget-button-keymap)
371 (unless (memq 'underline (face-list))
372 (and (fboundp 'make-face)
373 (funcall (intern "make-face") 'underline)))
374 ;; Must avoid calling set-face-underline-p directly, because it
375 ;; is a defsubst in emacs19, and will make the .elc files non
377 (unless (face-differs-from-default-p 'underline)
378 (funcall (intern "set-face-underline-p") 'underline t))
381 ((fboundp 'char-or-char-int-p)
382 ;; Handle both types of marks for XEmacs-20.x.
383 (defalias 'gnus-characterp 'char-or-char-int-p))
384 ;; V19 of XEmacs, probably.
386 (defalias 'gnus-characterp 'characterp)))
388 (defalias 'gnus-make-overlay 'make-extent)
389 (defalias 'gnus-delete-overlay 'delete-extent)
390 (defalias 'gnus-overlay-put 'set-extent-property)
391 (defalias 'gnus-move-overlay 'gnus-xmas-move-overlay)
392 (defalias 'gnus-overlay-buffer 'extent-object)
393 (defalias 'gnus-overlay-start 'extent-start-position)
394 (defalias 'gnus-overlay-end 'extent-end-position)
395 (defalias 'gnus-kill-all-overlays 'gnus-xmas-kill-all-overlays)
396 (defalias 'gnus-extent-detached-p 'extent-detached-p)
397 (defalias 'gnus-add-text-properties 'gnus-xmas-add-text-properties)
398 (defalias 'gnus-put-text-property 'gnus-xmas-put-text-property)
399 (defalias 'gnus-deactivate-mark 'ignore)
400 (defalias 'gnus-window-edges 'window-pixel-edges)
401 (defalias 'gnus-assq-delete-all 'gnus-xmas-assq-delete-all)
403 (if (and (<= emacs-major-version 19)
404 (< emacs-minor-version 14))
405 (defalias 'gnus-set-text-properties 'gnus-xmas-set-text-properties))
407 (unless (boundp 'standard-display-table)
408 (setq standard-display-table nil))
410 (defvar gnus-mouse-face-prop 'highlight)
412 (defun gnus-byte-code (func)
413 "Return a form that can be `eval'ed based on FUNC."
414 (let ((fval (indirect-function func)))
415 (if (compiled-function-p fval)
417 (cons 'progn (cdr (cdr fval))))))
419 (unless (fboundp 'match-string-no-properties)
420 (defalias 'match-string-no-properties 'match-string))
422 (defalias 'gnus-x-color-values
423 (if (fboundp 'x-color-values)
426 (color-instance-rgb-components
427 (make-color-instance color)))))
429 (unless (fboundp 'char-width)
430 (defalias 'char-width (lambda (ch) 1))))
432 (defun gnus-xmas-redefine ()
433 "Redefine lots of Gnus functions for XEmacs."
434 (defalias 'gnus-summary-set-display-table 'gnus-xmas-summary-set-display-table)
435 (defalias 'gnus-visual-turn-off-edit-menu 'identity)
436 (defalias 'gnus-summary-recenter 'gnus-xmas-summary-recenter)
437 (defalias 'gnus-extent-start-open 'gnus-xmas-extent-start-open)
438 (defalias 'gnus-article-push-button 'gnus-xmas-article-push-button)
439 (defalias 'gnus-window-top-edge 'gnus-xmas-window-top-edge)
440 (defalias 'gnus-read-event-char 'gnus-xmas-read-event-char)
441 (defalias 'gnus-group-startup-message 'gnus-xmas-group-startup-message)
442 (defalias 'gnus-tree-minimize 'gnus-xmas-tree-minimize)
443 (defalias 'gnus-appt-select-lowest-window
444 'gnus-xmas-appt-select-lowest-window)
445 (defalias 'gnus-mail-strip-quoted-names 'gnus-xmas-mail-strip-quoted-names)
446 (defalias 'gnus-character-to-event 'character-to-event)
447 (defalias 'gnus-mode-line-buffer-identification
448 'gnus-xmas-mode-line-buffer-identification)
449 (defalias 'gnus-key-press-event-p 'key-press-event-p)
450 (defalias 'gnus-region-active-p 'region-active-p)
451 (defalias 'gnus-mark-active-p 'region-exists-p)
452 (defalias 'gnus-annotation-in-region-p 'gnus-xmas-annotation-in-region-p)
453 (defalias 'gnus-mime-button-menu 'gnus-xmas-mime-button-menu)
454 (defalias 'gnus-image-type-available-p 'gnus-xmas-image-type-available-p)
455 (defalias 'gnus-put-image 'gnus-xmas-put-image)
456 (defalias 'gnus-create-image 'gnus-xmas-create-image)
457 (defalias 'gnus-remove-image 'gnus-xmas-remove-image)
459 (when (or (< emacs-major-version 21)
460 (and (= emacs-major-version 21)
461 (< emacs-minor-version 3)))
462 (defalias 'gnus-completing-read 'gnus-xmas-completing-read))
464 ;; These ones are not defcutom'ed, sometimes not even defvar'ed. They
465 ;; probably should. If that is done, the code below should then be moved
466 ;; where each variable is defined, in order not to mess with user settings.
468 (add-hook 'gnus-score-mode-hook 'gnus-xmas-score-menu-add)
469 (add-hook 'gnus-binary-mode-hook 'gnus-xmas-binary-menu-add)
470 (add-hook 'gnus-grouplens-mode-hook 'gnus-xmas-grouplens-menu-add)
471 (add-hook 'gnus-server-mode-hook 'gnus-xmas-server-menu-add)
472 (add-hook 'gnus-browse-mode-hook 'gnus-xmas-browse-menu-add)
473 (add-hook 'gnus-draft-mode-hook 'gnus-xmas-draft-menu-add)
474 (add-hook 'gnus-mailing-list-mode-hook 'gnus-xmas-mailing-list-menu-add))
477 ;;; XEmacs logo and toolbar.
479 (defun gnus-xmas-group-startup-message (&optional x y)
480 "Insert startup message in current buffer."
481 ;; Insert the message.
484 ((and (console-on-window-system-p)
487 (let* ((logo-xpm (expand-file-name "gnus.xpm" gnus-xmas-glyph-directory))
488 (logo-xbm (expand-file-name "gnus.xbm" gnus-xmas-glyph-directory))
490 (cond ((featurep 'xpm)
494 (("thing" . ,(car gnus-logo-colors))
495 ("shadow" . ,(cadr gnus-logo-colors))
497 ("background" . ,(face-background 'default)))])
499 `[xbm :file ,logo-xbm])
502 (set-extent-begin-glyph (make-extent (point) (point)) glyph)
503 (goto-char (point-min))
505 (insert (make-string (/ (max (- (window-width) (or x 35)) 0) 2)
508 (setq gnus-simple-splash nil))
509 (goto-char (point-min))
510 (let* ((pheight (+ 20 (count-lines (point-min) (point-max))))
511 (wheight (window-height))
512 (rest (- wheight pheight)))
513 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n))))
518 _ ___ __ ___ __ _ ___
538 (gnus-indent-rigidly (point-min) (point-max)
539 (/ (max (- (window-width) (or x 46)) 0) 2))
540 (goto-char (point-min))
542 (let* ((pheight (count-lines (point-min) (point-max)))
543 (wheight (window-height))
544 (rest (- wheight pheight)))
545 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
547 (put-text-property (point-min) (point-max) 'face 'gnus-splash-face)))
548 (setq modeline-buffer-identification
549 (list (concat gnus-version ": *Group*")))
550 (set-buffer-modified-p t))
555 (defcustom gnus-use-toolbar (if (featurep 'toolbar)
558 "*If nil, do not use a toolbar.
559 If it is non-nil, it must be a toolbar. The five valid values are
560 `default-toolbar', `top-toolbar', `bottom-toolbar',
561 `right-toolbar', and `left-toolbar'."
562 :type '(choice (const default-toolbar)
563 (const top-toolbar) (const bottom-toolbar)
564 (const left-toolbar) (const right-toolbar)
565 (const :tag "no toolbar" nil))
568 (defvar gnus-group-toolbar
569 '([gnus-group-get-new-news gnus-group-get-new-news t "Get new news"]
570 [gnus-group-get-new-news-this-group
571 gnus-group-get-new-news-this-group t "Get new news in this group"]
572 [gnus-group-catchup-current
573 gnus-group-catchup-current t "Catchup group"]
574 [gnus-group-describe-group
575 gnus-group-describe-group t "Describe group"]
576 [gnus-group-unsubscribe gnus-group-unsubscribe t "Unsubscribe group"]
577 [gnus-group-subscribe gnus-group-subscribe t "Subscribe group"]
578 [gnus-group-kill-group gnus-group-kill-group t "Kill group"]
579 [gnus-summary-mail-save
580 gnus-group-save-newsrc t "Save .newsrc files"] ; borrowed icon.
581 [gnus-group-exit gnus-group-exit t "Exit Gnus"])
582 "The group buffer toolbar.")
584 (defvar gnus-summary-toolbar
585 '([gnus-summary-prev-unread
586 gnus-summary-prev-page-or-article t "Page up"]
587 [gnus-summary-next-unread
588 gnus-summary-next-page t "Page down"]
589 [gnus-summary-post-news
590 gnus-summary-post-news t "Post an article"]
591 [gnus-summary-followup-with-original
592 gnus-summary-followup-with-original t
593 "Post a followup and yank the original"]
594 [gnus-summary-followup
595 gnus-summary-followup t "Post a followup"]
596 [gnus-summary-reply-with-original
597 gnus-summary-reply-with-original t "Mail a reply and yank the original"]
599 gnus-summary-reply t "Mail a reply"]
600 [gnus-summary-caesar-message
601 gnus-summary-caesar-message t "Rot 13"]
603 gnus-uu-decode-uu t "Decode uuencoded articles"]
604 [gnus-summary-save-article-file
605 gnus-summary-save-article-file t "Save article in file"]
606 [gnus-summary-save-article
607 gnus-summary-save-article t "Save article"]
609 gnus-uu-post-news t "Post a uuencoded article"]
610 [gnus-summary-cancel-article
611 gnus-summary-cancel-article t "Cancel article"]
612 [gnus-summary-catchup
613 gnus-summary-catchup t "Catchup"]
614 [gnus-summary-catchup-and-exit
615 gnus-summary-catchup-and-exit t "Catchup and exit"]
616 [gnus-summary-exit gnus-summary-exit t "Exit this summary"])
617 "The summary buffer toolbar.")
619 (defvar gnus-summary-mail-toolbar
621 [gnus-summary-prev-unread
622 gnus-summary-prev-unread-article t "Prev unread article"]
623 [gnus-summary-next-unread
624 gnus-summary-next-unread-article t "Next unread article"]
625 [gnus-summary-mail-reply gnus-summary-reply t "Reply"]
626 [gnus-summary-mail-originate gnus-summary-post-news t "Originate"]
627 [gnus-summary-mail-save gnus-summary-save-article t "Save"]
628 [gnus-summary-mail-copy gnus-summary-copy-article t "Copy message"]
629 [gnus-summary-mail-forward gnus-summary-mail-forward t "Forward message"]
630 [gnus-summary-caesar-message
631 gnus-summary-caesar-message t "Rot 13"]
633 gnus-uu-decode-uu t "Decode uuencoded articles"]
634 [gnus-summary-save-article-file
635 gnus-summary-save-article-file t "Save article in file"]
636 [gnus-summary-save-article
637 gnus-summary-save-article t "Save article"]
638 [gnus-summary-cancel-article ; usenet : cancellation :: mail : deletion.
639 gnus-summary-delete-article t "Delete message"]
640 [gnus-summary-catchup
641 gnus-summary-catchup t "Catchup"]
642 [gnus-summary-catchup-and-exit
643 gnus-summary-catchup-and-exit t "Catchup and exit"]
644 [gnus-summary-exit gnus-summary-exit t "Exit this summary"])
645 "The summary buffer mail toolbar.")
647 (defun gnus-xmas-setup-group-toolbar ()
648 (and gnus-use-toolbar
649 (message-xmas-setup-toolbar gnus-group-toolbar nil "gnus")
650 (set-specifier (symbol-value gnus-use-toolbar)
651 (cons (current-buffer) gnus-group-toolbar))))
653 (defun gnus-xmas-setup-summary-toolbar ()
654 (let ((bar (if (gnus-news-group-p gnus-newsgroup-name)
655 gnus-summary-toolbar gnus-summary-mail-toolbar)))
656 (and gnus-use-toolbar
657 (message-xmas-setup-toolbar bar nil "gnus")
658 (set-specifier (symbol-value gnus-use-toolbar)
659 (cons (current-buffer) bar)))))
661 (defun gnus-xmas-mail-strip-quoted-names (address)
662 "Protect mail-strip-quoted-names from nil input.
663 XEmacs compatibility workaround."
666 (mail-strip-quoted-names address)))
668 (defun gnus-xmas-call-region (command &rest args)
670 'call-process-region (point-min) (point-max) command t '(t nil) nil
673 (defvar gnus-xmas-modeline-left-extent
674 (let ((ext (copy-extent modeline-buffer-id-left-extent)))
677 (defvar gnus-xmas-modeline-right-extent
678 (let ((ext (copy-extent modeline-buffer-id-right-extent)))
681 (defvar gnus-xmas-modeline-glyph
683 (let* ((file-xpm (expand-file-name "gnus-pointer.xpm"
684 gnus-xmas-glyph-directory))
685 (file-xbm (expand-file-name "gnus-pointer.xbm"
686 gnus-xmas-glyph-directory))
689 (cond ((featurep 'xpm)
690 ;; Let's try a nifty XPM
691 `[xpm :file ,file-xpm])
693 ;; Then a not-so-nifty XBM
694 `[xbm :file ,file-xbm])
695 ;; Then the simple string
696 (t [string :data "Gnus:"])))))
697 (set-glyph-face glyph 'modeline-buffer-id)
700 (defun gnus-xmas-mode-line-buffer-identification (line)
701 (let ((line (car line))
704 ;; This is some weird type of id.
705 ((not (stringp line))
707 ;; This is non-standard, so we just pass it through.
708 ((not (string-match "^Gnus:" line))
710 ;; We have a standard line, so we colorize and glyphize it a bit.
712 (setq chop (match-end 0))
714 (if gnus-xmas-modeline-glyph
715 (cons gnus-xmas-modeline-left-extent gnus-xmas-modeline-glyph)
716 (cons gnus-xmas-modeline-left-extent (substring line 0 chop)))
717 (cons gnus-xmas-modeline-right-extent (substring line chop)))))))
719 (defun gnus-xmas-splash ()
720 (when (eq (device-type) 'x)
723 (defun gnus-xmas-annotation-in-region-p (b e)
724 (or (map-extents (lambda (e u) t) nil b e nil nil 'mm t)
726 (eq (cadr (memq 'gnus-undeletable (text-properties-at b))) t)
727 (text-property-any b e 'gnus-undeletable t))))
729 (defun gnus-xmas-mime-button-menu (event prefix)
730 "Construct a context-sensitive menu of MIME commands."
732 (let ((response (get-popup-menu-response
734 ,@(mapcar (lambda (c) `[,(caddr c) ,(car c) t])
735 gnus-mime-button-commands)))))
736 (set-buffer (event-buffer event))
737 (goto-char (event-point event))
738 (funcall (event-function response) (event-object response))))
740 (defun gnus-group-add-icon ()
741 "Add an icon to the current line according to `gnus-group-icon-list'."
744 ;; now find out where the line starts and leave point there.
745 (beg (progn (beginning-of-line) (point))))
747 (narrow-to-region beg end)
749 (when (search-forward "==&&==" nil t)
750 (let* ((group (gnus-group-group-name))
751 (entry (gnus-group-entry group))
752 (unread (if (numberp (car entry)) (car entry) 0))
753 (active (gnus-active group))
754 (total (if active (1+ (- (cdr active) (car active))) 0))
756 (method (gnus-server-get-method group (gnus-info-method info)))
757 (marked (gnus-info-marks info))
758 (mailp (memq 'mail (assoc (symbol-name
759 (car (or method gnus-select-method)))
760 gnus-valid-select-methods)))
761 (level (or (gnus-info-level info) gnus-level-killed))
762 (score (or (gnus-info-score info) 0))
763 (ticked (gnus-range-length (cdr (assq 'tick marked))))
764 (group-age (gnus-group-timestamp-delta group))
765 (inhibit-read-only t)
766 (list gnus-group-icon-list)
767 (mystart (match-beginning 0))
768 (myend (match-end 0)))
769 (goto-char (point-min))
771 (not (eval (caar list))))
772 (setq list (cdr list)))
774 (let* ((file (cdar list))
775 (glyph (gnus-group-icon-create-glyph
776 (buffer-substring mystart myend)
780 (mapcar 'delete-annotation (annotations-at myend))
781 (let ((ext (make-extent mystart myend))
782 (ant (make-annotation glyph myend 'text)))
783 ;; set text extent params
784 (set-extent-property ext 'end-open t)
785 (set-extent-property ext 'start-open t)
786 (set-extent-property ext 'invisible t)))
787 (delete-region mystart myend)))
788 (delete-region mystart myend))))
792 (defun gnus-group-icon-create-glyph (substring pixmap)
793 "Create a glyph for insertion into a group line."
795 (cdr-safe (assoc pixmap gnus-group-icon-cache))
796 (let* ((glyph (make-glyph
799 (expand-file-name pixmap gnus-xmas-glyph-directory))
801 (expand-file-name pixmap gnus-xmas-glyph-directory))
802 (cons 'tty substring)))))
803 (setq gnus-group-icon-cache
804 (cons (cons pixmap glyph) gnus-group-icon-cache))
805 (set-glyph-face glyph 'default)
808 (defun gnus-xmas-mailing-list-menu-add ()
809 (gnus-xmas-menu-add mailing-list
810 gnus-mailing-list-menu))
812 (defun gnus-xmas-image-type-available-p (type)
814 (featurep (if (eq type 'pbm) 'xbm type))))
816 (defun gnus-xmas-create-image (file &optional type data-p &rest props)
819 (car (last (split-string file "[.]")))))
820 (face (plist-get props :face))
822 (when (equal type "pbm")
826 (insert-file-contents-literally file))
827 (shell-command-on-region (point-min) (point-max)
828 "ppmtoxpm 2>/dev/null" t)
829 (setq file (buffer-string)
833 (if (equal type "xbm")
834 (make-glyph (list (cons 'x file)))
838 (insert-file-contents-literally file))
842 (mm-image-type-from-buffer))
843 :data (buffer-string))))))
845 (set-glyph-face glyph face))
848 (defun gnus-xmas-put-image (glyph &optional string category)
849 "Insert STRING, but display GLYPH.
850 Warning: Don't insert text immediately after the image."
851 (let ((begin (point))
853 (if (and (bobp) (not string))
857 (setq begin (1- begin)))
858 (setq extent (make-extent begin (point)))
859 (set-extent-property extent 'gnus-image category)
860 (set-extent-property extent 'duplicable t)
862 (set-extent-property extent 'invisible t))
863 (set-extent-property extent 'end-glyph glyph))
866 (defun gnus-xmas-remove-image (image &optional category)
869 (when (equal (extent-end-glyph ext) image)
870 (set-extent-property ext 'invisible nil)
871 (set-extent-property ext 'end-glyph nil))
873 nil nil nil nil nil 'gnus-image category))
875 (defun gnus-xmas-completing-read (prompt table &optional
876 predicate require-match history)
878 (not (boundp history)))
881 (if (symbol-value history)
882 (concat prompt " (" (car (symbol-value history)) "): ")
883 (concat prompt ": "))
890 ;; This macro is because XEmacs versions prior to 21.2 do not have the
891 ;; PROTOCOL argument to `open-network-stream'.
892 (defmacro gnus-xmas-open-network-stream (name buffer host service &optional protocol)
893 "Like `open-network-stream' but take into account older XEmacs versions."
894 (if (and (featurep 'xemacs)
895 (fboundp 'open-network-stream)
896 (emacs-version>= 21 2))
897 `(open-network-stream ,name ,buffer ,host ,service ,protocol)
898 `(open-network-stream ,name ,buffer ,host ,service)))
900 (defun gnus-xmas-assq-delete-all (key alist)
902 (while (setq elem (assq key alist))
903 (setq alist (delq elem alist)))
908 ;;; gnus-xmas.el ends here