21.5
Ben, please comment on whether this patch will interfere with synchs we
should do. I had great trouble understanding the code, and I think
this is much clearer (in addition to doing some sanity checks), but
I'll defer to your opinion.
Use "patch -p1" to apply.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 86e6e6c..c1ae6fc 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -0,0 +1,5 @@
+2006-05-20 Stephen J. Turnbull <stephen(a)xemacs.org>
+
+ * code-cmds.el: Update FSF copyright; improve header comment.
+ (coding-system-change-eol-conversion): Clarify, add sanity check.
+
diff --git a/lisp/code-cmds.el b/lisp/code-cmds.el
index f369ce2..51904d6 100644
--- a/lisp/code-cmds.el
+++ b/lisp/code-cmds.el
@@ -2,7 +2,7 @@
;; Copyright (C) 1995,1999 Electrotechnical Laboratory, JAPAN.
;; Licensed to the Free Software Foundation.
-;; Copyright (C) 2000 Free Software Foundation
+;; Copyright (C) 2000,2006 Free Software Foundation
;; Copyright (C) 1997 MORIOKA Tomohiko
;; Copyright (C) 2001, 2002 Ben Wing.
@@ -27,8 +27,8 @@
;;
;; This code defines the keybindings and utility commands for the
;; user to manipulate coding systems.
-;; This code used to be in mule-cmds.el which now only needs the
-;; additional bindings/commands that are avaible on the real mule.
+;; This code used to be in mule-cmds.el which now contains only the
+;; additional bindings/commands that are available for full Mule.
;;; Code:
@@ -53,41 +53,31 @@
(define-key coding-keymap "x" 'set-selection-coding-system)
(define-key coding-keymap "X" 'set-next-selection-coding-system))
+;; XEmacs change: make code readable, and sanity-check EOL-TYPE.
(defun coding-system-change-eol-conversion (coding-system eol-type)
- "Return a coding system which differs from CODING-SYSTEM in eol conversion.
-The returned coding system converts end-of-line by EOL-TYPE
-but text as the same way as CODING-SYSTEM.
-EOL-TYPE should be `lf', `crlf', `cr' or nil.
-If EOL-TYPE is nil, the returned coding system detects
-how end-of-line is formatted automatically while decoding.
-
-EOL-TYPE can be specified by an symbol `unix', `dos' or `mac'.
-They means `lf', `crlf', and `cr' respectively."
- (if (symbolp eol-type)
- (setq eol-type (cond ((or (eq eol-type 'unix)
- (eq eol-type 'lf))
- 'eol-lf)
- ((or (eq eol-type 'dos)
- (eq eol-type 'crlf))
- 'eol-crlf)
- ((or (eq eol-type 'mac)
- (eq eol-type 'cr))
- 'eol-cr)
- (t eol-type))))
+ "Return a version of CODING-SYSTEM that provides EOL-TYPE eol conversion.
+EOL-TYPE should be `lf', `crlf', `cr' or nil. nil means the returned coding
+system automatically detects the end-of-line convention while decoding.
+EOL-TYPE may also be one of the symbols `unix', `dos' or `mac', meaning
+`lf', `crlf', and `cr' respectively."
+ (setq eol-type (cond ((or (eq eol-type 'unix) (eq eol-type 'lf)) 'eol-lf)
+ ((or (eq eol-type 'dos) (eq eol-type 'crlf)) 'eol-crlf)
+ ((or (eq eol-type 'mac) (eq eol-type 'cr)) 'eol-cr)
+ ((null eol-type) nil)
+ (t (error 'invalid-constant eol-type))))
(coding-system-name
- (let ((orig-eol-type (coding-system-eol-type coding-system)))
- (if (null orig-eol-type)
- (if (not eol-type)
- coding-system
- (coding-system-property coding-system eol-type))
- (let ((base (coding-system-base coding-system)))
- (if (not eol-type)
- base
- (if (eq eol-type orig-eol-type)
- coding-system
- (setq orig-eol-type (coding-system-eol-type base))
- (if (null orig-eol-type)
- (coding-system-property base eol-type)))))))))
+ (let ((orig-eol-type (coding-system-eol-type coding-system))
+ (base (coding-system-base coding-system)))
+ (cond ((eq eol-type orig-eol-type) coding-system)
+ ((null orig-eol-type)
+ (coding-system-property coding-system eol-type))
+ ((null eol-type) base)
+ ((null (coding-system-eol-type base))
+ (coding-system-property base eol-type))
+ (t (warn "Please report bug: couldn't change EOL conversion of %s."
+ coding-system)
+ ;; return nil for compatibility with old code
+ nil)))))
;; (defun coding-system-change-text-conversion (coding-system coding)
;; "Return a coding system which differs from CODING-SYSTEM in text conversion.
--
Graduate School of Systems and Information Engineering University of Tsukuba
http://turnbull.sk.tsukuba.ac.jp/ Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
Economics of Information Communication and Computation Systems
Experimental Economics, Microeconomic Theory, Game Theory