* pccl.el: Enclose mule depended process by `unless-broken'.
[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 'broken)
28
29 ;; The condition for non-XEmacs mule t may be wrong.
30 ;; But I don't know exact version which introduce CCL on mule.
31 (broken-facility ccl-usable
32   "Emacs has CCL."
33   (and (featurep 'mule)
34        (if (featurep 'xemacs)
35            (>= emacs-major-version 21)
36          t)))
37
38 (unless-broken ccl-usable
39   (require 'ccl)
40   (require 'advice)
41
42   (if (featurep 'mule)
43       (if (featurep 'xemacs)
44           (if (>= emacs-major-version 21)
45               ;; for XEmacs-21-mule
46               (require 'pccl-20))
47         (if (>= emacs-major-version 20)
48             ;; for Emacs 20
49             (require 'pccl-20)
50           ;; for MULE 1.* and 2.*
51           (require 'pccl-om))))
52
53   (defadvice define-ccl-program
54     (before accept-long-ccl-program activate)
55     "When CCL-PROGRAM is too long, internal buffer is extended automaticaly."
56     (let ((try-ccl-compile t)
57           (prog (eval (ad-get-arg 1))))
58       (ad-set-arg 1 (` '(, prog)))
59       (while try-ccl-compile
60         (setq try-ccl-compile nil)
61         (condition-case sig
62             (ccl-compile prog)
63           (args-out-of-range
64            (if (and (eq (car (cdr sig)) ccl-program-vector)
65                     (= (car (cdr (cdr sig))) (length ccl-program-vector)))
66                (setq ccl-program-vector
67                      (make-vector (* 2 (length ccl-program-vector)) 0)
68                      try-ccl-compile t)
69              (signal (car sig) (cdr sig))))))))
70   )
71
72
73 ;;; @ end
74 ;;;
75
76 (provide 'pccl)
77
78 ;;; pccl.el ends here