1 | ;;; pces-raw.el --- pces submodule for emacsen without coding-system features |
---|
2 | |
---|
3 | ;; Copyright (C) 1995,1996,1997,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 | ;;; @ coding-system |
---|
28 | ;;; |
---|
29 | |
---|
30 | (defun decode-coding-string (string coding-system) |
---|
31 | "Decode the STRING which is encoded in CODING-SYSTEM." |
---|
32 | (copy-sequence string)) |
---|
33 | |
---|
34 | (defun encode-coding-string (string coding-system) |
---|
35 | "Encode the STRING as CODING-SYSTEM." |
---|
36 | (copy-sequence string)) |
---|
37 | |
---|
38 | (defun decode-coding-region (start end coding-system) |
---|
39 | "Decode the text between START and END which is encoded in CODING-SYSTEM." |
---|
40 | 0) |
---|
41 | |
---|
42 | (defun encode-coding-region (start end coding-system) |
---|
43 | "Encode the text between START and END to CODING-SYSTEM." |
---|
44 | 0) |
---|
45 | |
---|
46 | (defun detect-coding-region (start end) |
---|
47 | "Detect coding-system of the text in the region between START and END." |
---|
48 | ) |
---|
49 | |
---|
50 | (defun set-buffer-file-coding-system (coding-system &optional force) |
---|
51 | "Set buffer-file-coding-system of the current buffer to CODING-SYSTEM." |
---|
52 | ) |
---|
53 | |
---|
54 | |
---|
55 | ;;; @ without code-conversion |
---|
56 | ;;; |
---|
57 | |
---|
58 | (defmacro as-binary-process (&rest body) |
---|
59 | (` (let (selective-display) ; Disable ^M to nl translation. |
---|
60 | (,@ body)))) |
---|
61 | |
---|
62 | (defmacro as-binary-input-file (&rest body) |
---|
63 | (` (let ((emx-binary-mode t)) ; Stop CRLF to LF conversion in OS/2 |
---|
64 | (,@ body)))) |
---|
65 | |
---|
66 | (defmacro as-binary-output-file (&rest body) |
---|
67 | (` (let ((emx-binary-mode t)) ; Stop CRLF to LF conversion in OS/2 |
---|
68 | (,@ body)))) |
---|
69 | |
---|
70 | (defun write-region-as-binary (start end filename |
---|
71 | &optional append visit lockname) |
---|
72 | "Like `write-region', q.v., but don't code conversion." |
---|
73 | (let ((emx-binary-mode t)) |
---|
74 | (write-region start end filename append visit lockname))) |
---|
75 | |
---|
76 | (defun insert-file-contents-as-binary (filename |
---|
77 | &optional visit beg end replace) |
---|
78 | "Like `insert-file-contents', q.v., but don't code and format conversion. |
---|
79 | Like `insert-file-contents-literary', but it allows find-file-hooks, |
---|
80 | automatic uncompression, etc. |
---|
81 | |
---|
82 | Namely this function ensures that only format decoding and character |
---|
83 | code conversion will not take place." |
---|
84 | (let ((emx-binary-mode t)) |
---|
85 | ;; Returns list of absolute file name and length of data inserted. |
---|
86 | (insert-file-contents filename visit beg end replace))) |
---|
87 | |
---|
88 | (defun write-region-as-raw-text-CRLF (start end filename |
---|
89 | &optional append visit lockname) |
---|
90 | "Like `write-region', q.v., but write as network representation." |
---|
91 | (let ((the-buf (current-buffer))) |
---|
92 | (with-temp-buffer |
---|
93 | (insert-buffer-substring the-buf start end) |
---|
94 | (goto-char (point-min)) |
---|
95 | (while (re-search-forward "\\(\\=\\|[^\r]\\)\n" nil t) |
---|
96 | (replace-match "\\1\r\n")) |
---|
97 | (write-region (point-min)(point-max) filename append visit lockname)))) |
---|
98 | |
---|
99 | (defalias 'insert-file-contents-as-raw-text 'insert-file-contents) |
---|
100 | |
---|
101 | (defalias 'insert-file-contents-as-raw-text-CRLF 'insert-file-contents) |
---|
102 | |
---|
103 | (defun find-file-noselect-as-binary (filename &optional nowarn rawfile) |
---|
104 | "Like `find-file-noselect', q.v., but don't code and format conversion." |
---|
105 | (let ((emx-binary-mode t)) |
---|
106 | (find-file-noselect filename nowarn rawfile))) |
---|
107 | |
---|
108 | (defalias 'find-file-noselect-as-raw-text 'find-file-noselect) |
---|
109 | |
---|
110 | (defalias 'find-file-noselect-as-raw-text-CRLF 'find-file-noselect) |
---|
111 | |
---|
112 | (defun save-buffer-as-binary (&optional args) |
---|
113 | "Like `save-buffer', q.v., but don't encode." |
---|
114 | (let ((emx-binary-mode t)) |
---|
115 | (save-buffer args))) |
---|
116 | |
---|
117 | (defun save-buffer-as-raw-text-CRLF (&optional args) |
---|
118 | "Like `save-buffer', q.v., but save as network representation." |
---|
119 | (if (buffer-modified-p) |
---|
120 | (save-restriction |
---|
121 | (widen) |
---|
122 | (let ((the-buf (current-buffer)) |
---|
123 | (filename (buffer-file-name))) |
---|
124 | (if filename |
---|
125 | (prog1 |
---|
126 | (with-temp-buffer |
---|
127 | (insert-buffer the-buf) |
---|
128 | (goto-char (point-min)) |
---|
129 | (while (re-search-forward "\\(\\=\\|[^\r]\\)\n" nil t) |
---|
130 | (replace-match "\\1\r\n")) |
---|
131 | (setq buffer-file-name filename) |
---|
132 | (save-buffer args)) |
---|
133 | (set-buffer-modified-p nil) |
---|
134 | (clear-visited-file-modtime))))))) |
---|
135 | |
---|
136 | (defun open-network-stream-as-binary (name buffer host service) |
---|
137 | "Like `open-network-stream', q.v., but don't code conversion." |
---|
138 | (let ((emx-binary-mode t)) |
---|
139 | (open-network-stream name buffer host service))) |
---|
140 | |
---|
141 | |
---|
142 | ;;; @ with code-conversion (but actually it might be not done) |
---|
143 | ;;; |
---|
144 | |
---|
145 | (defun insert-file-contents-as-coding-system |
---|
146 | (coding-system filename &optional visit beg end replace) |
---|
147 | "Like `insert-file-contents', q.v., but CODING-SYSTEM is used to decode." |
---|
148 | (insert-file-contents filename visit beg end replace)) |
---|
149 | |
---|
150 | (defun write-region-as-coding-system |
---|
151 | (coding-system start end filename &optional append visit lockname) |
---|
152 | "Like `write-region', q.v., but CODING-SYSTEM is used to encode." |
---|
153 | (let (jka-compr-compression-info-list jam-zcat-filename-list) |
---|
154 | (write-region start end filename append visit lockname))) |
---|
155 | |
---|
156 | (defun find-file-noselect-as-coding-system |
---|
157 | (coding-system filename &optional nowarn rawfile) |
---|
158 | "Like `find-file-noselect', q.v., CODING-SYSTEM is used to decode." |
---|
159 | (find-file-noselect filename nowarn rawfile)) |
---|
160 | |
---|
161 | (defun save-buffer-as-coding-system (coding-system &optional args) |
---|
162 | "Like `save-buffer', q.v., CODING-SYSTEM is used to encode." |
---|
163 | (save-buffer args)) |
---|
164 | |
---|
165 | |
---|
166 | ;;; @ end |
---|
167 | ;;; |
---|
168 | |
---|
169 | (require 'product) |
---|
170 | (product-provide (provide 'pces-raw) (require 'apel-ver)) |
---|
171 | |
---|
172 | ;;; pces-raw.el ends here |
---|