tm 7.52.1.
[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.2 1996/04/17 15:17:24 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 (defun get-lc (chr)
49   "Return leading character of CHAR or LEADING-CHARACTER."
50   (if (< chr 128)
51       lc-ascii
52     chr))
53
54
55 ;;; @ version specific features
56 ;;;
57
58 (cond (running-emacs-19
59        (require 'emu-19)
60        (defun fontset-pixel-size (fontset)
61          (elt
62           (get-font-info
63            (some-element
64             (function
65              (lambda (n)
66                (not (= n -1))
67                ))
68             (cdr (get-fontset-info fontset))
69             )) 5))
70        )
71       (running-emacs-18
72        (require 'emu-18)
73        (defun tl:make-overlay (beg end &optional buffer type))
74        (defun tl:overlay-put (overlay prop value))
75        (defun tl:add-text-properties (start end properties &optional object))
76        ))
77
78
79 ;;; @@ truncate-string
80 ;;;
81
82 (or (fboundp 'truncate-string)
83 ;;; Imported from Mule-2.3
84 (defun truncate-string (str width &optional start-column)
85   "Truncate STR to fit in WIDTH columns.
86 Optional non-nil arg START-COLUMN specifies the starting column.
87 \[emu-mule.el; Mule 2.3 emulating function]"
88   (or start-column
89       (setq start-column 0))
90   (let ((max-width (string-width str))
91         (len (length str))
92         (from 0)
93         (column 0)
94         to-prev to ch)
95     (if (>= width max-width)
96         (setq width max-width))
97     (if (>= start-column width)
98         ""
99       (while (< column start-column)
100         (setq ch (aref str from)
101               column (+ column (char-width ch))
102               from (+ from (char-bytes ch))))
103       (if (< width max-width)
104           (progn
105             (setq to from)
106             (while (<= column width)
107               (setq ch (aref str to)
108                     column (+ column (char-width ch))
109                     to-prev to
110                     to (+ to (char-bytes ch))))
111             (setq to to-prev)))
112       (substring str from to))))
113 ;;;
114   )
115
116
117 ;;; @ end
118 ;;;
119
120 (provide 'emu-mule)
121
122 ;;; emu-mule.el ends here