1 ;;; gnus-xmas.el --- Gnus functions for XEmacs
3 ;; Copyright (C) 1995-2013 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 3, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
28 (autoload 'gnus-active "gnus" nil nil 'macro)
29 (autoload 'gnus-group-entry "gnus" nil nil 'macro)
30 (autoload 'gnus-info-level "gnus" nil nil 'macro)
31 (autoload 'gnus-info-marks "gnus" nil nil 'macro)
32 (autoload 'gnus-info-method "gnus" nil nil 'macro)
33 (autoload 'gnus-info-score "gnus" nil nil 'macro))
36 (defvar menu-bar-mode (featurep 'menubar))
37 (require 'messagexmas)
41 (defgroup gnus-xmas nil
42 "XEmacsoid support for Gnus"
45 (defcustom gnus-xmas-glyph-directory nil
46 "Directory where Gnus logos and icons are located.
47 If this variable is nil, Gnus will try to locate the directory
49 :type '(choice (const :tag "autodetect" nil)
53 (unless gnus-xmas-glyph-directory
54 (unless (setq gnus-xmas-glyph-directory
55 (message-xmas-find-glyph-directory "gnus"))
56 (error "Can't find glyph directory. \
57 Possibly the `etc' directory has not been installed.")))
59 ;;; Internal variables.
61 ;; Don't warn about these undefined variables.
64 (defvar gnus-active-hashtb)
65 (defvar gnus-article-buffer)
66 (defvar gnus-auto-center-summary)
67 (defvar gnus-current-headers)
68 (defvar gnus-level-killed)
69 (defvar gnus-level-zombie)
70 (defvar gnus-newsgroup-bookmarks)
71 (defvar gnus-newsgroup-dependencies)
72 (defvar gnus-newsgroup-selected-overlay)
73 (defvar gnus-newsrc-hashtb)
74 (defvar gnus-read-mark)
75 (defvar gnus-refer-article-method)
76 (defvar gnus-reffed-article-number)
77 (defvar gnus-unread-mark)
79 (defvar gnus-view-pseudos)
80 (defvar gnus-view-pseudos-separately)
82 (defvar gnus-zombie-list)
83 ;;defined in gnus-msg.el
84 (defvar gnus-article-copy)
85 (defvar gnus-check-before-posting)
86 ;;defined in gnus-vis.el
87 (defvar gnus-article-button-face)
88 (defvar gnus-article-mouse-face)
89 (defvar gnus-summary-selected-face)
90 (defvar gnus-group-reading-menu)
91 (defvar gnus-group-group-menu)
92 (defvar gnus-group-misc-menu)
93 (defvar gnus-summary-article-menu)
94 (defvar gnus-summary-thread-menu)
95 (defvar gnus-summary-misc-menu)
96 (defvar gnus-summary-post-menu)
97 (defvar gnus-summary-kill-menu)
98 (defvar gnus-article-article-menu)
99 (defvar gnus-article-treatment-menu)
100 (defvar gnus-mouse-2)
101 (defvar standard-display-table)
102 (defvar gnus-tree-minimize-window)
103 ;;`gnus-agent-mode' in gnus-agent.el will define it.
104 (defvar gnus-agent-summary-mode)
105 (defvar gnus-draft-mode)
107 (defcustom gnus-xmas-force-redisplay nil
108 "*If non-nil, force a redisplay before recentering the summary buffer.
109 This is ugly, but it works around a bug in `window-displayed-height'."
113 (defun gnus-xmas-switch-horizontal-scrollbar-off ()
114 (when (featurep 'scrollbar)
115 (set-specifier scrollbar-height (cons (current-buffer) 0))))
117 (defun gnus-xmas-summary-recenter ()
118 "\"Center\" point in the summary window.
119 If `gnus-auto-center-summary' is nil, or the article buffer isn't
120 displayed, no centering will be performed."
121 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
122 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
123 ;; Force redisplay to get properly computed window height.
124 (when gnus-xmas-force-redisplay
126 (when gnus-auto-center-summary
127 (let* ((height (if (fboundp 'window-displayed-height)
128 (window-displayed-height)
129 (- (window-height) 2)))
130 (top (cond ((< height 4) 0)
132 (t (if (numberp gnus-auto-center-summary)
133 gnus-auto-center-summary
135 (bottom (save-excursion (goto-char (point-max))
136 (forward-line (- height))
138 (window (get-buffer-window (current-buffer))))
139 (when (get-buffer-window gnus-article-buffer)
140 ;; Only do recentering when the article buffer is displayed,
141 ;; Set the window start to either `bottom', which is the biggest
142 ;; possible valid number, or the second line from the top,
143 ;; whichever is the least.
144 ;; NOFORCE parameter suggested by Daniel Pittman <daniel@danann.net>.
146 window (min bottom (save-excursion (forward-line (- top)) (point)))
148 ;; Do horizontal recentering while we're at it.
149 (when (and (get-buffer-window (current-buffer) t)
150 (not (eq gnus-auto-center-summary 'vertical)))
151 (let ((selected (selected-window)))
152 (select-window (get-buffer-window (current-buffer) t))
153 (gnus-summary-position-point)
154 (gnus-horizontal-recenter)
155 (select-window selected))))))
157 (defun gnus-xmas-summary-set-display-table ()
158 ;; Setup the display table -- like `gnus-summary-setup-display-table',
159 ;; but done in an XEmacsish way.
160 (let ((table (make-display-table))
162 ;; Nix out all the control chars...
163 (while (>= (setq i (1- i)) 0)
164 (gnus-put-display-table i [??] table))
165 ;; ... but not newline and cr, of course. (cr is necessary for the
166 ;; selective display).
167 (gnus-put-display-table ?\n nil table)
168 (gnus-put-display-table ?\r nil table)
169 ;; We keep TAB as well.
170 (gnus-put-display-table ?\t nil table)
171 ;; We nix out any glyphs over 126 below ctl-arrow.
172 (let ((i (if (integerp ctl-arrow) ctl-arrow 160)))
173 (while (>= (setq i (1- i)) 127)
174 (unless (gnus-get-display-table i table)
175 (gnus-put-display-table i [??] table))))
176 ;; Can't use `set-specifier' because of a bug in 19.14 and earlier
177 (add-spec-to-specifier current-display-table table (current-buffer) nil)))
179 (defun gnus-xmas-add-text-properties (start end props &optional object)
180 (add-text-properties start end props object)
181 (put-text-property start end 'start-closed nil object))
183 (defun gnus-xmas-put-text-property (start end prop value &optional object)
184 (put-text-property start end prop value object)
185 (put-text-property start end 'start-closed nil object))
187 (defun gnus-xmas-extent-start-open (point)
188 (map-extents (lambda (extent arg)
189 (set-extent-property extent 'start-open t))
190 nil point (min (1+ (point)) (point-max))))
192 (defun gnus-xmas-article-push-button (event)
193 "Check text under the mouse pointer for a callback function.
194 If the text under the mouse pointer has a `gnus-callback' property,
195 call it with the value of the `gnus-data' text property."
197 (set-buffer (window-buffer (event-window event)))
198 (let* ((pos (event-closest-point event))
199 (data (get-text-property pos 'gnus-data))
200 (fun (get-text-property pos 'gnus-callback)))
203 (funcall fun data))))
205 (defun gnus-xmas-move-overlay (extent start end &optional buffer)
206 (set-extent-endpoints extent start end buffer))
208 (defun gnus-xmas-kill-all-overlays ()
209 "Delete all extents in the current buffer."
210 (map-extents (lambda (extent ignore)
211 (delete-extent extent)
214 (defun gnus-xmas-overlays-in (beg end)
215 "Return a list of the extents that overlap the region BEG ... END."
216 (mapcar-extents #'identity nil nil beg end))
218 (defun gnus-xmas-window-top-edge (&optional window)
219 (nth 1 (window-pixel-edges window)))
221 (defun gnus-xmas-tree-minimize ()
222 (when (and gnus-tree-minimize-window
223 (not (one-window-p)))
224 (let* ((window-min-height 2)
225 (height (1+ (count-lines (point-min) (point-max))))
226 (min (max (1- window-min-height) height))
227 (tot (if (numberp gnus-tree-minimize-window)
228 (min gnus-tree-minimize-window min)
230 (win (get-buffer-window (current-buffer)))
231 (wh (and win (1- (window-height win)))))
234 (let ((selected (selected-window)))
236 (enlarge-window (- tot wh))
237 (select-window selected))))))
239 ;; Select the lowest window on the frame.
240 (defun gnus-xmas-select-lowest-window ()
241 (let* ((lowest-window (selected-window))
242 (bottom-edge (car (cdr (cdr (cdr (window-pixel-edges))))))
243 (last-window (previous-window))
246 (let* ((this-window (next-window))
247 (next-bottom-edge (car (cdr (cdr (cdr
250 (when (< bottom-edge next-bottom-edge)
251 (setq bottom-edge next-bottom-edge)
252 (setq lowest-window this-window))
254 (select-window this-window)
255 (when (eq last-window this-window)
256 (select-window lowest-window)
257 (setq window-search nil))))))
259 (defmacro gnus-xmas-menu-add (type &rest menus)
260 `(gnus-xmas-menu-add-1 ',type ',menus))
261 (put 'gnus-xmas-menu-add 'lisp-indent-function 1)
263 (defun gnus-xmas-menu-add-1 (type menus)
264 (when (and menu-bar-mode
265 (gnus-visual-p (intern (format "%s-menu" type)) 'menu))
267 (easy-menu-add (symbol-value (pop menus))))))
269 (defun gnus-xmas-group-menu-add ()
270 (gnus-xmas-menu-add group
271 gnus-group-reading-menu gnus-group-group-menu gnus-group-misc-menu))
273 (defun gnus-xmas-summary-menu-add ()
274 (gnus-xmas-menu-add summary
275 gnus-summary-misc-menu gnus-summary-kill-menu
276 gnus-summary-article-menu gnus-summary-thread-menu
277 gnus-summary-post-menu ))
279 (defun gnus-xmas-article-menu-add ()
280 (gnus-xmas-menu-add article
281 gnus-article-article-menu gnus-article-treatment-menu
282 gnus-article-post-menu gnus-article-commands-menu))
284 (defun gnus-xmas-score-menu-add ()
285 (gnus-xmas-menu-add score
288 (defun gnus-xmas-pick-menu-add ()
289 (gnus-xmas-menu-add pick
292 (defun gnus-xmas-topic-menu-add ()
293 (gnus-xmas-menu-add topic
296 (defun gnus-xmas-binary-menu-add ()
297 (gnus-xmas-menu-add binary
300 (defun gnus-xmas-agent-summary-menu-add ()
301 (gnus-xmas-menu-add agent-summary
302 gnus-agent-summary-menu))
304 (defun gnus-xmas-agent-group-menu-add ()
305 (gnus-xmas-menu-add agent-group
306 gnus-agent-group-menu))
308 (defun gnus-xmas-agent-server-menu-add ()
309 (gnus-xmas-menu-add agent-server
310 gnus-agent-server-menu))
312 (defun gnus-xmas-tree-menu-add ()
313 (gnus-xmas-menu-add tree
316 (defun gnus-xmas-draft-menu-add ()
317 (gnus-xmas-menu-add draft
320 (defun gnus-xmas-server-menu-add ()
321 (gnus-xmas-menu-add menu
322 gnus-server-server-menu gnus-server-connections-menu))
324 (defun gnus-xmas-browse-menu-add ()
325 (gnus-xmas-menu-add browse
328 (defun gnus-xmas-read-event-char (&optional prompt)
329 "Get the next event."
331 (display-message 'no-log (format "%s" prompt)))
332 (let ((event (next-command-event)))
334 ;; We junk all non-key events. Is this naughty?
335 (while (not (or (key-press-event-p event)
336 (button-press-event-p event)))
337 (dispatch-event event)
338 (setq event (next-command-event)))
339 (cons (and (key-press-event-p event)
340 (event-to-character event))
343 (defun gnus-xmas-article-describe-bindings (&optional prefix)
344 "Show a list of all defined keys, and their definitions.
345 The optional argument PREFIX, if non-nil, should be a key sequence;
346 then we display only bindings that start with that prefix."
348 (gnus-article-check-buffer)
349 (let ((keymap (copy-keymap gnus-article-mode-map))
350 (map (copy-keymap gnus-article-send-map))
351 (sumkeys (where-is-internal 'gnus-article-read-summary-keys))
353 (define-key keymap "S" map)
354 (set-keymap-default-binding map nil)
355 (with-current-buffer gnus-article-current-summary
358 (if (setq parent (keymap-parent gnus-article-mode-map))
360 (setq parent (copy-keymap parent))
361 (set-keymap-parent parent (current-local-map)))
362 (current-local-map)))
363 (let ((def (key-binding "S"))
365 (set-keymap-parent map (if (symbolp def)
368 (dolist (key sumkeys)
369 (when (setq def (key-binding key))
370 (define-key keymap key def))))
371 (when (boundp 'gnus-agent-summary-mode)
372 (setq agent gnus-agent-summary-mode))
373 (when (boundp 'gnus-draft-mode)
374 (setq draft gnus-draft-mode)))
376 (setq major-mode 'gnus-article-mode)
377 (use-local-map keymap)
378 (set (make-local-variable 'gnus-agent-summary-mode) agent)
379 (set (make-local-variable 'gnus-draft-mode) draft)
380 (describe-bindings prefix))))
382 (defun gnus-xmas-define ()
383 (setq gnus-mouse-2 [button2])
384 (setq gnus-mouse-3 [button3])
385 (setq gnus-widget-button-keymap widget-button-keymap)
387 (unless (memq 'underline (face-list))
388 (and (fboundp 'make-face)
389 (funcall (intern "make-face") 'underline)))
390 ;; Must avoid calling set-face-underline-p directly, because it
391 ;; is a defsubst in emacs19, and will make the .elc files non
393 (unless (face-differs-from-default-p 'underline)
394 (funcall (intern "set-face-underline-p") 'underline t))
396 (defalias 'gnus-make-overlay
397 (lambda (beg end &optional buffer front-advance rear-advance)
398 "Create a new overlay with range BEG to END in BUFFER.
399 FRONT-ADVANCE and REAR-ADVANCE are ignored."
400 (make-extent beg end buffer)))
402 (defalias 'gnus-delete-overlay 'delete-extent)
403 (defalias 'gnus-overlay-get 'extent-property)
404 (defalias 'gnus-overlay-put 'set-extent-property)
405 (defalias 'gnus-move-overlay 'gnus-xmas-move-overlay)
406 (defalias 'gnus-overlay-buffer 'extent-object)
407 (defalias 'gnus-overlay-start 'extent-start-position)
408 (defalias 'gnus-overlay-end 'extent-end-position)
409 (defalias 'gnus-overlays-in 'gnus-xmas-overlays-in)
410 (defalias 'gnus-kill-all-overlays 'gnus-xmas-kill-all-overlays)
411 (defalias 'gnus-extent-detached-p 'extent-detached-p)
412 (defalias 'gnus-add-text-properties 'gnus-xmas-add-text-properties)
413 (defalias 'gnus-put-text-property 'gnus-xmas-put-text-property)
414 (defalias 'gnus-deactivate-mark 'ignore)
415 (defalias 'gnus-window-edges 'window-pixel-edges)
416 (defalias 'gnus-assq-delete-all 'gnus-xmas-assq-delete-all)
418 (unless (fboundp 'member-ignore-case)
419 (defun member-ignore-case (elt list)
421 (or (not (stringp (car list)))
422 (not (string= (downcase elt) (downcase (car list))))))
423 (setq list (cdr list)))
426 (unless (boundp 'standard-display-table)
427 (setq standard-display-table nil))
429 (defvar gnus-mouse-face-prop 'highlight)
431 (unless (fboundp 'match-string-no-properties)
432 (defalias 'match-string-no-properties 'match-string))
434 (unless (fboundp 'char-width)
435 (defalias 'char-width (lambda (ch) 1))))
437 (defun gnus-xmas-redefine ()
438 "Redefine lots of Gnus functions for XEmacs."
439 (defalias 'gnus-summary-set-display-table 'gnus-xmas-summary-set-display-table)
440 (defalias 'gnus-visual-turn-off-edit-menu 'identity)
441 (defalias 'gnus-summary-recenter 'gnus-xmas-summary-recenter)
442 (defalias 'gnus-extent-start-open 'gnus-xmas-extent-start-open)
443 (defalias 'gnus-article-push-button 'gnus-xmas-article-push-button)
444 (defalias 'gnus-window-top-edge 'gnus-xmas-window-top-edge)
445 (defalias 'gnus-read-event-char 'gnus-xmas-read-event-char)
446 (defalias 'gnus-group-startup-message 'gnus-xmas-group-startup-message)
447 (defalias 'gnus-tree-minimize 'gnus-xmas-tree-minimize)
448 (defalias 'gnus-select-lowest-window
449 'gnus-xmas-select-lowest-window)
450 (defalias 'gnus-mail-strip-quoted-names 'gnus-xmas-mail-strip-quoted-names)
451 (defalias 'gnus-character-to-event 'character-to-event)
452 (defalias 'gnus-mode-line-buffer-identification
453 'gnus-xmas-mode-line-buffer-identification)
454 (defalias 'gnus-key-press-event-p 'key-press-event-p)
455 (defalias 'gnus-region-active-p 'region-active-p)
456 (defalias 'gnus-mark-active-p 'region-exists-p)
457 (defalias 'gnus-annotation-in-region-p 'gnus-xmas-annotation-in-region-p)
458 (defalias 'gnus-mime-button-menu 'gnus-xmas-mime-button-menu)
459 (defalias 'gnus-mime-security-button-menu
460 'gnus-xmas-mime-security-button-menu)
461 (defalias 'gnus-image-type-available-p 'gnus-xmas-image-type-available-p)
462 (defalias 'gnus-put-image 'gnus-xmas-put-image)
463 (defalias 'gnus-create-image 'gnus-xmas-create-image)
464 (defalias 'gnus-remove-image 'gnus-xmas-remove-image)
465 (defalias 'gnus-article-describe-bindings
466 'gnus-xmas-article-describe-bindings)
468 ;; These ones are not defcutom'ed, sometimes not even defvar'ed. They
469 ;; probably should. If that is done, the code below should then be moved
470 ;; where each variable is defined, in order not to mess with user settings.
472 (add-hook 'gnus-score-mode-hook 'gnus-xmas-score-menu-add)
473 (add-hook 'gnus-binary-mode-hook 'gnus-xmas-binary-menu-add)
474 (add-hook 'gnus-server-mode-hook 'gnus-xmas-server-menu-add)
475 (add-hook 'gnus-browse-mode-hook 'gnus-xmas-browse-menu-add)
476 (add-hook 'gnus-draft-mode-hook 'gnus-xmas-draft-menu-add)
477 (add-hook 'gnus-mailing-list-mode-hook 'gnus-xmas-mailing-list-menu-add))
480 ;;; XEmacs logo and toolbar.
482 (defun gnus-xmas-group-startup-message (&optional x y)
483 "Insert startup message in current buffer."
484 ;; Insert the message.
487 ((and (console-on-window-system-p)
490 (let* ((logo-xpm (expand-file-name "gnus.xpm" gnus-xmas-glyph-directory))
491 (logo-xbm (expand-file-name "gnus.xbm" gnus-xmas-glyph-directory))
493 (cond ((featurep 'xpm)
497 (("thing" . ,(car gnus-logo-colors))
498 ("shadow" . ,(cadr gnus-logo-colors))
500 ("background" . ,(face-background 'default)))])
502 `[xbm :file ,logo-xbm])
505 (set-extent-begin-glyph (make-extent (point) (point)) glyph)
506 (goto-char (point-min))
508 (insert (make-string (/ (max (- (window-width) (or x 35)) 0) 2)
511 (goto-char (point-min))
512 (let* ((pheight (+ 20 (count-lines (point-min) (point-max))))
513 (wheight (window-height))
514 (rest (- wheight pheight)))
515 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n))))
520 _ ___ __ ___ __ _ ___
540 (gnus-indent-rigidly (point-min) (point-max)
541 (/ (max (- (window-width) (or x 46)) 0) 2))
542 (goto-char (point-min))
544 (let* ((pheight (count-lines (point-min) (point-max)))
545 (wheight (window-height))
546 (rest (- wheight pheight)))
547 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
549 (put-text-property (point-min) (point-max) 'face 'gnus-splash)))
550 (setq modeline-buffer-identification
551 (list (concat gnus-version ": *Group*")))
552 (set-buffer-modified-p t))
557 (defun gnus-xmas-update-toolbars ()
558 "Update the toolbars' appearance."
559 (when (and (not noninteractive)
560 (featurep 'gnus-xmas))
562 (dolist (buffer (buffer-list))
564 (cond ((eq major-mode 'gnus-group-mode)
565 (gnus-xmas-setup-group-toolbar))
566 ((eq major-mode 'gnus-summary-mode)
567 (gnus-xmas-setup-summary-toolbar)))))))
569 (defcustom gnus-use-toolbar (if (featurep 'toolbar) 'default)
570 "*Position to display the toolbar. Nil means do not use a toolbar.
571 If it is non-nil, it should be one of the symbols `default', `top',
572 `bottom', `right', and `left'. `default' means to use the default
573 toolbar, the rest mean to display the toolbar on the place which those
575 :type '(choice (const default)
576 (const top) (const bottom) (const left) (const right)
577 (const :tag "no toolbar" nil))
578 :set (lambda (symbol value)
582 (memq value (list 'default 'top 'bottom 'right 'left)))
585 (gnus-xmas-update-toolbars))
588 (defcustom gnus-toolbar-thickness
589 (if (featurep 'toolbar)
590 (cons (specifier-instance default-toolbar-height)
591 (specifier-instance default-toolbar-width)))
592 "*Cons of the height and the width specifying the thickness of a toolbar.
593 The height is used for the toolbar displayed on the top or the bottom,
594 the width is used for the toolbar displayed on the right or the left."
595 :type '(cons :tag "height & width"
596 (integer :tag "height") (integer :tag "width"))
597 :set (lambda (symbol value)
600 (if (and (consp value) (natnump (car value)) (natnump (cdr value)))
603 (gnus-xmas-update-toolbars))
606 (defvar gnus-group-toolbar
607 '([gnus-group-get-new-news gnus-group-get-new-news t "Get new news"]
608 [gnus-group-get-new-news-this-group
609 gnus-group-get-new-news-this-group t "Get new news in this group"]
610 [gnus-group-catchup-current
611 gnus-group-catchup-current t "Catchup group"]
612 [gnus-group-describe-group
613 gnus-group-describe-group t "Describe group"]
614 [gnus-group-unsubscribe gnus-group-unsubscribe t "Unsubscribe group"]
615 [gnus-group-subscribe gnus-group-subscribe t "Subscribe group"]
616 [gnus-group-kill-group gnus-group-kill-group t "Kill group"]
617 [gnus-summary-mail-save
618 gnus-group-save-newsrc t "Save .newsrc files"] ; borrowed icon.
619 [gnus-group-exit gnus-group-exit t "Exit Gnus"])
620 "The group buffer toolbar.")
622 (defvar gnus-summary-toolbar
623 '([gnus-summary-prev-unread
624 gnus-summary-prev-page-or-article t "Page up"]
625 [gnus-summary-next-unread
626 gnus-summary-next-page t "Page down"]
627 [gnus-summary-post-news
628 gnus-summary-post-news t "Post an article"]
629 [gnus-summary-followup-with-original
630 gnus-summary-followup-with-original t
631 "Post a followup and yank the original"]
632 [gnus-summary-followup
633 gnus-summary-followup t "Post a followup"]
634 [gnus-summary-reply-with-original
635 gnus-summary-reply-with-original t "Mail a reply and yank the original"]
637 gnus-summary-reply t "Mail a reply"]
638 [gnus-summary-caesar-message
639 gnus-summary-caesar-message t "Rot 13"]
641 gnus-uu-decode-uu t "Decode uuencoded articles"]
642 [gnus-summary-save-article-file
643 gnus-summary-save-article-file t "Save article in file"]
644 [gnus-summary-save-article
645 gnus-summary-save-article t "Save article"]
647 gnus-uu-post-news t "Post a uuencoded article"]
648 [gnus-summary-cancel-article
649 gnus-summary-cancel-article t "Cancel article"]
650 [gnus-summary-catchup
651 gnus-summary-catchup t "Catchup"]
652 [gnus-summary-catchup-and-exit
653 gnus-summary-catchup-and-exit t "Catchup and exit"]
654 [gnus-summary-exit gnus-summary-exit t "Exit this summary"])
655 "The summary buffer toolbar.")
657 (defvar gnus-summary-mail-toolbar
659 [gnus-summary-prev-unread
660 gnus-summary-prev-unread-article t "Prev unread article"]
661 [gnus-summary-next-unread
662 gnus-summary-next-unread-article t "Next unread article"]
663 [gnus-summary-mail-reply gnus-summary-reply t "Reply"]
664 [gnus-summary-mail-originate gnus-summary-post-news t "Originate"]
665 [gnus-summary-mail-save gnus-summary-save-article t "Save"]
666 [gnus-summary-mail-copy gnus-summary-copy-article t "Copy message"]
667 [gnus-summary-mail-forward gnus-summary-mail-forward t "Forward message"]
668 [gnus-summary-caesar-message
669 gnus-summary-caesar-message t "Rot 13"]
671 gnus-uu-decode-uu t "Decode uuencoded articles"]
672 [gnus-summary-save-article-file
673 gnus-summary-save-article-file t "Save article in file"]
674 [gnus-summary-save-article
675 gnus-summary-save-article t "Save article"]
676 [gnus-summary-cancel-article ; usenet : cancellation :: mail : deletion.
677 gnus-summary-delete-article t "Delete message"]
678 [gnus-summary-catchup
679 gnus-summary-catchup t "Catchup"]
680 [gnus-summary-catchup-and-exit
681 gnus-summary-catchup-and-exit t "Catchup and exit"]
682 [gnus-summary-exit gnus-summary-exit t "Exit this summary"])
683 "The summary buffer mail toolbar.")
685 (defun gnus-xmas-setup-toolbar (toolbar)
686 (when (featurep 'toolbar)
687 (if (and gnus-use-toolbar
688 (message-xmas-setup-toolbar toolbar nil "gnus"))
689 (let ((bar (or (intern-soft (format "%s-toolbar" gnus-use-toolbar))
691 (height (car gnus-toolbar-thickness))
692 (width (cdr gnus-toolbar-thickness))
693 (cur (current-buffer))
695 (set-specifier (symbol-value bar) toolbar cur)
696 (set-specifier default-toolbar-height height cur)
697 (set-specifier default-toolbar-width width cur)
698 (set-specifier top-toolbar-height height cur)
699 (set-specifier bottom-toolbar-height height cur)
700 (set-specifier right-toolbar-width width cur)
701 (set-specifier left-toolbar-width width cur)
702 (if (eq bar 'default-toolbar)
704 (remove-specifier default-toolbar-visible-p cur)
705 (remove-specifier top-toolbar cur)
706 (remove-specifier top-toolbar-visible-p cur)
707 (remove-specifier bottom-toolbar cur)
708 (remove-specifier bottom-toolbar-visible-p cur)
709 (remove-specifier right-toolbar cur)
710 (remove-specifier right-toolbar-visible-p cur)
711 (remove-specifier left-toolbar cur)
712 (remove-specifier left-toolbar-visible-p cur))
713 (set-specifier (symbol-value (intern (format "%s-visible-p" bar)))
715 (setq bars (delq bar (list 'default-toolbar
716 'bottom-toolbar 'top-toolbar
717 'right-toolbar 'left-toolbar)))
719 (set-specifier (symbol-value (intern (format "%s-visible-p"
722 (let ((cur (current-buffer)))
723 (set-specifier default-toolbar-visible-p nil cur)
724 (set-specifier top-toolbar-visible-p nil cur)
725 (set-specifier bottom-toolbar-visible-p nil cur)
726 (set-specifier right-toolbar-visible-p nil cur)
727 (set-specifier left-toolbar-visible-p nil cur)))))
729 (defun gnus-xmas-setup-group-toolbar ()
730 (gnus-xmas-setup-toolbar gnus-group-toolbar))
732 (defun gnus-xmas-setup-summary-toolbar ()
733 (gnus-xmas-setup-toolbar (if (gnus-news-group-p gnus-newsgroup-name)
735 gnus-summary-mail-toolbar)))
737 (defun gnus-xmas-mail-strip-quoted-names (address)
738 "Protect mail-strip-quoted-names from nil input.
739 XEmacs compatibility workaround."
742 (mail-strip-quoted-names address)))
744 (defvar gnus-xmas-modeline-left-extent
745 (let ((ext (copy-extent modeline-buffer-id-left-extent)))
748 (defvar gnus-xmas-modeline-right-extent
749 (let ((ext (copy-extent modeline-buffer-id-right-extent)))
752 (defvar gnus-xmas-modeline-glyph
754 (let* ((file-xpm (expand-file-name "gnus-pointer.xpm"
755 gnus-xmas-glyph-directory))
756 (file-xbm (expand-file-name "gnus-pointer.xbm"
757 gnus-xmas-glyph-directory))
760 (cond ((featurep 'xpm)
761 ;; Let's try a nifty XPM
762 `[xpm :file ,file-xpm])
764 ;; Then a not-so-nifty XBM
765 `[xbm :file ,file-xbm])
766 ;; Then the simple string
767 (t [string :data "Gnus:"])))))
768 (set-glyph-face glyph 'modeline-buffer-id)
771 (defun gnus-xmas-mode-line-buffer-identification (line)
772 (let ((line (car line))
775 ;; This is some weird type of id.
776 ((not (stringp line))
778 ;; This is non-standard, so we just pass it through.
779 ((not (string-match "^Gnus:" line))
781 ;; We have a standard line, so we colorize and glyphize it a bit.
783 (setq chop (match-end 0))
785 (if gnus-xmas-modeline-glyph
786 (cons gnus-xmas-modeline-left-extent gnus-xmas-modeline-glyph)
787 (cons gnus-xmas-modeline-left-extent (substring line 0 chop)))
788 (cons gnus-xmas-modeline-right-extent (substring line chop)))))))
790 (defun gnus-xmas-annotation-in-region-p (b e)
791 (or (map-extents (lambda (e u) t) nil b e nil nil 'mm t)
793 (eq (cadr (memq 'gnus-undeletable (text-properties-at b))) t)
794 (text-property-any b e 'gnus-undeletable t))))
796 (defun gnus-xmas-mime-button-menu (event prefix)
797 "Construct a context-sensitive menu of MIME commands."
799 (let ((response (get-popup-menu-response
801 ,@(mapcar (lambda (c) `[,(caddr c) ,(car c) t])
802 gnus-mime-button-commands)))))
803 (set-buffer (event-buffer event))
804 (goto-char (event-point event))
805 (funcall (event-function response) (event-object response))))
807 (defun gnus-xmas-mime-security-button-menu (event prefix)
808 "Construct a context-sensitive menu of security commands."
811 (get-popup-menu-response
815 (unless (eq (car c) 'undefined)
816 `[,(caddr c) ,(car c) t]))
817 gnus-mime-security-button-commands))))))
818 (set-buffer (event-buffer event))
819 (goto-char (event-point event))
820 (funcall (event-function response) (event-object response))))
822 (defun gnus-xmas-mailing-list-menu-add ()
823 (gnus-xmas-menu-add mailing-list
824 gnus-mailing-list-menu))
826 (defun gnus-xmas-image-type-available-p (type)
827 (and (if (fboundp 'display-images-p)
830 (featurep (if (eq type 'pbm) 'xbm type))))
832 (defun gnus-xmas-create-image (file &optional type data-p &rest props)
837 (string-match "[.]" file))
838 (car (last (split-string file "[.]"))))))
839 (face (plist-get props :face))
841 (when (equal type "pbm")
845 (insert-file-contents-literally file))
846 (shell-command-on-region (point-min) (point-max)
847 "ppmtoxpm 2>/dev/null" t)
848 (setq file (buffer-string)
852 (if (equal type "xbm")
853 (make-glyph (list (cons 'x file)))
857 (insert-file-contents-literally file))
862 (mm-image-type-from-buffer))
863 :data (buffer-string))))))
865 (set-glyph-face glyph face))
868 (defun gnus-xmas-put-image (glyph &optional string category)
869 "Insert STRING, but display GLYPH.
870 Warning: Don't insert text immediately after the image."
871 (let ((begin (point))
873 (if (and (bobp) (not string))
877 (setq begin (1- begin)))
878 (setq extent (make-extent begin (point)))
879 (set-extent-property extent 'gnus-image category)
880 (set-extent-property extent 'duplicable t)
882 (set-extent-property extent 'invisible t))
883 (set-extent-property extent 'end-glyph glyph))
886 (defun gnus-xmas-remove-image (image &optional category)
887 "Remove the image matching IMAGE and CATEGORY found first."
890 (when (equal (extent-end-glyph ext) image)
891 (set-extent-property ext 'invisible nil)
892 (set-extent-property ext 'end-glyph nil)
894 nil nil nil nil nil 'gnus-image category))
896 (defun gnus-xmas-assq-delete-all (key alist)
898 (while (setq elem (assq key alist))
899 (setq alist (delq elem alist)))
904 ;;; gnus-xmas.el ends here