1 ;;; pccl.el --- Portable CCL utility for Mule 2.*
3 ;; Copyright (C) 1998 Free Software Foundation, Inc.
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
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
41 (if (featurep 'xemacs)
42 (if (>= emacs-major-version 21)
43 ;; for XEmacs 21 with mule
45 (if (>= emacs-major-version 20)
51 (static-if (or (featurep 'xemacs) (< emacs-major-version 21))
52 (defadvice define-ccl-program
53 (before accept-long-ccl-program activate)
54 "When CCL-PROGRAM is too long, internal buffer is extended automatically."
55 (let ((try-ccl-compile t)
56 (prog (eval (ad-get-arg 1))))
57 (ad-set-arg 1 (` '(, prog)))
58 (while try-ccl-compile
59 (setq try-ccl-compile nil)
63 (if (and (eq (car (cdr sig)) ccl-program-vector)
64 (= (car (cdr (cdr sig))) (length ccl-program-vector)))
65 (setq ccl-program-vector
66 (make-vector (* 2 (length ccl-program-vector)) 0)
68 (signal (car sig) (cdr sig)))))))))
70 (static-when (and (not (featurep 'xemacs)) (< emacs-major-version 21))
71 (defun-maybe transform-make-coding-system-args (name type &optional doc-string props)
72 "For internal use only.
73 Transform XEmacs style args for `make-coding-system' to Emacs style.
74 Value is a list of transformed arguments."
75 (let ((mnemonic (string-to-char (or (plist-get props 'mnemonic) "?")))
76 (eol-type (plist-get props 'eol-type))
79 ((eq eol-type 'lf) (setq eol-type 'unix))
80 ((eq eol-type 'crlf) (setq eol-type 'dos))
81 ((eq eol-type 'cr) (setq eol-type 'mac)))
82 (if (setq tmp (plist-get props 'post-read-conversion))
83 (setq properties (plist-put properties 'post-read-conversion tmp)))
84 (if (setq tmp (plist-get props 'pre-write-conversion))
85 (setq properties (plist-put properties 'pre-write-conversion tmp)))
88 (` ((, name) 1 (, mnemonic) (, doc-string)
89 nil (, properties) (, eol-type))))
90 ((eq type 'iso2022) ; This is not perfect.
91 (if (plist-get props 'escape-quoted)
92 (error "escape-quoted is not supported: %S"
93 (` ((, name) (, type) (, doc-string) (, props)))))
94 (let ((g0 (plist-get props 'charset-g0))
95 (g1 (plist-get props 'charset-g1))
96 (g2 (plist-get props 'charset-g2))
97 (g3 (plist-get props 'charset-g3))
100 (eq (cadr (assoc 'latin-jisx0201
101 (plist-get props 'input-charset-conversion)))
103 (eq (cadr (assoc 'ascii
104 (plist-get props 'output-charset-conversion)))
108 (eq (cadr (assoc 'japanese-jisx0208-1978
109 (plist-get props 'input-charset-conversion)))
111 (eq (cadr (assoc 'japanese-jisx0208
112 (plist-get props 'output-charset-conversion)))
113 'japanese-jisx0208-1978))))
115 (if (plist-get props 'force-g0-on-output)
116 (setq g0 (` (nil (, g0))))
117 (setq g0 (` ((, g0) t)))))
119 (if (plist-get props 'force-g1-on-output)
120 (setq g1 (` (nil (, g1))))
121 (setq g1 (` ((, g1) t)))))
123 (if (plist-get props 'force-g2-on-output)
124 (setq g2 (` (nil (, g2))))
125 (setq g2 (` ((, g2) t)))))
127 (if (plist-get props 'force-g3-on-output)
128 (setq g3 (` (nil (, g3))))
129 (setq g3 (` ((, g3) t)))))
130 (` ((, name) 2 (, mnemonic) (, doc-string)
131 ((, g0) (, g1) (, g2) (, g3)
132 (, (plist-get props 'short))
133 (, (not (plist-get props 'no-ascii-eol)))
134 (, (not (plist-get props 'no-ascii-cntl)))
135 (, (plist-get props 'seven))
137 (, (not (plist-get props 'lock-shift)))
140 (, (plist-get props 'no-iso6429))
142 (, properties) (, eol-type)))))
144 (` ((, name) 3 (, mnemonic) (, doc-string)
145 nil (, properties) (, eol-type))))
147 (` ((, name) 4 (, mnemonic) (, doc-string)
148 ((, (plist-get props 'decode)) . (, (plist-get props 'encode)))
149 (, properties) (, eol-type))))
151 (error "unsupported XEmacs style make-coding-style arguments: %S"
152 (` ((, name) (, type) (, doc-string) (, props))))))))
153 (defadvice make-coding-system
154 (before ccl-compat (name type &rest ad-subr-args) activate)
155 "Emulate XEmacs style make-coding-system."
156 (when (and (symbolp type) (not (memq type '(t nil))))
157 (let ((args (apply 'transform-make-coding-system-args
158 name type ad-subr-args)))
159 (setq type (cadr args)
160 ad-subr-args (cddr args)))))))
167 (product-provide (provide 'pccl) (require 'apel-ver))
169 ;;; pccl.el ends here