From 3a7d2134fc7383b8138a6d62268bd9448fd63ca5 Mon Sep 17 00:00:00 2001 From: yamaoka Date: Thu, 4 Feb 1999 12:02:29 +0000 Subject: [PATCH] * poem-20.el, poem-ltn1.el, poem-nemacs.el, poem-om.el (save-buffer-as-binary): New function. (save-buffer-as-raw-text-CRLF): New function. (save-buffer-as-coding-system): New function. * poem-om.el (poem-ccl-decode-raw-text): Rewrite again for plural `CR's. It will be tagged with "apel-mcs-2-199902041200". --- ChangeLog | 10 ++++++++++ poem-20.el | 16 ++++++++++++++++ poem-ltn1.el | 28 ++++++++++++++++++++++++++++ poem-nemacs.el | 30 ++++++++++++++++++++++++++++++ poem-om.el | 55 +++++++++++++++++++++++++++++++++++++++++-------------- 5 files changed, 125 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index fda6293..0dece1d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 1999-02-04 Katsumi Yamaoka + * poem-20.el, poem-ltn1.el, poem-nemacs.el, poem-om.el + (save-buffer-as-binary): New function. + (save-buffer-as-raw-text-CRLF): New function. + (save-buffer-as-coding-system): New function. + + * poem-om.el (poem-ccl-decode-raw-text): Rewrite again for plural + `CR's. + +1999-02-04 Katsumi Yamaoka + * poem-om.el (poem-ccl-decode-raw-text): Rewrite for fixing a bug that the last datum will be missed if the input data is not ended with `CRLF'. diff --git a/poem-20.el b/poem-20.el index 6a5f4f4..e4e2786 100644 --- a/poem-20.el +++ b/poem-20.el @@ -89,6 +89,16 @@ except for line-break code." format-alist) (find-file-noselect filename nowarn rawfile))) +(defun save-buffer-as-binary (&optional args) + "Like `save-buffer', q.v., but don't encode." + (let ((coding-system-for-write 'binary)) + (save-buffer args))) + +(defun save-buffer-as-raw-text-CRLF (&optional args) + "Like `save-buffer', q.v., but save as network representation." + (let ((coding-system-for-write 'raw-text-dos)) + (save-buffer args))) + (defun open-network-stream-as-binary (name buffer host service) "Like `open-network-stream', q.v., but don't code conversion." (let ((coding-system-for-read 'binary) @@ -123,6 +133,12 @@ be applied to `coding-system-for-read'." format-alist) (find-file-noselect filename nowarn rawfile))) +(defun save-buffer-as-coding-system (coding-system &optional args) + "Like `save-buffer', q.v., but CODING-SYSTEM the first arg will be +applied to `coding-system-for-write'." + (let ((coding-system-for-write coding-system)) + (save-buffer args))) + ;;; @ end ;;; diff --git a/poem-ltn1.el b/poem-ltn1.el index f7e23c4..59ef43a 100644 --- a/poem-ltn1.el +++ b/poem-ltn1.el @@ -163,6 +163,30 @@ code conversion will not take place." (defalias find-file-noselect-as-raw-text '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." (let ((emx-binary-mode t)) @@ -190,6 +214,10 @@ ignored." 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 ;;; diff --git a/poem-nemacs.el b/poem-nemacs.el index 2741b9f..9170a8e 100644 --- a/poem-nemacs.el +++ b/poem-nemacs.el @@ -237,6 +237,30 @@ except for line-break code." (set-process-kanji-code process 0) process)) +(defun save-buffer-as-binary (&optional args) + "Like `save-buffer', q.v., but don't encode." + (as-binary-output-file + (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-as-binary args)) + (set-buffer-modified-p nil) + (clear-visited-file-modtime))))))) + ;;; @ with code-conversion ;;; @@ -265,6 +289,12 @@ be applied to `kanji-fileio-code'." kanji-expected-code) (find-file-noselect filename nowarn))) +(defun save-buffer-as-coding-system (coding-system &optional args) + "Like `save-buffer', q.v., but CODING-SYSTEM the first arg will be +applied to `kanji-fileio-code'." + (let ((kanji-fileio-code coding-system)) + (save-buffer args))) + ;;; @ buffer representation ;;; diff --git a/poem-om.el b/poem-om.el index 5fcd560..34751d3 100644 --- a/poem-om.el +++ b/poem-om.el @@ -51,14 +51,25 @@ (define-ccl-program poem-ccl-decode-raw-text '(1 - (loop - (read-if (r0 == ?\x0d) - (read-if (r1 == ?\x0a) - (write r1) - ((write r0) - (write r1))) - (write r0)) - (repeat))) + ((r2 = 0) + (read r0) + (loop + (if (r0 == ?\x0d) + ((r2 = 1) + (read-if (r1 == ?\x0a) + ((r0 = ?\x0a) + (r2 = 0) + (write-read-repeat r0)) + ((write r0) + (r0 = (r1 + 0)) + (repeat)))) + ((r2 = 0) + (write-read-repeat r0))))) + ;; This EOF BLOCK won't work out in practice. So the last datum + ;; might be lost if it's value is ?\x0d. + (if r2 + (write r0)) + ) "Convert line-break code from CRLF to LF.") (define-ccl-program poem-ccl-encode-raw-text @@ -225,6 +236,12 @@ be applied to `file-coding-system-for-read'." (find-file-noselect filename nowarn))) )) +(defun save-buffer-as-coding-system (coding-system &optional args) + "Like `save-buffer', q.v., but CODING-SYSTEM the first arg will be +applied to `coding-system-for-write'." + (let ((file-coding-system coding-system)) + (save-buffer args))) + ;;; @ without code-conversion ;;; @@ -299,12 +316,6 @@ code." (write-region-as-coding-system 'raw-text-dos start end filename append visit lockname)) -(defun open-network-stream-as-binary (name buffer host service) - "Like `open-network-stream', q.v., but don't code conversion." - (let ((process (open-network-stream name buffer host service))) - (set-process-coding-system process *noconv* *noconv*) - process)) - (defun find-file-noselect-as-binary (filename &optional nowarn rawfile) "Like `find-file-noselect', q.v., but don't code and format conversion." (find-file-noselect-as-coding-system 'binary filename nowarn rawfile)) @@ -314,6 +325,22 @@ code." conversion except for line-break code." (find-file-noselect-as-coding-system 'raw-text filename nowarn rawfile)) +(defun save-buffer-as-binary (&optional args) + "Like `save-buffer', q.v., but don't encode." + (let ((file-coding-system 'binary)) + (save-buffer args))) + +(defun save-buffer-as-raw-text-CRLF (&optional args) + "Like `save-buffer', q.v., but save as network representation." + (let ((file-coding-system 'raw-text-dos)) + (save-buffer args))) + +(defun open-network-stream-as-binary (name buffer host service) + "Like `open-network-stream', q.v., but don't code conversion." + (let ((process (open-network-stream name buffer host service))) + (set-process-coding-system process *noconv* *noconv*) + process)) + ;;; @ buffer representation ;;; -- 1.7.10.4