b6cf55f36c72c6eb15c40ab412d9e807a1905af4
[elisp/apel.git] / emu-e20_2.el
1 ;;; emu-e20_2.el --- emu API implementation for Emacs 20.1 and 20.2
2
3 ;; Copyright (C) 1996,1997,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 emu.
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 ;;; Commentary:
26
27 ;;    This module requires Emacs 20.1 and 20.2.
28
29 ;;; Code:
30
31 ;;; @ MIME charset
32 ;;;
33
34 (defsubst encode-mime-charset-region (start end charset)
35   "Encode the text between START and END as MIME CHARSET."
36   (let (cs)
37     (if (and enable-multibyte-characters
38              (setq cs (mime-charset-to-coding-system charset)))
39         (encode-coding-region start end cs)
40       )))
41
42 (defsubst decode-mime-charset-region (start end charset)
43   "Decode the text between START and END as MIME CHARSET."
44   (let (cs)
45     (if (and enable-multibyte-characters
46              (setq cs (mime-charset-to-coding-system charset)))
47         (decode-coding-region start end cs)
48       )))
49
50 (defsubst encode-mime-charset-string (string charset)
51   "Encode the STRING as MIME CHARSET."
52   (let (cs)
53     (if (and enable-multibyte-characters
54              (setq cs (mime-charset-to-coding-system charset)))
55         (encode-coding-string string cs)
56       string)))
57
58 (defsubst decode-mime-charset-string (string charset)
59   "Decode the STRING as MIME CHARSET."
60   (let (cs)
61     (if (and enable-multibyte-characters
62              (setq cs (mime-charset-to-coding-system charset)))
63         (decode-coding-string string cs)
64       string)))
65
66
67 ;;; @ character
68 ;;;
69
70 (defalias 'char-length 'char-bytes)
71
72 (defmacro char-next-index (char index)
73   "Return index of character succeeding CHAR whose index is INDEX."
74   `(+ index (char-bytes char)))
75
76
77 ;;; @ string
78 ;;;
79
80 (defalias 'sset 'store-substring)
81
82 (defun string-to-char-list (string)
83   "Return a list of which elements are characters in the STRING."
84   (let* ((len (length string))
85          (i 0)
86          l chr)
87     (while (< i len)
88       (setq chr (sref string i))
89       (setq l (cons chr l))
90       (setq i (+ i (char-bytes chr)))
91       )
92     (nreverse l)
93     ))
94
95 (defalias 'string-to-int-list 'string-to-char-list)
96
97 ;;; @@ obsoleted aliases
98 ;;;
99 ;;; You should not use them.
100
101 (defalias 'string-columns 'string-width)
102 (make-obsolete 'string-columns 'string-width)
103
104
105 ;;; @ end
106 ;;;
107
108 (provide 'emu-e20_2)
109
110 ;;; emu-e20_2.el ends here