Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* poem-20.el, poem-e20_2.el, poem-ltn1.el, poem-nemacs.el, poem-om.el

(find-file-noselect-as-coding-system): Be CODING-SYSTEM the 1st arg.
(insert-file-contents-as-coding-system): Likewise.
* poem-20.el, poem-ltn1.el, poem-nemacs.el, poem-om.el
(write-region-as-coding-system): Likewise.
  • Loading branch information...
commit dcebdbd2fd6899b7f2a1b780f1b7cb3d0b11220e 1 parent aa5ed66
yamaoka authored
Showing with 164 additions and 238 deletions.
  1. +0 −53 ChangeLog
  2. +2 −0  pccl-20.el
  3. +6 −4 pccl-om.el
  4. +156 −181 poem-om.el
View
53 ChangeLog
@@ -1,56 +1,3 @@
-1998-12-17 MORIOKA Tomohiko <morioka@jaist.ac.jp>
-
- * poem-om.el (poem-decode-raw-text): New function for MULE 1.
- (poem-encode-raw-text-CRLF): Likewise.
- (raw-text): New coding-system for MULE 1.
- (raw-text-dos): Likewise.
- (insert-file-contents-as-raw-text): Share implementation.
- (write-region-as-raw-text-CRLF): Likewise.
- (find-file-noselect-as-raw-text): Likewise.
-
-1998-12-17 MORIOKA Tomohiko <morioka@jaist.ac.jp>
-
- * poem-om.el: Share definition of coding-system `binary'.
- (write-region-as-binary): Share implementation.
- (find-file-noselect-as-binary): Likewise.
-
-1998-12-16 MORIOKA Tomohiko <morioka@jaist.ac.jp>
-
- * poem-om.el (insert-file-contents-as-binary): Share
- implementation.
-
-1998-12-16 Katsumi Yamaoka <yamaoka@jpl.org>
-
- * poem-om.el (find-file-noselect-as-raw-text): Use
- `find-file-noselect-as-coding-system' under Mule 2.*.
- (find-file-noselect-as-binary): Likewise.
- (insert-file-contents-as-raw-text): Use
- `insert-file-contents-as-coding-system' under Mule 2.*.
- (insert-file-contents-as-binary): Likewise.
- (write-region-as-raw-text-CRLF): Use
- `write-region-as-coding-system' under Mule 2.*.
- (write-region-as-binary): Likewise.
- (truncate-string): Use `defun-maybe'.
- (toplevel): Don't refer to `running-emacs-19_29-or-later', use
- `emacs-major-version' and `emacs-minor-version' instead.
-
-1998-12-16 Katsumi Yamaoka <yamaoka@jpl.org>
-
- * pccl-om.el (toplevel): Don't require `poem'.
- Use `code-convert-string' instead of `encode-coding-string' or
- `decode-coding-string'.
-
- * poem-om.el (binary): EMACS 20 emulating coding-system for Mule
- 2.3 based on Emacs 19.[28-34].
- (raw-text): EMACS 20 emulating coding-system based on native CCL
- for Mule 2.3 based on Emacs 19.[28-34].
- (raw-text-dos): Likewise.
- (find-file-noselect-as-binary): Separate for some Mules.
-
-1998-12-15 Tanaka Akira <akr@jaist.ac.jp>
-
- * pccl-20.el: Do not require 'poem.
-
1998-12-14 Katsumi Yamaoka <yamaoka@jpl.org>
* poem-20.el, poem-e20_2.el, poem-ltn1.el, poem-nemacs.el, poem-om.el
View
2  pccl-20.el
@@ -25,6 +25,8 @@
;;; Code:
+(require 'poem)
+
(eval-when-compile (require 'ccl))
(require 'broken)
View
10 pccl-om.el
@@ -26,6 +26,8 @@
;;; Code:
+(require 'poem)
+
(eval-when-compile (require 'ccl))
(require 'broken)
@@ -80,19 +82,19 @@ If CCL-PROG is symbol, it is dereferenced.
(broken-facility ccl-execute-eof-block-on-encoding-null
"Emacs forgets executing CCL_EOF_BLOCK with encoding on empty input."
- (equal (code-convert-string "" *internal* 'test-ccl-eof-block-cs) "[EOF]"))
+ (equal (encode-coding-string "" 'test-ccl-eof-block-cs) "[EOF]"))
(broken-facility ccl-execute-eof-block-on-encoding-some
"Emacs forgets executing CCL_EOF_BLOCK with encoding on non-empty input."
- (equal (code-convert-string "a" *internal* 'test-ccl-eof-block-cs) "a[EOF]"))
+ (equal (encode-coding-string "a" 'test-ccl-eof-block-cs) "a[EOF]"))
(broken-facility ccl-execute-eof-block-on-decoding-null
"Emacs forgets executing CCL_EOF_BLOCK with decoding on empty input."
- (equal (code-convert-string "" 'test-ccl-eof-block-cs *internal*) "[EOF]"))
+ (equal (decode-coding-string "" 'test-ccl-eof-block-cs) "[EOF]"))
(broken-facility ccl-execute-eof-block-on-decoding-some
"Emacs forgets executing CCL_EOF_BLOCK with decoding on non-empty input."
- (equal (code-convert-string "a" 'test-ccl-eof-block-cs *internal*) "a[EOF]"))
+ (equal (decode-coding-string "a" 'test-ccl-eof-block-cs) "a[EOF]"))
(broken-facility ccl-execute-eof-block-on-encoding
"Emacs may forget executing CCL_EOF_BLOCK with encoding."
View
337 poem-om.el
@@ -3,7 +3,6 @@
;; Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
-;; Katsumi Yamaoka <yamaoka@jpl.org>
;; Keywords: emulation, compatibility, Mule
;; This file is part of APEL (A Portable Emacs Library).
@@ -48,75 +47,6 @@
pat (1+ (match-beginning 0)) (1- (match-end 0))))
0))
))))
-
- (define-ccl-program ccl-decode-raw-text
- '(1
- ((read r1 r0)
- (loop
- (r2 = (r1 == ?\x0d))
- (r2 &= (r0 == ?\x0a))
- (if r2
- ((write ?\x0a)
- (read r1 r0)
- (repeat))
- ((write r1)
- (r1 = (r0 + 0))
- (read r0)
- (repeat)
- ))))
- (write r1))
- "Convert line-break code from CRLF to LF.")
-
- (define-ccl-program ccl-encode-raw-text
- '(1
- ((read r0)
- (loop (write-read-repeat r0))))
- "Pass through without any conversions.")
-
- (define-ccl-program ccl-encode-raw-text-CRLF
- '(2
- ((loop
- (read r0)
- (if (r0 == ?\x0a)
- (write "\x0d\x0a")
- (write r0))
- (repeat))))
- "Convert line-break code from LF to CRLF.")
-
- (make-coding-system
- 'raw-text 4 ?=
- "No conversion"
- nil
- (cons ccl-decode-raw-text ccl-encode-raw-text))
-
- (make-coding-system
- 'raw-text-dos 4 ?=
- "No conversion"
- nil
- (cons ccl-decode-raw-text ccl-encode-raw-text-CRLF))
- )
- (t
- (defun poem-decode-raw-text (from to)
- (save-restriction
- (narrow-to-region from to)
- (goto-char (point-min))
- (while (re-search-forward "\r$" nil t)
- (replace-match "")
- )))
- (defun poem-encode-raw-text-CRLF (from to)
- (save-restriction
- (narrow-to-region from to)
- (goto-char (point-min))
- (while (re-search-forward "\\(\\=\\|[^\r]\\)\n" nil t)
- (replace-match "\\1\r\n")
- )))
-
- (make-coding-system 'raw-text nil ?= "No conversion")
- (put 'raw-text 'post-read-conversion 'poem-decode-raw-text)
-
- (make-coding-system 'raw-text-dos nil ?= "No conversion")
- (put 'raw-text-dos 'post-read-conversion 'poem-decode-raw-text)
- (put 'raw-text-dos 'pre-write-conversion 'poem-encode-raw-text-CRLF)
))
@@ -186,62 +116,13 @@
(defalias 'set-buffer-file-coding-system 'set-file-coding-system)
-;;; @ with code-conversion
-;;;
-
-(defun insert-file-contents-as-coding-system
- (coding-system filename &optional visit beg end replace)
- "Like `insert-file-contents', q.v., but CODING-SYSTEM the first arg will
-be applied to `file-coding-system-for-read'."
- (let ((file-coding-system-for-read coding-system))
- (insert-file-contents filename visit beg end replace)))
-
-(cond
- ((and (>= emacs-major-version 19) (>= emacs-minor-version 29))
- ;; for MULE 2.3 based on Emacs 19.34.
- (defun write-region-as-coding-system
- (coding-system start end filename &optional append visit lockname)
- "Like `write-region', q.v., but CODING-SYSTEM the first arg will be
-applied to `file-coding-system'."
- (let ((file-coding-system coding-system)
- jka-compr-compression-info-list jam-zcat-filename-list)
- (write-region start end filename append visit lockname)))
-
- (defun find-file-noselect-as-coding-system
- (coding-system filename &optional nowarn rawfile)
- "Like `find-file-noselect', q.v., but CODING-SYSTEM the first arg will
-be applied to `file-coding-system-for-read'."
- (let ((file-coding-system-for-read coding-system))
- (find-file-noselect filename nowarn rawfile)))
- )
- (t
- ;; for MULE 2.3 based on Emacs 19.28 or MULE 1.*.
- (defun write-region-as-coding-system
- (coding-system start end filename &optional append visit lockname)
- "Like `write-region', q.v., but CODING-SYSTEM the first arg will be
-applied to `file-coding-system'."
- (let ((file-coding-system coding-system)
- jka-compr-compression-info-list jam-zcat-filename-list)
- (write-region start end filename append visit)))
-
- (defun find-file-noselect-as-coding-system
- (coding-system filename &optional nowarn rawfile)
- "Like `find-file-noselect', q.v., but CODING-SYSTEM the first arg will
-be applied to `file-coding-system-for-read'."
- (let ((file-coding-system-for-read coding-system))
- (find-file-noselect filename nowarn)))
- ))
-
-
;;; @ without code-conversion
;;;
-(make-coding-system 'binary nil ?= "No conversion")
-
(defmacro as-binary-process (&rest body)
(` (let (selective-display ; Disable ^M to nl translation.
;; Mule
- mc-flag
+ mc-flag
(default-process-coding-system (cons *noconv* *noconv*))
program-coding-system-alist)
(,@ body))))
@@ -260,17 +141,6 @@ be applied to `file-coding-system-for-read'."
(defalias 'set-process-input-coding-system 'set-process-coding-system)
-(defun insert-binary-file-contents-literally (filename
- &optional visit beg end replace)
- "Like `insert-file-contents-literally', q.v., but don't code conversion.
-A buffer may be modified in several ways after reading into the buffer due
-to advanced Emacs features, such as file-name-handlers, format decoding,
-find-file-hooks, etc.
- This function ensures that none of these modifications will take place."
- (as-binary-input-file
- ;; Returns list absolute file name and length of data inserted.
- (insert-file-contents-literally filename visit beg end replace)))
-
(defun insert-file-contents-as-binary (filename
&optional visit beg end replace)
"Like `insert-file-contents', q.v., but don't code and format conversion.
@@ -290,21 +160,86 @@ Like `insert-file-contents-literary', but it allows find-file-hooks,
automatic uncompression, etc.
Like `insert-file-contents-as-binary', but it converts line-break
code."
- ;; Returns list absolute file name and length of data inserted.
- (insert-file-contents-as-coding-system 'raw-text
- filename visit beg end replace))
-
-(defun write-region-as-binary (start end filename
- &optional append visit lockname)
- "Like `write-region', q.v., but don't code conversion."
- (write-region-as-coding-system 'binary
- start end filename append visit lockname))
-
-(defun write-region-as-raw-text-CRLF (start end filename
- &optional append visit lockname)
- "Like `write-region', q.v., but don't code conversion."
- (write-region-as-coding-system 'raw-text-dos
- start end filename append visit lockname))
+ (save-excursion
+ (save-restriction
+ (narrow-to-region (point)(point))
+ (let ((return-val
+ ;; Returns list absolute file name and length of data inserted.
+ (insert-file-contents-as-binary filename visit beg end replace)))
+ (goto-char (point-min))
+ (while (re-search-forward "\r$" nil t)
+ (replace-match ""))
+ (list (car return-val) (buffer-size))))))
+
+(defun insert-binary-file-contents-literally (filename
+ &optional visit beg end replace)
+ "Like `insert-file-contents-literally', q.v., but don't code conversion.
+A buffer may be modified in several ways after reading into the buffer due
+to advanced Emacs features, such as file-name-handlers, format decoding,
+find-file-hooks, etc.
+ This function ensures that none of these modifications will take place."
+ (as-binary-input-file
+ ;; Returns list absolute file name and length of data inserted.
+ (insert-file-contents-literally filename visit beg end replace)))
+
+(cond
+ (running-emacs-19_29-or-later
+ ;; for MULE 2.3 based on Emacs 19.34.
+ (defun write-region-as-binary (start end filename
+ &optional append visit lockname)
+ "Like `write-region', q.v., but don't code conversion."
+ (as-binary-output-file
+ (write-region start end filename append visit lockname)))
+
+ (defun write-region-as-raw-text-CRLF (start end filename
+ &optional append visit lockname)
+ "Like `write-region', q.v., but don't code conversion."
+ (let ((the-buf (current-buffer)))
+ (with-temp-buffer
+ (insert-buffer-substring the-buf start end)
+ (goto-char (point-min))
+ (while (re-search-forward "\\(\\=\\|[^\r]\\)\n" nil t)
+ (replace-match "\\1\r\n"))
+ (write-region-as-binary (point-min)(point-max)
+ filename append visit lockname))))
+ )
+ (t
+ ;; for MULE 2.3 based on Emacs 19.28.
+ (defun write-region-as-binary (start end filename
+ &optional append visit lockname)
+ "Like `write-region', q.v., but don't code conversion."
+ (as-binary-output-file
+ (write-region start end filename append visit)))
+
+ (defun write-region-as-raw-text-CRLF (start end filename
+ &optional append visit lockname)
+ "Like `write-region', q.v., but don't code conversion."
+ (let ((the-buf (current-buffer)))
+ (with-temp-buffer
+ (insert-buffer-substring the-buf start end)
+ (goto-char (point-min))
+ (while (re-search-forward "\\(\\=\\|[^\r]\\)\n" nil t)
+ (replace-match "\\1\r\n"))
+ (write-region-as-binary (point-min)(point-max)
+ filename append visit))))
+ ))
+
+(defun find-file-noselect-as-binary (filename &optional nowarn rawfile)
+ "Like `find-file-noselect', q.v., but don't code and format conversion."
+ (as-binary-input-file (find-file-noselect filename nowarn rawfile)))
+
+(defun find-file-noselect-as-raw-text (filename &optional nowarn rawfile)
+ "Like `find-file-noselect', q.v., but it does not code and format conversion
+except for line-break code."
+ (save-current-buffer
+ (prog1
+ (set-buffer (find-file-noselect-as-binary filename nowarn rawfile))
+ (let ((flag (buffer-modified-p)))
+ (save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward "\r$" nil t)
+ (replace-match "")))
+ (set-buffer-modified-p flag)))))
(defun open-network-stream-as-binary (name buffer host service)
"Like `open-network-stream', q.v., but don't code conversion."
@@ -312,14 +247,52 @@ code."
(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))
-(defun find-file-noselect-as-raw-text (filename &optional nowarn rawfile)
- "Like `find-file-noselect', q.v., but it does not code and format
-conversion except for line-break code."
- (find-file-noselect-as-coding-system 'raw-text filename nowarn rawfile))
+;;; @ with code-conversion
+;;;
+
+(defun insert-file-contents-as-coding-system
+ (coding-system filename &optional visit beg end replace)
+ "Like `insert-file-contents', q.v., but CODING-SYSTEM the first arg will
+be applied to `file-coding-system-for-read'."
+ (let ((file-coding-system-for-read coding-system))
+ (insert-file-contents filename visit beg end replace)))
+
+(cond
+ (running-emacs-19_29-or-later
+ ;; for MULE 2.3 based on Emacs 19.34.
+ (defun write-region-as-coding-system
+ (coding-system start end filename &optional append visit lockname)
+ "Like `write-region', q.v., but CODING-SYSTEM the first arg will be
+applied to `file-coding-system'."
+ (let ((file-coding-system coding-system)
+ jka-compr-compression-info-list jam-zcat-filename-list)
+ (write-region start end filename append visit lockname)))
+
+ (defun find-file-noselect-as-coding-system
+ (coding-system filename &optional nowarn rawfile)
+ "Like `find-file-noselect', q.v., but CODING-SYSTEM the first arg will
+be applied to `file-coding-system-for-read'."
+ (let ((file-coding-system-for-read coding-system))
+ (find-file-noselect filename nowarn rawfile)))
+ )
+ (t
+ ;; for MULE 2.3 based on Emacs 19.28.
+ (defun write-region-as-coding-system
+ (coding-system start end filename &optional append visit lockname)
+ "Like `write-region', q.v., but CODING-SYSTEM the first arg will be
+applied to `file-coding-system'."
+ (let ((file-coding-system coding-system)
+ jka-compr-compression-info-list jam-zcat-filename-list)
+ (write-region start end filename append visit)))
+
+ (defun find-file-noselect-as-coding-system
+ (coding-system filename &optional nowarn rawfile)
+ "Like `find-file-noselect', q.v., but CODING-SYSTEM the first arg will
+be applied to `file-coding-system-for-read'."
+ (let ((file-coding-system-for-read coding-system))
+ (find-file-noselect filename nowarn)))
+ ))
;;; @ buffer representation
@@ -399,37 +372,39 @@ If POS is out of range, the value is nil."
(defalias 'string-to-int-list 'string-to-char-list)
-;; Imported from Mule-2.3
-(defun-maybe truncate-string (str width &optional start-column)
- "\
+(or (fboundp 'truncate-string)
+ ;; Imported from Mule-2.3
+ (defun truncate-string (str width &optional start-column)
+ "\
Truncate STR to fit in WIDTH columns.
Optional non-nil arg START-COLUMN specifies the starting column.
\[emu-mule.el; Mule 2.3 emulating function]"
- (or start-column
- (setq start-column 0))
- (let ((max-width (string-width str))
- (len (length str))
- (from 0)
- (column 0)
- to-prev to ch)
- (if (>= width max-width)
- (setq width max-width))
- (if (>= start-column width)
- ""
- (while (< column start-column)
- (setq ch (aref str from)
- column (+ column (char-width ch))
- from (+ from (char-bytes ch))))
- (if (< width max-width)
- (progn
- (setq to from)
- (while (<= column width)
- (setq ch (aref str to)
- column (+ column (char-width ch))
- to-prev to
- to (+ to (char-bytes ch))))
- (setq to to-prev)))
- (substring str from to))))
+ (or start-column
+ (setq start-column 0))
+ (let ((max-width (string-width str))
+ (len (length str))
+ (from 0)
+ (column 0)
+ to-prev to ch)
+ (if (>= width max-width)
+ (setq width max-width))
+ (if (>= start-column width)
+ ""
+ (while (< column start-column)
+ (setq ch (aref str from)
+ column (+ column (char-width ch))
+ from (+ from (char-bytes ch))))
+ (if (< width max-width)
+ (progn
+ (setq to from)
+ (while (<= column width)
+ (setq ch (aref str to)
+ column (+ column (char-width ch))
+ to-prev to
+ to (+ to (char-bytes ch))))
+ (setq to to-prev)))
+ (substring str from to))))
+ )
(defalias 'looking-at-as-unibyte 'looking-at)

0 comments on commit dcebdbd

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