(Download): Renamed from "Anonymous FTP"; modify for
[elisp/apel.git] / poem-ltn1.el
1 ;;; poem-ltn1.el --- poem implementation for Emacs 19 and XEmacs without MULE
2
3 ;; Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc.
4
5 ;; Author: MORIOKA Tomohiko <tomo@m17n.org>
6 ;; Keywords: emulation, compatibility, Mule
7
8 ;; This file is part of APEL (A Portable Emacs Library).
9
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.
14
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.
19
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., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
24
25 ;;; Code:
26
27 ;;; @ buffer representation
28 ;;;
29
30 (eval-when-compile
31   (require 'poe))
32
33 (defun-maybe set-buffer-multibyte (flag)
34   "Set the multibyte flag of the current buffer to FLAG.
35 If FLAG is t, this makes the buffer a multibyte buffer.
36 If FLAG is nil, this makes the buffer a single-byte buffer.
37 The buffer contents remain unchanged as a sequence of bytes
38 but the contents viewed as characters do change.
39 \[Emacs 20.3 emulating macro]"
40   )
41
42
43 ;;; @ character set
44 ;;;
45
46 (put 'ascii 'charset-description "Character set of ASCII")
47 (put 'ascii 'charset-registry "ASCII")
48
49 (put 'latin-iso8859-1 'charset-description "Character set of ISO-8859-1")
50 (put 'latin-iso8859-1 'charset-registry "ISO8859-1")
51
52 (defun charset-description (charset)
53   "Return description of CHARSET."
54   (get charset 'charset-description))
55
56 (defun charset-registry (charset)
57   "Return registry name of CHARSET."
58   (get charset 'charset-registry))
59
60 (defun charset-width (charset)
61   "Return number of columns a CHARSET occupies when displayed."
62   1)
63
64 (defun charset-direction (charset)
65   "Return the direction of a character of CHARSET by
66   0 (left-to-right) or 1 (right-to-left)."
67   0)
68
69 (defun find-charset-string (str)
70   "Return a list of charsets in the string."
71   (if (string-match "[\200-\377]" str)
72       '(latin-iso8859-1)
73     ))
74
75 (defalias 'find-non-ascii-charset-string 'find-charset-string)
76
77 (defun find-charset-region (start end)
78   "Return a list of charsets in the region between START and END."
79   (if (save-excursion
80         (goto-char start)
81         (re-search-forward "[\200-\377]" end t))
82       '(latin-iso8859-1)
83     ))
84
85 (defalias 'find-non-ascii-charset-region 'find-charset-region)
86
87
88 ;;; @ character
89 ;;;
90
91 (defun char-charset (char)
92   "Return the character set of char CHAR."
93   (if (< char 128)
94       'ascii
95     'latin-iso8859-1))
96
97 (defun char-bytes (char)
98   "Return number of bytes a character in CHAR occupies in a buffer."
99   1)
100
101 (defun char-width (char)
102   "Return number of columns a CHAR occupies when displayed."
103   1)
104
105 (defun split-char (character)
106   "Return list of charset and one or two position-codes of CHARACTER."
107   (cons (char-charset character) character))
108
109 (defalias 'char-length 'char-bytes)
110
111 (defmacro char-next-index (char index)
112   "Return index of character succeeding CHAR whose index is INDEX."
113   (` (1+ (, index))))
114
115
116 ;;; @ string
117 ;;;
118
119 (defalias 'string-width 'length)
120
121 (defun string-to-char-list (str)
122   (mapcar (function identity) str))
123
124 (defalias 'string-to-int-list 'string-to-char-list)
125
126 (defalias 'sref 'aref)
127
128 (defun truncate-string (str width &optional start-column)
129   "Truncate STR to fit in WIDTH columns.
130 Optional non-nil arg START-COLUMN specifies the starting column.
131 \[emu-latin1.el; MULE 2.3 emulating function]"
132   (or start-column
133       (setq start-column 0))
134   (if (> (length str) width)
135       (substring str start-column width)
136     str))
137
138 (defalias 'looking-at-as-unibyte 'looking-at)
139
140 ;;; @@ obsoleted aliases
141 ;;;
142 ;;; You should not use them.
143
144 (defalias 'string-columns 'length)
145 (make-obsolete 'string-columns 'string-width)
146
147
148 ;;; @ end
149 ;;;
150
151 (require 'product)
152 (product-provide (provide 'poem-ltn1) (require 'apel-ver))
153
154 ;;; poem-ltn1.el ends here