Update.
[elisp/apel.git] / poem-ltn1.el
index aa0d3b8..544af55 100644 (file)
@@ -27,6 +27,9 @@
 ;;; @ buffer representation
 ;;;
 
+(eval-when-compile
+  (require 'poe))
+
 (defun-maybe set-buffer-multibyte (flag)
   "Set the multibyte flag of the current buffer to FLAG.
 If FLAG is t, this makes the buffer a multibyte buffer.
@@ -156,12 +159,40 @@ code conversion will not take place."
 
 (defalias 'insert-file-contents-as-raw-text 'insert-file-contents)
 
+(defalias 'insert-file-contents-as-raw-text-CRLF 'insert-file-contents)
+
 (defun find-file-noselect-as-binary (filename &optional nowarn rawfile)
   "Like `find-file-noselect', q.v., but don't code and format conversion."
   (let ((emx-binary-mode t))
     (find-file-noselect filename nowarn rawfile)))
 
-(defalias find-file-noselect-as-raw-text 'find-file-noselect)
+(defalias 'find-file-noselect-as-raw-text 'find-file-noselect)
+
+(defalias 'find-file-noselect-as-raw-text-CRLF 'find-file-noselect)
+
+(defun save-buffer-as-binary (&optional args)
+  "Like `save-buffer', q.v., but don't encode."
+  (let ((emx-binary-mode t))
+    (save-buffer args)))
+
+(defun save-buffer-as-raw-text-CRLF (&optional args)
+  "Like `save-buffer', q.v., but save as network representation."
+  (if (buffer-modified-p)
+      (save-restriction
+       (widen)
+       (let ((the-buf (current-buffer))
+             (filename (buffer-file-name)))
+         (if filename
+             (prog1
+                 (with-temp-buffer
+                   (insert-buffer the-buf)
+                   (goto-char (point-min))
+                   (while (re-search-forward "\\(\\=\\|[^\r]\\)\n" nil t)
+                     (replace-match "\\1\r\n"))
+                   (setq buffer-file-name filename)
+                   (save-buffer args))
+               (set-buffer-modified-p nil)
+               (clear-visited-file-modtime)))))))
 
 (defun open-network-stream-as-binary (name buffer host service)
   "Like `open-network-stream', q.v., but don't code conversion."
@@ -173,24 +204,27 @@ code conversion will not take place."
 ;;;
 
 (defun insert-file-contents-as-coding-system
-  (filename coding-system &optional visit beg end replace)
-  "Like `insert-file-contents', q.v., but CODING-SYSTEM the second arg will
-be applied to `coding-system-for-read'."
+  (coding-system filename &optional visit beg end replace)
+  "Like `insert-file-contents', q.v., CODING-SYSTEM the first arg will be
+ignored."
   (insert-file-contents filename visit beg end replace))
 
-(defun write-region-as-coding-system (start end filename coding-system
-                                           &optional append visit lockname)
-  "Like `write-region', q.v., but CODING-SYSTEM the fourth arg will be
-applied to `coding-system-for-write'."
+(defun write-region-as-coding-system
+  (coding-system start end filename &optional append visit lockname)
+  "Like `write-region', q.v., CODING-SYSTEM the first arg will be ignored."
   (let (jka-compr-compression-info-list jam-zcat-filename-list)
     (write-region start end filename append visit lockname)))
 
-(defun find-file-noselect-as-coding-system (filename coding-system
-                                                    &optional nowarn rawfile)
-  "Like `find-file-noselect', q.v., but CODING-SYSTEM the second arg will
-be applied to `coding-system-for-read'."
+(defun find-file-noselect-as-coding-system
+  (coding-system filename &optional nowarn rawfile)
+  "Like `find-file-noselect', q.v., CODING-SYSTEM the first arg will be
+ignored."
   (find-file-noselect filename nowarn rawfile))
 
+(defun save-buffer-as-coding-system (coding-system &optional args)
+  "Like `save-buffer', q.v., CODING-SYSTEM the first arg will be ignored."
+  (save-buffer args))
+
 
 ;;; @ character
 ;;;