Explicitly require poe when bytecompiling.
[elisp/apel.git] / poem-xm.el
1 ;;; poem-xm.el --- poem module for XEmacs-mule; -*-byte-compile-dynamic: t;-*-
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 (eval-when-compile
28   (require 'poe))
29 (require 'poem-20)
30
31
32 ;;; @ fix coding-system definition
33 ;;;
34
35 ;; It seems not bug, but I can not permit it...
36 (and (coding-system-property 'iso-2022-jp 'input-charset-conversion)
37      (copy-coding-system 'iso-2022-7bit 'iso-2022-jp))
38
39 (and (coding-system-property 'iso-2022-jp-dos 'input-charset-conversion)
40      (copy-coding-system 'iso-2022-7bit-dos 'iso-2022-jp-dos))
41
42 ;; Redefine if -{dos|mac|unix} is not found.
43 (or (find-coding-system 'raw-text-dos)
44     (copy-coding-system 'no-conversion-dos 'raw-text-dos))
45 (or (find-coding-system 'raw-text-mac)
46     (copy-coding-system 'no-conversion-mac 'raw-text-mac))
47 (or (find-coding-system 'raw-text-unix)
48     (copy-coding-system 'no-conversion-unix 'raw-text-unix))
49
50 (or (find-coding-system 'ctext-dos)
51     (make-coding-system
52      'ctext 'iso2022
53      "Coding-system used in X as Compound Text Encoding."
54      '(charset-g0 ascii charset-g1 latin-iso8859-1
55                   eol-type nil
56                   mnemonic "CText")))
57
58 (or (find-coding-system 'iso-2022-jp-2-dos)
59     (make-coding-system
60      'iso-2022-jp-2 'iso2022
61      "ISO-2022 coding system using SS2 for 96-charset in 7-bit code."
62      '(charset-g0 ascii
63        charset-g2 t ;; unspecified but can be used later.
64        seven t
65        short t
66        mnemonic "ISO7/SS2"
67        eol-type nil)))
68
69 (or (find-coding-system 'gb2312-dos)
70     (copy-coding-system 'cn-gb-2312-dos 'gb2312-dos))
71 (or (find-coding-system 'gb2312-mac)
72     (copy-coding-system 'cn-gb-2312-mac 'gb2312-mac))
73 (or (find-coding-system 'gb2312-unix)
74     (copy-coding-system 'cn-gb-2312-unix 'gb2312-unix))
75
76 (or (find-coding-system 'euc-kr-dos)
77     (make-coding-system
78      'euc-kr 'iso2022
79      "Coding-system of Korean EUC (Extended Unix Code)."
80      '(charset-g0 ascii charset-g1 korean-ksc5601
81                   mnemonic "ko/EUC"
82                   eol-type nil)))
83
84 ;; (when (= (function-max-args 'coding-system-list) 0)
85 ;;   (or (fboundp 'coding-system-list-internal)
86 ;;       (fset 'coding-system-list-internal
87 ;;             (symbol-function 'coding-system-list)))
88 ;;   (defun coding-system-list (&optional base-only)
89 ;;     "Return a list of all existing coding systems.
90 ;; If optional arg BASE-ONLY is non-nil, only base coding systems are listed."
91 ;;     (if base-only
92 ;;         (let (dest
93 ;;               (rest (coding-system-list-internal))
94 ;;               cs)
95 ;;           (while rest
96 ;;             (setq cs (coding-system-name (coding-system-base (pop rest))))
97 ;;             (or (memq cs dest)
98 ;;                 (push cs dest))
99 ;;             )
100 ;;           dest)
101 ;;       (coding-system-list-internal)))
102 ;;   )
103
104
105 ;;; @ without code-conversion
106 ;;;
107
108 (defun insert-file-contents-as-binary (filename
109                                        &optional visit beg end replace)
110   "Like `insert-file-contents', but only reads in the file literally.
111 A buffer may be modified in several ways after reading into the buffer,
112 to Emacs features such as format decoding, character code
113 conversion, find-file-hooks, automatic uncompression, etc.
114
115 This function ensures that none of these modifications will take place."
116   (let ((format-alist nil)
117         (after-insert-file-functions nil)
118         (coding-system-for-read 'binary)
119         (coding-system-for-write 'binary)
120         (jka-compr-compression-info-list nil)
121         (jam-zcat-filename-list nil)
122         (find-buffer-file-type-function
123          (if (fboundp 'find-buffer-file-type)
124              (symbol-function 'find-buffer-file-type)
125            nil)))
126     (unwind-protect
127         (progn
128           (fset 'find-buffer-file-type (lambda (filename) t))
129           (insert-file-contents filename visit beg end replace))
130       (if find-buffer-file-type-function
131           (fset 'find-buffer-file-type find-buffer-file-type-function)
132         (fmakunbound 'find-buffer-file-type)))))
133
134
135 ;;; @ buffer representation
136 ;;;
137
138 (defsubst-maybe set-buffer-multibyte (flag)
139   "Set the multibyte flag of the current buffer to FLAG.
140 If FLAG is t, this makes the buffer a multibyte buffer.
141 If FLAG is nil, this makes the buffer a single-byte buffer.
142 The buffer contents remain unchanged as a sequence of bytes
143 but the contents viewed as characters do change.
144 \[Emacs 20.3 emulating function]"
145   flag)
146
147
148 ;;; @ character
149 ;;;
150
151 ;; avoid bug of XEmacs
152 (or (integerp (cdr (split-char ?a)))
153     (defun split-char (char)
154       "Return list of charset and one or two position-codes of CHAR."
155       (let ((charset (char-charset char)))
156         (if (eq charset 'ascii)
157             (list charset (char-int char))
158           (let ((i 0)
159                 (len (charset-dimension charset))
160                 (code (if (integerp char)
161                           char
162                         (char-int char)))
163                 dest)
164             (while (< i len)
165               (setq dest (cons (logand code 127) dest)
166                     code (lsh code -7)
167                     i (1+ i)))
168             (cons charset dest)))))
169     )
170
171 (defmacro char-next-index (char index)
172   "Return index of character succeeding CHAR whose index is INDEX."
173   `(1+ ,index))
174
175
176 ;;; @ string
177 ;;;
178
179 (defun-maybe string-to-int-list (str)
180   (mapcar #'char-int str))
181
182 (defalias 'looking-at-as-unibyte 'looking-at)
183
184
185 ;;; @ end
186 ;;;
187
188 (provide 'poem-xm)
189
190 ;;; poem-xm.el ends here