1 ;;; poem-nemacs.el --- poem implementation for Nemacs
3 ;; Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc.
5 ;; Author: MORIOKA Tomohiko <tomo@m17n.org>
6 ;; Keywords: emulation, compatibility, Mule
8 ;; This file is part of APEL (A Portable Emacs Library).
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.
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.
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.
31 'charset-description "Character set of ASCII")
33 'charset-registry "ASCII")
35 (put 'japanese-jisx0208
36 'charset-description "Character set of JIS X0208-1983")
37 (put 'japanese-jisx0208
38 'charset-registry "JISX0208.1983")
40 (defun charset-description (charset)
41 "Return description of CHARSET. [emu-nemacs.el]"
42 (get charset 'charset-description))
44 (defun charset-registry (charset)
45 "Return registry name of CHARSET. [emu-nemacs.el]"
46 (get charset 'charset-registry))
48 (defun charset-width (charset)
49 "Return number of columns a CHARSET occupies when displayed.
51 (if (eq charset 'ascii)
55 (defun charset-direction (charset)
56 "Return the direction of a character of CHARSET by
57 0 (left-to-right) or 1 (right-to-left). [emu-nemacs.el]"
60 (defun find-charset-string (str)
61 "Return a list of charsets in the string.
62 \[emu-nemacs.el; Mule emulating function]"
63 (if (string-match "[\200-\377]" str)
67 (defalias 'find-non-ascii-charset-string 'find-charset-string)
69 (defun find-charset-region (start end)
70 "Return a list of charsets in the region between START and END.
71 \[emu-nemacs.el; Mule emulating function]"
74 (narrow-to-region start end)
76 (re-search-forward "[\200-\377]" nil t)))
80 (defalias 'find-non-ascii-charset-region 'find-charset-region)
82 (defun check-ASCII-string (str)
85 (setq len (length str))
88 (if (>= (elt str i) 128)
93 ;;; @@ for old MULE emulation
96 ;;(defconst lc-ascii 0)
97 ;;(defconst lc-jp 146)
100 ;;; @ buffer representation
103 (defsubst-maybe set-buffer-multibyte (flag)
104 "Set the multibyte flag of the current buffer to FLAG.
105 If FLAG is t, this makes the buffer a multibyte buffer.
106 If FLAG is nil, this makes the buffer a single-byte buffer.
107 The buffer contents remain unchanged as a sequence of bytes
108 but the contents viewed as characters do change.
109 \[Emacs 20.3 emulating function]"
110 (setq kanji-flag flag)
117 (defun char-charset (chr)
118 "Return the character set of char CHR.
119 \[emu-nemacs.el; MULE emulating function]"
124 (defun char-bytes (chr)
125 "Return number of bytes CHAR will occupy in a buffer.
126 \[emu-nemacs.el; Mule emulating function]"
131 (defun char-width (char)
132 "Return number of columns a CHAR occupies when displayed.
138 (defalias 'char-length 'char-bytes)
140 (defmacro char-next-index (char index)
141 "Return index of character succeeding CHAR whose index is INDEX.
143 (` (+ (, index) (char-bytes (, char)))))
149 (defalias 'string-width 'length)
151 (defun sref (str idx)
152 "Return the character in STR at index IDX.
153 \[emu-nemacs.el; Mule emulating function]"
154 (let ((chr (aref str idx)))
157 (logior (lsh (aref str (1+ idx)) 8) chr))))
159 (defun string-to-char-list (str)
160 (let ((i 0)(len (length str)) dest chr)
162 (setq chr (aref str i))
165 chr (+ (lsh chr 8) (aref str i)))
167 (setq dest (cons chr dest))
171 (fset 'string-to-int-list (symbol-function 'string-to-char-list))
173 ;;; Imported from Mule-2.3
174 (defun truncate-string (str width &optional start-column)
175 "Truncate STR to fit in WIDTH columns.
176 Optional non-nil arg START-COLUMN specifies the starting column.
177 \[emu-mule.el; Mule 2.3 emulating function]"
179 (setq start-column 0))
180 (let ((max-width (string-width str))
185 (if (>= width max-width)
186 (setq width max-width))
187 (if (>= start-column width)
189 (while (< column start-column)
190 (setq ch (aref str from)
191 column (+ column (char-width ch))
192 from (+ from (char-bytes ch))))
193 (if (< width max-width)
196 (while (<= column width)
197 (setq ch (aref str to)
198 column (+ column (char-width ch))
200 to (+ to (char-bytes ch))))
202 (substring str from to))))
204 (defalias 'looking-at-as-unibyte 'looking-at)
206 ;;; @@ obsoleted aliases
208 ;;; You should not use them.
210 (defalias 'string-columns 'length)
217 (product-provide (provide 'poem-nemacs) (require 'apel-ver))
219 ;;; poem-nemacs.el ends here