1 ;;; -*-byte-compile-dynamic: t;-*-
2 ;;; poem-20.el --- poem submodule for Emacs 20 and XEmacs-mule
4 ;; Copyright (C) 1997,1998 Free Software Foundation, Inc.
6 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Keywords: emulation, compatibility, Mule
9 ;; This file is part of APEL (A Portable Emacs Library).
11 ;; This program is free software; you can redistribute it and/or
12 ;; modify it under the terms of the GNU General Public License as
13 ;; published by the Free Software Foundation; either version 2, or (at
14 ;; your option) any later version.
16 ;; This program is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
28 ;; This module requires Emacs 20.0.93, XEmacs 20.3-b5 (with mule)
33 ;;; @ without code-conversion
36 (defmacro as-binary-process (&rest body)
37 `(let (selective-display ; Disable ^M to nl translation.
38 (coding-system-for-read 'binary)
39 (coding-system-for-write 'binary))
42 (defmacro as-binary-input-file (&rest body)
43 `(let ((coding-system-for-read 'binary))
46 (defmacro as-binary-output-file (&rest body)
47 `(let ((coding-system-for-write 'binary))
50 (defun write-region-as-binary (start end filename
51 &optional append visit lockname)
52 "Like `write-region', q.v., but don't encode."
53 (let ((coding-system-for-write 'binary)
54 jka-compr-compression-info-list jam-zcat-filename-list)
55 (write-region start end filename append visit lockname)))
57 ;; `insert-file-contents-literally' of Emacs 20 supports
58 ;; `file-name-handler-alist'.
59 (defalias 'insert-file-contents-as-binary 'insert-file-contents-literally)
61 (defun insert-file-contents-as-raw-text (filename
62 &optional visit beg end replace)
63 "Like `insert-file-contents', q.v., but don't code and format conversion.
64 Like `insert-file-contents-literary', but it allows find-file-hooks,
65 automatic uncompression, etc.
66 Like `insert-file-contents-as-binary', but it converts line-break
68 (let ((coding-system-for-read 'raw-text)
70 ;; Returns list of absolute file name and length of data inserted.
71 (insert-file-contents filename visit beg end replace)))
73 (defun insert-file-contents-as-raw-text-CRLF (filename
74 &optional visit beg end replace)
75 "Like `insert-file-contents', q.v., but don't code and format conversion.
76 Like `insert-file-contents-literary', but it allows find-file-hooks,
77 automatic uncompression, etc.
78 Like `insert-file-contents-as-binary', but it converts line-break code
80 (let ((coding-system-for-read 'raw-text-dos)
82 ;; Returns list of absolute file name and length of data inserted.
83 (insert-file-contents filename visit beg end replace)))
85 (defun write-region-as-raw-text-CRLF (start end filename
86 &optional append visit lockname)
87 "Like `write-region', q.v., but write as network representation."
88 (let ((coding-system-for-write 'raw-text-dos))
89 (write-region start end filename append visit lockname)))
91 (defun find-file-noselect-as-binary (filename &optional nowarn rawfile)
92 "Like `find-file-noselect', q.v., but don't code and format conversion."
93 (let ((coding-system-for-read 'binary)
95 (find-file-noselect filename nowarn rawfile)))
97 (defun find-file-noselect-as-raw-text (filename &optional nowarn rawfile)
98 "Like `find-file-noselect', q.v., but it does not code and format conversion
99 except for line-break code."
100 (let ((coding-system-for-read 'raw-text)
102 (find-file-noselect filename nowarn rawfile)))
104 (defun find-file-noselect-as-raw-text-CRLF (filename &optional nowarn rawfile)
105 "Like `find-file-noselect', q.v., but it does not code and format conversion
106 except for line-break code."
107 (let ((coding-system-for-read 'raw-text-dos)
109 (find-file-noselect filename nowarn rawfile)))
111 (defun save-buffer-as-binary (&optional args)
112 "Like `save-buffer', q.v., but don't encode."
113 (let ((coding-system-for-write 'binary))
116 (defun save-buffer-as-raw-text-CRLF (&optional args)
117 "Like `save-buffer', q.v., but save as network representation."
118 (let ((coding-system-for-write 'raw-text-dos))
121 (defun open-network-stream-as-binary (name buffer host service)
122 "Like `open-network-stream', q.v., but don't code conversion."
123 (let ((coding-system-for-read 'binary)
124 (coding-system-for-write 'binary))
125 (open-network-stream name buffer host service)))
128 ;;; @ with code-conversion
131 (defun insert-file-contents-as-coding-system
132 (coding-system filename &optional visit beg end replace)
133 "Like `insert-file-contents', q.v., but CODING-SYSTEM the first arg will
134 be applied to `coding-system-for-read'."
135 (let ((coding-system-for-read coding-system)
137 (insert-file-contents filename visit beg end replace)))
139 (defun write-region-as-coding-system
140 (coding-system start end filename &optional append visit lockname)
141 "Like `write-region', q.v., but CODING-SYSTEM the first arg will be
142 applied to `coding-system-for-write'."
143 (let ((coding-system-for-write coding-system)
144 jka-compr-compression-info-list jam-zcat-filename-list)
145 (write-region start end filename append visit lockname)))
147 (defun find-file-noselect-as-coding-system
148 (coding-system filename &optional nowarn rawfile)
149 "Like `find-file-noselect', q.v., but CODING-SYSTEM the first arg will
150 be applied to `coding-system-for-read'."
151 (let ((coding-system-for-read coding-system)
153 (find-file-noselect filename nowarn rawfile)))
155 (defun save-buffer-as-coding-system (coding-system &optional args)
156 "Like `save-buffer', q.v., but CODING-SYSTEM the first arg will be
157 applied to `coding-system-for-write'."
158 (let ((coding-system-for-write coding-system))
167 ;;; poem-20.el ends here