Commits

Anonymous committed ecb926b

maintainer update <874rji74h7.fsf@tleeps18.sk.tsukuba.ac.jp>

Comments (0)

Files changed (7)

+2002-03-15  Stephen J. Turnbull  <stephen@xemacs.org>
+
+	* latin-unity-latin9.el: Bind the EuroSign keysym.
+
+	* latin-unity.el (latin-unity-representations-present-region): Use
+	skipchars algorithm for a big speedup.
+	(latin-unity-maybe-remap): Fix broken bitvector tests.
+
+2002-03-07  Stephen J. Turnbull  <stephen@xemacs.org>
+
+	* Makefile (check): Cheesy new regression test.
+	(ELCS): Add latin-unity-latin9.elc.
+
+	* README (Implementation): Document latin-unity-latin9.el.
+
+	* latin-unity-latin9.el: Split out from latin-unity-vars.
+
+	* latin-unity.el (Requires): New latin-unity-latin9.
+	(latin-unity-sanity-check): Correct polarity of NO-ERROR in calls
+	to latin-unity-maybe-remap.
+	(latin-unity-maybe-remap): Document NO-ERROR.
+	(latin-unity-test): Old name, new function (regression testing).
+	(latin-unity-example): Renamed from latin-unity-test.
+
+	* latin-unity.texi (Basic Functionality): Document cl-macs
+	messages.  Cosmetic changes.
+	(Interactive Usage): Document name change to latin-unity-example
+	and new function of old name latin-unity-test.
+
 2002-03-05  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* latin-unity.el (latin-unity-guess-coding-system):
 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
+# Last-Modified: 14 March 2002
+
 # The XEmacs CVS version is canonical.  Keep versions n'sync.
 VERSION = 0.99
 AUTHOR_VERSION = 1.00
 CATEGORY = mule
 
 ELCS = latin-unity.elc latin-unity-vars.elc latin-euro-input.elc \
-       latin-unity-tables.elc latin-unity-utils.elc
+       latin-unity-latin9.elc latin-unity-tables.elc latin-unity-utils.elc
 
 # for defvars and creation of ISO 8859/15 charset and coding system
 PRELOADS=-l cl-macs -l latin-unity-vars.el
 # There should be a rule here to build latin-unity-tables.el.
 # Then add latin-unity-tables.elc to GENERATED.
 
+# We'd like this to be utf-8, but then pre-21.5.6 would have to depend on
+# Mule-UCS
+check: all
+	xemacs -no-autoloads -batch \
+		-eval "(setq load-path (cons \"`pwd`/\" load-path))" \
+		-l latin-unity-vars -l latin-unity \
+		-f latin-unity-install -f latin-unity-test \
+		-eval "(write-file \"./latintest\" nil 'iso-2022-7)"
+
 srckit: srckit-std
 
 binkit: binkit-common
 ***** latin-unity
 
+Last-modified: 2002 March 14
+
 Mule bogusly considers the various ISO-8859 extended character sets as
 disjoint, when ISO 8859 itself clearly considers them to be subsets of
 a larger character set.  For example, all of the Latin character sets
     ISO-2022-JP (including Latin-1 characters) to ISO 8859/1 if all
     the Japanese were deleted.  (untested)
 
-  o ISO 8859/15 for XEmacs 21.4 (lightly tested) and 21.1 (untested).
+  o ISO 8859/15 for XEmacs 21.4 (lightly tested) and 21.1 (untested),
+    including binding the EuroSign keysym to ISO 8859/15 0xA4.
     To get 'iso-8859-15 preferred to 'iso-8859-1 in autodetection, use
     (set-coding-category-system 'iso-8-1 'iso-8859-15).  (untested)
     Alternatively set language environment to Latin-9.
   o Hooks into `write-region' to prevent (or at least drastically
     reduce the probability of) introduction of ISO 2022 escape
     sequences for "foreign" character sets.  This hook is not set by
-    default in this package yet; try M-x latin-unity-test RET for a
+    default in this package yet; try M-x latin-unity-example RET for a
     short introduction and some useful C-x C-e'able exprs.
 
     This may permit us to turn off support for those sequences
 
 Current misfeatures:
 
+  o Must load latin-unity-vars before reading a file with ISO 8859/15,
+    there is no way to autoload a charset.
+
   o Need `(require 'latin-euro-input)' to get Quail support.
 
-  o If the buffer is changed by the hook, apparently write-region
-    starts over again from the top.  The buffer is checked again, and
-    you are asked to choose the coding system again.  If you choose
-    the same one, then the save goes through.
-
-    Note that if you choose a non-default coding system the first time
-    through, you will not get your choice as a default the second
-    time.  You'll get the same default as the first time.
-
-  o Probable performance hit on large (> 20kB) buffers with many
-    (>20%) non-ASCII characters.  Possible optimizations are given near
-    `latin-unity-region-feasible-representations' in latin-unity.el.
+  o Possible performance hit on large (> 20kB) buffers with many
+    (>20%) non-ASCII characters.  Partially optimized, but see near
+    `latin-unity-region-representations-feasible-region' in
+    latin-unity.el for possible further optimizations.
 
   o Package depends on Mule-UCS, LEIM (Quail), and fsf-compat.
 
   o Integration to development tree (but probably not 21.4, this
     package should be good enough).
 
-  o Charset completion for the interactive recoding/remapping functions.
-
   o Hook into MUAs.
 
   o GNU Emacs support.
 latin-unity-vars.el contains the definition of ISO 8859/15 and variables
 common to several modules.
 
+latin-unity-latin9.el defines the Latin-9 environment.  It contains
+Latin-9 characters so cannot be part of latin-unity-vars.el.
+
 latin-euro-input.el contains Dave Love's Quail input method for Latin 9.
 
 latin-unity-tables.el contains the table of feasible character sets and
-;;; latin-9-input.el --- Input method for Latin-9 (ISO 8859/15) -*- coding: iso-2022-jp -*-
+;;; latin-euro-input.el --- Input method for Latin-9 (ISO 8859/15) -*- coding: iso-2022-jp -*-
 
 ;; Copyright (C) 2001, 2002 Free Software Foundation, Inc
 
 ;; Author: Dave Love
 ;; Adapted-by: Stephen J. Turnbull for XEmacs
 ;; Keywords: mule, input methods
-;; Created: 2002 March 1
-;; Last-modified: 2002 March 1
+;; Added: 2002 March 1
+;; Last-modified: 2002 March 14
 
 ;; This file is part of XEmacs.
 
  ("~=" ?,b/(B)
  ("/=" ?,b,(B))
 
+(provide 'latin-euro-input)
+
+;; end of latin-euro-input.el
 ;; Author: Stephen J. Turnbull
 ;; Keywords: mule, charsets
 ;; Created: 2002 January 26
-;; Last-modified: 2002 January 26
+;; Last-modified: 2002 March 7
 
 ;; This file is part of XEmacs.
 
 
 ;; Provides the 'iso-8859-15 coding system if not yet defined.
 
+;; This file must not contain non-builtin charsets outside of comments,
+;; due to a bug fixed in XEmacs 21.4.7/21.5.7.  For that reason, the Latin-9
+;; language environment is provided in latin-unity-latin9.el.
+
 ;;; Code:
 
 (provide 'latin-unity-vars)
      charset-g2 t			; grrr
      charset-g3 t			; grrr
      mnemonic "MIME/Ltn-9")))
-(defun setup-latin9-environment ()
-  "Set up multilingual environment (MULE) for European Latin-9 users."
-  (interactive)
-  (set-language-environment "Latin-9"))
-
-(set-language-info-alist
- "Latin-9" '((charset ascii latin-iso8859-15)
-	     (coding-system iso-8859-15)
-	     (coding-priority iso-8859-15)
-	     (input-method . "latin-9-prefix")
-	     (sample-text
-	      ;; I'd like to append ", my ,b$(B0.02" to the following string,
-	      ;; but can't due to a bug in escape-quoted support
-	      ;; NB: convert the Latin-1 to Latin-9 when possible
-	      . "Hello, Hej, Tere, Hei, Bonjour, Gr,b|_(B Gott, Ciao, ,b!(BHola!, my ,b$(B0.02")
-	     (documentation . "\
-This language environment is a generic one for Latin-9 (ISO-8859-15)
-character set which supports the Euro and the following languages:
- Danish, Dutch, English, Faeroese, Finnish, French, German, Icelandic,
- Irish, Italian, Norwegian, Portuguese, Spanish, and Swedish.
-We also have a German specific language environment \"German\"."))
- '("European"))
-;)
 
 ;; latin-unity-equivalence-table
 ;; could speed things up a tiny bit by splitting out the bit-vector, but
 ;; Author: Stephen J. Turnbull
 ;; Keywords: mule, charsets
 ;; Created: 2002 January 17
-;; Last-modified: 2002 January 21
+;; Last-modified: 2002 March 14
 
 ;; This file is part of XEmacs.
 
 ;;; Requires
 ;; Do NOT require latin-unity-utils; that requires Mule-UCS.
 
-(require 'latin-unity-vars)
+(require 'latin-unity-vars)		; define iso-8859-15
+(require 'latin-unity-latin9)		; uses iso-8859-15
 (require 'latin-unity-tables)
 
 
 
 
 ;; #### possibly it would be faster to do this in the previous function
-;; however, this is not obvious because this function is quite fast (the
-;; region mapping is all in C), and therefore we can short-circuit the
-;; slow Lisp function above
+;; charsets-in-region is in Lisp and quite slow.  :-(
 (defun latin-unity-representations-present-region (begin end &optional buffer)
   "Return a cons of two bit vectors giving character sets in region.
 
 character sets.  BUFFER defaults to the current buffer."
 
   (let ((lsets 0)
-	(asets 0))
-    (mapc
-     (lambda (cs)
-       (cond ((memq cs '(ascii latin-jisx0201))
-	      (setq asets (logior (get cs 'latin-unity-flag-bit) asets)))
-	     ((get cs 'latin-unity-bit-flag)
-	      (setq lsets (logior (get cs 'latin-unity-flag-bit) lsets)))))
-     (save-excursion
-       (set-buffer (or buffer (current-buffer)))
-       (save-restriction
-	 (widen)
-	 ;; #### not quite right, should test
-	 (charsets-in-region (or begin (point-min))
-			     (or end (and (null begin) (point-max)))))))
+	(asets 0)
+	(skipchars ""))
+    (save-excursion
+      (set-buffer (or buffer (current-buffer)))
+      (save-restriction
+	;; #### not quite right, should test
+	(narrow-to-region (or begin (point-min))
+			  (or end (and (null begin) (point-max))))
+	(goto-char (point-min))
+	(while (not (eobp))
+	  (let* ((ch (char-after))
+		 (cs (car (split-char ch))))
+	    (cond
+	     ((eq cs 'ascii)
+	      (setq skipchars (concat "\000-\177" skipchars))
+	      (setq asets (logior (get cs 'latin-unity-flag-bit 0) asets)))
+	     ((eq cs 'latin-jisx0201)
+	      ;; #### get this someday
+	      ;;(setq skipchars (concat skipchars latin-unity-latin-jisx0201))
+	      (setq skipchars (concat skipchars (list ch)))
+	      (setq asets (logior (get cs 'latin-unity-flag-bit 0) asets)))
+	     (t
+	      ;; #### actually we can do the whole charset here
+	      ;; precompute and set a property on the cs symbol
+	      (setq skipchars (concat skipchars (list ch)))
+	      (setq lsets (logior (get cs 'latin-unity-flag-bit 0) lsets)))))
+	  ;; The characters skipped here can't change asciisets
+	  (skip-chars-forward skipchars))))
     (cons lsets asets)))
 
-
 ;; #### I see nothing useful to be done with APPEND.
 ;; FILENAME, VISIT, or LOCKNAME could be used to default the coding system,
 ;; but this would conflict with the semantics of `write-region'.
 ;; #### The efficiency of this function can clearly be improved.
+;; #### Maybe this function should have a no-ask for the sake of testing?
+
+(defcustom latin-unity-like-to-live-dangerously nil
+  "Suppress warnings about failure to remap buffer."
+  :type 'boolean
+  :group 'latin-unity)
 
 ;;;###autoload
 (defun latin-unity-sanity-check (begin end filename append visit lockname
 This function is intended for use as a `write-region-pre-hook'.  It does
 nothing except return nil if `write-region' handlers are inhibited."
 
-  (let ((buffer-default
-	 ;; theoretically we could look at other write-region-prehooks,
-	 ;; but they might write the buffer and we lose bad
-	 (or coding-system
-	     buffer-file-coding-system
-	     (find-file-coding-system-for-write-from-filename filename)))
-	(preferred (coding-category-system (car (coding-priority-list))))
-	;; check what representations are feasible
-	;; csets == compatible character sets as (latin . ascii)
-	(csets (latin-unity-representations-feasible-region begin end))
-	;; as an optimization we also check for what's in the buffer
-	;; psets == present in buffer character sets as (latin . ascii)
-	(psets (latin-unity-representations-present-region begin end)))
-    (when latin-unity-debug
-      ;; cheezy debug code
-      (cond ((null csets) (error "no feasible reps vectors?!?"))
-	    ((null (cdr csets)) (error "no ascii reps vector?!?"))
-	    ((null (car csets)) (error "no latin reps vector?!?"))
-	    ((null psets) (error "no reps present vectors?!?"))
-	    ((null (cdr psets)) (error "no ascii reps present vector?!?"))
-	    ((null (car psets)) (error "no latin reps present vector?!?"))
-	    ((null (get 'ascii 'latin-unity-flag-bit))
-	     (error "no flag bit for ascii?!?")))
-      (message "%s %s" csets psets)
-      (sit-for 1))
+  ;; don't do anything if we're in a `write-region' handler
+  (if (eq inhibit-file-name-operation 'write-region)
+      ;; is this the right return value?
+      nil
+    (let ((buffer-default
+	   ;; theoretically we could look at other write-region-prehooks,
+	   ;; but they might write the buffer and we lose bad
+	   (or coding-system
+	       buffer-file-coding-system
+	       (find-file-coding-system-for-write-from-filename filename)))
+	  (preferred (coding-category-system (car (coding-priority-list))))
+	  ;; check what representations are feasible
+	  ;; csets == compatible character sets as (latin . ascii)
+	  (csets (latin-unity-representations-feasible-region begin end))
+	  ;; as an optimization we also check for what's in the buffer
+	  ;; psets == present in buffer character sets as (latin . ascii)
+	  (psets (latin-unity-representations-present-region begin end)))
+      (when latin-unity-debug
+	;; cheezy debug code
+	(cond ((null csets) (error "no feasible reps vectors?!?"))
+	      ((null (cdr csets)) (error "no ascii reps vector?!?"))
+	      ((null (car csets)) (error "no latin reps vector?!?"))
+	      ((null psets) (error "no reps present vectors?!?"))
+	      ((null (cdr psets)) (error "no ascii reps present vector?!?"))
+	      ((null (car psets)) (error "no latin reps present vector?!?"))
+	      ((null (get 'ascii 'latin-unity-flag-bit))
+	       (error "no flag bit for ascii?!?")))
+	(message "%s %s" csets psets)
+	(sit-for 1))
 
-    (cond
+      (cond
+       ;; try the preapproved systems
+       ((catch 'done
+	  (let ((systems latin-unity-preapproved-coding-system-list)
+		(sys (car latin-unity-preapproved-coding-system-list)))
+	    ;; while always returns nil
+	    (while systems
+	      ;; #### to get rid of this we probably need to preprocess
+	      ;; latin-unity-preapproved-coding-system-list
+	      (setq sys (cond ((and (eq sys 'buffer-default) buffer-default))
+			      ((and (eq sys 'preferred) preferred))
+			      (t sys)))
+	      (when (latin-unity-maybe-remap begin end sys csets psets t)
+		(throw 'done sys))
+	      (setq systems (cdr systems))
+	      (setq sys (car systems))))))
 
-     ;; don't do anything if we're in a `write-region' handler
-     ;; is this the right return value?
-     ((eq inhibit-file-name-operation 'write-region) nil)
+       ;; ask the user about the preferred systems
+       ;; #### RFE: It also would be nice if the offending characters
+       ;; were marked in the buffer being checked.
+       (t (let* ((recommended
+		  (latin-unity-recommend-representation begin end csets))
+		 (codesys (car recommended))
+		 ;(charset (cdr recommended)) ; unused?
+		 )
+	    (when latin-unity-debug (message "%s" recommended))
+	    ;; compute return
+	    (cond
 
-     ;; try the preapproved systems
-     ((catch 'done
-	(let ((systems latin-unity-preapproved-coding-system-list)
-	      (sys (car latin-unity-preapproved-coding-system-list)))
-	  ;; while always returns nil
-	  (while systems
-	    ;; #### to get rid of this we probably need to preprocess
-	    ;; latin-unity-preapproved-coding-system-list
-	    (setq sys (cond ((and (eq sys 'buffer-default) buffer-default))
-			    ((and (eq sys 'preferred) preferred))
-			    (t sys)))
-	    (when (latin-unity-maybe-remap begin end sys csets psets)
-	      (throw 'done sys))
-	    (setq systems (cdr systems))
-	    (setq sys (car systems))))))
+	     ;; universal coding systems
+	     ;; #### we might want to unify here if the codesys is ISO 2022
+	     ;; but we don't have enough information to decide
+	     ((memq codesys latin-unity-ucs-list) codesys)
 
-     ;; ask the user about the preferred systems
-     ;; #### RFE: It also would be nice if the offending characters
-     ;; were marked in the buffer being checked.
-     (t (let* ((recommended
-		(latin-unity-recommend-representation begin end csets))
-	       (codesys (car recommended))
-	       (charset (cdr recommended)))
-	  (when latin-unity-debug (message "%s" recommended))
-	  ;; compute return
-	  (cond
+	     ;; ISO 2022 (including ISO 8859) compatible systems
+	     ;; #### maybe we should check for G2 and G3 sets
+	     ;; note the special case is necessary, as 'iso-8859-1 is NOT
+	     ;; type 'iso2022, it's type 'no-conversion
+	     ((or (memq codesys latin-unity-iso-8859-1-aliases)
+		  (eq (coding-system-type codesys) 'iso2022))
+	      ;; #### make sure maybe-remap always returns a coding system
+	      ;; #### I thought about like-to-live-dangerously here,
+	      ;; but first make sure make sure maybe-remap returns nil
+	      (when (latin-unity-maybe-remap begin end codesys csets psets nil)
+		codesys))
 
-	   ;; universal coding systems
-	   ;; #### we might want to unify here if the codesys is ISO 2022
-	   ;; but we don't have enough information to decide
-	   ((memq codesys latin-unity-ucs-list) codesys)
+	     ;; other coding systems -- eg Windows 125x, KOI8?
+	     ;; #### unimplemented
 
-	   ;; ISO 2022 (including ISO 8859) compatible systems
-	   ;; #### maybe we should check for G2 and G3 sets
-	   ;; note the special case is necessary, as 'iso-8859-1 is NOT
-	   ;; type 'iso2022, it's type 'no-conversion
-	   ((or (memq codesys latin-unity-iso-8859-1-aliases)
-		(eq (coding-system-type codesys) 'iso2022))
-	    ;; #### make sure maybe-remap always returns a coding system
-	    (when (latin-unity-maybe-remap begin end codesys csets psets)
-	      codesys))
+	     ;; no luck, pass the buck back to `write-region'
+	     ;; #### we really shouldn't do this, defeats the purpose
+	     (t (unless latin-unity-like-to-live-dangerously
+		  (warn (concat "Passing to default coding system,"
+				" data corruption likely"))
+		  (ding)
+		  nil))
+	     )))
+       ))))
 
-	   ;; other coding systems -- eg Windows 125x, KOI8?
-	   ;; #### unimplemented
 
-	   ;; no luck, pass the buck back to `write-region'
-	   ;; #### we really shouldn't do this, defeats the purpose
-	   (t (unless latin-unity-like-to-live-dangerously
-		(warn (concat "Passing to default coding system,"
-			      " data corruption likely"))
-		(ding)
-		nil))
-	   )))
-     )))
-
-
+;; #### maybe this is what we want to test?  add a no-ask flag.
 (defun latin-unity-recommend-representation (begin end feasible
 					     &optional buffer)
   "Recommend a representation for BEGIN to END from FEASIBLE in BUFFER.
 		  (widen)
 		  (let ((begin (or begin (point-min)))
 			(end (or end (point-max))))
+		    ;; #### this function is slow!
 		    (charsets-in-region begin end))))))
       (insert "
 
 			 (coding-system-property val 'charset-g1)))))))))
 
 ;; this could be a flet in latin-unity-sanity-check
-(defun latin-unity-maybe-remap (begin end codesys feasible &optional present)
+;; -- no, this is what we want to test?
+;; #### this function's interface needs to change, s/codesys/charset/
+;; #### did you update all calls?
+;; #### did you update all docs?
+(defun latin-unity-maybe-remap (begin end codesys feasible
+				&optional present no-error)
   "Try to remap from BEGIN to END to CODESYS.  Return nil on failure.
 
 Return CODESYS on success.  CODESYS is a coding system or nil.
 can represent all non-ASCII characters and ASCII characters, respectively,
 in the current buffer.
 PRESENT is a cons of bitvectors indicating the set of non-ASCII and ASCII
-character sets, respectively, present in the current buffer."
+character sets, respectively, present in the current buffer.
+
+Pass NO-ERROR to `latin-unity-remap-region'."
 
   ;; may God bless and keep the Mule ... far away from us!
   (when (memq codesys latin-unity-iso-8859-1-aliases)
      ;; this is just an optimization, as the next arm should catch it
      ;; note we can assume ASCII here, as if GL is JIS X 0201 Roman,
      ;; GR will be JIS X 0201 Katakana
-     ((and (= (logxor (get 'ascii 'latin-unity-flag-bit) (cdr present)) 0)
-	   (= (logxor (get gr 'latin-unity-flag-bit 0) (car present)) 0))
+     ((and (/= (cdr present) 0)
+	   (/= (car present) 0)
+	   (= (get 'ascii 'latin-unity-flag-bit) (cdr present))
+	   (= (get gr 'latin-unity-flag-bit 0) (car present)))
       codesys)
      ;; we represent everything in the buffer with remapping
-     ((and (logand (get 'ascii 'latin-unity-flag-bit) (cdr feasible))
-	   (logand (get gr 'latin-unity-flag-bit 0) (car feasible)))
-      (progn (when latin-unity-debug (message "trying remap")) t)
-      (latin-unity-remap-region begin end gr codesys))
+     ((and (/= (logand (get 'ascii 'latin-unity-flag-bit) (cdr feasible)) 0)
+	   (/= (logand (get gr 'latin-unity-flag-bit 0) (car feasible)) 0))
+      (when latin-unity-debug (message "trying remap"))
+      (latin-unity-remap-region begin end gr codesys no-error))
      (t nil))))
 
 
 To recode characters that were decoded in the wrong coding system, use
 `latin-unity-recode-region'."
 
-  (interactive "*r\nSCharacter set: ")
   (interactive
    (let ((begin (region-beginning))
 	 (end (region-end)))
 
 	(let ((remaining (delq character-set
 			       (delq 'ascii
+				     ;; #### this function is slow!
 				     (charsets-in-region begin end)))))
 	  (when (or remaining latin-unity-debug)
 	    (message (format "Could not remap characters from %s to %s"
 	  (cond ((memq coding-system latin-unity-ucs-list) coding-system)
 		((null remaining)
 		 (or coding-system
-		     (cdr (assq codesys latin-unity-cset-codesys-alist))
+		     (cdr (assq coding-system latin-unity-cset-codesys-alist))
 		     ;; #### Is this the right thing to do here?
 		     t))
 		(t (unless no-error (error 'args-out-of-range
       coding-system)))
 
 
+;; tests
+(defun latin-unity-test ()
+  "Test the latin-unity package.  Requires mule-ucs, but easy to generalize.
+
+You need to run `latin-unity-install' first."
+
+  (interactive)
+
+  ;; save variables we intend to trash
+  (put 'latin-unity-test 'ucs-list latin-unity-ucs-list)
+  (put 'latin-unity-test 'preapproved
+       latin-unity-preapproved-coding-system-list)
+  (put 'latin-unity-test 'preferred
+       latin-unity-preferred-coding-system-list)
+  (put 'latin-unity-test 'default buffer-file-coding-system)
+
+  (pop-to-buffer "*latin-unity test*")
+  (erase-buffer)
+
+  ;; #### need to check error conditions and stuff too
+  (mapc (lambda (test)
+	  (let ((coding-system (car test))
+		(string (cdr test)))
+	    (setq buffer-file-coding-system coding-system)
+	    (goto-char (point-max))
+	    (let ((a (point)))
+	      (insert string)
+	      (let ((b (point))
+		    (coding-system-for-read coding-system))
+		(insert "\n")
+		(write-region a b "/tmp/test-latin-unity")
+		(goto-char (+ (point)
+			      (second (insert-file-contents
+				       "/tmp/test-latin-unity"))))
+		(if (string= (buffer-substring a b)
+			     (buffer-substring (1+ b) (point)))
+		    (insert "\nPassed.\n")
+		  (insert "\nFailed.\n"))))))
+	(list
+	 ;; Erwan David's example
+	 (cons 'iso-8859-15
+	       (concat "test accentu"
+		       (list (make-char 'latin-iso8859-1 #x69))
+		       ", avec "
+		       (list (make-char 'latin-iso8859-15 #x24))
+		       "uro."))
+	 ))
+
+  ;; restore variables we trashed
+  (setq latin-unity-ucs-list (get 'latin-unity-test 'ucs-list))
+  (setq latin-unity-preapproved-coding-system-list
+	(get 'latin-unity-test 'preapproved))
+  (setq latin-unity-preferred-coding-system-list
+	(get 'latin-unity-test 'preferred))
+  (setq buffer-file-coding-system (get 'latin-unity-test 'default))
+  )
+
+
 ;;;###autoload  
-(defun latin-unity-test ()
-  "Test the latin-unity package.
+(defun latin-unity-example ()
+  "An example of the latin-unity package.
 
 At present it just makes a multilingual buffer.  To test, setq
 buffer-file-coding-system to some value, make the buffer dirty (eg
 with RET BackSpace), and save."
 
   (interactive)
-  (switch-to-buffer (get-buffer-create "latin-unity test"))
+  (switch-to-buffer (get-buffer-create "latin-unity example"))
   (erase-buffer)
   (insert "From here ...\n")
   (insert "Latin-1: f")
 
 M-: (latin-unity-uninstall) RET.
 
-Note:  the *install functions are interactive, I wrote them as above so you
-can C-x C-e them in this buffer.
+Note:  the *install functions are interactive---you can execute with M-x.
+I wrote them as above so you can C-x C-e them in this buffer.
 "))
 
 ;;; end of latin-unity.el
 @c %**end of header
 
 @c Version values, for easy modification
-@set VERSION 0.8
-@set UPDATED Sunday 24 February 2002
+@set VERSION 0.9
+@set UPDATED Thursday 2002 March 7
 
 @c ** Many people seem to prefer this footenote style
 @footnotestyle end
 * What latin-unity Cannot Do for You::  Inherent problems of 8-bit charsets.
 
 For programmers:
-@c * Interfaces::                  Calling @pkgname{} from Lisp code.
+* Interfaces::                  Calling @pkgname{} from Lisp code.
 * Charsets and Coding Systems:: Reference lists with annotations.
 
 For maintainers:
 
 This function is idempotent.  It will reinitialize any hooks or variables
 that are not in initial state.
+
+Note: a quirk in XEmacs means that the @file{cl-macs} library cannot be
+required, it must be loaded explicitly.  This means that if you invoke
+@samp{latin-unity-install} in your init file, XEmacs will print
+@example
+Loading cl-macs...
+Loading cl-macs...done
+@end example
+on your console, as these messages have not yet been redirected to the
+@samp{ *Message-Log*} buffer.
 @end defun
 
 
 @defun latin-unity-uninstall
-
 There are no arguments.
 
 Clean up hooks and void variables used by latin-unity.
 
 
 @defopt latin-unity-ucs-list
+List of coding systems considered to be universal.
+
 The default value is @code{'(utf-8 iso-2022-7 ctext escape-quoted)}.
 
-List of coding systems considered to be universal.
-
 Order matters; coding systems earlier in the list will be preferred when
 recommending a coding system.
 
 @end defun
 
 
-@defun latin-unity-test
+@defun latin-unity-example
 
-Really cheesy tests for @pkgname{}.
+A cheesy example for @pkgname{}.
 
 At present it just makes a multilingual buffer.  To test, setq
 buffer-file-coding-system to some value, make the buffer dirty (eg
 with RET BackSpace), and save.
 @end defun
 
+@defun latin-unity-test
+
+A simple automated test suite for latin-unity.
+@end defun
+
 
 @node Installation, Configuration, Usage, Top
 @chapter Installing @pkgname{} with your (X)Emacs
 Usage}.
 
 
-@node What latin-unity Cannot Do for You, Charsets and Coding Systems, Theory of Operation, Top
+@node What latin-unity Cannot Do for You, Interfaces, Theory of Operation, Top
 @chapter What latin-unity Cannot Do for You
 
 @pkgname{} @strong{cannot} save you if you insist on exporting data in
 that @emph{this is German and Swedish} and stays in Latin-1, while
 @emph{that is Polish} and needs to be recoded to Latin-2.
 
-@node Charsets and Coding Systems, Internals, What latin-unity Cannot Do for You, Top
+@node Interfaces, Charsets and Coding Systems, What latin-unity Cannot Do for You, Top
+@chapter Interfaces
+
+The Latin-9 language environment is provided in
+@file{latin-unity-latin9.el}.  This file when compiled contains Latin 9
+characters, so you @strong{must} load @file{latin-unity-vars.el} first
+to define those characters.  Otherwise the Lisp reader is likely to
+signal an error due to stray ISO 2022 control sequences.
+
+Sorry, that's all I have to say for now---but it's important!
+
+@node Charsets and Coding Systems, Internals, Interfaces, Top
 @chapter Charsets and Coding Systems
 
 This section provides reference lists of Mule charsets and coding