1 ;;; messagexmas.el --- XEmacs extensions to message
2 ;; Copyright (C) 1996,97,98,99 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; Keywords: mail, news
7 ;; This file is part of GNU Emacs.
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)
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.
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.
28 (eval-when-compile (require 'cl))
31 (defvar message-xmas-dont-activate-region t
32 "If t, don't activate region after yanking.")
34 (defvar message-xmas-glyph-directory nil
35 "*Directory where Message logos and icons are located.
36 If this variable is nil, Message will try to locate the directory
39 (defvar message-use-toolbar (if (featurep 'toolbar)
42 "*If nil, do not use a toolbar.
43 If it is non-nil, it must be a toolbar. The five valid values are
44 `default-toolbar', `top-toolbar', `bottom-toolbar',
45 `right-toolbar', and `left-toolbar'.")
47 (defvar message-toolbar
48 '([message-spell ispell-message t "Spell"]
49 [message-help (Info-goto-node "(Message)Top") t "Message help"])
50 "The message buffer toolbar.")
52 (defun message-xmas-find-glyph-directory (&optional package)
53 (setq package (or package "message"))
54 (let ((dir (symbol-value
55 (intern-soft (concat package "-xmas-glyph-directory")))))
56 (if (and (stringp dir) (file-directory-p dir))
58 (nnheader-find-etc-directory package))))
60 (defun message-xmas-setup-toolbar (bar &optional force package)
61 (let ((dir (message-xmas-find-glyph-directory package))
62 (xpm (if (featurep 'xpm) "xpm" "xbm"))
63 icon up down disabled name)
65 (setq message-xmas-glyph-directory dir))
68 (setq icon (aref (car bar) 0)
69 name (symbol-name icon)
73 (setq up (concat dir name "-up." xpm))
74 (setq down (concat dir name "-down." xpm))
75 (setq disabled (concat dir name "-disabled." xpm))
76 (if (not (file-exists-p up))
79 (set icon (toolbar-make-button-list
80 up (and (file-exists-p down) down)
81 (and (file-exists-p disabled) disabled)))))))
84 (defun message-setup-toolbar ()
85 (and message-use-toolbar
86 (message-xmas-setup-toolbar message-toolbar)
87 (set-specifier (symbol-value message-use-toolbar)
88 (cons (current-buffer) message-toolbar))))
90 (defun message-xmas-exchange-point-and-mark ()
91 "Exchange point and mark, but allow for XEmacs' optional argument."
92 (exchange-point-and-mark message-xmas-dont-activate-region))
94 (defun message-xmas-maybe-fontify ()
95 (when (featurep 'font-lock)
96 (font-lock-set-defaults)))
98 (defun message-xmas-make-caesar-translation-table (n)
99 "Create a rot table with offset N."
101 (table (make-string 256 0))
103 (A (mm-char-int ?A)))
104 (while (< (incf i) 256)
107 (substring table 0 A)
108 (substring table (+ A n) (+ A n (- 26 n)))
109 (substring table A (+ A n))
110 (substring table (+ A 26) a)
111 (substring table (+ a n) (+ a n (- 26 n)))
112 (substring table a (+ a n))
113 (substring table (+ a 26) 255))))
115 (add-hook 'message-mode-hook 'message-xmas-maybe-fontify)
117 (defun message-xmas-redefine ()
118 "Redefine message functions for XEmacs."
119 (defalias 'message-exchange-point-and-mark
120 'message-xmas-exchange-point-and-mark)
122 (when (>= emacs-major-version 20)
123 (defalias 'message-make-caesar-translation-table
124 'message-xmas-make-caesar-translation-table)))
126 (message-xmas-redefine)
128 (provide 'messagexmas)
130 ;;; messagexmas.el ends here