update keywords.
[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       ((featurep 'file-coding)
50        ;; file coding xemacs
51        (require 'poem-xfc)
52        )
53       (t
54        (require 'poem-ltn1)
55        ))
56
57
58 ;;; @ Emacs 20.3 emulation
59 ;;;
60
61 (defsubst-maybe string-as-unibyte (string)
62   "Return a unibyte string with the same individual bytes as STRING.
63 If STRING is unibyte, the result is STRING itself.
64 \[Emacs 20.3 emulating macro]"
65   string)
66
67 (defsubst-maybe string-as-multibyte (string)
68   "Return a multibyte string with the same individual bytes as STRING.
69 If STRING is multibyte, the result is STRING itself.
70 \[Emacs 20.3 emulating macro]"
71   string)
72
73 (defun-maybe charset-after (&optional pos)
74   "Return charset of a character in current buffer at position POS.
75 If POS is nil, it defauls to the current point.
76 If POS is out of range, the value is nil.
77 \[Emacs 20.3 emulating function]"
78   (char-charset (char-after pos))
79   )
80
81 ;;; @ XEmacs-mule emulation
82 ;;;
83
84 (defalias-maybe 'char-int 'identity)
85
86 (defalias-maybe 'int-char 'identity)
87
88 (defalias-maybe 'characterp 'integerp)
89
90 (defalias-maybe 'char-or-char-int-p 'integerp)
91
92 (defun-maybe char-octet (ch &optional n)
93   "Return the octet numbered N (should be 0 or 1) of char CH.
94 N defaults to 0 if omitted. [XEmacs-mule emulating function]"
95   (or (nth (if n
96                (1+ n)
97              1)
98            (split-char ch))
99       0))
100
101
102 ;;; @ end
103 ;;;
104
105 (provide 'poem)
106
107 ;;; poem.el ends here