Merge poe.
[elisp/apel.git] / poem-xm.el
1 ;;; poem-xm.el --- poem implementation for XEmacs-mule
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 (require 'poem-20)
28
29
30 ;;; @ fix coding-system definition
31 ;;;
32
33 ;; It seems not bug, but I can not permit it...
34 (and (coding-system-property 'iso-2022-jp 'input-charset-conversion)
35      (copy-coding-system 'iso-2022-7bit 'iso-2022-jp))
36
37 ;; Redefine if -{dos|mac|unix} is not found.
38 (or (find-coding-system 'raw-text-dos)
39     (copy-coding-system 'no-conversion-dos 'raw-text-dos))
40 (or (find-coding-system 'raw-text-mac)
41     (copy-coding-system 'no-conversion-mac 'raw-text-mac))
42 (or (find-coding-system 'raw-text-unix)
43     (copy-coding-system 'no-conversion-unix 'raw-text-unix))
44
45 (or (find-coding-system 'ctext-dos)
46     (make-coding-system
47      'ctext 'iso2022
48      "Coding-system used in X as Compound Text Encoding."
49      '(charset-g0 ascii charset-g1 latin-iso8859-1
50                   eol-type nil
51                   mnemonic "CText")))
52
53 (or (find-coding-system 'iso-2022-jp-2-dos)
54     (make-coding-system
55      'iso-2022-jp-2 'iso2022
56      "ISO-2022 coding system using SS2 for 96-charset in 7-bit code."
57      '(charset-g0 ascii
58        charset-g2 t ;; unspecified but can be used later.
59        seven t
60        short t
61        mnemonic "ISO7/SS2"
62        eol-type nil)))
63
64 (or (find-coding-system 'euc-kr-dos)
65     (make-coding-system
66      'euc-kr 'iso2022
67      "Coding-system of Korean EUC (Extended Unix Code)."
68      '(charset-g0 ascii charset-g1 korean-ksc5601
69                   mnemonic "ko/EUC"
70                   eol-type nil)))
71
72
73 ;;; @ buffer representation
74 ;;;
75
76 (defsubst-maybe set-buffer-multibyte (flag)
77   "Set the multibyte flag of the current buffer to FLAG.
78 If FLAG is t, this makes the buffer a multibyte buffer.
79 If FLAG is nil, this makes the buffer a single-byte buffer.
80 The buffer contents remain unchanged as a sequence of bytes
81 but the contents viewed as characters do change.
82 \[Emacs 20.3 emulating function]"
83   flag)
84
85
86 ;;; @ character
87 ;;;
88
89 ;; avoid bug of XEmacs
90 (or (integerp (cdr (split-char ?a)))
91     (defun split-char (char)
92       "Return list of charset and one or two position-codes of CHAR."
93       (let ((charset (char-charset char)))
94         (if (eq charset 'ascii)
95             (list charset (char-int char))
96           (let ((i 0)
97                 (len (charset-dimension charset))
98                 (code (if (integerp char)
99                           char
100                         (char-int char)))
101                 dest)
102             (while (< i len)
103               (setq dest (cons (logand code 127) dest)
104                     code (lsh code -7)
105                     i (1+ i)))
106             (cons charset dest)))))
107     )
108
109 (defmacro char-next-index (char index)
110   "Return index of character succeeding CHAR whose index is INDEX."
111   `(1+ ,index))
112
113
114 ;;; @ string
115 ;;;
116
117 (defun string-to-int-list (str)
118   (mapcar #'char-int str))
119
120 (defalias 'looking-at-as-unibyte 'looking-at)
121
122
123 ;;; @ end
124 ;;;
125
126 (provide 'poem-xm)
127
128 ;;; poem-xm.el ends here