Split off features about coding-system from poem-xm.el and
[elisp/apel.git] / pces-xfc.el
1 ;;; pces-xfc.el --- pces module for XEmacs with file coding
2
3 ;; Copyright (C) 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., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Code:
26
27 (require 'pces-20)
28
29 (if (featurep 'mule)
30     (require 'pces-xm)
31   )
32
33
34 ;;; @ fix coding-system definition
35 ;;;
36
37 ;; Redefine if -{dos|mac|unix} is not found.
38 (or (find-coding-system 'raw-text-dos)
39     (copy-coding-system 'no-conversion-dos 'raw-text-dos))
40 (or (find-coding-system 'raw-text-mac)
41     (copy-coding-system 'no-conversion-mac 'raw-text-mac))
42 (or (find-coding-system 'raw-text-unix)
43     (copy-coding-system 'no-conversion-unix 'raw-text-unix))
44
45
46 ;;; @ without code-conversion
47 ;;;
48
49 (defun insert-file-contents-as-binary (filename
50                                        &optional visit beg end replace)
51   "Like `insert-file-contents', but only reads in the file literally.
52 A buffer may be modified in several ways after reading into the buffer,
53 to Emacs features such as format decoding, character code
54 conversion, find-file-hooks, automatic uncompression, etc.
55
56 This function ensures that none of these modifications will take place."
57   (let ((format-alist nil)
58         (after-insert-file-functions nil)
59         (coding-system-for-read 'binary)
60         (coding-system-for-write 'binary)
61         (jka-compr-compression-info-list nil)
62         (jam-zcat-filename-list nil)
63         (find-buffer-file-type-function
64          (if (fboundp 'find-buffer-file-type)
65              (symbol-function 'find-buffer-file-type)
66            nil)))
67     (unwind-protect
68         (progn
69           (fset 'find-buffer-file-type (lambda (filename) t))
70           (insert-file-contents filename visit beg end replace))
71       (if find-buffer-file-type-function
72           (fset 'find-buffer-file-type find-buffer-file-type-function)
73         (fmakunbound 'find-buffer-file-type)))))
74
75
76 ;;; @ end
77 ;;;
78
79 (provide 'pces-xfc)
80
81 ;;; pces-xfc.el ends here