1 ;;; gnus-xmas.el --- Gnus functions for XEmacs
3 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
4 ;; Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
32 (defvar menu-bar-mode (featurep 'menubar))
33 (require 'messagexmas)
36 (defgroup gnus-xmas nil
37 "XEmacsoid support for Gnus"
40 (defcustom gnus-xmas-glyph-directory nil
41 "Directory where Gnus logos and icons are located.
42 If this variable is nil, Gnus will try to locate the directory
44 :type '(choice (const :tag "autodetect" nil)
48 (unless gnus-xmas-glyph-directory
49 (unless (setq gnus-xmas-glyph-directory
50 (message-xmas-find-glyph-directory "gnus"))
51 (error "Can't find glyph directory. \
52 Possibly the `etc' directory has not been installed.")))
54 ;;; Internal variables.
56 ;; Don't warn about these undefined variables.
59 (defvar gnus-active-hashtb)
60 (defvar gnus-article-buffer)
61 (defvar gnus-auto-center-summary)
62 (defvar gnus-current-headers)
63 (defvar gnus-level-killed)
64 (defvar gnus-level-zombie)
65 (defvar gnus-newsgroup-bookmarks)
66 (defvar gnus-newsgroup-dependencies)
67 (defvar gnus-newsgroup-selected-overlay)
68 (defvar gnus-newsrc-hashtb)
69 (defvar gnus-read-mark)
70 (defvar gnus-refer-article-method)
71 (defvar gnus-reffed-article-number)
72 (defvar gnus-unread-mark)
74 (defvar gnus-view-pseudos)
75 (defvar gnus-view-pseudos-separately)
77 (defvar gnus-zombie-list)
78 ;;defined in gnus-msg.el
79 (defvar gnus-article-copy)
80 (defvar gnus-check-before-posting)
81 ;;defined in gnus-vis.el
82 (defvar gnus-article-button-face)
83 (defvar gnus-article-mouse-face)
84 (defvar gnus-summary-selected-face)
85 (defvar gnus-group-reading-menu)
86 (defvar gnus-group-group-menu)
87 (defvar gnus-group-misc-menu)
88 (defvar gnus-summary-article-menu)
89 (defvar gnus-summary-thread-menu)
90 (defvar gnus-summary-misc-menu)
91 (defvar gnus-summary-post-menu)
92 (defvar gnus-summary-kill-menu)
93 (defvar gnus-article-article-menu)
94 (defvar gnus-article-treatment-menu)
96 (defvar standard-display-table)
97 (defvar gnus-tree-minimize-window)
99 (defun gnus-xmas-set-text-properties (start end props &optional buffer)
100 "You should NEVER use this function. It is ideologically blasphemous.
101 It is provided only to ease porting of broken FSF Emacs programs."
104 (map-extents (lambda (extent ignored)
105 (remove-text-properties
107 (list (extent-property extent 'text-prop) nil)
110 buffer start end nil nil 'text-prop)
111 (gnus-add-text-properties start end props buffer)))
113 (defun gnus-xmas-highlight-selected-summary ()
114 ;; Highlight selected article in summary buffer
115 (when gnus-summary-selected-face
116 (when gnus-newsgroup-selected-overlay
117 (delete-extent gnus-newsgroup-selected-overlay))
118 (setq gnus-newsgroup-selected-overlay
119 (make-extent (gnus-point-at-bol) (gnus-point-at-eol)))
120 (set-extent-face gnus-newsgroup-selected-overlay
121 gnus-summary-selected-face)))
123 (defcustom gnus-xmas-force-redisplay nil
124 "*If non-nil, force a redisplay before recentering the summary buffer.
125 This is ugly, but it works around a bug in `window-displayed-height'."
129 (defun gnus-xmas-switch-horizontal-scrollbar-off ()
130 (when (featurep 'scrollbar)
131 (set-specifier scrollbar-height (cons (current-buffer) 0))))
133 (defun gnus-xmas-summary-recenter ()
134 "\"Center\" point in the summary window.
135 If `gnus-auto-center-summary' is nil, or the article buffer isn't
136 displayed, no centering will be performed."
137 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
138 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
139 ;; Force redisplay to get properly computed window height.
140 (when gnus-xmas-force-redisplay
142 (when gnus-auto-center-summary
143 (let* ((height (if (fboundp 'window-displayed-height)
144 (window-displayed-height)
145 (- (window-height) 2)))
146 (top (cond ((< height 4) 0)
148 (t (if (numberp gnus-auto-center-summary)
149 gnus-auto-center-summary
151 (bottom (save-excursion (goto-char (point-max))
152 (forward-line (- height))
154 (window (get-buffer-window (current-buffer))))
155 (when (get-buffer-window gnus-article-buffer)
156 ;; Only do recentering when the article buffer is displayed,
157 ;; Set the window start to either `bottom', which is the biggest
158 ;; possible valid number, or the second line from the top,
159 ;; whichever is the least.
160 ;; NOFORCE parameter suggested by Daniel Pittman <daniel@danann.net>.
162 window (min bottom (save-excursion (forward-line (- top)) (point)))
164 ;; Do horizontal recentering while we're at it.
165 (when (and (get-buffer-window (current-buffer) t)
166 (not (eq gnus-auto-center-summary 'vertical)))
167 (let ((selected (selected-window)))
168 (select-window (get-buffer-window (current-buffer) t))
169 (gnus-summary-position-point)
170 (gnus-horizontal-recenter)
171 (select-window selected))))))
173 (defun gnus-xmas-summary-set-display-table ()
174 ;; Setup the display table -- like `gnus-summary-setup-display-table',
175 ;; but done in an XEmacsish way.
176 (let ((table (make-display-table))
178 ;; Nix out all the control chars...
179 (while (>= (setq i (1- i)) 0)
181 ;; ... but not newline and cr, of course. (cr is necessary for the
182 ;; selective display).
185 ;; We keep TAB as well.
187 ;; We nix out any glyphs over 126 below ctl-arrow.
188 (let ((i (if (integerp ctl-arrow) ctl-arrow 160)))
189 (while (>= (setq i (1- i)) 127)
190 (unless (aref table i)
191 (aset table i [??]))))
192 ;; Can't use `set-specifier' because of a bug in 19.14 and earlier
193 (add-spec-to-specifier current-display-table table (current-buffer) nil)))
195 (defun gnus-xmas-add-text-properties (start end props &optional object)
196 (add-text-properties start end props object)
197 (put-text-property start end 'start-closed nil object))
199 (defun gnus-xmas-put-text-property (start end prop value &optional object)
200 (put-text-property start end prop value object)
201 (put-text-property start end 'start-closed nil object))
203 (defun gnus-xmas-extent-start-open (point)
204 (map-extents (lambda (extent arg)
205 (set-extent-property extent 'start-open t))
206 nil point (min (1+ (point)) (point-max))))
208 (defun gnus-xmas-article-push-button (event)
209 "Check text under the mouse pointer for a callback function.
210 If the text under the mouse pointer has a `gnus-callback' property,
211 call it with the value of the `gnus-data' text property."
213 (set-buffer (window-buffer (event-window event)))
214 (let* ((pos (event-closest-point event))
215 (data (get-text-property pos 'gnus-data))
216 (fun (get-text-property pos 'gnus-callback)))
219 (funcall fun data))))
221 (defun gnus-xmas-move-overlay (extent start end &optional buffer)
222 (set-extent-endpoints extent start end buffer))
224 (defun gnus-xmas-kill-all-overlays ()
225 "Delete all extents in the current buffer."
226 (map-extents (lambda (extent ignore)
227 (delete-extent extent)
230 (defun gnus-xmas-window-top-edge (&optional window)
231 (nth 1 (window-pixel-edges window)))
233 (defun gnus-xmas-tree-minimize ()
234 (when (and gnus-tree-minimize-window
235 (not (one-window-p)))
236 (let* ((window-min-height 2)
237 (height (1+ (count-lines (point-min) (point-max))))
238 (min (max (1- window-min-height) height))
239 (tot (if (numberp gnus-tree-minimize-window)
240 (min gnus-tree-minimize-window min)
242 (win (get-buffer-window (current-buffer)))
243 (wh (and win (1- (window-height win)))))
246 (let ((selected (selected-window)))
248 (enlarge-window (- tot wh))
249 (select-window selected))))))
251 ;; Select the lowest window on the frame.
252 (defun gnus-xmas-appt-select-lowest-window ()
253 (let* ((lowest-window (selected-window))
254 (bottom-edge (car (cdr (cdr (cdr (window-pixel-edges))))))
255 (last-window (previous-window))
258 (let* ((this-window (next-window))
259 (next-bottom-edge (car (cdr (cdr (cdr
262 (when (< bottom-edge next-bottom-edge)
263 (setq bottom-edge next-bottom-edge)
264 (setq lowest-window this-window))
266 (select-window this-window)
267 (when (eq last-window this-window)
268 (select-window lowest-window)
269 (setq window-search nil))))))
271 (defmacro gnus-xmas-menu-add (type &rest menus)
272 `(gnus-xmas-menu-add-1 ',type ',menus))
273 (put 'gnus-xmas-menu-add 'lisp-indent-function 1)
275 (defun gnus-xmas-menu-add-1 (type menus)
276 (when (and menu-bar-mode
277 (gnus-visual-p (intern (format "%s-menu" type)) 'menu))
279 (easy-menu-add (symbol-value (pop menus))))))
281 (defun gnus-xmas-group-menu-add ()
282 (gnus-xmas-menu-add group
283 gnus-group-reading-menu gnus-group-group-menu gnus-group-misc-menu))
285 (defun gnus-xmas-summary-menu-add ()
286 (gnus-xmas-menu-add summary
287 gnus-summary-misc-menu gnus-summary-kill-menu
288 gnus-summary-article-menu gnus-summary-thread-menu
289 gnus-summary-post-menu ))
291 (defun gnus-xmas-article-menu-add ()
292 (gnus-xmas-menu-add article
293 gnus-article-article-menu gnus-article-treatment-menu
294 gnus-article-post-menu gnus-article-commands-menu))
296 (defun gnus-xmas-score-menu-add ()
297 (gnus-xmas-menu-add score
300 (defun gnus-xmas-pick-menu-add ()
301 (gnus-xmas-menu-add pick
304 (defun gnus-xmas-topic-menu-add ()
305 (gnus-xmas-menu-add topic
308 (defun gnus-xmas-binary-menu-add ()
309 (gnus-xmas-menu-add binary
312 (defun gnus-xmas-agent-summary-menu-add ()
313 (gnus-xmas-menu-add agent-summary
314 gnus-agent-summary-menu))
316 (defun gnus-xmas-agent-group-menu-add ()
317 (gnus-xmas-menu-add agent-group
318 gnus-agent-group-menu))
320 (defun gnus-xmas-agent-server-menu-add ()
321 (gnus-xmas-menu-add agent-server
322 gnus-agent-server-menu))
324 (defun gnus-xmas-tree-menu-add ()
325 (gnus-xmas-menu-add tree
328 (defun gnus-xmas-draft-menu-add ()
329 (gnus-xmas-menu-add draft
332 (defun gnus-xmas-server-menu-add ()
333 (gnus-xmas-menu-add menu
334 gnus-server-server-menu gnus-server-connections-menu))
336 (defun gnus-xmas-browse-menu-add ()
337 (gnus-xmas-menu-add browse
340 (defun gnus-xmas-grouplens-menu-add ()
341 (gnus-xmas-menu-add grouplens
342 gnus-grouplens-menu))
344 (defun gnus-xmas-read-event-char (&optional prompt)
345 "Get the next event."
347 (message "%s" prompt))
348 (let ((event (next-command-event)))
350 ;; We junk all non-key events. Is this naughty?
351 (while (not (or (key-press-event-p event)
352 (button-press-event-p event)))
353 (dispatch-event event)
354 (setq event (next-command-event)))
355 (cons (and (key-press-event-p event)
356 (event-to-character event))
359 (defun gnus-xmas-define ()
360 (setq gnus-mouse-2 [button2])
361 (setq gnus-mouse-3 [button3])
362 (setq gnus-widget-button-keymap widget-button-keymap)
364 (unless (memq 'underline (face-list))
365 (and (fboundp 'make-face)
366 (funcall (intern "make-face") 'underline)))
367 ;; Must avoid calling set-face-underline-p directly, because it
368 ;; is a defsubst in emacs19, and will make the .elc files non
370 (unless (face-differs-from-default-p 'underline)
371 (funcall (intern "set-face-underline-p") 'underline t))
374 ((fboundp 'char-or-char-int-p)
375 ;; Handle both types of marks for XEmacs-20.x.
376 (defalias 'gnus-characterp 'char-or-char-int-p))
377 ;; V19 of XEmacs, probably.
379 (defalias 'gnus-characterp 'characterp)))
381 (defalias 'gnus-make-overlay 'make-extent)
382 (defalias 'gnus-delete-overlay 'delete-extent)
383 (defalias 'gnus-overlay-put 'set-extent-property)
384 (defalias 'gnus-move-overlay 'gnus-xmas-move-overlay)
385 (defalias 'gnus-overlay-buffer 'extent-object)
386 (defalias 'gnus-overlay-start 'extent-start-position)
387 (defalias 'gnus-overlay-end 'extent-end-position)
388 (defalias 'gnus-kill-all-overlays 'gnus-xmas-kill-all-overlays)
389 (defalias 'gnus-extent-detached-p 'extent-detached-p)
390 (defalias 'gnus-add-text-properties 'gnus-xmas-add-text-properties)
391 (defalias 'gnus-put-text-property 'gnus-xmas-put-text-property)
392 (defalias 'gnus-deactivate-mark 'ignore)
393 (defalias 'gnus-window-edges 'window-pixel-edges)
395 (if (and (<= emacs-major-version 19)
396 (< emacs-minor-version 14))
397 (defalias 'gnus-set-text-properties 'gnus-xmas-set-text-properties))
399 (unless (boundp 'standard-display-table)
400 (setq standard-display-table nil))
402 (defvar gnus-mouse-face-prop 'highlight)
404 (defun gnus-byte-code (func)
405 "Return a form that can be `eval'ed based on FUNC."
406 (let ((fval (indirect-function func)))
407 (if (compiled-function-p fval)
409 (cons 'progn (cdr (cdr fval))))))
411 (defalias 'gnus-x-color-values
412 (if (fboundp 'x-color-values)
415 (color-instance-rgb-components
416 (make-color-instance color))))))
418 (defun gnus-xmas-redefine ()
419 "Redefine lots of Gnus functions for XEmacs."
420 (defalias 'gnus-summary-set-display-table 'gnus-xmas-summary-set-display-table)
421 (defalias 'gnus-visual-turn-off-edit-menu 'identity)
422 (defalias 'gnus-summary-recenter 'gnus-xmas-summary-recenter)
423 (defalias 'gnus-extent-start-open 'gnus-xmas-extent-start-open)
424 (defalias 'gnus-article-push-button 'gnus-xmas-article-push-button)
425 (defalias 'gnus-window-top-edge 'gnus-xmas-window-top-edge)
426 (defalias 'gnus-read-event-char 'gnus-xmas-read-event-char)
427 (defalias 'gnus-group-startup-message 'gnus-xmas-group-startup-message)
428 (defalias 'gnus-tree-minimize 'gnus-xmas-tree-minimize)
429 (defalias 'gnus-appt-select-lowest-window
430 'gnus-xmas-appt-select-lowest-window)
431 (defalias 'gnus-mail-strip-quoted-names 'gnus-xmas-mail-strip-quoted-names)
432 (defalias 'gnus-character-to-event 'character-to-event)
433 (defalias 'gnus-mode-line-buffer-identification
434 'gnus-xmas-mode-line-buffer-identification)
435 (defalias 'gnus-key-press-event-p 'key-press-event-p)
436 (defalias 'gnus-region-active-p 'region-active-p)
437 (defalias 'gnus-annotation-in-region-p 'gnus-xmas-annotation-in-region-p)
438 (defalias 'gnus-mime-button-menu 'gnus-xmas-mime-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 (when (or (< emacs-major-version 21)
445 (and (= emacs-major-version 21)
446 (< emacs-minor-version 3)))
447 (defalias 'gnus-completing-read 'gnus-xmas-completing-read))
449 ;; These ones are not defcutom'ed, sometimes not even defvar'ed. They
450 ;; probably should. If that is done, the code below should then be moved
451 ;; where each variable is defined, in order not to mess with user settings.
453 (add-hook 'gnus-score-mode-hook 'gnus-xmas-score-menu-add)
454 (add-hook 'gnus-binary-mode-hook 'gnus-xmas-binary-menu-add)
455 (add-hook 'gnus-grouplens-mode-hook 'gnus-xmas-grouplens-menu-add)
456 (add-hook 'gnus-server-mode-hook 'gnus-xmas-server-menu-add)
457 (add-hook 'gnus-browse-mode-hook 'gnus-xmas-browse-menu-add)
458 (add-hook 'gnus-draft-mode-hook 'gnus-xmas-draft-menu-add)
459 (add-hook 'gnus-mailing-list-mode-hook 'gnus-xmas-mailing-list-menu-add)
461 (when (featurep 'mule)
462 (defun gnus-truncate-string (str end-column &optional start-column padding)
463 "Truncate string STR to end at column END-COLUMN.
464 The optional 2nd arg START-COLUMN, if non-nil, specifies
465 the starting column; that means to return the characters occupying
466 columns START-COLUMN ... END-COLUMN of STR.
468 The optional 3rd arg PADDING, if non-nil, specifies a padding character
469 to add at the end of the result if STR doesn't reach column END-COLUMN,
470 or if END-COLUMN comes in the middle of a character in STR.
471 PADDING is also added at the beginning of the result
472 if column START-COLUMN appears in the middle of a character in STR.
474 If PADDING is nil, no padding is added in these cases, so
475 the resulting string may be narrower than END-COLUMN.
476 \[Emacs 20.3 emulating function]"
478 (setq start-column 0))
479 (let ((len (length str))
482 (head-padding "") (tail-padding "")
483 ch last-column last-idx from-idx)
485 (while (< column start-column)
486 (setq ch (aref str idx)
487 column (+ column (char-width ch))
489 (args-out-of-range (setq idx len)))
490 (if (< column start-column)
491 (if padding (make-string end-column padding) "")
492 (if (and padding (> column start-column))
494 (make-string (- column start-column) padding)))
496 (if (< end-column column)
499 (while (< column end-column)
500 (setq last-column column
503 column (+ column (char-width ch))
505 (args-out-of-range (setq idx len)))
506 (if (> column end-column)
507 (setq column last-column idx last-idx))
508 (if (and padding (< column end-column))
510 (make-string (- end-column column) padding))))
511 (setq str (substring str from-idx idx))
513 (concat head-padding str tail-padding)
516 ;;; XEmacs logo and toolbar.
518 (defun gnus-xmas-group-startup-message (&optional x y)
519 "Insert startup message in current buffer."
520 ;; Insert the message.
523 ((and (console-on-window-system-p)
526 (let* ((logo-xpm (expand-file-name "gnus.xpm" gnus-xmas-glyph-directory))
527 (logo-xbm (expand-file-name "gnus.xbm" gnus-xmas-glyph-directory))
529 (cond ((featurep 'xpm)
533 (("thing" . ,(car gnus-logo-colors))
534 ("shadow" . ,(cadr gnus-logo-colors))
536 ("background" . ,(face-background 'default)))])
538 `[xbm :file ,logo-xbm])
540 (wpheight (window-pixel-height))
541 (rest (max 0 (1- (/ (* (- wpheight (glyph-height glyph))
545 (set-extent-begin-glyph (make-extent (point) (point)) glyph)
546 (goto-char (point-min))
548 (insert (make-string (/ (max (- (window-width) (or x 35)) 0) 2)
551 (setq gnus-simple-splash nil)
552 (goto-char (point-min))
553 (insert gnus-product-name " " gnus-version-number
554 (if (zerop (string-to-number gnus-revision-number))
556 (concat " (r" gnus-revision-number ")"))
557 " based on " gnus-original-product-name " v"
558 gnus-original-version-number "\n")
560 (put-text-property (point-min) (point) 'face 'gnus-splash-face)
561 (insert-char ?\ (prog1
562 (max 0 (/ (- (window-width) (point)) 2))
563 (goto-char (point-min))))
565 (insert-char ?\n rest)
566 (set-window-start (selected-window) (point-min))))
570 _ ___ __ ___ __ _ ___
589 (goto-char (point-min))
590 (insert gnus-product-name " " gnus-version-number
591 (if (zerop (string-to-number gnus-revision-number))
593 (concat " (r" gnus-revision-number ")"))
594 " based on " gnus-original-product-name " v"
595 gnus-original-version-number)
596 (insert-char ?\ (prog1
597 (max 0 (/ (- (window-width) (point)) 2))
598 (goto-char (point-min))))
601 (gnus-indent-rigidly (point) (point-max)
602 (/ (max (- (window-width) (or x 46)) 0) 2))
603 (goto-char (point-min))
605 (let* ((pheight (count-lines (point-min) (point-max)))
606 (wheight (window-height))
607 (rest (- wheight pheight)))
608 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
610 (put-text-property (point-min) (point-max) 'face 'gnus-splash-face)))
611 (goto-char (point-min))
612 (setq modeline-buffer-identification
613 (list (concat gnus-version ": *Group*")))
614 (set-buffer-modified-p t))
619 (defcustom gnus-use-toolbar (if (featurep 'toolbar)
622 "*If nil, do not use a toolbar.
623 If it is non-nil, it must be a toolbar. The five valid values are
624 `default-toolbar', `top-toolbar', `bottom-toolbar',
625 `right-toolbar', and `left-toolbar'."
626 :type '(choice (const default-toolbar)
627 (const top-toolbar) (const bottom-toolbar)
628 (const left-toolbar) (const right-toolbar)
629 (const :tag "no toolbar" nil))
632 (defvar gnus-group-toolbar
633 '([gnus-group-get-new-news gnus-group-get-new-news t "Get new news"]
634 [gnus-group-get-new-news-this-group
635 gnus-group-get-new-news-this-group t "Get new news in this group"]
636 [gnus-group-catchup-current
637 gnus-group-catchup-current t "Catchup group"]
638 [gnus-group-describe-group
639 gnus-group-describe-group t "Describe group"]
640 [gnus-group-unsubscribe gnus-group-unsubscribe t "Unsubscribe group"]
641 [gnus-group-subscribe gnus-group-subscribe t "Subscribe group"]
642 [gnus-group-kill-group gnus-group-kill-group t "Kill group"]
643 [gnus-summary-mail-save
644 gnus-group-save-newsrc t "Save .newsrc files"] ; borrowed icon.
645 [gnus-group-exit gnus-group-exit t "Exit Gnus"])
646 "The group buffer toolbar.")
648 (defvar gnus-summary-toolbar
649 '([gnus-summary-prev-unread
650 gnus-summary-prev-page-or-article t "Page up"]
651 [gnus-summary-next-unread
652 gnus-summary-next-page t "Page down"]
653 [gnus-summary-post-news
654 gnus-summary-post-news t "Post an article"]
655 [gnus-summary-followup-with-original
656 gnus-summary-followup-with-original t
657 "Post a followup and yank the original"]
658 [gnus-summary-followup
659 gnus-summary-followup t "Post a followup"]
660 [gnus-summary-reply-with-original
661 gnus-summary-reply-with-original t "Mail a reply and yank the original"]
663 gnus-summary-reply t "Mail a reply"]
664 [gnus-summary-caesar-message
665 gnus-summary-caesar-message t "Rot 13"]
667 gnus-uu-decode-uu t "Decode uuencoded articles"]
668 [gnus-summary-save-article-file
669 gnus-summary-save-article-file t "Save article in file"]
670 [gnus-summary-save-article
671 gnus-summary-save-article t "Save article"]
673 gnus-uu-post-news t "Post a uuencoded article"]
674 [gnus-summary-cancel-article
675 gnus-summary-cancel-article t "Cancel article"]
676 [gnus-summary-catchup
677 gnus-summary-catchup t "Catchup"]
678 [gnus-summary-catchup-and-exit
679 gnus-summary-catchup-and-exit t "Catchup and exit"]
680 [gnus-summary-exit gnus-summary-exit t "Exit this summary"])
681 "The summary buffer toolbar.")
683 (defvar gnus-summary-mail-toolbar
685 [gnus-summary-prev-unread
686 gnus-summary-prev-unread-article t "Prev unread article"]
687 [gnus-summary-next-unread
688 gnus-summary-next-unread-article t "Next unread article"]
689 [gnus-summary-mail-reply gnus-summary-reply t "Reply"]
690 [gnus-summary-mail-originate gnus-summary-post-news t "Originate"]
691 [gnus-summary-mail-save gnus-summary-save-article t "Save"]
692 [gnus-summary-mail-copy gnus-summary-copy-article t "Copy message"]
693 [gnus-summary-mail-forward gnus-summary-mail-forward t "Forward message"]
694 [gnus-summary-caesar-message
695 gnus-summary-caesar-message t "Rot 13"]
697 gnus-uu-decode-uu t "Decode uuencoded articles"]
698 [gnus-summary-save-article-file
699 gnus-summary-save-article-file t "Save article in file"]
700 [gnus-summary-save-article
701 gnus-summary-save-article t "Save article"]
702 [gnus-summary-cancel-article ; usenet : cancellation :: mail : deletion.
703 gnus-summary-delete-article t "Delete message"]
704 [gnus-summary-catchup
705 gnus-summary-catchup t "Catchup"]
706 [gnus-summary-catchup-and-exit
707 gnus-summary-catchup-and-exit t "Catchup and exit"]
708 [gnus-summary-exit gnus-summary-exit t "Exit this summary"])
709 "The summary buffer mail toolbar.")
711 (defun gnus-xmas-setup-group-toolbar ()
712 (and gnus-use-toolbar
713 (message-xmas-setup-toolbar gnus-group-toolbar nil "gnus")
714 (set-specifier (symbol-value gnus-use-toolbar)
715 (cons (current-buffer) gnus-group-toolbar))))
717 (defun gnus-xmas-setup-summary-toolbar ()
718 (let ((bar (if (gnus-news-group-p gnus-newsgroup-name)
719 gnus-summary-toolbar gnus-summary-mail-toolbar)))
720 (and gnus-use-toolbar
721 (message-xmas-setup-toolbar bar nil "gnus")
722 (set-specifier (symbol-value gnus-use-toolbar)
723 (cons (current-buffer) bar)))))
725 (defun gnus-xmas-mail-strip-quoted-names (address)
726 "Protect mail-strip-quoted-names from nil input.
727 XEmacs compatibility workaround."
730 (mail-strip-quoted-names address)))
732 (defun gnus-xmas-call-region (command &rest args)
734 'call-process-region (point-min) (point-max) command t '(t nil) nil
737 (defvar gnus-xmas-modeline-left-extent
738 (let ((ext (copy-extent modeline-buffer-id-left-extent)))
741 (defvar gnus-xmas-modeline-right-extent
742 (let ((ext (copy-extent modeline-buffer-id-right-extent)))
745 (defvar gnus-xmas-modeline-glyph
747 (let* ((file-xpm (expand-file-name "gnus-pointer.xpm"
748 gnus-xmas-glyph-directory))
749 (file-xbm (expand-file-name "gnus-pointer.xbm"
750 gnus-xmas-glyph-directory))
753 (cond ((featurep 'xpm)
754 ;; Let's try a nifty XPM
755 `[xpm :file ,file-xpm])
757 ;; Then a not-so-nifty XBM
758 `[xbm :file ,file-xbm])
759 ;; Then the simple string
760 (t [string :data "Gnus:"])))))
761 (set-glyph-face glyph 'modeline-buffer-id)
764 (defun gnus-xmas-mode-line-buffer-identification (line)
765 (let ((line (car line))
768 ;; This is some weird type of id.
769 ((not (stringp line))
771 ;; This is non-standard, so we just pass it through.
772 ((not (string-match "^Gnus:" line))
774 ;; We have a standard line, so we colorize and glyphize it a bit.
776 (setq chop (match-end 0))
778 (if gnus-xmas-modeline-glyph
779 (cons gnus-xmas-modeline-left-extent gnus-xmas-modeline-glyph)
780 (cons gnus-xmas-modeline-left-extent (substring line 0 chop)))
781 (cons gnus-xmas-modeline-right-extent (substring line chop)))))))
783 (defun gnus-xmas-splash ()
784 (when (eq (device-type) 'x)
787 (defun gnus-xmas-annotation-in-region-p (b e)
788 (or (map-extents (lambda (e u) t) nil b e nil nil 'mm t)
790 (eq (cadr (memq 'gnus-undeletable (text-properties-at b))) t)
791 (text-property-any b e 'gnus-undeletable t))))
793 (defun gnus-xmas-mime-button-menu (event)
794 "Construct a context-sensitive menu of MIME commands."
796 (let ((response (get-popup-menu-response
798 ,@(mapcar (lambda (c) `[,(caddr c) ,(car c) t])
799 gnus-mime-button-commands)))))
800 (set-buffer (event-buffer event))
801 (goto-char (event-point event))
802 (funcall (event-function response) (event-object response))))
804 (defun gnus-group-add-icon ()
805 "Add an icon to the current line according to `gnus-group-icon-list'."
807 (end (progn (end-of-line) (point)))
808 ;; now find out where the line starts and leave point there.
809 (beg (progn (beginning-of-line) (point))))
811 (narrow-to-region beg end)
813 (when (search-forward "==&&==" nil t)
814 (let* ((group (gnus-group-group-name))
815 (entry (gnus-group-entry group))
816 (unread (if (numberp (car entry)) (car entry) 0))
817 (active (gnus-active group))
818 (total (if active (1+ (- (cdr active) (car active))) 0))
820 (method (gnus-server-get-method group (gnus-info-method info)))
821 (marked (gnus-info-marks info))
822 (mailp (memq 'mail (assoc (symbol-name
823 (car (or method gnus-select-method)))
824 gnus-valid-select-methods)))
825 (level (or (gnus-info-level info) gnus-level-killed))
826 (score (or (gnus-info-score info) 0))
827 (ticked (gnus-range-length (cdr (assq 'tick marked))))
828 (group-age (gnus-group-timestamp-delta group))
829 (inhibit-read-only t)
830 (list gnus-group-icon-list)
831 (mystart (match-beginning 0))
832 (myend (match-end 0)))
833 (goto-char (point-min))
835 (not (eval (caar list))))
836 (setq list (cdr list)))
838 (let* ((file (cdar list))
839 (glyph (gnus-group-icon-create-glyph
840 (buffer-substring mystart myend)
844 (mapcar 'delete-annotation (annotations-at myend))
845 (let ((ext (make-extent mystart myend))
846 (ant (make-annotation glyph myend 'text)))
847 ;; set text extent params
848 (set-extent-property ext 'end-open t)
849 (set-extent-property ext 'start-open t)
850 (set-extent-property ext 'invisible t)))
851 (delete-region mystart myend)))
852 (delete-region mystart myend))))
856 (defun gnus-group-icon-create-glyph (substring pixmap)
857 "Create a glyph for insertion into a group line."
859 (cdr-safe (assoc pixmap gnus-group-icon-cache))
860 (let* ((glyph (make-glyph
863 (expand-file-name pixmap gnus-xmas-glyph-directory))
865 (expand-file-name pixmap gnus-xmas-glyph-directory))
866 (cons 'tty substring)))))
867 (setq gnus-group-icon-cache
868 (cons (cons pixmap glyph) gnus-group-icon-cache))
869 (set-glyph-face glyph 'default)
872 (defun gnus-xmas-mailing-list-menu-add ()
873 (gnus-xmas-menu-add mailing-list
874 gnus-mailing-list-menu))
876 (defun gnus-xmas-image-type-available-p (type)
878 (featurep (if (eq type 'pbm) 'xbm type))))
880 (defun gnus-xmas-create-image (file &optional type data-p &rest props)
883 (car (last (split-string file "[.]")))))
884 (face (plist-get props :face))
886 (when (equal type "pbm")
890 (insert-file-contents file))
891 (shell-command-on-region (point-min) (point-max)
892 "ppmtoxpm 2>/dev/null" t)
893 (setq file (buffer-string)
897 (if (equal type "xbm")
898 (make-glyph (list (cons 'x file)))
902 (insert-file-contents file))
906 (mm-image-type-from-buffer))
907 :data (buffer-string))))))
909 (set-glyph-face glyph face))
912 (defun gnus-xmas-put-image (glyph &optional string)
913 "Insert STRING, but display GLYPH.
914 Warning: Don't insert text immediately after the image."
915 (let ((begin (point))
917 (if (and (bobp) (not string))
921 (setq begin (1- begin)))
922 (setq extent (make-extent begin (point)))
923 (set-extent-property extent 'gnus-image t)
924 (set-extent-property extent 'duplicable t)
926 (set-extent-property extent 'invisible t))
927 (set-extent-property extent 'end-glyph glyph))
930 (defun gnus-xmas-remove-image (image)
933 (when (equal (extent-end-glyph ext) image)
934 (set-extent-property ext 'invisible nil)
935 (set-extent-property ext 'end-glyph nil))
937 nil nil nil nil nil 'gnus-image))
939 (defun gnus-xmas-completing-read (prompt table &optional
940 predicate require-match history)
942 (not (boundp history)))
945 (if (symbol-value history)
946 (concat prompt " (" (car (symbol-value history)) "): ")
947 (concat prompt ": "))
956 ;;; gnus-xmas.el ends here