* pccl.el (define-long-ccl-program): New macro.
[elisp/apel.git] / pccl.el
1 ;;; pccl.el --- Portable CCL utility for Mule 1.* and Mule 2.*
2
3 ;; Copyright (C) 1998 Free Software Foundation, Inc.
4
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Keywords: emulation, compatibility, Mule
7
8 ;; This file is part of APEL (A Portable Emacs Library).
9
10 ;; This program is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or (at
13 ;; your option) any later version.
14
15 ;; This program 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.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Code:
26
27 (require 'ccl)
28 (require 'broken)
29
30 (if (featurep 'mule)
31     (if (featurep 'xemacs)
32         (if (>= emacs-major-version 21)
33             ;; for XEmacs-21-mule
34             (require 'pccl-20))
35       (if (>= emacs-major-version 20)
36           ;; for Emacs 20
37           (require 'pccl-20)
38         ;; for MULE 1.* and 2.*
39         (require 'pccl-om))))
40
41 (broken-facility ccl-usable
42   "Emacs has CCL."
43   (and (featurep 'mule)
44        (if (featurep 'xemacs)
45            (>= emacs-major-version 21)
46          t)))
47
48 (defmacro define-long-ccl-program (name ccl-program &optional doc)
49   "Define CCL program as define-ccl-program."
50   (setq ccl-program (eval ccl-program))
51   (let ((try-ccl-compile t))
52     (while try-ccl-compile
53       (setq try-ccl-compile nil)
54       (condition-case sig
55           (ccl-compile ccl-program)
56         (args-out-of-range
57          (if (and (eq (car (cdr sig)) ccl-program-vector)
58                   (= (car (cdr (cdr sig))) (length ccl-program-vector)))
59              (setq ccl-program-vector
60                    (make-vector (* 2 (length ccl-program-vector)) 0)
61                    try-ccl-compile t)
62            (signal (car sig) (cdr sig))))))
63     (` (define-ccl-program (, name) '(, ccl-program) (, doc)))))
64
65
66 ;;; @ end
67 ;;;
68
69 (provide 'pccl)
70
71 ;;; pccl.el ends here