* egg-edep.el (egg-string-match-charset): More portable definition.
[elisp/tamago.git] / egg-edep.el
1 ;; egg-edep.el --- This file serves Emacs version dependent definitions
2
3 ;; Copyright (C) 1999,2000 PFU LIMITED
4
5 ;; Author: NIIBE Yutaka <gniibe@chroot.org>
6 ;;         KATAYAMA Yoshio <kate@pfu.co.jp>
7
8 ;; Maintainer: TOMURA Satoru <tomura@etl.go.jp>
9
10 ;; Keywords: mule, multilingual, input method
11
12 ;; This file is part of EGG.
13
14 ;; EGG is free software; you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; any later version.
18
19 ;; EGG is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 ;; GNU General Public License for more details.
23
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27 ;; Boston, MA 02111-1307, USA.
28
29 ;;; Commentary:
30
31 ;;; Code:
32
33
34 (if (featurep 'xemacs)
35     (progn
36       (defun egg-characterp (char)
37         (characterp char))
38       (defun egg-char-bytes (x) 1)
39       (defun egg-charset-bytes (x) 1)
40       (defun egg-char-bytes-at (str pos) 1)
41       (defun egg-chars-in-period (str pos len) len)
42       (defalias 'egg-string-to-vector 'identity)
43       (defalias 'egg-string-to-char-at 'aref)
44       (unless (fboundp 'set-buffer-multibyte)
45         (defun set-buffer-multibyte (ignored)
46           nil)))
47   (if (and (fboundp 'set-buffer-multibyte)
48            (subrp (symbol-function 'set-buffer-multibyte)))
49       ;; Emacs 20.3
50       (progn
51         (defun egg-char-bytes (x) 1)
52         (defun egg-charset-bytes (x) 1)
53         (defun egg-char-bytes-at (str pos) 1)
54         (defun egg-chars-in-period (str pos len) len)
55         (defalias 'egg-string-to-vector 'identity)
56         (defalias 'egg-string-to-char-at 'aref)
57         )
58     ;; Emacs 20.2
59     (defun set-buffer-multibyte (flag)
60       (setq enable-multibyte-characters flag))
61     (defalias 'string-as-unibyte 'identity)
62     (defalias 'string-as-multibyte 'identity)
63     (defalias 'coding-system-put 'put)
64
65     (defalias 'egg-char-bytes 'char-bytes)
66     (defalias 'egg-charset-bytes 'charset-bytes)
67     (defun egg-char-bytes-at (str pos)
68       (char-bytes (egg-string-to-char-at str pos)))
69     (defun egg-chars-in-period (str pos len)
70       (chars-in-string (substring str pos (+ pos len))))
71     (defalias 'egg-string-to-vector 'string-to-vector)
72     (defalias 'egg-string-to-char-at 'sref)
73     )
74   (defun egg-characterp (char)
75     (numberp char)))
76
77 ;; Elisp bug fix
78
79 (defun egg-next-single-property-change (pos prop &optional object limit)
80   (if (featurep 'xemacs)
81       (next-single-property-change pos prop object limit)
82     (if limit
83         (min limit (next-single-property-change pos prop object (1+ limit)))
84       (next-single-property-change pos prop object))))
85
86 (defun egg-string-match-charset (charset string &optional start)
87   (eq charset (char-charset (aref string (or start 0)))))
88
89 (defun egg-string-match-charset-end (charset string &optional start)
90   (let ((index (or start 0))
91         (str-len (length string)))
92     (while (and (< index str-len)
93                 (eq charset (char-charset (aref string index))))
94       (setq index (1+ index)))
95     index))
96
97 (provide 'egg-edep)