Remove non-free old and crusty clearcase pkg
[packages] / xemacs-packages / x-symbol / lisp / x-symbol-xmacs.el
1 ;;; x-symbol-xmacs.el --- make package x-symbol work with XEmacs
2
3 ;; Copyright (C) 1998-1999, 2001-2003 Free Software Foundation, Inc.
4 ;;
5 ;; Author: Christoph Wedler <wedler@users.sourceforge.net>
6 ;; Maintainer: (Please use `M-x x-symbol-package-bug' to contact the maintainer)
7 ;; Version: 4.5
8 ;; Keywords: WYSIWYG, LaTeX, HTML, wp, math, internationalization
9 ;; X-URL: http://x-symbol.sourceforge.net/
10
11 ;; This program 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)
14 ;; any later version.
15 ;;
16 ;; This program 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.
20 ;;
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program; if not, write to the Free Software
23 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24
25 ;;; Commentary:
26
27 ;; If you want to use package x-symbol, please visit the URL (use
28 ;; \\[x-symbol-package-web]) and read the info (use \\[x-symbol-package-info]).
29
30 ;;; Code:
31
32 ;;; Release dates: XEmacs-21.1.2 = 14 May 1999, XEmacs-21.1.9 = 13 Feb 2000.
33
34 (provide 'x-symbol-xmacs)
35 ;; the following line can be included AFTER (require 'x-symbol-{mule/nomule}) has been deleted from x-symbol-hooks
36 ;;(eval-when-compile (require 'x-symbol))       ; x-symbol also requires this file
37
38 (cond ((not (and (fboundp 'emacs-version>=) (emacs-version>= 20 4)))
39        ;; Yes, it probably works with XEmacs-20.2, too, but I do not want to
40        ;; care about its bug in `string-match':
41        (error "Package X-Symbol requires XEmacs-21.1.9+"))
42       ((or (emacs-version>= 21 2) (not x-symbol-warn-of-old-emacs)))
43       ((< emacs-major-version 21)
44        (warn "X-Symbol: minor problem in GRID, upgrade to XEmacs-21.1.9+"))
45       ((or (zerop emacs-minor-version)
46            ;; 3rd arg for `emacs-version>=' introduced in XEmacs-21.2.15
47            (not (and (boundp 'emacs-patch-level)
48                      (>= emacs-patch-level 9))))
49        ;; XEmacs-21.1.8 + X-Symbol + abbrev-mode + input method TOKEN => core
50        (setq-default x-symbol-token-input nil)
51        (warn "X-Symbol: XEmacs might core, upgrade to XEmacs-21.1.9+")))
52
53 (when (eq (console-type) 'mswindows)
54   (unless (emacs-version>= 21 4)
55     (warn "X-Symbol: might not work correctly, upgrade to XEmacs-21.4+"))
56   (unless (and (boundp 'x-symbol-default-coding)
57                (or (null x-symbol-default-coding)
58                    (eq x-symbol-default-coding 'iso-8859-1)))
59     ;; no idea about XEmacs/NT in a Japanese environment...
60     (warn "X-Symbol: only limited support with XEmacs-21.4+ on Windows")
61     (setq x-symbol-default-coding 'iso-8859-1))
62   (unless (and (boundp 'x-symbol-latin-force-use)
63                (eq x-symbol-latin-force-use 'mswindows-user))
64     ;; Hm, this isn't a really great situation that all font settings are
65     ;; useless for MS-Windows...
66     (setq x-symbol-latin1-fonts
67           '(("Microsoft Sans Serif:Regular:11::Western"
68              "Courier New:Regular:11::Western")))
69     ;; Latin2 != CP1250, see EMACS/lisp/international/codepage.el
70     (setq x-symbol-latin2-fonts nil)
71     ;;    '(("Microsoft Sans Serif:Regular:11::Central European"
72     ;;       "Courier New:Regular:11::Central European")))
73     ;; Latina-3 from <http://www.esperanto.se/html/latina.html> does not work,
74     ;; I have no time to download and test various others...
75     (setq x-symbol-latin3-fonts nil)
76     (setq x-symbol-latin5-fonts
77           '(("Microsoft Sans Serif:Regular:11::Turkish"
78              "Courier New:Regular:11::Turkish")))
79     (setq x-symbol-latin9-fonts nil)
80     (setq x-symbol-xsymb0-fonts
81           '(("Symbol:Regular:11::Symbol")))
82     (setq x-symbol-xsymb1-fonts nil)
83     (make-face 'x-symbol-heading-face)
84     (set-face-font 'x-symbol-heading-face
85                    "Microsoft Sans Serif:Bold:10::Western")
86     (set-face-foreground 'x-symbol-heading-face "green4")
87     (set-face-underline-p 'x-symbol-heading-face t)
88     (make-face 'x-symbol-info-face)
89     (set-face-font 'x-symbol-info-face
90                    "Microsoft Sans Serif:Regular:10::Western")
91     (set-face-foreground 'x-symbol-info-face "green4")
92     (make-face 'x-symbol-emph-info-face)
93     (set-face-font 'x-symbol-emph-info-face
94                    "Microsoft Sans Serif:Regular:10::Western")
95     (set-face-foreground 'x-symbol-emph-info-face "red4")))
96
97
98 ;;;===========================================================================
99 ;;;  Fixing non X-Symbol induced annoyances
100 ;;;===========================================================================
101
102 (defun x-symbol-paren-reset-mode ()
103   (make-local-variable 'paren-mode)
104   (setq paren-mode nil))
105 (add-hook 'list-mode-hook 'x-symbol-paren-reset-mode)
106
107
108 ;;;===========================================================================
109 ;;;  Autoloads
110 ;;;===========================================================================
111
112 (autoload 'browse-url "browse-url" nil t)
113
114
115 ;;;===========================================================================
116 ;;;  Bug workarounds
117 ;;;===========================================================================
118
119 ;; Workaround for XEmacs bug (since XEmacs-20) with char syntax `inherit': the
120 ;; following should be executed before(!) the AucTeX's syntax table is created.
121 (unless (or (featurep 'mule) (emacs-version>= 21 4)) ; OK in XEmacs-21.4.5
122   (modify-syntax-entry ?\237 "\\" (standard-syntax-table))
123   (modify-syntax-entry ?\236 "\\" (standard-syntax-table))
124   (modify-syntax-entry ?\235 "\\" (standard-syntax-table))
125   (modify-syntax-entry ?\234 "\\" (standard-syntax-table))
126   (modify-syntax-entry ?\233 "\\" (standard-syntax-table))
127   (modify-syntax-entry ?\232 "\\" (standard-syntax-table))
128   ;; Add appropriately if more csets (fonts) are added.
129   )
130
131
132 ;;;===========================================================================
133 ;;;  X-Symbol functions that depend on the Emacs flavor
134 ;;;===========================================================================
135
136 (defvar x-symbol-xmacs-default-face-fonts nil)
137
138 (defalias 'x-symbol-directory-files 'directory-files)
139
140 (defun x-symbol-event-in-current-buffer ()
141   (or (null current-mouse-event)
142       (eq (event-buffer current-mouse-event) (current-buffer))))
143
144 (defun x-symbol-create-image (file type)
145   (make-image-instance (vector (or type 'autodetect) ; autodetect is not clever
146                                :file file)
147                        nil nil t))
148
149 (defalias 'x-symbol-make-glyph 'make-glyph)
150
151 (defalias 'x-symbol-set-glyph-image 'set-glyph-image)
152
153 (defun x-symbol-set-face-font (face font charsets default)
154   "Set font to use for text using FACE and CHARSETS."
155   (if default
156       (progn
157         (push (cons face font) x-symbol-xmacs-default-face-fonts)
158         (set-face-property face 'font font))
159     (set-face-property face 'font font nil '(mule-fonts) 'prepend)
160     (let ((dfont (assq face x-symbol-xmacs-default-face-fonts)))
161       (if dfont (set-face-property face 'font (cdr dfont))))))
162
163 (defun x-symbol-event-matches-key-specifier-p (event specifier)
164   "Return non-nil if EVENT matches key or mouse SPECIFIER.
165 This is like `event-matches-key-specifier-p', except that it also works
166 for mouse events."
167   (if (mouse-event-p event)
168       (equal (aref (events-to-keys (vector event)) 0) specifier)
169     (condition-case nil
170         (event-matches-key-specifier-p event specifier)
171       (error nil))))
172
173 (defun x-symbol-window-width (&optional window)
174   "Return the number of display columns in WINDOW (corrected version)."
175   (or window (setq window (selected-window)))
176   (/ (- (window-pixel-width window)
177         (window-left-margin-pixel-width window) ; ??
178         (window-right-margin-pixel-width window) ; ??
179         (specifier-instance scrollbar-width window))
180      (font-instance-width (face-font-instance 'default window))))
181
182 ;;; Local IspellPersDict: .ispell_xsymb
183 ;;; x-symbol-xmacs.el ends here