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)
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 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 open-network-stream-as-binary (name buffer host service)
80 "Like `open-network-stream', q.v., but don't code conversion."
81 (let ((coding-system-for-read 'binary)
82 (coding-system-for-write 'binary))
83 (open-network-stream name buffer host service)))
86 ;;; @ with code-conversion
89 (defun insert-file-contents-as-specified-coding-system (filename &rest args)
90 "Like `insert-file-contents', q.v., but code convert by the specified
91 coding-system. ARGS the optional arguments are passed to
92 `insert-file-contents' except for the last element. The last element of
93 ARGS must be a coding-system."
94 (let ((coding-system-for-read (car (reverse args)))
96 (apply 'insert-file-contents filename (nreverse (cdr (nreverse args))))))
98 (defun write-region-as-specified-coding-system (start end filename
100 "Like `write-region', q.v., but code convert by the specified coding-system.
101 ARGS the optional arguments are passed to `write-region' except for the last
102 element. The last element of ARGS must be a coding-system."
103 (let ((coding-system-for-write (car (reverse args)))
104 jka-compr-compression-info-list jam-zcat-filename-list)
105 (apply 'write-region start end filename
106 (nreverse (cdr (nreverse args))))))
114 ;;; poem-20.el ends here