1 ;;; fsf-compat-unicode.el --- Provide the FSF's Mule UCS subsets in XEmacs.
3 ;; Copyright (C) 2006 by Free Software Foundation, Inc.
5 ;; Author: Aidan Kehoe <kehoea@parhasard.net>
6 ;; Keywords: Unicode, Mule
8 ;; This file is part of XEmacs.
10 ;; XEmacs is free software; you can redistribute it and/or modify it
11 ;; under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; XEmacs is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 ;;; Synched up with: Not in FSF
31 ;;; Only for 21.5 and newer. Compiles with 21.4 fine.
33 (eval-when-compile (require 'ccl))
35 ;; Check at runtime that the Unicode support is available, and that its
36 ;; coverage is good enough.
37 (unless (and (fboundp 'encode-char) (decode-char 'ucs #x31C)
38 (eq #x31C (encode-char (decode-char 'ucs #x31C) 'ucs)))
40 "Unicode support or coverage needed not available"))
42 ;; For redisplay of these character sets, provide a CCL program to address
43 ;; iso10646-1 X11 fonts.
44 (defvar fsf-compat-ccl-program
46 (let ((pre-existing [1 10 131127 7 98872 65823 147513 8 82009 255 22]))
47 (when (and (> emacs-major-version 20) (> emacs-minor-version 4)
49 ;; In the event that we're compiling on 21.5, check that the
50 ;; pre-existing constant reflects the intended CCL
51 ;; program. Otherwise, just go ahead and use it.
52 (assert (equal pre-existing
57 (mule-to-unicode r0 r1)
59 (r2 = (r0 & #xFF))))))
61 "The pre-compiled CCL program appears broken. "))
63 "CCL program required by `fsf-compat-init-mule-unicode-charsets'.")
66 (defun fsf-compat-init-mule-unicode-charsets ()
67 "Make some Mule character sets that the FSF uses available in XEmacs.
69 These character sets cover some Unicode code space explicitly; we use a
70 different solution to the same problem, so you should only need these
71 character sets if you're editing FSF source. "
74 for (first-ucs last-ucs final) in '((#x0100 #x24FF ?1)
79 (intern (format "mule-unicode-%04x-%04x"
81 (make-charset charset-symbol
83 "Unicode subset (U+%04X..U+%04X) for FSF compatibility."
86 registries ["iso10646-1"]
92 short-name ,(format "Unicode subset U+%04X" first-ucs)
93 long-name ,(format "Unicode subset (U+%04X..U+%04X)"
95 ccl-program ,fsf-compat-ccl-program))
96 ;; The names of the character sets lie, at least as of GNU Emacs
97 ;; 22.0.50.3. The difference appears to be that they keep assigning
98 ;; code points until the end of the 96x96 space of the character sets.
99 (loop for ku from 32 to 127 do
100 (loop for ten from 32 to 127 do
101 (set-unicode-conversion (make-char charset-symbol ku ten) first-ucs)
102 (incf first-ucs))))))
104 ;; The following code creates a form, which, when evaluated in GNU Emacs,
105 ;; checks our compatibility with their three character sets.
108 ; (insert "(require 'cl)\n\n(assert\n (and\n")
110 ; for charset-symbol in '(mule-unicode-2500-33ff
111 ; mule-unicode-e000-ffff
112 ; mule-unicode-0100-24ff)
114 ; (loop for ku from 32 to 127 do
115 ; (loop for ten from 32 to 127 do
117 ; " (eq (encode-char (make-char '%s %d %d) 'ucs) #x%04X)\n"
118 ; charset-symbol ku ten
119 ; (encode-char (make-char charset-symbol ku ten) 'ucs))))))
120 ; (insert " ) nil \"We're incompatible with the FSF!\")"))
121 ;;; end fsf-compat-unicode.el