1 ;;; gnus-xmas.el --- Gnus functions for XEmacs
3 ;; Copyright (C) 1995-2016 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/>.
27 (globally-declare-boundp
28 '(gnus-article-mode-map gnus-article-send-map
29 gnus-article-current-summary gnus-pick-mode gnus-mouse-3
30 gnus-widget-button-keymap gnus-logo-colors gnus-newsgroup-name
31 gnus-mime-button-commands gnus-mime-security-button-commands))
34 (autoload 'gnus-active "gnus" nil nil 'macro)
35 (autoload 'gnus-group-entry "gnus" nil nil 'macro)
36 (autoload 'gnus-info-level "gnus" nil nil 'macro)
37 (autoload 'gnus-info-marks "gnus" nil nil 'macro)
38 (autoload 'gnus-info-method "gnus" nil nil 'macro)
39 (autoload 'gnus-info-score "gnus" nil nil 'macro))
42 (defvar menu-bar-mode (featurep 'menubar))
43 (require 'messagexmas)
47 (defgroup gnus-xmas nil
48 "XEmacsoid support for Gnus"
51 (defcustom gnus-xmas-glyph-directory nil
52 "Directory where Gnus logos and icons are located.
53 If this variable is nil, Gnus will try to locate the directory
55 :type '(choice (const :tag "autodetect" nil)
59 (unless gnus-xmas-glyph-directory
60 (unless (setq gnus-xmas-glyph-directory
61 (message-xmas-find-glyph-directory "gnus"))
62 (error "Can't find glyph directory. \
63 Possibly the `etc' directory has not been installed.")))
65 ;;; Internal variables.
67 ;; Don't warn about these undefined variables.
70 (defvar gnus-active-hashtb)
71 (defvar gnus-article-buffer)
72 (defvar gnus-auto-center-summary)
73 (defvar gnus-current-headers)
74 (defvar gnus-level-killed)
75 (defvar gnus-level-zombie)
76 (defvar gnus-newsgroup-bookmarks)
77 (defvar gnus-newsgroup-dependencies)
78 (defvar gnus-newsgroup-selected-overlay)
79 (defvar gnus-newsrc-hashtb)
80 (defvar gnus-read-mark)
81 (defvar gnus-refer-article-method)
82 (defvar gnus-reffed-article-number)
83 (defvar gnus-unread-mark)
85 (defvar gnus-view-pseudos)
86 (defvar gnus-view-pseudos-separately)
88 (defvar gnus-zombie-list)
89 ;;defined in gnus-msg.el
90 (defvar gnus-article-copy)
91 (defvar gnus-check-before-posting)
92 ;;defined in gnus-vis.el
93 (defvar gnus-article-button-face)
94 (defvar gnus-article-mouse-face)
95 (defvar gnus-summary-selected-face)
96 (defvar gnus-group-reading-menu)
97 (defvar gnus-group-group-menu)
98 (defvar gnus-group-misc-menu)
99 (defvar gnus-summary-article-menu)
100 (defvar gnus-summary-thread-menu)
101 (defvar gnus-summary-misc-menu)
102 (defvar gnus-summary-post-menu)
103 (defvar gnus-summary-kill-menu)
104 (defvar gnus-article-article-menu)
105 (defvar gnus-article-treatment-menu)
106 (defvar gnus-mouse-2)
107 (defvar standard-display-table)
108 (defvar gnus-tree-minimize-window)
109 ;;`gnus-agent-mode' in gnus-agent.el will define it.
110 (defvar gnus-agent-summary-mode)
111 (defvar gnus-draft-mode)
113 (defcustom gnus-xmas-force-redisplay nil
114 "*If non-nil, force a redisplay before recentering the summary buffer.
115 This is ugly, but it works around a bug in `window-displayed-height'."
119 (defun gnus-xmas-switch-horizontal-scrollbar-off ()
120 (when (featurep 'scrollbar)
121 (set-specifier scrollbar-height (cons (current-buffer) 0))))
123 (defun gnus-xmas-summary-recenter ()
124 "\"Center\" point in the summary window.
125 If `gnus-auto-center-summary' is nil, or the article buffer isn't
126 displayed, no centering will be performed."
127 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
128 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
129 ;; Force redisplay to get properly computed window height.
130 (when gnus-xmas-force-redisplay
132 (when gnus-auto-center-summary
133 (let* ((height (if (fboundp 'window-displayed-height)
134 (window-displayed-height)
135 (- (window-height) 2)))
136 (top (cond ((< height 4) 0)
138 (t (if (numberp gnus-auto-center-summary)
139 gnus-auto-center-summary
141 (bottom (save-excursion (goto-char (point-max))
142 (forward-line (- height))
144 (window (get-buffer-window (current-buffer))))
145 (when (get-buffer-window gnus-article-buffer)
146 ;; Only do recentering when the article buffer is displayed,
147 ;; Set the window start to either `bottom', which is the biggest
148 ;; possible valid number, or the second line from the top,
149 ;; whichever is the least.
150 ;; NOFORCE parameter suggested by Daniel Pittman <daniel@danann.net>.
152 window (min bottom (save-excursion (forward-line (- top)) (point)))
154 ;; Do horizontal recentering while we're at it.
155 (when (and (get-buffer-window (current-buffer) t)
156 (not (eq gnus-auto-center-summary 'vertical)))
157 (let ((selected (selected-window)))
158 (select-window (get-buffer-window (current-buffer) t))
159 (gnus-summary-position-point)
160 (gnus-horizontal-recenter)
161 (select-window selected))))))
163 (defun gnus-xmas-summary-set-display-table ()
164 ;; Setup the display table -- like `gnus-summary-setup-display-table',
165 ;; but done in an XEmacsish way.
166 (let ((table (make-display-table))
168 ;; Nix out all the control chars...
169 (while (>= (setq i (1- i)) 0)
170 (gnus-put-display-table i [??] table))
171 ;; ... but not newline and cr, of course. (cr is necessary for the
172 ;; selective display).
173 (gnus-put-display-table ?\n nil table)
174 (gnus-put-display-table ?\r nil table)
175 ;; We keep TAB as well.
176 (gnus-put-display-table ?\t nil table)
177 ;; We nix out any glyphs over 126 below ctl-arrow.
178 (let ((i (if (integerp ctl-arrow) ctl-arrow 160)))
179 (while (>= (setq i (1- i)) 127)
180 (unless (gnus-get-display-table i table)
181 (gnus-put-display-table i [??] table))))
182 ;; Can't use `set-specifier' because of a bug in 19.14 and earlier
183 (add-spec-to-specifier current-display-table table (current-buffer) nil)))
185 (defun gnus-xmas-add-text-properties (start end props &optional object)
186 (add-text-properties start end props object)
187 (put-text-property start end 'start-closed nil object))
189 (defun gnus-xmas-put-text-property (start end prop value &optional object)
190 (put-text-property start end prop value object)
191 (put-text-property start end 'start-closed nil object))
193 (defun gnus-xmas-extent-start-open (point)
194 (map-extents (lambda (extent arg)
195 (set-extent-property extent 'start-open t))
196 nil point (min (1+ (point)) (point-max))))
198 (defun gnus-xmas-article-push-button (event)
199 "Check text under the mouse pointer for a callback function.
200 If the text under the mouse pointer has a `gnus-callback' property,
201 call it with the value of the `gnus-data' text property."
203 (set-buffer (window-buffer (event-window event)))
204 (let* ((pos (event-closest-point event))
205 (data (get-text-property pos 'gnus-data))
206 (fun (get-text-property pos 'gnus-callback)))
209 (funcall fun data))))
211 (defun gnus-xmas-kill-all-overlays ()
212 "Delete all extents in the current buffer."
213 (map-extents (lambda (extent ignore)
214 (delete-extent extent)
217 (defun gnus-xmas-window-top-edge (&optional window)
218 (nth 1 (window-pixel-edges window)))
220 (defun gnus-xmas-tree-minimize ()
221 (when (and gnus-tree-minimize-window
222 (not (one-window-p)))
223 (let* ((window-min-height 2)
224 (height (1+ (count-lines (point-min) (point-max))))
225 (min (max (1- window-min-height) height))
226 (tot (if (numberp gnus-tree-minimize-window)
227 (min gnus-tree-minimize-window min)
229 (win (get-buffer-window (current-buffer)))
230 (wh (and win (1- (window-height win)))))
233 (let ((selected (selected-window)))
235 (enlarge-window (- tot wh))
236 (select-window selected))))))
238 ;; Select the lowest window on the frame.
239 (defun gnus-xmas-select-lowest-window ()
240 (let* ((lowest-window (selected-window))
241 (bottom-edge (car (cdr (cdr (cdr (window-pixel-edges))))))
242 (last-window (previous-window))
245 (let* ((this-window (next-window))
246 (next-bottom-edge (car (cdr (cdr (cdr
249 (when (< bottom-edge next-bottom-edge)
250 (setq bottom-edge next-bottom-edge)
251 (setq lowest-window this-window))
253 (select-window this-window)
254 (when (eq last-window this-window)
255 (select-window lowest-window)
256 (setq window-search nil))))))
258 (defmacro gnus-xmas-menu-add (type &rest menus)
259 `(gnus-xmas-menu-add-1 ',type ',menus))
260 (put 'gnus-xmas-menu-add 'lisp-indent-function 1)
262 (defun gnus-xmas-menu-add-1 (type menus)
263 (when (and menu-bar-mode
264 (gnus-visual-p (intern (format "%s-menu" type)) 'menu))
266 (easy-menu-add (symbol-value (pop menus))))))
268 (defun gnus-xmas-group-menu-add ()
269 (gnus-xmas-menu-add group
270 gnus-group-reading-menu gnus-group-group-menu gnus-group-misc-menu))
272 (defun gnus-xmas-summary-menu-add ()
273 (gnus-xmas-menu-add summary
274 gnus-summary-misc-menu gnus-summary-kill-menu
275 gnus-summary-article-menu gnus-summary-thread-menu
276 gnus-summary-post-menu ))
278 (defun gnus-xmas-article-menu-add ()
279 (gnus-xmas-menu-add article
280 gnus-article-article-menu gnus-article-treatment-menu
281 gnus-article-post-menu gnus-article-commands-menu))
283 (defun gnus-xmas-score-menu-add ()
284 (gnus-xmas-menu-add score
287 (defun gnus-xmas-pick-menu-add ()
288 (gnus-xmas-menu-add pick
291 (defun gnus-xmas-topic-menu-add ()
292 (gnus-xmas-menu-add topic
295 (defun gnus-xmas-binary-menu-add ()
296 (gnus-xmas-menu-add binary
299 (defun gnus-xmas-agent-summary-menu-add ()
300 (gnus-xmas-menu-add agent-summary
301 gnus-agent-summary-menu))
303 (defun gnus-xmas-agent-group-menu-add ()
304 (gnus-xmas-menu-add agent-group
305 gnus-agent-group-menu))
307 (defun gnus-xmas-agent-server-menu-add ()
308 (gnus-xmas-menu-add agent-server
309 gnus-agent-server-menu))
311 (defun gnus-xmas-tree-menu-add ()
312 (gnus-xmas-menu-add tree
315 (defun gnus-xmas-draft-menu-add ()
316 (gnus-xmas-menu-add draft
319 (defun gnus-xmas-server-menu-add ()
320 (gnus-xmas-menu-add menu
321 gnus-server-server-menu gnus-server-connections-menu))
323 (defun gnus-xmas-browse-menu-add ()
324 (gnus-xmas-menu-add browse
327 (defun gnus-xmas-read-event-char (&optional prompt)
328 "Get the next event."
330 (display-message 'no-log (format "%s" prompt)))
331 (let ((event (next-command-event)))
333 ;; We junk all non-key events. Is this naughty?
334 (while (not (or (key-press-event-p event)
335 (button-press-event-p event)))
336 (dispatch-event event)
337 (setq event (next-command-event)))
338 (cons (and (key-press-event-p event)
339 (event-to-character event))
342 (defun gnus-xmas-article-describe-bindings (&optional prefix)
343 "Show a list of all defined keys, and their definitions.
344 The optional argument PREFIX, if non-nil, should be a key sequence;
345 then we display only bindings that start with that prefix."
347 (gnus-article-check-buffer)
348 (let ((keymap (copy-keymap gnus-article-mode-map))
349 (map (copy-keymap gnus-article-send-map))
350 (sumkeys (where-is-internal 'gnus-article-read-summary-keys))
352 (define-key keymap "S" map)
353 (set-keymap-default-binding map nil)
354 (with-current-buffer gnus-article-current-summary
357 (if (setq parent (keymap-parent gnus-article-mode-map))
359 (setq parent (copy-keymap parent))
360 (set-keymap-parent parent (current-local-map)))
361 (current-local-map)))
362 (let ((def (key-binding "S"))
364 (set-keymap-parent map (if (symbolp def)
367 (dolist (key sumkeys)
368 (when (setq def (key-binding key))
369 (define-key keymap key def))))
370 (when (boundp 'gnus-agent-summary-mode)
371 (setq agent gnus-agent-summary-mode))
372 (when (boundp 'gnus-draft-mode)
373 (setq draft gnus-draft-mode)))
375 (setq major-mode 'gnus-article-mode)
376 (use-local-map keymap)
377 (set (make-local-variable 'gnus-agent-summary-mode) agent)
378 (set (make-local-variable 'gnus-draft-mode) draft)
379 (describe-bindings prefix))))
381 (defun gnus-xmas-define ()
382 (setq gnus-mouse-2 [button2])
383 (setq gnus-mouse-3 [button3])
384 (setq gnus-widget-button-keymap widget-button-keymap)
386 (unless (memq 'underline (face-list))
387 (and (fboundp 'make-face)
388 (funcall (intern "make-face") 'underline)))
389 ;; Must avoid calling set-face-underline-p directly, because it
390 ;; is a defsubst in emacs19, and will make the .elc files non
392 (unless (face-differs-from-default-p 'underline)
393 (funcall (intern "set-face-underline-p") 'underline t))
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 (unless (fboundp 'member-ignore-case)
404 (defun member-ignore-case (elt list)
406 (or (not (stringp (car list)))
407 (not (string= (downcase elt) (downcase (car list))))))
408 (setq list (cdr list)))
411 (unless (boundp 'standard-display-table)
412 (setq standard-display-table nil))
414 (defvar gnus-mouse-face-prop 'highlight)
416 (unless (fboundp 'match-string-no-properties)
417 (defalias 'match-string-no-properties 'match-string))
419 (unless (fboundp 'char-width)
420 (defalias 'char-width (lambda (ch) 1))))
422 (defun gnus-xmas-redefine ()
423 "Redefine lots of Gnus functions for XEmacs."
424 (defalias 'gnus-summary-set-display-table 'gnus-xmas-summary-set-display-table)
425 (defalias 'gnus-visual-turn-off-edit-menu 'identity)
426 (defalias 'gnus-summary-recenter 'gnus-xmas-summary-recenter)
427 (defalias 'gnus-extent-start-open 'gnus-xmas-extent-start-open)
428 (defalias 'gnus-article-push-button 'gnus-xmas-article-push-button)
429 (defalias 'gnus-window-top-edge 'gnus-xmas-window-top-edge)
430 (defalias 'gnus-read-event-char 'gnus-xmas-read-event-char)
431 (defalias 'gnus-group-startup-message 'gnus-xmas-group-startup-message)
432 (defalias 'gnus-tree-minimize 'gnus-xmas-tree-minimize)
433 (defalias 'gnus-select-lowest-window
434 'gnus-xmas-select-lowest-window)
435 (defalias 'gnus-mail-strip-quoted-names 'gnus-xmas-mail-strip-quoted-names)
436 (defalias 'gnus-character-to-event 'character-to-event)
437 (defalias 'gnus-mode-line-buffer-identification
438 'gnus-xmas-mode-line-buffer-identification)
439 (defalias 'gnus-key-press-event-p 'key-press-event-p)
440 (defalias 'gnus-region-active-p 'region-active-p)
441 (defalias 'gnus-mark-active-p 'region-exists-p)
442 (defalias 'gnus-annotation-in-region-p 'gnus-xmas-annotation-in-region-p)
443 (defalias 'gnus-mime-button-menu 'gnus-xmas-mime-button-menu)
444 (defalias 'gnus-mime-security-button-menu
445 'gnus-xmas-mime-security-button-menu)
446 (defalias 'gnus-image-type-available-p 'gnus-xmas-image-type-available-p)
447 (defalias 'gnus-put-image 'gnus-xmas-put-image)
448 (defalias 'gnus-create-image 'gnus-xmas-create-image)
449 (defalias 'gnus-remove-image 'gnus-xmas-remove-image)
450 (defalias 'gnus-article-describe-bindings
451 'gnus-xmas-article-describe-bindings)
453 ;; These ones are not defcutom'ed, sometimes not even defvar'ed. They
454 ;; probably should. If that is done, the code below should then be moved
455 ;; where each variable is defined, in order not to mess with user settings.
457 (add-hook 'gnus-score-mode-hook 'gnus-xmas-score-menu-add)
458 (add-hook 'gnus-binary-mode-hook 'gnus-xmas-binary-menu-add)
459 (add-hook 'gnus-server-mode-hook 'gnus-xmas-server-menu-add)
460 (add-hook 'gnus-browse-mode-hook 'gnus-xmas-browse-menu-add)
461 (add-hook 'gnus-draft-mode-hook 'gnus-xmas-draft-menu-add)
462 (add-hook 'gnus-mailing-list-mode-hook 'gnus-xmas-mailing-list-menu-add))
465 ;;; XEmacs logo and toolbar.
467 (defun gnus-xmas-group-startup-message (&optional x y)
468 "Insert startup message in current buffer."
469 ;; Insert the message.
472 ((and (console-on-window-system-p)
475 (let* ((logo-xpm (expand-file-name "gnus.xpm" gnus-xmas-glyph-directory))
476 (logo-xbm (expand-file-name "gnus.xbm" gnus-xmas-glyph-directory))
478 (cond ((featurep 'xpm)
482 (("thing" . ,(car gnus-logo-colors))
483 ("shadow" . ,(cadr gnus-logo-colors))
485 ("background" . ,(face-background 'default)))])
487 `[xbm :file ,logo-xbm])
490 (set-extent-begin-glyph (make-extent (point) (point)) glyph)
491 (goto-char (point-min))
493 (insert (make-string (/ (max (- (window-width) (or x 35)) 0) 2)
496 (goto-char (point-min))
497 (let* ((pheight (+ 20 (count-lines (point-min) (point-max))))
498 (wheight (window-height))
499 (rest (- wheight pheight)))
500 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n))))
505 _ ___ __ ___ __ _ ___
525 (gnus-indent-rigidly (point-min) (point-max)
526 (/ (max (- (window-width) (or x 46)) 0) 2))
527 (goto-char (point-min))
529 (let* ((pheight (count-lines (point-min) (point-max)))
530 (wheight (window-height))
531 (rest (- wheight pheight)))
532 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
534 (put-text-property (point-min) (point-max) 'face 'gnus-splash)))
535 (setq modeline-buffer-identification
536 (list (concat gnus-version ": *Group*")))
537 (set-buffer-modified-p t))
542 (defun gnus-xmas-update-toolbars ()
543 "Update the toolbars' appearance."
544 (when (and (not noninteractive)
545 (featurep 'gnus-xmas))
547 (dolist (buffer (buffer-list))
549 (cond ((eq major-mode 'gnus-group-mode)
550 (gnus-xmas-setup-group-toolbar))
551 ((eq major-mode 'gnus-summary-mode)
552 (gnus-xmas-setup-summary-toolbar)))))))
554 (defcustom gnus-use-toolbar (if (featurep 'toolbar) 'default)
555 "*Position to display the toolbar. Nil means do not use a toolbar.
556 If it is non-nil, it should be one of the symbols `default', `top',
557 `bottom', `right', and `left'. `default' means to use the default
558 toolbar, the rest mean to display the toolbar on the place which those
560 :type '(choice (const default)
561 (const top) (const bottom) (const left) (const right)
562 (const :tag "no toolbar" nil))
563 :set (lambda (symbol value)
567 (memq value (list 'default 'top 'bottom 'right 'left)))
570 (gnus-xmas-update-toolbars))
573 (defcustom gnus-toolbar-thickness
574 (if (featurep 'toolbar)
575 (cons (specifier-instance default-toolbar-height)
576 (specifier-instance default-toolbar-width)))
577 "*Cons of the height and the width specifying the thickness of a toolbar.
578 The height is used for the toolbar displayed on the top or the bottom,
579 the width is used for the toolbar displayed on the right or the left."
580 :type '(cons :tag "height & width"
581 (integer :tag "height") (integer :tag "width"))
582 :set (lambda (symbol value)
585 (if (and (consp value) (natnump (car value)) (natnump (cdr value)))
588 (gnus-xmas-update-toolbars))
591 (defvar gnus-group-toolbar
592 '([gnus-group-get-new-news gnus-group-get-new-news t "Get new news"]
593 [gnus-group-get-new-news-this-group
594 gnus-group-get-new-news-this-group t "Get new news in this group"]
595 [gnus-group-catchup-current
596 gnus-group-catchup-current t "Catchup group"]
597 [gnus-group-describe-group
598 gnus-group-describe-group t "Describe group"]
599 [gnus-group-unsubscribe gnus-group-unsubscribe t "Unsubscribe group"]
600 [gnus-group-subscribe gnus-group-subscribe t "Subscribe group"]
601 [gnus-group-kill-group gnus-group-kill-group t "Kill group"]
602 [gnus-summary-mail-save
603 gnus-group-save-newsrc t "Save .newsrc files"] ; borrowed icon.
604 [gnus-group-exit gnus-group-exit t "Exit Gnus"])
605 "The group buffer toolbar.")
607 (defvar gnus-summary-toolbar
608 '([gnus-summary-prev-unread
609 gnus-summary-prev-page-or-article t "Page up"]
610 [gnus-summary-next-unread
611 gnus-summary-next-page t "Page down"]
612 [gnus-summary-post-news
613 gnus-summary-post-news t "Post an article"]
614 [gnus-summary-followup-with-original
615 gnus-summary-followup-with-original t
616 "Post a followup and yank the original"]
617 [gnus-summary-followup
618 gnus-summary-followup t "Post a followup"]
619 [gnus-summary-reply-with-original
620 gnus-summary-reply-with-original t "Mail a reply and yank the original"]
622 gnus-summary-reply t "Mail a reply"]
623 [gnus-summary-caesar-message
624 gnus-summary-caesar-message t "Rot 13"]
626 gnus-uu-decode-uu t "Decode uuencoded articles"]
627 [gnus-summary-save-article-file
628 gnus-summary-save-article-file t "Save article in file"]
629 [gnus-summary-save-article
630 gnus-summary-save-article t "Save article"]
632 gnus-uu-post-news t "Post a uuencoded article"]
633 [gnus-summary-cancel-article
634 gnus-summary-cancel-article t "Cancel article"]
635 [gnus-summary-catchup
636 gnus-summary-catchup t "Catchup"]
637 [gnus-summary-catchup-and-exit
638 gnus-summary-catchup-and-exit t "Catchup and exit"]
639 [gnus-summary-exit gnus-summary-exit t "Exit this summary"])
640 "The summary buffer toolbar.")
642 (defvar gnus-summary-mail-toolbar
644 [gnus-summary-prev-unread
645 gnus-summary-prev-unread-article t "Prev unread article"]
646 [gnus-summary-next-unread
647 gnus-summary-next-unread-article t "Next unread article"]
648 [gnus-summary-mail-reply gnus-summary-reply t "Reply"]
649 [gnus-summary-mail-originate gnus-summary-post-news t "Originate"]
650 [gnus-summary-mail-save gnus-summary-save-article t "Save"]
651 [gnus-summary-mail-copy gnus-summary-copy-article t "Copy message"]
652 [gnus-summary-mail-forward gnus-summary-mail-forward t "Forward message"]
653 [gnus-summary-caesar-message
654 gnus-summary-caesar-message t "Rot 13"]
656 gnus-uu-decode-uu t "Decode uuencoded articles"]
657 [gnus-summary-save-article-file
658 gnus-summary-save-article-file t "Save article in file"]
659 [gnus-summary-save-article
660 gnus-summary-save-article t "Save article"]
661 [gnus-summary-cancel-article ; usenet : cancellation :: mail : deletion.
662 gnus-summary-delete-article t "Delete message"]
663 [gnus-summary-catchup
664 gnus-summary-catchup t "Catchup"]
665 [gnus-summary-catchup-and-exit
666 gnus-summary-catchup-and-exit t "Catchup and exit"]
667 [gnus-summary-exit gnus-summary-exit t "Exit this summary"])
668 "The summary buffer mail toolbar.")
670 (defun gnus-xmas-setup-toolbar (toolbar)
671 (when (featurep 'toolbar)
672 (if (and gnus-use-toolbar
673 (message-xmas-setup-toolbar toolbar nil "gnus"))
674 (let ((bar (or (intern-soft (format "%s-toolbar" gnus-use-toolbar))
676 (height (car gnus-toolbar-thickness))
677 (width (cdr gnus-toolbar-thickness))
678 (cur (current-buffer))
680 (set-specifier (symbol-value bar) toolbar cur)
681 (set-specifier default-toolbar-height height cur)
682 (set-specifier default-toolbar-width width cur)
683 (set-specifier top-toolbar-height height cur)
684 (set-specifier bottom-toolbar-height height cur)
685 (set-specifier right-toolbar-width width cur)
686 (set-specifier left-toolbar-width width cur)
687 (if (eq bar 'default-toolbar)
689 (remove-specifier default-toolbar-visible-p cur)
690 (remove-specifier top-toolbar cur)
691 (remove-specifier top-toolbar-visible-p cur)
692 (remove-specifier bottom-toolbar cur)
693 (remove-specifier bottom-toolbar-visible-p cur)
694 (remove-specifier right-toolbar cur)
695 (remove-specifier right-toolbar-visible-p cur)
696 (remove-specifier left-toolbar cur)
697 (remove-specifier left-toolbar-visible-p cur))
698 (set-specifier (symbol-value (intern (format "%s-visible-p" bar)))
700 (setq bars (delq bar (list 'default-toolbar
701 'bottom-toolbar 'top-toolbar
702 'right-toolbar 'left-toolbar)))
704 (set-specifier (symbol-value (intern (format "%s-visible-p"
707 (let ((cur (current-buffer)))
708 (set-specifier default-toolbar-visible-p nil cur)
709 (set-specifier top-toolbar-visible-p nil cur)
710 (set-specifier bottom-toolbar-visible-p nil cur)
711 (set-specifier right-toolbar-visible-p nil cur)
712 (set-specifier left-toolbar-visible-p nil cur)))))
714 (defun gnus-xmas-setup-group-toolbar ()
715 (gnus-xmas-setup-toolbar gnus-group-toolbar))
717 (defun gnus-xmas-setup-summary-toolbar ()
718 (gnus-xmas-setup-toolbar (if (gnus-news-group-p gnus-newsgroup-name)
720 gnus-summary-mail-toolbar)))
722 (defun gnus-xmas-mail-strip-quoted-names (address)
723 "Protect mail-strip-quoted-names from nil input.
724 XEmacs compatibility workaround."
727 (mail-strip-quoted-names address)))
729 (defvar gnus-xmas-modeline-left-extent
730 (let ((ext (copy-extent modeline-buffer-id-left-extent)))
733 (defvar gnus-xmas-modeline-right-extent
734 (let ((ext (copy-extent modeline-buffer-id-right-extent)))
737 (defvar gnus-xmas-modeline-glyph
739 (let* ((file-xpm (expand-file-name "gnus-pointer.xpm"
740 gnus-xmas-glyph-directory))
741 (file-xbm (expand-file-name "gnus-pointer.xbm"
742 gnus-xmas-glyph-directory))
745 (cond ((featurep 'xpm)
746 ;; Let's try a nifty XPM
747 `[xpm :file ,file-xpm])
749 ;; Then a not-so-nifty XBM
750 `[xbm :file ,file-xbm])
751 ;; Then the simple string
752 (t [string :data "Gnus:"])))))
753 (set-glyph-face glyph 'modeline-buffer-id)
756 (defun gnus-xmas-mode-line-buffer-identification (line)
757 (let ((line (car line))
760 ;; This is some weird type of id.
761 ((not (stringp line))
763 ;; This is non-standard, so we just pass it through.
764 ((not (string-match "^Gnus:" line))
766 ;; We have a standard line, so we colorize and glyphize it a bit.
768 (setq chop (match-end 0))
770 (if gnus-xmas-modeline-glyph
771 (cons gnus-xmas-modeline-left-extent gnus-xmas-modeline-glyph)
772 (cons gnus-xmas-modeline-left-extent (substring line 0 chop)))
773 (cons gnus-xmas-modeline-right-extent (substring line chop)))))))
775 (defun gnus-xmas-annotation-in-region-p (b e)
776 (or (map-extents (lambda (e u) t) nil b e nil nil 'mm t)
778 (eq (cadr (memq 'gnus-undeletable (text-properties-at b))) t)
779 (text-property-any b e 'gnus-undeletable t))))
781 (defun gnus-xmas-mime-button-menu (event prefix)
782 "Construct a context-sensitive menu of MIME commands."
784 (let ((response (get-popup-menu-response
786 ,@(mapcar (lambda (c) `[,(caddr c) ,(car c) t])
787 gnus-mime-button-commands)))))
788 (set-buffer (event-buffer event))
789 (goto-char (event-point event))
790 (funcall (event-function response) (event-object response))))
792 (defun gnus-xmas-mime-security-button-menu (event prefix)
793 "Construct a context-sensitive menu of security commands."
796 (get-popup-menu-response
800 (unless (eq (car c) 'undefined)
801 `[,(caddr c) ,(car c) t]))
802 gnus-mime-security-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-mailing-list-menu-add ()
808 (gnus-xmas-menu-add mailing-list
809 gnus-mailing-list-menu))
811 (defun gnus-xmas-image-type-available-p (type)
812 (and (if (fboundp 'display-images-p)
815 (featurep (if (eq type 'pbm) 'xbm type))))
817 (defun gnus-xmas-create-image (file &optional type data-p &rest props)
822 (string-match "[.]" file))
823 (car (last (split-string file "[.]"))))))
824 (face (plist-get props :face))
826 (when (equal type "pbm")
830 (insert-file-contents-literally file))
831 (shell-command-on-region (point-min) (point-max)
832 "ppmtoxpm 2>/dev/null" t)
833 (setq file (buffer-string)
837 (if (equal type "xbm")
838 (make-glyph (list (cons 'x file)))
842 (insert-file-contents-literally file))
847 (mm-image-type-from-buffer))
848 :data (buffer-string))))))
850 (set-glyph-face glyph face))
853 (defun gnus-xmas-put-image (glyph &optional string category)
854 "Insert STRING, but display GLYPH.
855 Warning: Don't insert text immediately after the image."
856 (let ((begin (point))
858 (if (and (bobp) (not string))
862 (setq begin (1- begin)))
863 (setq extent (make-extent begin (point)))
864 (set-extent-property extent 'gnus-image category)
865 (set-extent-property extent 'duplicable t)
867 (set-extent-property extent 'invisible t))
868 (set-extent-property extent 'end-glyph glyph))
871 (defun gnus-xmas-remove-image (image &optional category)
872 "Remove the image matching IMAGE and CATEGORY found first."
875 (when (equal (extent-end-glyph ext) image)
876 (set-extent-property ext 'invisible nil)
877 (set-extent-property ext 'end-glyph nil)
879 nil nil nil nil nil 'gnus-image category))
881 (defun gnus-xmas-assq-delete-all (key alist)
883 (while (setq elem (assq key alist))
884 (setq alist (delq elem alist)))
889 ;;; gnus-xmas.el ends here