Sync up with egg-980712.
[elisp/egg.git] / egg-edep.el
1 ;; This file serves Emacs version dependent definitions
2
3 (if (and (fboundp 'set-buffer-multibyte)
4          (subrp (symbol-function 'set-buffer-multibyte)))
5     ;; Emacs 20.3
6     (progn
7       (defun egg-char-bytes (x) 1)
8       (defun egg-charset-bytes (x) 1)
9       (defun egg-char-bytes-at (str pos) 1)
10       (defun egg-chars-in-period (str pos len) len)
11       (defalias 'egg-string-to-vector 'identity)
12       (defalias 'egg-string-to-char-at 'aref)
13       )
14   ;; Emacs 20.2
15   (defun set-buffer-multibyte (flag)
16     (setq enable-multibyte-characters flag))
17   (defalias 'string-as-unibyte 'identity)
18   (defalias 'string-as-multibyte 'identity)
19   (defalias 'coding-system-put 'put)
20
21   (defalias 'egg-char-bytes 'char-bytes)
22   (defalias 'egg-charset-bytes 'charset-bytes)
23   (defun egg-char-bytes-at (str pos)
24     (char-bytes (egg-string-to-char-at str pos)))
25   (defun egg-chars-in-period (str pos len)
26     (chars-in-string (substring str pos (+ pos len))))
27   (defalias 'egg-string-to-vector 'string-to-vector)
28   (defun egg-string-to-char-at (str pos)
29     (let ((c (aref str pos)))
30       (if (or (< c ?\200)
31               (>= c ?\240)
32               (>= (1+ pos) (length str))
33               (< (aref str (1+ pos)) ?\240))
34           c
35         (string-match "[\240-\377]+" str (1+ pos))
36         (string-to-char (substring str pos (match-end 0))))))
37   )
38
39 ;; Elisp bug fix
40
41 (defun egg-next-single-property-change (pos prop &optional object limit)
42   (min limit (next-single-property-change pos prop object (1+ limit))))
43
44 (provide 'egg-edep)