2 ;;; emu-nemacs.el --- Mule 2 emulation module for NEmacs
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1993 .. 1996 MORIOKA Tomohiko
7 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;;; modified by KOBAYASHI Shuhei <shuhei@cmpt01.phys.tohoku.ac.jp>
10 ;;; $Id: emu-nemacs.el,v 7.12 1996/04/24 13:45:09 morioka Exp $
11 ;;; Keywords: emulation, compatibility, NEmacs, Mule
13 ;;; This file is part of tl (Tiny Library).
15 ;;; This program is free software; you can redistribute it and/or
16 ;;; modify it under the terms of the GNU General Public License as
17 ;;; published by the Free Software Foundation; either version 2, or
18 ;;; (at your option) any later version.
20 ;;; This program is distributed in the hope that it will be useful,
21 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 ;;; General Public License for more details.
25 ;;; You should have received a copy of the GNU General Public License
26 ;;; along with This program. If not, write to the Free Software
27 ;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
40 (defun char-charset (chr)
41 "Return the character set of char CHR.
42 \[emu-nemacs.el; XEmacs 20 emulating function]"
47 (defalias 'char-leading-char 'char-charset)
48 (defalias 'get-lc 'char-charset)
58 (defconst *internal* 3)
59 (defconst *euc-japan* 3)
61 (defun code-convert-string (str ic oc)
62 "Convert code in STRING from SOURCE code to TARGET code,
63 On successful converion, returns the result string,
64 else returns nil. [emu-nemacs.el; Mule emulating function]"
66 (convert-string-kanji-code str ic oc)
69 (defun code-convert-region (beg end ic oc)
70 "Convert code of the text between BEGIN and END from SOURCE
71 to TARGET. On successful conversion returns t,
72 else returns nil. [emu-nemacs.el; Mule emulating function]"
74 (convert-region-kanji-code beg end ic oc)))
76 (defun code-detect-region (start end)
77 "Detect coding-system of the text in the region between START and END.
78 \[emu-nemacs.el; Mule emulating function]"
81 (narrow-to-region start end)
83 (re-search-forward "[\200-\377]" nil t)
88 (defun set-file-coding-system (coding-system &optional force)
89 (set-kanji-fileio-code coding-system)
93 ;;; @ character and string
96 (defun char-bytes (chr)
97 "Return number of bytes CHAR will occupy in a buffer.
98 \[emu-nemacs.el; Mule emulating function]"
101 (defun char-width (chr)
102 "Return number of columns CHAR will occupy when displayed.
103 \[emu-nemacs.el; Mule emulating function]"
104 (if (< chr 128) 1 2))
106 (defun string-width (str)
107 "Return number of columns STRING will occupy.
108 \[emu-nemacs.el; Mule emulating function]"
111 (defun sref (str idx)
112 "Return the character in STR at index IDX.
113 \[emu-nemacs.el; Mule emulating function]"
114 (let ((chr (aref str idx)))
117 (logior (lsh (aref str (1+ idx)) 8) chr)
120 (defun string-to-char-list (str)
121 (let ((i 0)(len (length str)) dest chr)
123 (setq chr (aref str i))
126 chr (+ (lsh chr 8) (aref str i))
128 (setq dest (cons chr dest))
134 (fset 'string-to-int-list (symbol-function 'string-to-char-list))
136 (defun find-charset-string (str)
137 "Return a list of leading-chars in the string.
138 \[emu-nemacs.el; Mule emulating function]"
139 (if (string-match "[\200-\377]" str)
143 (defun find-charset-region (start end)
144 "Return a list of leading-chars in the region between START and END.
145 \[emu-nemacs.el; Mule emulating function]"
148 (narrow-to-region start end)
150 (re-search-forward "[\200-\377]" nil t)
155 (defun check-ASCII-string (str)
158 (setq len (length str))
161 (if (>= (elt str i) 128)
167 ;;; Imported from Mule-2.3
168 (defun truncate-string (str width &optional start-column)
169 "Truncate STR to fit in WIDTH columns.
170 Optional non-nil arg START-COLUMN specifies the starting column.
171 \[emu-mule.el; Mule 2.3 emulating function]"
173 (setq start-column 0))
174 (let ((max-width (string-width str))
179 (if (>= width max-width)
180 (setq width max-width))
181 (if (>= start-column width)
183 (while (< column start-column)
184 (setq ch (aref str from)
185 column (+ column (char-width ch))
186 from (+ from (char-bytes ch))))
187 (if (< width max-width)
190 (while (<= column width)
191 (setq ch (aref str to)
192 column (+ column (char-width ch))
194 to (+ to (char-bytes ch))))
196 (substring str from to))))
199 ;;; @ text property emulation
202 (setq tl:available-face-attribute-alist
204 ;;(bold . inversed-region)
205 (italic . underlined-region)
206 (underline . underlined-region)
209 ;; by YAMATE Keiichirou 1994/10/28
210 (defun attribute-add-narrow-attribute (attr from to)
211 (or (consp (symbol-value attr))
213 (let* ((attr-value (symbol-value attr))
214 (len (car attr-value))
217 (while (and (< posfrom len)
218 (> from (nth posfrom attr-value)))
219 (setq posfrom (1+ posfrom)))
221 (while (and (< posto len)
222 (> to (nth posto attr-value)))
223 (setq posto (1+ posto)))
224 (if (= posto posfrom)
225 (if (= (% posto 2) 1)
227 (= to (nth posto attr-value)))
228 (set-marker (nth posto attr-value) from)
229 (setcdr (nthcdr (1- posfrom) attr-value)
230 (cons (set-marker-type (set-marker (make-marker)
233 (cons (set-marker-type (set-marker (make-marker)
236 (nthcdr posto attr-value))))
237 (setcar attr-value (+ len 2))))
238 (if (= (% posfrom 2) 0)
239 (setq posfrom (1- posfrom))
240 (set-marker (nth posfrom attr-value) from))
241 (if (= (% posto 2) 0)
243 (setq posto (1- posto))
244 (set-marker (nth posto attr-value) to))
245 (setcdr (nthcdr posfrom attr-value)
246 (nthcdr posto attr-value)))))
248 (defalias 'tl:make-overlay 'cons)
250 (defun tl:overlay-put (overlay prop value)
251 (let ((ret (and (eq prop 'face)
252 (assq value tl:available-face-attribute-alist)
255 (attribute-add-narrow-attribute (cdr ret)
256 (car overlay)(cdr overlay))
259 (defun tl:add-text-properties (start end properties &optional object))
265 (provide 'emu-nemacs)
267 ;;; emu-nemacs.el ends here