1 ;;; poem-e20_2.el --- poem implementation for Emacs 20.1 and 20.2
3 ;; Copyright (C) 1996,1997,1998 Free Software Foundation, Inc.
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Keywords: emulation, compatibility, Mule
8 ;; This file is part of APEL (A Portable Emacs Library).
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.
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.
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., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 ;; This module requires Emacs 20.1 and 20.2.
31 ;;; @ buffer representation
34 (defun-maybe set-buffer-multibyte (flag)
35 "Set the multibyte flag of the current buffer to FLAG.
36 If FLAG is t, this makes the buffer a multibyte buffer.
37 If FLAG is nil, this makes the buffer a single-byte buffer.
38 The buffer contents remain unchanged as a sequence of bytes
39 but the contents viewed as characters do change.
40 \[Emacs 20.3 emulating function]"
41 (setq enable-multibyte-characters flag)
48 (defalias 'char-length 'char-bytes)
50 (defmacro char-next-index (char index)
51 "Return index of character succeeding CHAR whose index is INDEX."
52 `(+ ,index (char-bytes ,char)))
58 (defalias 'sset 'store-substring)
60 (defun string-to-char-list (string)
61 "Return a list of which elements are characters in the STRING."
62 (let* ((len (length string))
66 (setq chr (sref string i))
68 (setq i (+ i (char-bytes chr)))
72 (defalias 'string-to-int-list 'string-to-char-list)
74 (defun looking-at-as-unibyte (regexp)
75 "Like `looking-at', but string is regarded as unibyte sequence."
76 (let (enable-multibyte-characters)
79 ;;; @@ obsoleted aliases
81 ;;; You should not use them.
83 (defalias 'string-columns 'string-width)
84 (make-obsolete 'string-columns 'string-width)
87 ;;; @ without code-conversion
90 (defun insert-file-contents-as-binary (filename
91 &optional visit beg end replace)
92 "Like `insert-file-contents', q.v., but don't code and format conversion.
93 Like `insert-file-contents-literary', but it allows find-file-hooks,
94 automatic uncompression, etc.
96 Namely this function ensures that only format decoding and character
97 code conversion will not take place."
98 (let ((flag enable-multibyte-characters)
99 (coding-system-for-read 'binary)
102 ;; Returns list absolute file name and length of data inserted.
103 (insert-file-contents filename visit beg end replace)
104 ;; This operation does not change the length.
105 (set-buffer-multibyte flag))))
107 (defun insert-file-contents-as-raw-text (filename
108 &optional visit beg end replace)
109 "Like `insert-file-contents', q.v., but don't code and format conversion.
110 Like `insert-file-contents-literary', but it allows find-file-hooks,
111 automatic uncompression, etc.
112 Like `insert-file-contents-as-binary', but it converts line-break
114 (let ((flag enable-multibyte-characters)
115 (coding-system-for-read 'raw-text)
118 ;; Returns list absolute file name and length of data inserted.
119 (insert-file-contents filename visit beg end replace)
120 ;; This operation does not change the length.
121 (set-buffer-multibyte flag))))
123 (defun insert-file-contents-as-raw-text-CRLF (filename
124 &optional visit beg end replace)
125 "Like `insert-file-contents', q.v., but don't code and format conversion.
126 Like `insert-file-contents-literary', but it allows find-file-hooks,
127 automatic uncompression, etc.
128 Like `insert-file-contents-as-binary', but it converts line-break code
130 (let ((flag enable-multibyte-characters)
131 (coding-system-for-read 'raw-text-dos)
134 ;; Returns list absolute file name and length of data inserted.
135 (insert-file-contents filename visit beg end replace)
136 ;; This operation does not change the length.
137 (set-buffer-multibyte flag))))
139 (defun find-file-noselect-as-binary (filename &optional nowarn rawfile)
140 "Like `find-file-noselect', q.v., but don't code and format conversion."
141 (let ((flag enable-multibyte-characters)
142 (coding-system-for-read 'binary)
146 (set-buffer (find-file-noselect filename nowarn rawfile))
147 (set-buffer-multibyte flag)))))
149 (defun find-file-noselect-as-raw-text (filename &optional nowarn rawfile)
150 "Like `find-file-noselect', q.v., but it does not code and format conversion
151 except for line-break code."
152 (let ((flag enable-multibyte-characters)
153 (coding-system-for-read 'raw-text)
157 (set-buffer (find-file-noselect filename nowarn rawfile))
158 (set-buffer-multibyte flag)))))
160 (defun find-file-noselect-as-raw-text-CRLF (filename &optional nowarn rawfile)
161 "Like `find-file-noselect', q.v., but it does not code and format conversion
162 except for line-break code."
163 (let ((flag enable-multibyte-characters)
164 (coding-system-for-read 'raw-text-dos)
168 (set-buffer (find-file-noselect filename nowarn rawfile))
169 (set-buffer-multibyte flag)))))
172 ;;; @ with code-conversion
175 (defun insert-file-contents-as-coding-system
176 (coding-system filename &optional visit beg end replace)
177 "Like `insert-file-contents', q.v., but CODING-SYSTEM the first arg will
178 be applied to `coding-system-for-read'."
179 (let ((flag enable-multibyte-characters)
180 (coding-system-for-read coding-system)
183 (insert-file-contents filename visit beg end replace)
184 (set-buffer-multibyte flag))))
186 (defun find-file-noselect-as-coding-system
187 (coding-system filename &optional nowarn rawfile)
188 "Like `find-file-noselect', q.v., but CODING-SYSTEM the first arg will
189 be applied to `coding-system-for-read'."
190 (let ((flag enable-multibyte-characters)
191 (coding-system-for-read coding-system)
195 (set-buffer (find-file-noselect filename nowarn rawfile))
196 (set-buffer-multibyte flag)))))
202 (provide 'poem-e20_2)
204 ;;; poem-e20_2.el ends here