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., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
25 ;;; ##### Much of the logic here is flawed in the context of XEmacs
26 ;;; packages. All the static-if and broken-facility stuff is evaluated at
27 ;;; compile time, which is inappropriate if the file is to be compiled on a
28 ;;; non-Mule XEmacs and to run on a Mule XEmacs. Aidan Kehoe, Di Aug 14
29 ;;; 21:31:39 CEST 2007
35 (broken-facility ccl-usable
38 (if (featurep 'xemacs)
39 (>= emacs-major-version 21)
40 (>= emacs-major-version 19))))
42 (unless-broken ccl-usable
48 (if (featurep 'xemacs)
49 (if (>= emacs-major-version 21)
50 ;; for XEmacs 21 with mule
52 (if (>= emacs-major-version 20)
56 (require 'pccl-om)))))
58 (static-if (or (featurep 'xemacs) (< emacs-major-version 21))
59 (defadvice define-ccl-program
60 (before accept-long-ccl-program activate)
61 "When CCL-PROGRAM is too long, internal buffer is extended automatically."
62 (let ((try-ccl-compile t)
63 (prog (eval (ad-get-arg 1))))
64 (ad-set-arg 1 (` '(, prog)))
65 (while try-ccl-compile
66 (setq try-ccl-compile nil)
70 (if (and (eq (car (cdr sig)) ccl-program-vector)
71 (= (car (cdr (cdr sig))) (length ccl-program-vector)))
72 (setq ccl-program-vector
73 (make-vector (* 2 (length ccl-program-vector)) 0)
75 (signal (car sig) (cdr sig)))))))))
77 (static-when (and (not (featurep 'xemacs)) (< emacs-major-version 21))
78 (defun-maybe transform-make-coding-system-args (name type &optional doc-string props)
79 "For internal use only.
80 Transform XEmacs style args for `make-coding-system' to Emacs style.
81 Value is a list of transformed arguments."
82 (let ((mnemonic (string-to-char (or (plist-get props 'mnemonic) "?")))
83 (eol-type (plist-get props 'eol-type))
86 ((eq eol-type 'lf) (setq eol-type 'unix))
87 ((eq eol-type 'crlf) (setq eol-type 'dos))
88 ((eq eol-type 'cr) (setq eol-type 'mac)))
89 (if (setq tmp (plist-get props 'post-read-conversion))
90 (setq properties (plist-put properties 'post-read-conversion tmp)))
91 (if (setq tmp (plist-get props 'pre-write-conversion))
92 (setq properties (plist-put properties 'pre-write-conversion tmp)))
95 (` ((, name) 1 (, mnemonic) (, doc-string)
96 nil (, properties) (, eol-type))))
97 ((eq type 'iso2022) ; This is not perfect.
98 (if (plist-get props 'escape-quoted)
99 (error "escape-quoted is not supported: %S"
100 (` ((, name) (, type) (, doc-string) (, props)))))
101 (let ((g0 (plist-get props 'charset-g0))
102 (g1 (plist-get props 'charset-g1))
103 (g2 (plist-get props 'charset-g2))
104 (g3 (plist-get props 'charset-g3))
107 (eq (cadr (assoc 'latin-jisx0201
108 (plist-get props 'input-charset-conversion)))
110 (eq (cadr (assoc 'ascii
111 (plist-get props 'output-charset-conversion)))
115 (eq (cadr (assoc 'japanese-jisx0208-1978
116 (plist-get props 'input-charset-conversion)))
118 (eq (cadr (assoc 'japanese-jisx0208
119 (plist-get props 'output-charset-conversion)))
120 'japanese-jisx0208-1978))))
122 (if (plist-get props 'force-g0-on-output)
123 (setq g0 (` (nil (, g0))))
124 (setq g0 (` ((, g0) t)))))
126 (if (plist-get props 'force-g1-on-output)
127 (setq g1 (` (nil (, g1))))
128 (setq g1 (` ((, g1) t)))))
130 (if (plist-get props 'force-g2-on-output)
131 (setq g2 (` (nil (, g2))))
132 (setq g2 (` ((, g2) t)))))
134 (if (plist-get props 'force-g3-on-output)
135 (setq g3 (` (nil (, g3))))
136 (setq g3 (` ((, g3) t)))))
137 (` ((, name) 2 (, mnemonic) (, doc-string)
138 ((, g0) (, g1) (, g2) (, g3)
139 (, (plist-get props 'short))
140 (, (not (plist-get props 'no-ascii-eol)))
141 (, (not (plist-get props 'no-ascii-cntl)))
142 (, (plist-get props 'seven))
144 (, (not (plist-get props 'lock-shift)))
147 (, (plist-get props 'no-iso6429))
149 (, properties) (, eol-type)))))
151 (` ((, name) 3 (, mnemonic) (, doc-string)
152 nil (, properties) (, eol-type))))
154 (` ((, name) 4 (, mnemonic) (, doc-string)
155 ((, (plist-get props 'decode)) . (, (plist-get props 'encode)))
156 (, properties) (, eol-type))))
158 (error "unsupported XEmacs style make-coding-style arguments: %S"
159 (` ((, name) (, type) (, doc-string) (, props))))))))
160 (defadvice make-coding-system
161 (before ccl-compat (name type &rest ad-subr-args) activate)
162 "Emulate XEmacs style make-coding-system."
163 (when (and (symbolp type) (not (memq type '(t nil))))
164 (let ((args (apply 'transform-make-coding-system-args
165 name type ad-subr-args)))
166 (setq type (cadr args)
167 ad-subr-args (cddr args)))))))
174 (product-provide (provide 'pccl) (require 'apel-ver))
176 ;;; pccl.el ends here