1 ;;; gnus-xmas.el --- Gnus functions for XEmacs
3 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
4 ;; 2005, 2006 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 3, 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., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, 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-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-read-event-char (&optional prompt)
334 "Get the next event."
336 (message "%s" prompt))
337 (let ((event (next-command-event)))
339 ;; We junk all non-key events. Is this naughty?
340 (while (not (or (key-press-event-p event)
341 (button-press-event-p event)))
342 (dispatch-event event)
343 (setq event (next-command-event)))
344 (cons (and (key-press-event-p event)
345 (event-to-character event))
348 (defun gnus-xmas-define ()
349 (setq gnus-mouse-2 [button2])
350 (setq gnus-mouse-3 [button3])
351 (setq gnus-widget-button-keymap widget-button-keymap)
353 (unless (memq 'underline (face-list))
354 (and (fboundp 'make-face)
355 (funcall (intern "make-face") 'underline)))
356 ;; Must avoid calling set-face-underline-p directly, because it
357 ;; is a defsubst in emacs19, and will make the .elc files non
359 (unless (face-differs-from-default-p 'underline)
360 (funcall (intern "set-face-underline-p") 'underline t))
363 ((fboundp 'char-or-char-int-p)
364 ;; Handle both types of marks for XEmacs-20.x.
365 (defalias 'gnus-characterp 'char-or-char-int-p))
366 ;; V19 of XEmacs, probably.
368 (defalias 'gnus-characterp 'characterp)))
370 (defalias 'gnus-make-overlay
371 (lambda (beg end &optional buffer front-advance rear-advance)
372 "Create a new overlay with range BEG to END in BUFFER.
373 FRONT-ADVANCE and REAR-ADVANCE are ignored."
374 (make-extent beg end buffer)))
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-select-lowest-window
427 'gnus-xmas-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-mime-security-button-menu
438 'gnus-xmas-mime-security-button-menu)
439 (defalias 'gnus-image-type-available-p 'gnus-xmas-image-type-available-p)
440 (defalias 'gnus-put-image 'gnus-xmas-put-image)
441 (defalias 'gnus-create-image 'gnus-xmas-create-image)
442 (defalias 'gnus-remove-image 'gnus-xmas-remove-image)
444 ;; These ones are not defcutom'ed, sometimes not even defvar'ed. They
445 ;; probably should. If that is done, the code below should then be moved
446 ;; where each variable is defined, in order not to mess with user settings.
448 (add-hook 'gnus-score-mode-hook 'gnus-xmas-score-menu-add)
449 (add-hook 'gnus-binary-mode-hook 'gnus-xmas-binary-menu-add)
450 (add-hook 'gnus-server-mode-hook 'gnus-xmas-server-menu-add)
451 (add-hook 'gnus-browse-mode-hook 'gnus-xmas-browse-menu-add)
452 (add-hook 'gnus-draft-mode-hook 'gnus-xmas-draft-menu-add)
453 (add-hook 'gnus-mailing-list-mode-hook 'gnus-xmas-mailing-list-menu-add))
456 ;;; XEmacs logo and toolbar.
458 (defun gnus-xmas-group-startup-message (&optional x y)
459 "Insert startup message in current buffer."
460 ;; Insert the message.
463 ((and (console-on-window-system-p)
466 (let* ((logo-xpm (expand-file-name "gnus.xpm" gnus-xmas-glyph-directory))
467 (logo-xbm (expand-file-name "gnus.xbm" gnus-xmas-glyph-directory))
469 (cond ((featurep 'xpm)
473 (("thing" . ,(car gnus-logo-colors))
474 ("shadow" . ,(cadr gnus-logo-colors))
476 ("background" . ,(face-background 'default)))])
478 `[xbm :file ,logo-xbm])
481 (set-extent-begin-glyph (make-extent (point) (point)) glyph)
482 (goto-char (point-min))
484 (insert (make-string (/ (max (- (window-width) (or x 35)) 0) 2)
487 (setq gnus-simple-splash nil))
488 (goto-char (point-min))
489 (let* ((pheight (+ 20 (count-lines (point-min) (point-max))))
490 (wheight (window-height))
491 (rest (- wheight pheight)))
492 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n))))
497 _ ___ __ ___ __ _ ___
517 (gnus-indent-rigidly (point-min) (point-max)
518 (/ (max (- (window-width) (or x 46)) 0) 2))
519 (goto-char (point-min))
521 (let* ((pheight (count-lines (point-min) (point-max)))
522 (wheight (window-height))
523 (rest (- wheight pheight)))
524 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
526 (put-text-property (point-min) (point-max) 'face 'gnus-splash)))
527 (setq modeline-buffer-identification
528 (list (concat gnus-version ": *Group*")))
529 (set-buffer-modified-p t))
534 (defun gnus-xmas-update-toolbars ()
535 "Update the toolbars' appearance."
536 (when (and (not noninteractive)
537 (featurep 'gnus-xmas))
539 (dolist (buffer (buffer-list))
541 (cond ((eq major-mode 'gnus-group-mode)
542 (gnus-xmas-setup-group-toolbar))
543 ((eq major-mode 'gnus-summary-mode)
544 (gnus-xmas-setup-summary-toolbar)))))))
546 (defcustom gnus-use-toolbar (if (featurep 'toolbar) 'default)
547 "*Position to display the toolbar. Nil means do not use a toolbar.
548 If it is non-nil, it should be one of the symbols `default', `top',
549 `bottom', `right', and `left'. `default' means to use the default
550 toolbar, the rest mean to display the toolbar on the place which those
552 :type '(choice (const default)
553 (const top) (const bottom) (const left) (const right)
554 (const :tag "no toolbar" nil))
555 :set (lambda (symbol value)
559 (memq value (list 'default 'top 'bottom 'right 'left)))
562 (gnus-xmas-update-toolbars))
565 (defcustom gnus-toolbar-thickness
566 (if (featurep 'toolbar)
567 (cons (specifier-instance default-toolbar-height)
568 (specifier-instance default-toolbar-width)))
569 "*Cons of the height and the width specifying the thickness of a toolbar.
570 The height is used for the toolbar displayed on the top or the bottom,
571 the width is used for the toolbar displayed on the right or the left."
572 :type '(cons :tag "height & width"
573 (integer :tag "height") (integer :tag "width"))
574 :set (lambda (symbol value)
577 (if (and (consp value) (natnump (car value)) (natnump (cdr value)))
580 (gnus-xmas-update-toolbars))
583 (defvar gnus-group-toolbar
584 '([gnus-group-get-new-news gnus-group-get-new-news t "Get new news"]
585 [gnus-group-get-new-news-this-group
586 gnus-group-get-new-news-this-group t "Get new news in this group"]
587 [gnus-group-catchup-current
588 gnus-group-catchup-current t "Catchup group"]
589 [gnus-group-describe-group
590 gnus-group-describe-group t "Describe group"]
591 [gnus-group-unsubscribe gnus-group-unsubscribe t "Unsubscribe group"]
592 [gnus-group-subscribe gnus-group-subscribe t "Subscribe group"]
593 [gnus-group-kill-group gnus-group-kill-group t "Kill group"]
594 [gnus-summary-mail-save
595 gnus-group-save-newsrc t "Save .newsrc files"] ; borrowed icon.
596 [gnus-group-exit gnus-group-exit t "Exit Gnus"])
597 "The group buffer toolbar.")
599 (defvar gnus-summary-toolbar
600 '([gnus-summary-prev-unread
601 gnus-summary-prev-page-or-article t "Page up"]
602 [gnus-summary-next-unread
603 gnus-summary-next-page t "Page down"]
604 [gnus-summary-post-news
605 gnus-summary-post-news t "Post an article"]
606 [gnus-summary-followup-with-original
607 gnus-summary-followup-with-original t
608 "Post a followup and yank the original"]
609 [gnus-summary-followup
610 gnus-summary-followup t "Post a followup"]
611 [gnus-summary-reply-with-original
612 gnus-summary-reply-with-original t "Mail a reply and yank the original"]
614 gnus-summary-reply t "Mail a reply"]
615 [gnus-summary-caesar-message
616 gnus-summary-caesar-message t "Rot 13"]
618 gnus-uu-decode-uu t "Decode uuencoded articles"]
619 [gnus-summary-save-article-file
620 gnus-summary-save-article-file t "Save article in file"]
621 [gnus-summary-save-article
622 gnus-summary-save-article t "Save article"]
624 gnus-uu-post-news t "Post a uuencoded article"]
625 [gnus-summary-cancel-article
626 gnus-summary-cancel-article t "Cancel article"]
627 [gnus-summary-catchup
628 gnus-summary-catchup t "Catchup"]
629 [gnus-summary-catchup-and-exit
630 gnus-summary-catchup-and-exit t "Catchup and exit"]
631 [gnus-summary-exit gnus-summary-exit t "Exit this summary"])
632 "The summary buffer toolbar.")
634 (defvar gnus-summary-mail-toolbar
636 [gnus-summary-prev-unread
637 gnus-summary-prev-unread-article t "Prev unread article"]
638 [gnus-summary-next-unread
639 gnus-summary-next-unread-article t "Next unread article"]
640 [gnus-summary-mail-reply gnus-summary-reply t "Reply"]
641 [gnus-summary-mail-originate gnus-summary-post-news t "Originate"]
642 [gnus-summary-mail-save gnus-summary-save-article t "Save"]
643 [gnus-summary-mail-copy gnus-summary-copy-article t "Copy message"]
644 [gnus-summary-mail-forward gnus-summary-mail-forward t "Forward message"]
645 [gnus-summary-caesar-message
646 gnus-summary-caesar-message t "Rot 13"]
648 gnus-uu-decode-uu t "Decode uuencoded articles"]
649 [gnus-summary-save-article-file
650 gnus-summary-save-article-file t "Save article in file"]
651 [gnus-summary-save-article
652 gnus-summary-save-article t "Save article"]
653 [gnus-summary-cancel-article ; usenet : cancellation :: mail : deletion.
654 gnus-summary-delete-article t "Delete message"]
655 [gnus-summary-catchup
656 gnus-summary-catchup t "Catchup"]
657 [gnus-summary-catchup-and-exit
658 gnus-summary-catchup-and-exit t "Catchup and exit"]
659 [gnus-summary-exit gnus-summary-exit t "Exit this summary"])
660 "The summary buffer mail toolbar.")
662 (defun gnus-xmas-setup-toolbar (toolbar)
663 (when (featurep 'toolbar)
664 (if (and gnus-use-toolbar
665 (message-xmas-setup-toolbar toolbar nil "gnus"))
666 (let ((bar (or (intern-soft (format "%s-toolbar" gnus-use-toolbar))
668 (height (car gnus-toolbar-thickness))
669 (width (cdr gnus-toolbar-thickness))
670 (cur (current-buffer))
672 (set-specifier (symbol-value bar) toolbar cur)
673 (set-specifier default-toolbar-height height cur)
674 (set-specifier default-toolbar-width width cur)
675 (set-specifier top-toolbar-height height cur)
676 (set-specifier bottom-toolbar-height height cur)
677 (set-specifier right-toolbar-width width cur)
678 (set-specifier left-toolbar-width width cur)
679 (if (eq bar 'default-toolbar)
681 (remove-specifier default-toolbar-visible-p cur)
682 (remove-specifier top-toolbar cur)
683 (remove-specifier top-toolbar-visible-p cur)
684 (remove-specifier bottom-toolbar cur)
685 (remove-specifier bottom-toolbar-visible-p cur)
686 (remove-specifier right-toolbar cur)
687 (remove-specifier right-toolbar-visible-p cur)
688 (remove-specifier left-toolbar cur)
689 (remove-specifier left-toolbar-visible-p cur))
690 (set-specifier (symbol-value (intern (format "%s-visible-p" bar)))
692 (setq bars (delq bar (list 'default-toolbar
693 'bottom-toolbar 'top-toolbar
694 'right-toolbar 'left-toolbar)))
696 (set-specifier (symbol-value (intern (format "%s-visible-p"
699 (let ((cur (current-buffer)))
700 (set-specifier default-toolbar-visible-p nil cur)
701 (set-specifier top-toolbar-visible-p nil cur)
702 (set-specifier bottom-toolbar-visible-p nil cur)
703 (set-specifier right-toolbar-visible-p nil cur)
704 (set-specifier left-toolbar-visible-p nil cur)))))
706 (defun gnus-xmas-setup-group-toolbar ()
707 (gnus-xmas-setup-toolbar gnus-group-toolbar))
709 (defun gnus-xmas-setup-summary-toolbar ()
710 (gnus-xmas-setup-toolbar (if (gnus-news-group-p gnus-newsgroup-name)
712 gnus-summary-mail-toolbar)))
714 (defun gnus-xmas-mail-strip-quoted-names (address)
715 "Protect mail-strip-quoted-names from nil input.
716 XEmacs compatibility workaround."
719 (mail-strip-quoted-names address)))
721 (defun gnus-xmas-call-region (command &rest args)
723 'call-process-region (point-min) (point-max) command t '(t nil) nil
726 (defvar gnus-xmas-modeline-left-extent
727 (let ((ext (copy-extent modeline-buffer-id-left-extent)))
730 (defvar gnus-xmas-modeline-right-extent
731 (let ((ext (copy-extent modeline-buffer-id-right-extent)))
734 (defvar gnus-xmas-modeline-glyph
736 (let* ((file-xpm (expand-file-name "gnus-pointer.xpm"
737 gnus-xmas-glyph-directory))
738 (file-xbm (expand-file-name "gnus-pointer.xbm"
739 gnus-xmas-glyph-directory))
742 (cond ((featurep 'xpm)
743 ;; Let's try a nifty XPM
744 `[xpm :file ,file-xpm])
746 ;; Then a not-so-nifty XBM
747 `[xbm :file ,file-xbm])
748 ;; Then the simple string
749 (t [string :data "Gnus:"])))))
750 (set-glyph-face glyph 'modeline-buffer-id)
753 (defun gnus-xmas-mode-line-buffer-identification (line)
754 (let ((line (car line))
757 ;; This is some weird type of id.
758 ((not (stringp line))
760 ;; This is non-standard, so we just pass it through.
761 ((not (string-match "^Gnus:" line))
763 ;; We have a standard line, so we colorize and glyphize it a bit.
765 (setq chop (match-end 0))
767 (if gnus-xmas-modeline-glyph
768 (cons gnus-xmas-modeline-left-extent gnus-xmas-modeline-glyph)
769 (cons gnus-xmas-modeline-left-extent (substring line 0 chop)))
770 (cons gnus-xmas-modeline-right-extent (substring line chop)))))))
772 (defun gnus-xmas-splash ()
773 (when (eq (device-type) 'x)
776 (defun gnus-xmas-annotation-in-region-p (b e)
777 (or (map-extents (lambda (e u) t) nil b e nil nil 'mm t)
779 (eq (cadr (memq 'gnus-undeletable (text-properties-at b))) t)
780 (text-property-any b e 'gnus-undeletable t))))
782 (defun gnus-xmas-mime-button-menu (event prefix)
783 "Construct a context-sensitive menu of MIME commands."
785 (let ((response (get-popup-menu-response
787 ,@(mapcar (lambda (c) `[,(caddr c) ,(car c) t])
788 gnus-mime-button-commands)))))
789 (set-buffer (event-buffer event))
790 (goto-char (event-point event))
791 (funcall (event-function response) (event-object response))))
793 (defun gnus-xmas-mime-security-button-menu (event prefix)
794 "Construct a context-sensitive menu of security commands."
797 (get-popup-menu-response
801 (unless (eq (car c) 'undefined)
802 `[,(caddr c) ,(car c) t]))
803 gnus-mime-security-button-commands))))))
804 (set-buffer (event-buffer event))
805 (goto-char (event-point event))
806 (funcall (event-function response) (event-object response))))
808 (defun gnus-group-add-icon ()
809 "Add an icon to the current line according to `gnus-group-icon-list'."
812 ;; now find out where the line starts and leave point there.
813 (beg (progn (beginning-of-line) (point))))
815 (narrow-to-region beg end)
817 (when (search-forward "==&&==" nil t)
818 (let* ((group (gnus-group-group-name))
819 (entry (gnus-group-entry group))
820 (unread (if (numberp (car entry)) (car entry) 0))
821 (active (gnus-active group))
822 (total (if active (1+ (- (cdr active) (car active))) 0))
824 (method (gnus-server-get-method group (gnus-info-method info)))
825 (marked (gnus-info-marks info))
826 (mailp (memq 'mail (assoc (symbol-name
827 (car (or method gnus-select-method)))
828 gnus-valid-select-methods)))
829 (level (or (gnus-info-level info) gnus-level-killed))
830 (score (or (gnus-info-score info) 0))
831 (ticked (gnus-range-length (cdr (assq 'tick marked))))
832 (group-age (gnus-group-timestamp-delta group))
833 (inhibit-read-only t)
834 (list gnus-group-icon-list)
835 (mystart (match-beginning 0))
836 (myend (match-end 0)))
837 (goto-char (point-min))
839 (not (eval (caar list))))
840 (setq list (cdr list)))
842 (let* ((file (cdar list))
843 (glyph (gnus-group-icon-create-glyph
844 (buffer-substring mystart myend)
848 (mapc 'delete-annotation (annotations-at myend))
849 (let ((ext (make-extent mystart myend))
850 (ant (make-annotation glyph myend 'text)))
851 ;; set text extent params
852 (set-extent-property ext 'end-open t)
853 (set-extent-property ext 'start-open t)
854 (set-extent-property ext 'invisible t)))
855 (delete-region mystart myend)))
856 (delete-region mystart myend))))
860 (defun gnus-group-icon-create-glyph (substring pixmap)
861 "Create a glyph for insertion into a group line."
863 (cdr-safe (assoc pixmap gnus-group-icon-cache))
864 (let* ((glyph (make-glyph
867 (expand-file-name pixmap gnus-xmas-glyph-directory))
869 (expand-file-name pixmap gnus-xmas-glyph-directory))
870 (cons 'tty substring)))))
871 (setq gnus-group-icon-cache
872 (cons (cons pixmap glyph) gnus-group-icon-cache))
873 (set-glyph-face glyph 'default)
876 (defun gnus-xmas-mailing-list-menu-add ()
877 (gnus-xmas-menu-add mailing-list
878 gnus-mailing-list-menu))
880 (defun gnus-xmas-image-type-available-p (type)
881 (and (if (fboundp 'display-images-p)
884 (featurep (if (eq type 'pbm) 'xbm type))))
886 (defun gnus-xmas-create-image (file &optional type data-p &rest props)
889 (car (last (split-string file "[.]")))))
890 (face (plist-get props :face))
892 (when (equal type "pbm")
896 (insert-file-contents-literally file))
897 (shell-command-on-region (point-min) (point-max)
898 "ppmtoxpm 2>/dev/null" t)
899 (setq file (buffer-string)
903 (if (equal type "xbm")
904 (make-glyph (list (cons 'x file)))
908 (insert-file-contents-literally file))
912 (mm-image-type-from-buffer))
913 :data (buffer-string))))))
915 (set-glyph-face glyph face))
918 (defun gnus-xmas-put-image (glyph &optional string category)
919 "Insert STRING, but display GLYPH.
920 Warning: Don't insert text immediately after the image."
921 (let ((begin (point))
923 (if (and (bobp) (not string))
927 (setq begin (1- begin)))
928 (setq extent (make-extent begin (point)))
929 (set-extent-property extent 'gnus-image category)
930 (set-extent-property extent 'duplicable t)
932 (set-extent-property extent 'invisible t))
933 (set-extent-property extent 'end-glyph glyph))
936 (defun gnus-xmas-remove-image (image &optional category)
937 "Remove the image matching IMAGE and CATEGORY found first."
940 (when (equal (extent-end-glyph ext) image)
941 (set-extent-property ext 'invisible nil)
942 (set-extent-property ext 'end-glyph nil)
944 nil nil nil nil nil 'gnus-image category))
946 (defun gnus-xmas-assq-delete-all (key alist)
948 (while (setq elem (assq key alist))
949 (setq alist (delq elem alist)))
954 ;;; arch-tag: 4e84de3f-ea0a-4ee3-bfeb-e03d46fcacef
955 ;;; gnus-xmas.el ends here