tm 7.52.2.
[elisp/apel.git] / emu-mule.el
1 ;;;
2 ;;; emu-mule.el --- Mule 2.* emulation module for Mule
3 ;;;
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1994,1995 MORIOKA Tomohiko
6 ;;;
7 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;;; Version:
9 ;;;     $Id: emu-mule.el,v 7.3 1996/04/24 13:48:31 morioka Exp $
10 ;;; Keywords: emulation, compatibility, Mule
11 ;;;
12 ;;; This file is part of tl (Tiny Library).
13 ;;;
14 ;;; This program is free software; you can redistribute it and/or
15 ;;; modify it under the terms of the GNU General Public License as
16 ;;; published by the Free Software Foundation; either version 2, or
17 ;;; (at your option) any later version.
18 ;;;
19 ;;; This program is distributed in the hope that it will be useful,
20 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22 ;;; General Public License for more details.
23 ;;;
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with This program.  If not, write to the Free Software
26 ;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
27 ;;;
28 ;;; Code:
29
30 (defun some-element (pred seq)
31   "Return the first element of sequence SEQ
32 whose return value applied function PRED is not nil.
33 [emu-mule; tl-list function]"
34  (let ((i 0)(len (length seq)) element)
35    (catch 'tag
36      (while (< i len)
37        (if (funcall pred (setq element (elt seq i)))
38            (throw 'tag element)
39          )
40        (setq i (+ i 1))
41        ))
42    ))
43
44
45 ;;; @ leading-character
46 ;;;
47
48 (defalias 'char-charset 'char-leading-char)
49
50 (defun get-lc (chr)
51   "Return leading character of CHAR or LEADING-CHARACTER."
52   (if (< chr 128)
53       lc-ascii
54     chr))
55
56
57 ;;; @ version specific features
58 ;;;
59
60 (cond (running-emacs-19
61        (require 'emu-19)
62        (defun fontset-pixel-size (fontset)
63          (elt
64           (get-font-info
65            (some-element
66             (function
67              (lambda (n)
68                (not (= n -1))
69                ))
70             (cdr (get-fontset-info fontset))
71             )) 5))
72        )
73       (running-emacs-18
74        (require 'emu-18)
75        (defun tl:make-overlay (beg end &optional buffer type))
76        (defun tl:overlay-put (overlay prop value))
77        (defun tl:add-text-properties (start end properties &optional object))
78        ))
79
80
81 ;;; @@ truncate-string
82 ;;;
83
84 (or (fboundp 'truncate-string)
85 ;;; Imported from Mule-2.3
86 (defun truncate-string (str width &optional start-column)
87   "Truncate STR to fit in WIDTH columns.
88 Optional non-nil arg START-COLUMN specifies the starting column.
89 \[emu-mule.el; Mule 2.3 emulating function]"
90   (or start-column
91       (setq start-column 0))
92   (let ((max-width (string-width str))
93         (len (length str))
94         (from 0)
95         (column 0)
96         to-prev to ch)
97     (if (>= width max-width)
98         (setq width max-width))
99     (if (>= start-column width)
100         ""
101       (while (< column start-column)
102         (setq ch (aref str from)
103               column (+ column (char-width ch))
104               from (+ from (char-bytes ch))))
105       (if (< width max-width)
106           (progn
107             (setq to from)
108             (while (<= column width)
109               (setq ch (aref str to)
110                     column (+ column (char-width ch))
111                     to-prev to
112                     to (+ to (char-bytes ch))))
113             (setq to to-prev)))
114       (substring str from to))))
115 ;;;
116   )
117
118
119 ;;; @ end
120 ;;;
121
122 (provide 'emu-mule)
123
124 ;;; emu-mule.el ends here