c4253c40ee84acce2b32b54a18d5e42bed5d1baa
[gnus] / lisp / messagexmas.el
1 ;;; messagexmas.el --- XEmacs extensions to message
2 ;; Copyright (C) 1996 Free Software Foundation, Inc.
3
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
5 ;; Keywords: mail, news
6
7 ;; This file is part of GNU Emacs.
8
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
13
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
23
24 ;;; Commentary:
25
26 ;;; Code:
27
28 (defvar message-xmas-dont-activate-region nil
29   "If t, don't activate region after yanking.")
30
31 (defvar message-xmas-glyph-directory nil
32   "*Directory where Message logos and icons are located.
33 If this variable is nil, Message will try to locate the directory
34 automatically.")
35
36 (defvar message-use-toolbar (if (featurep 'toolbar)
37                                 'default-toolbar
38                               nil)
39   "*If nil, do not use a toolbar.
40 If it is non-nil, it must be a toolbar.  The five legal values are
41 `default-toolbar', `top-toolbar', `bottom-toolbar',
42 `right-toolbar', and `left-toolbar'.")
43
44 (defvar message-toolbar 
45   '([message-spell ispell-message t "Spell"]
46     [message-help (Info-goto-node "(Message)Top") t "Message help"])
47   "The message buffer toolbar.")
48
49 (defun message-xmas-find-glyph-directory (&optional package)
50   (setq package (or package "message"))
51   (let ((dir (symbol-value
52               (intern-soft (concat package "-xmas-glyph-directory")))))
53     (if (and (stringp dir) (file-directory-p dir))
54         dir
55       (nnheader-find-etc-directory package))))
56
57 (defun message-xmas-setup-toolbar (bar &optional force package)
58   (let ((dir (message-xmas-find-glyph-directory package))
59         (xpm (if (featurep 'xpm) "xpm" "xbm"))
60         icon up down disabled name)
61     (unless package
62       (setq message-xmas-glyph-directory dir))
63     (when dir
64       (while bar
65         (setq icon (aref (car bar) 0)
66               name (symbol-name icon)
67               bar (cdr bar))
68         (when (or force
69                   (not (boundp icon)))
70           (setq up (concat dir name "-up." xpm))
71           (setq down (concat dir name "-down." xpm))
72           (setq disabled (concat dir name "-disabled." xpm))
73           (if (not (file-exists-p up))
74               (setq bar nil
75                     dir nil)
76             (set icon (toolbar-make-button-list
77                        up (and (file-exists-p down) down)
78                        (and (file-exists-p disabled) disabled)))))))
79     dir))
80
81 (defun message-setup-toolbar ()
82   (and message-use-toolbar
83        (message-xmas-setup-toolbar message-toolbar)
84        (set-specifier (symbol-value message-use-toolbar)
85                       (cons (current-buffer) message-toolbar))))
86
87 (defun message-xmas-exchange-point-and-mark ()
88   "Exchange point and mark, but allow for XEmacs' optional argument."
89   (exchange-point-and-mark message-xmas-dont-activate-region))
90
91 (fset 'message-exchange-point-and-mark 'message-xmas-exchange-point-and-mark)
92
93 (provide 'messagexmas)
94
95 ;;; messagexmas.el ends here