1 ;;; pccl.el --- Portable CCL utility for Mule 2.*
3 ;; Copyright (C) 1998,1999,2001,2002 Free Software Foundation, Inc.
5 ;; Author: Tanaka Akira <akr@m17n.org>
6 ;; Keywords: emulation, compatibility, Mule
8 ;; This file is part of APEL (A Portable Emacs Library).
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.
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.
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.
29 (broken-facility ccl-usable
32 (if (featurep 'xemacs)
33 (>= emacs-major-version 21)
34 (>= emacs-major-version 19))))
36 (unless-broken ccl-usable
42 (if (featurep 'xemacs)
43 (if (>= emacs-major-version 21)
44 ;; for XEmacs 21 with mule
46 (if (>= emacs-major-version 20)
50 (require 'pccl-om)))))
52 (static-if (or (featurep 'xemacs) (< emacs-major-version 21))
53 (defadvice define-ccl-program
54 (before accept-long-ccl-program activate)
55 "When CCL-PROGRAM is too long, internal buffer is extended automatically."
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)
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)
69 (signal (car sig) (cdr sig)))))))))
71 (static-when (and (not (featurep 'xemacs)) (< emacs-major-version 21))
72 (defun-maybe transform-make-coding-system-args (name type &optional doc-string props)
73 "For internal use only.
74 Transform XEmacs style args for `make-coding-system' to Emacs style.
75 Value is a list of transformed arguments."
76 (let ((mnemonic (string-to-char (or (plist-get props 'mnemonic) "?")))
77 (eol-type (plist-get props 'eol-type))
80 ((eq eol-type 'lf) (setq eol-type 'unix))
81 ((eq eol-type 'crlf) (setq eol-type 'dos))
82 ((eq eol-type 'cr) (setq eol-type 'mac)))
83 (if (setq tmp (plist-get props 'post-read-conversion))
84 (setq properties (plist-put properties 'post-read-conversion tmp)))
85 (if (setq tmp (plist-get props 'pre-write-conversion))
86 (setq properties (plist-put properties 'pre-write-conversion tmp)))
89 (` ((, name) 1 (, mnemonic) (, doc-string)
90 nil (, properties) (, eol-type))))
91 ((eq type 'iso2022) ; This is not perfect.
92 (if (plist-get props 'escape-quoted)
93 (error "escape-quoted is not supported: %S"
94 (` ((, name) (, type) (, doc-string) (, props)))))
95 (let ((g0 (plist-get props 'charset-g0))
96 (g1 (plist-get props 'charset-g1))
97 (g2 (plist-get props 'charset-g2))
98 (g3 (plist-get props 'charset-g3))
101 (eq (cadr (assoc 'latin-jisx0201
102 (plist-get props 'input-charset-conversion)))
104 (eq (cadr (assoc 'ascii
105 (plist-get props 'output-charset-conversion)))
109 (eq (cadr (assoc 'japanese-jisx0208-1978
110 (plist-get props 'input-charset-conversion)))
112 (eq (cadr (assoc 'japanese-jisx0208
113 (plist-get props 'output-charset-conversion)))
114 'japanese-jisx0208-1978))))
116 (if (plist-get props 'force-g0-on-output)
117 (setq g0 (` (nil (, g0))))
118 (setq g0 (` ((, g0) t)))))
120 (if (plist-get props 'force-g1-on-output)
121 (setq g1 (` (nil (, g1))))
122 (setq g1 (` ((, g1) t)))))
124 (if (plist-get props 'force-g2-on-output)
125 (setq g2 (` (nil (, g2))))
126 (setq g2 (` ((, g2) t)))))
128 (if (plist-get props 'force-g3-on-output)
129 (setq g3 (` (nil (, g3))))
130 (setq g3 (` ((, g3) t)))))
131 (` ((, name) 2 (, mnemonic) (, doc-string)
132 ((, g0) (, g1) (, g2) (, g3)
133 (, (plist-get props 'short))
134 (, (not (plist-get props 'no-ascii-eol)))
135 (, (not (plist-get props 'no-ascii-cntl)))
136 (, (plist-get props 'seven))
138 (, (not (plist-get props 'lock-shift)))
141 (, (plist-get props 'no-iso6429))
143 (, properties) (, eol-type)))))
145 (` ((, name) 3 (, mnemonic) (, doc-string)
146 nil (, properties) (, eol-type))))
148 (` ((, name) 4 (, mnemonic) (, doc-string)
149 ((, (plist-get props 'decode)) . (, (plist-get props 'encode)))
150 (, properties) (, eol-type))))
152 (error "unsupported XEmacs style make-coding-style arguments: %S"
153 (` ((, name) (, type) (, doc-string) (, props))))))))
154 (defadvice make-coding-system
155 (before ccl-compat (name type &rest ad-subr-args) activate)
156 "Emulate XEmacs style make-coding-system."
157 (when (and (symbolp type) (not (memq type '(t nil))))
158 (let ((args (apply 'transform-make-coding-system-args
159 name type ad-subr-args)))
160 (setq type (cadr args)
161 ad-subr-args (cddr args)))))))
168 (product-provide (provide 'pccl) (require 'apel-ver))
170 ;;; pccl.el ends here