Sync up with egg-980627.
[elisp/egg.git] / egg-edep.el
diff --git a/egg-edep.el b/egg-edep.el
new file mode 100644 (file)
index 0000000..2d1e3d9
--- /dev/null
@@ -0,0 +1,44 @@
+;; This file serves Emacs version dependent definitions
+
+(if (and (fboundp 'set-buffer-multibyte)
+        (subrp (symbol-function 'set-buffer-multibyte)))
+    ;; Emacs 20.3
+    (progn
+      (defun egg-char-bytes (x) 1)
+      (defun egg-charset-bytes (x) 1)
+      (defun egg-char-bytes-at (str pos) 1)
+      (defun egg-chars-in-period (str pos len) len)
+      (defalias 'egg-string-to-vector 'identity)
+      (defalias 'egg-string-to-char-at 'aref)
+      )
+  ;; Emacs 20.2
+  (defun set-buffer-multibyte (flag)
+    (setq enable-multibyte-characters flag))
+  (defalias 'string-as-unibyte 'identity)
+  (defalias 'string-as-multibyte 'identity)
+  (defalias 'coding-system-put 'put)
+
+  (defalias 'egg-char-bytes 'char-bytes)
+  (defalias 'egg-charset-bytes 'charset-bytes)
+  (defun egg-char-bytes-at (str pos)
+    (char-bytes (egg-string-to-char-at str pos)))
+  (defun egg-chars-in-period (str pos len)
+    (chars-in-string (substring str pos (+ pos len))))
+  (defalias 'egg-string-to-vector 'string-to-vector)
+  (defun egg-string-to-char-at (str pos)
+    (let ((c (aref str pos)))
+      (if (or (< c ?\200)
+             (>= c ?\240)
+             (>= (1+ pos) (length str))
+             (< (aref str (1+ pos)) ?\240))
+         c
+       (string-match "[\240-\377]+" str (1+ pos))
+       (string-to-char (substring str pos (match-end 0))))))
+  )
+
+;; Elisp bug fix
+
+(defun egg-next-single-property-change (pos prop &optional object limit)
+  (min limit (next-single-property-change pos prop object (1+ limit))))
+
+(provide 'egg-edep)