1 ;;; messagexmas.el --- XEmacs extensions to message
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2003, 2004
4 ;; Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Keywords: mail, news
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl))
33 (defvar message-xmas-dont-activate-region t
34 "If t, don't activate region after yanking.")
36 (defvar message-xmas-glyph-directory nil
37 "*Directory where Message logos and icons are located.
38 If this variable is nil, Message will try to locate the directory
41 (defvar message-use-toolbar (if (featurep 'toolbar)
44 "*If nil, do not use a toolbar.
45 If it is non-nil, it must be a toolbar. The five valid values are
46 `default-toolbar', `top-toolbar', `bottom-toolbar',
47 `right-toolbar', and `left-toolbar'.")
49 (defvar message-toolbar
50 '([message-spell ispell-message t "Spell"]
51 [message-help (Info-goto-node "(Message)Top") t "Message help"])
52 "The message buffer toolbar.")
54 (defun message-xmas-find-glyph-directory (&optional package)
55 (setq package (or package "message"))
56 (let ((dir (symbol-value
57 (intern-soft (concat package "-xmas-glyph-directory")))))
58 (if (and (stringp dir) (file-directory-p dir))
60 (nnheader-find-etc-directory package))))
62 (defun message-xmas-setup-toolbar (bar &optional force package)
63 (let ((dir (message-xmas-find-glyph-directory package))
64 (xpm (if (featurep 'xpm) "xpm" "xbm"))
65 icon up down disabled name)
67 (setq message-xmas-glyph-directory dir))
70 (setq icon (aref (car bar) 0)
71 name (symbol-name icon)
75 (setq up (concat dir name "-up." xpm))
76 (setq down (concat dir name "-down." xpm))
77 (setq disabled (concat dir name "-disabled." xpm))
78 (if (not (file-exists-p up))
81 (set icon (toolbar-make-button-list
82 up (and (file-exists-p down) down)
83 (and (file-exists-p disabled) disabled)))))))
86 (defun message-setup-toolbar ()
87 (and message-use-toolbar
88 (message-xmas-setup-toolbar message-toolbar)
89 (set-specifier (symbol-value message-use-toolbar)
90 (cons (current-buffer) message-toolbar))))
92 (defun message-xmas-exchange-point-and-mark ()
93 "Exchange point and mark, but allow for XEmacs' optional argument."
94 (exchange-point-and-mark message-xmas-dont-activate-region))
96 (defun message-xmas-maybe-fontify ()
97 (when (featurep 'font-lock)
98 (font-lock-set-defaults)))
100 (defun message-xmas-make-caesar-translation-table (n)
101 "Create a rot table with offset N."
103 (table (make-string 256 0))
106 (while (< (incf i) 256)
109 (substring table 0 A)
110 (substring table (+ A n) (+ A n (- 26 n)))
111 (substring table A (+ A n))
112 (substring table (+ A 26) a)
113 (substring table (+ a n) (+ a n (- 26 n)))
114 (substring table a (+ a n))
115 (substring table (+ a 26) 255))))
117 (defun message-xmas-make-date (&optional now)
118 "Make a valid data header.
119 If NOW, use that time instead."
120 (let ((zone (car (current-time-zone)))
126 (format "%s %s%02d%02d"
127 (format-time-string "%a, %d %b %Y %T" now)
130 (/ (% zone 3600) 60))))
132 (add-hook 'message-mode-hook 'message-xmas-maybe-fontify)
134 (defun message-xmas-redefine ()
135 "Redefine message functions for XEmacs."
136 (defalias 'message-exchange-point-and-mark
137 'message-xmas-exchange-point-and-mark)
138 (defalias 'message-mark-active-p
140 (defalias 'message-make-caesar-translation-table
141 'message-xmas-make-caesar-translation-table)
142 (defalias 'message-make-overlay 'make-extent)
143 (defalias 'message-delete-overlay 'delete-extent)
144 (defalias 'message-overlay-put 'set-extent-property)
145 (defalias 'message-make-date 'message-xmas-make-date))
147 (message-xmas-redefine)
149 (provide 'messagexmas)
151 ;;; messagexmas.el ends here