Skip to content
Browse files

* 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-199902041200".
  • Loading branch information...
1 parent 058a7a3 commit cb957fd9daed595652179af2be7d9de6df7be251 yamaoka committed
Showing with 125 additions and 14 deletions.
  1. +10 −0 ChangeLog
  2. +16 −0 poem-20.el
  3. +28 −0 poem-ltn1.el
  4. +30 −0 poem-nemacs.el
  5. +41 −14 poem-om.el
View
10 ChangeLog
@@ -1,5 +1,15 @@
1999-02-04 Katsumi Yamaoka <yamaoka@jpl.org>
+ * 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 <yamaoka@jpl.org>
+
* 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'.
View
16 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
;;;
View
28 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
;;;
View
30 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
;;;
View
55 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
;;;

0 comments on commit cb957fd

Please sign in to comment.
Something went wrong with that request. Please try again.