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 () ,properties ,eol-type))
89 ((eq type 'iso2022) ; This is not perfect.
90 (if (plist-get props 'escape-quoted)
91 (error "escape-quoted is not supported: %S"
92 `(,name ,type ,doc-string ,props)))
93 (let ((g0 (plist-get props 'charset-g0))
94 (g1 (plist-get props 'charset-g1))
95 (g2 (plist-get props 'charset-g2))
96 (g3 (plist-get props 'charset-g3))
99 (eq (cadr (assoc 'latin-jisx0201
100 (plist-get props 'input-charset-conversion)))
102 (eq (cadr (assoc 'ascii
103 (plist-get props 'output-charset-conversion)))
107 (eq (cadr (assoc 'japanese-jisx0208-1978
108 (plist-get props 'input-charset-conversion)))
110 (eq (cadr (assoc 'japanese-jisx0208
111 (plist-get props 'output-charset-conversion)))
112 'japanese-jisx0208-1978))))
114 (if (plist-get props 'force-g0-on-output)
118 (if (plist-get props 'force-g1-on-output)
122 (if (plist-get props 'force-g2-on-output)
126 (if (plist-get props 'force-g3-on-output)
129 `(,name 2 ,mnemonic ,doc-string
131 ,(plist-get props 'short)
132 ,(not (plist-get props 'no-ascii-eol))
133 ,(not (plist-get props 'no-ascii-cntl))
134 ,(plist-get props 'seven)
136 ,(not (plist-get props 'lock-shift))
139 ,(plist-get props 'no-iso6429)
141 ,properties ,eol-type)))
143 `(,name 3 ,mnemonic ,doc-string () ,properties ,eol-type))
145 `(,name 4 ,mnemonic ,doc-string
146 (,(plist-get props 'decode) . ,(plist-get props 'encode))
147 ,properties ,eol-type))
149 (error "unsupported XEmacs style make-coding-style arguments: %S"
150 `(,name ,type ,doc-string ,props))))))
151 (defadvice make-coding-system
152 (before ccl-compat (name type &rest ad-subr-args) activate)
153 "Emulate XEmacs style make-coding-system."
154 (when (and (symbolp type) (not (memq type '(t nil))))
155 (let ((args (apply 'transform-make-coding-system-args
156 name type ad-subr-args)))
157 (setq type (cadr args)
158 ad-subr-args (cddr args)))))))
165 (product-provide (provide 'pccl) (require 'apel-ver))
167 ;;; pccl.el ends here