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.8 1996/03/14 16:25:39 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.
37 (defconst emacs-major-version (string-to-int emacs-version))
46 (defun char-leading-char (chr)
47 "Return leading character of CHAR.
48 \[emu-nemacs.el; Mule emulating function]"
53 (defalias 'get-lc 'char-leading-char)
63 (defconst *internal* 3)
64 (defconst *euc-japan* 3)
66 (defun code-convert-string (str ic oc)
67 "Convert code in STRING from SOURCE code to TARGET code,
68 On successful converion, returns the result string,
69 else returns nil. [emu-nemacs.el; Mule emulating function]"
71 (convert-string-kanji-code str ic oc)
74 (defun code-convert-region (beg end ic oc)
75 "Convert code of the text between BEGIN and END from SOURCE
76 to TARGET. On successful conversion returns t,
77 else returns nil. [emu-nemacs.el; Mule emulating function]"
79 (convert-region-kanji-code beg end ic oc)))
81 (defun code-detect-region (start end)
82 "Detect coding-system of the text in the region between START and END.
83 \[emu-orig.el; Mule emulating function]"
86 (narrow-to-region start end)
88 (re-search-forward "[\200-\377]" nil t)
93 (defun set-file-coding-system (coding-system &optional force)
94 (set-kanji-fileio-code coding-system)
98 ;;; @ character and string
101 (defun char-bytes (chr)
102 "Return number of bytes CHAR will occupy in a buffer.
103 \[Mule compatible function in tm-nemacs]"
104 (if (< chr 128) 1 2))
106 (defun char-width (chr)
107 "Return number of columns CHAR will occupy when displayed.
108 \[Mule compatible function in tm-nemacs]"
109 (if (< chr 128) 1 2))
111 (defun string-width (str)
112 "Return number of columns STRING will occupy.
113 \[Mule compatible function in tm-nemacs]"
116 (defun string-to-char-list (str)
117 (let ((i 0)(len (length str)) dest chr)
119 (setq chr (aref str i))
122 chr (+ (lsh chr 8) (aref str i))
124 (setq dest (cons chr dest))
130 (defun find-charset-string (str)
131 "Return a list of leading-chars in the string.
132 \[emu-nemacs.el; Mule emulating function]"
133 (if (string-match "[\200-\377]" str)
137 (defun find-charset-region (start end)
138 "Return a list of leading-chars in the region between START and END.
139 \[emu-nemacs.el; Mule emulating function]"
142 (narrow-to-region start end)
144 (re-search-forward "[\200-\377]" nil t)
149 (defun check-ASCII-string (str)
152 (setq len (length str))
155 (if (>= (elt str i) 128)
161 ;;; Imported from Mule-2.3
162 (defun truncate-string (str width &optional start-column)
163 "Truncate STR to fit in WIDTH columns.
164 Optional non-nil arg START-COLUMN specifies the starting column.
165 \[emu-mule.el; Mule 2.3 emulating function]"
167 (setq start-column 0))
168 (let ((max-width (string-width str))
173 (if (>= width max-width)
174 (setq width max-width))
175 (if (>= start-column width)
177 (while (< column start-column)
178 (setq ch (aref str from)
179 column (+ column (char-width ch))
180 from (+ from (char-bytes ch))))
181 (if (< width max-width)
184 (while (<= column width)
185 (setq ch (aref str to)
186 column (+ column (char-width ch))
188 to (+ to (char-bytes ch))))
190 (substring str from to))))
193 ;;; @ text property emulation
196 (setq tl:available-face-attribute-alist
198 ;;(bold . inversed-region)
199 (italic . underlined-region)
200 (underline . underlined-region)
203 ;; by YAMATE Keiichirou 1994/10/28
204 (defun attribute-add-narrow-attribute (attr from to)
205 (or (consp (symbol-value attr))
207 (let* ((attr-value (symbol-value attr))
208 (len (car attr-value))
211 (while (and (< posfrom len)
212 (> from (nth posfrom attr-value)))
213 (setq posfrom (1+ posfrom)))
215 (while (and (< posto len)
216 (> to (nth posto attr-value)))
217 (setq posto (1+ posto)))
218 (if (= posto posfrom)
219 (if (= (% posto 2) 1)
221 (= to (nth posto attr-value)))
222 (set-marker (nth posto attr-value) from)
223 (setcdr (nthcdr (1- posfrom) attr-value)
224 (cons (set-marker-type (set-marker (make-marker)
227 (cons (set-marker-type (set-marker (make-marker)
230 (nthcdr posto attr-value))))
231 (setcar attr-value (+ len 2))))
232 (if (= (% posfrom 2) 0)
233 (setq posfrom (1- posfrom))
234 (set-marker (nth posfrom attr-value) from))
235 (if (= (% posto 2) 0)
237 (setq posto (1- posto))
238 (set-marker (nth posto attr-value) to))
239 (setcdr (nthcdr posfrom attr-value)
240 (nthcdr posto attr-value)))))
242 (defalias 'tl:make-overlay 'cons)
244 (defun tl:overlay-put (overlay prop value)
245 (let ((ret (and (eq prop 'face)
246 (assq value tl:available-face-attribute-alist)
249 (attribute-add-narrow-attribute (cdr ret)
250 (car overlay)(cdr overlay))
253 (defun tl:add-text-properties (start end properties &optional object))
259 (provide 'emu-nemacs)
261 ;;; emu-nemacs.el ends here