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-dos)
70 ;; Returns list of absolute file name and length of data inserted.
71 (insert-file-contents filename visit beg end replace)))
73 (defun write-region-as-raw-text-CRLF (start end filename
74 &optional append visit lockname)
75 "Like `write-region', q.v., but write as network representation."
76 (let ((coding-system-for-write 'raw-text-dos))
77 (write-region start end filename append visit lockname)))
79 (defun find-file-noselect-as-binary (filename &optional nowarn rawfile)
80 "Like `find-file-noselect', q.v., but don't code and format conversion."
81 (let ((coding-system-for-write 'binary)
83 (find-file-noselect filename nowarn rawfile)))
85 (defun find-file-noselect-as-raw-text (filename &optional nowarn rawfile)
86 "Like `find-file-noselect', q.v., but it does not code and format conversion
87 except for line-break code."
88 (let ((coding-system-for-read 'raw-text-dos)
90 (find-file-noselect filename nowarn rawfile)))
92 (defun save-buffer-as-binary (&optional args)
93 "Like `save-buffer', q.v., but don't encode."
94 (let ((coding-system-for-write 'binary))
97 (defun save-buffer-as-raw-text-CRLF (&optional args)
98 "Like `save-buffer', q.v., but save as network representation."
99 (let ((coding-system-for-write 'raw-text-dos))
102 (defun open-network-stream-as-binary (name buffer host service)
103 "Like `open-network-stream', q.v., but don't code conversion."
104 (let ((coding-system-for-read 'binary)
105 (coding-system-for-write 'binary))
106 (open-network-stream name buffer host service)))
109 ;;; @ with code-conversion
112 (defun insert-file-contents-as-coding-system
113 (coding-system filename &optional visit beg end replace)
114 "Like `insert-file-contents', q.v., but CODING-SYSTEM the first arg will
115 be applied to `coding-system-for-read'."
116 (let ((coding-system-for-read coding-system)
118 (insert-file-contents filename visit beg end replace)))
120 (defun write-region-as-coding-system
121 (coding-system start end filename &optional append visit lockname)
122 "Like `write-region', q.v., but CODING-SYSTEM the first arg will be
123 applied to `coding-system-for-write'."
124 (let ((coding-system-for-write coding-system)
125 jka-compr-compression-info-list jam-zcat-filename-list)
126 (write-region start end filename append visit lockname)))
128 (defun find-file-noselect-as-coding-system
129 (coding-system filename &optional nowarn rawfile)
130 "Like `find-file-noselect', q.v., but CODING-SYSTEM the first arg will
131 be applied to `coding-system-for-read'."
132 (let ((coding-system-for-read coding-system)
134 (find-file-noselect filename nowarn rawfile)))
136 (defun save-buffer-as-coding-system (coding-system &optional args)
137 "Like `save-buffer', q.v., but CODING-SYSTEM the first arg will be
138 applied to `coding-system-for-write'."
139 (let ((coding-system-for-write coding-system))
148 ;;; poem-20.el ends here