(code-convert-string, code-convert-region, insert-binary-file-contents):
[elisp/apel.git] / poem.el
1 ;;; poem.el --- Emulate latest MULE features; -*-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 (require 'poe)
28
29 (eval-and-compile
30   (unless (fboundp 'open-network-stream)
31     (require 'tcp)))
32
33 (cond ((featurep 'mule)
34        (cond ((featurep 'xemacs)
35               (require 'poem-xm)
36               )
37              ((>= emacs-major-version 20)
38               (require 'poem-e20)
39               )
40              (t
41               ;; for MULE 1.* and 2.*
42               (require 'poem-om)
43               ))
44        )
45       ((boundp 'NEMACS)
46        ;; for Nemacs and Nepoch
47        (require 'poem-nemacs)
48        )
49       (t
50        (require 'poem-ltn1)
51        ))
52
53
54 ;;; @ Emacs 20.3 emulation
55 ;;;
56
57 (defsubst-maybe string-as-unibyte (string)
58   "Return a unibyte string with the same individual bytes as STRING.
59 If STRING is unibyte, the result is STRING itself.
60 \[Emacs 20.3 emulating macro]"
61   string)
62
63 (defsubst-maybe string-as-multibyte (string)
64   "Return a multibyte string with the same individual bytes as STRING.
65 If STRING is multibyte, the result is STRING itself.
66 \[Emacs 20.3 emulating macro]"
67   string)
68
69 (defun-maybe charset-after (&optional pos)
70   "Return charset of a character in current buffer at position POS.
71 If POS is nil, it defauls to the current point.
72 If POS is out of range, the value is nil.
73 \[Emacs 20.3 emulating function]"
74   (char-charset (char-after pos))
75   )
76
77 ;;; @ XEmacs-mule emulation
78 ;;;
79
80 (defalias-maybe 'char-int 'identity)
81
82 (defalias-maybe 'int-char 'identity)
83
84 (defalias-maybe 'characterp 'integerp)
85
86 (defalias-maybe 'char-or-char-int-p 'integerp)
87
88 (defun-maybe char-octet (ch &optional n)
89   "Return the octet numbered N (should be 0 or 1) of char CH.
90 N defaults to 0 if omitted. [XEmacs-mule emulating function]"
91   (or (nth (if n
92                (1+ n)
93              1)
94            (split-char ch))
95       0))
96
97
98 ;;; @ end
99 ;;;
100
101 (provide 'poem)
102
103 ;;; poem.el ends here