(list-character-sets-2): Don't print
[bpt/emacs.git] / lisp / international / iso-cvt.el
index c05bda7..eb94794 100644 (file)
@@ -1,7 +1,8 @@
-;;; iso-cvt.-el -- translate ISO 8859-1 from/to various encodings -*- coding: iso-latin-1 -*-
+;;; iso-cvt.el --- translate ISO 8859-1 from/to various encodings -*- coding: iso-latin-1 -*-
 ;; This file was formerly called gm-lingo.el.
 
-;; Copyright (C) 1993, 1994, 1995, 1996, 1998, 2000 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001,
+;;   2002, 2003, 2004, 2005, 2006, 2007  Free Software Foundation, Inc.
 
 ;; Author: Michael Gschwind <mike@vlsivie.tuwien.ac.at>
 ;; Keywords: tex, iso, latin, i18n
@@ -20,8 +21,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 ;; This lisp code is a general framework for translating various
 ; If you are interested in questions related to using the ISO 8859-1
 ; characters set (configuring emacs, Unix, etc. to use ISO), then you
 ; can get the ISO 8859-1 FAQ via anonymous ftp from
-; ftp.vlsivie.tuwien.ac.at in /pub/bit/FAQ-ISO-8859-1
+; ftp.vlsivie.tuwien.ac.at in /pub/8bit/FAQ-ISO-8859-1
 
 ;;; Code:
 
-(require 'format)
-
 (defvar iso-spanish-trans-tab
   '(
     ("~n" "ñ")
@@ -86,8 +85,7 @@
 (defun iso-spanish (from to &optional buffer)
   "Translate net conventions for Spanish to ISO 8859-1.
 The region between FROM and TO is translated using the table TRANS-TAB.
-Optional arg BUFFER is ignored (so that the function can can be used in
-`format-alist')."
+Optional arg BUFFER is ignored (for use in `format-alist')."
   (interactive "*r")
   (iso-translate-conventions from to iso-spanish-trans-tab))
 
@@ -128,11 +126,10 @@ little.")
 (defun iso-german (from to &optional buffer)
  "Translate net conventions for German to ISO 8859-1.
 The region between FROM and TO is translated using the table TRANS-TAB.
-Optional arg BUFFER is ignored (so that the function can can be used in
-`format-alist')."
+Optional arg BUFFER is ignored (for use in `format-alist')."
  (interactive "*r")
  (iso-translate-conventions from to iso-german-trans-tab))
+
 (defvar iso-iso2tex-trans-tab
   '(
     ("ä" "{\\\\\"a}")
@@ -201,8 +198,7 @@ Optional arg BUFFER is ignored (so that the function can can be used in
 (defun iso-iso2tex (from to &optional buffer)
  "Translate ISO 8859-1 characters to TeX sequences.
 The region between FROM and TO is translated using the table TRANS-TAB.
-Optional arg BUFFER is ignored (so that the function can can be used in
-`format-alist')."
+Optional arg BUFFER is ignored (for use in `format-alist')."
  (interactive "*r")
  (iso-translate-conventions from to iso-iso2tex-trans-tab))
 
@@ -269,10 +265,16 @@ Optional arg BUFFER is ignored (so that the function can can be used in
     ("\\\\`e" "è")
     ("\\\\'e" "é")
     ("\\\\^e" "ê")
-    ("\\\\\"\\\\i" "ï")
-    ("\\\\`\\\\i" "ì")
-    ("\\\\'\\\\i" "í")
-    ("\\\\^\\\\i" "î")
+    ;; Discard spaces and/or one EOF after macro \i.
+    ;; Converting it back will use braces.
+    ("\\\\\"\\\\i *\n\n" "ï\n\n")
+    ("\\\\\"\\\\i *\n?" "ï")
+    ("\\\\`\\\\i *\n\n" "ì\n\n")
+    ("\\\\`\\\\i *\n?" "ì")
+    ("\\\\'\\\\i *\n\n" "í\n\n")
+    ("\\\\'\\\\i *\n?" "í")
+    ("\\\\^\\\\i *\n\n" "î\n\n")
+    ("\\\\^\\\\i *\n?" "î")
     ("\\\\\"i" "ï")
     ("\\\\`i" "ì")
     ("\\\\'i" "í")
@@ -388,8 +390,7 @@ contains commonly used sequences.")
 (defun iso-tex2iso (from to &optional buffer)
  "Translate TeX sequences to ISO 8859-1 characters.
 The region between FROM and TO is translated using the table TRANS-TAB.
-Optional arg BUFFER is ignored (so that the function can can be used in
-`format-alist')."
+Optional arg BUFFER is ignored (for use in `format-alist')."
  (interactive "*r")
  (iso-translate-conventions from to iso-tex2iso-trans-tab))
 
@@ -647,8 +648,7 @@ contains commonly used sequences.")
 (defun iso-gtex2iso (from to &optional buffer)
  "Translate German TeX sequences to ISO 8859-1 characters.
 The region between FROM and TO is translated using the table TRANS-TAB.
-Optional arg BUFFER is ignored (so that the function can can be used in
-`format-alist')."
+Optional arg BUFFER is ignored (for use in `format-alist')."
  (interactive "*r")
  (iso-translate-conventions from to iso-gtex2iso-trans-tab))
 
@@ -656,8 +656,7 @@ Optional arg BUFFER is ignored (so that the function can can be used in
 (defun iso-iso2gtex (from to &optional buffer)
  "Translate ISO 8859-1 characters to German TeX sequences.
 The region between FROM and TO is translated using the table TRANS-TAB.
-Optional arg BUFFER is ignored (so that the function can can be used in
-`format-alist')."
+Optional arg BUFFER is ignored (for use in `format-alist')."
  (interactive "*r")
  (iso-translate-conventions from to iso-iso2gtex-trans-tab))
 
@@ -674,8 +673,7 @@ Optional arg BUFFER is ignored (so that the function can can be used in
 (defun iso-iso2duden (from to &optional buffer)
  "Translate ISO 8859-1 characters to German TeX sequences.
 The region between FROM and TO is translated using the table TRANS-TAB.
-Optional arg BUFFER is ignored (so that the function can can be used in
-`format-alist')."
+Optional arg BUFFER is ignored (for use in `format-alist')."
  (interactive "*r")
  (iso-translate-conventions from to iso-iso2duden-trans-tab))
 
@@ -793,6 +791,7 @@ Optional arg BUFFER is ignored (so that the function can can be used in
     ("&iuml;" "ï")
     ("&eth;" "ð")
     ("&ntilde;" "ñ")
+    ("&nbsp;" " ")
     ("&ograve;" "ò")
     ("&oacute;" "ó")
     ("&ocirc;" "ô")
@@ -811,8 +810,7 @@ Optional arg BUFFER is ignored (so that the function can can be used in
 (defun iso-iso2sgml (from to &optional buffer)
  "Translate ISO 8859-1 characters in the region to SGML entities.
 The entities used are from \"ISO 8879:1986//ENTITIES Added Latin 1//EN\".
-Optional arg BUFFER is ignored (so that the function can can be used in
-`format-alist')."
+Optional arg BUFFER is ignored (for use in `format-alist')."
  (interactive "*r")
  (iso-translate-conventions from to iso-iso2sgml-trans-tab))
 
@@ -820,8 +818,7 @@ Optional arg BUFFER is ignored (so that the function can can be used in
 (defun iso-sgml2iso (from to &optional buffer)
  "Translate SGML entities in the region to ISO 8859-1 characters.
 The entities used are from \"ISO 8879:1986//ENTITIES Added Latin 1//EN\".
-Optional arg BUFFER is ignored (so that the function can can be used in
-`format-alist')."
+Optional arg BUFFER is ignored (for use in `format-alist')."
  (interactive "*r")
  (iso-translate-conventions from to iso-sgml2iso-trans-tab))
 
@@ -836,71 +833,70 @@ Optional arg BUFFER is ignored (so that the function can can be used in
   "Warn that format is write-only."
   (interactive)
   (error "This format is write-only"))
-                        
+
 ;;;###autoload
 (defun iso-cvt-define-menu ()
-  "Add submenus to the Files menu, to convert to and from various formats."
+  "Add submenus to the File menu, to convert to and from various formats."
   (interactive)
 
-  (define-key menu-bar-files-menu [load-as-separator] '("--"))
-
-  (define-key menu-bar-files-menu [load-as] '("Load As..."  . load-as))
-  (defvar load-as-menu-map (make-sparse-keymap "Load As..."))
-  (fset 'load-as load-as-menu-map)
-
-  ;;(define-key menu-bar-files-menu [insert-as] '("Insert As..."  . insert-as))
-  (defvar insert-as-menu-map (make-sparse-keymap "Insert As..."))
-  (fset 'insert-as insert-as-menu-map)
-
-  (define-key menu-bar-files-menu [write-as] '("Write As..."  . write-as))
-  (defvar write-as-menu-map (make-sparse-keymap "Write As..."))
-  (fset 'write-as write-as-menu-map)
-
-  (define-key menu-bar-files-menu [translate-separator] '("--"))
-
-  (define-key menu-bar-files-menu [translate-to] '("Translate to..."  . translate-to))
-  (defvar translate-to-menu-map (make-sparse-keymap "Translate to..."))
-  (fset 'translate-to translate-to-menu-map)
-
-  (define-key menu-bar-files-menu [translate-from] '("Translate from..."  . translate-from))
-  (defvar translate-from-menu-map (make-sparse-keymap "Translate from..."))
-  (fset 'translate-from translate-from-menu-map)
-
-  (let ((file-types (reverse format-alist))
-       name
-       str-name)
-    (while file-types
-      (setq name (car (car file-types))
-           str-name (car (cdr (car file-types)))
-           file-types (cdr file-types))
-      (if (stringp str-name)
-         (progn
-           (define-key load-as-menu-map (vector name)
-             (cons str-name
-                   `(lambda (file)
-                      (interactive (format "FFind file (as %s): " ,name))
-                      (format-find-file file ',name))))
-           (define-key insert-as-menu-map (vector name)
-             (cons str-name
-                   `(lambda (file)
-                      (interactive (format "FInsert file (as %s): " ,name))
-                      (format-insert-file file ',name))))
-           (define-key write-as-menu-map (vector name)
-             (cons str-name
-                   `(lambda (file)
-                      (interactive (format "FWrite file (as %s): " ,name))
-                         (format-write-file file ',name))))
-           (define-key translate-to-menu-map (vector name)
-             (cons str-name
-                   `(lambda ()
-                      (interactive)
-                         (format-encode-buffer ',name))))
-           (define-key translate-from-menu-map (vector name)
-             (cons str-name
-                   `(lambda ()
-                      (interactive)
-                      (format-decode-buffer ',name)))))))))
+  (let ((load-as-menu-map (make-sparse-keymap "Load As..."))
+       (insert-as-menu-map (make-sparse-keymap "Insert As..."))
+       (write-as-menu-map (make-sparse-keymap "Write As..."))
+       (translate-to-menu-map (make-sparse-keymap "Translate to..."))
+       (translate-from-menu-map (make-sparse-keymap "Translate from..."))
+       (menu menu-bar-file-menu))
+       
+    (define-key menu [load-as-separator] '("--"))
+
+    (define-key menu [load-as] '("Load As..." . iso-cvt-load-as))
+    (fset 'iso-cvt-load-as load-as-menu-map)
+
+    ;;(define-key menu [insert-as] '("Insert As..." . iso-cvt-insert-as))
+    (fset 'iso-cvt-insert-as insert-as-menu-map)
+
+    (define-key menu [write-as] '("Write As..." . iso-cvt-write-as))
+    (fset 'iso-cvt-write-as write-as-menu-map)
+
+    (define-key menu [translate-separator] '("--"))
+
+    (define-key menu [translate-to] '("Translate to..." . iso-cvt-translate-to))
+    (fset 'iso-cvt-translate-to translate-to-menu-map)
+
+    (define-key menu [translate-from] '("Translate from..." . iso-cvt-translate-from))
+    (fset 'iso-cvt-translate-from translate-from-menu-map)
+
+    (dolist (file-type (reverse format-alist))
+      (let ((name (car file-type))
+           (str-name (cadr file-type)))
+       (if (stringp str-name)
+           (progn
+             (define-key load-as-menu-map (vector name)
+               (cons str-name
+                     `(lambda (file)
+                        (interactive ,(format "FFind file (as %s): " name))
+                        (format-find-file file ',name))))
+             (define-key insert-as-menu-map (vector name)
+               (cons str-name
+                     `(lambda (file)
+                        (interactive (format "FInsert file (as %s): " ,name))
+                        (format-insert-file file ',name))))
+             (define-key write-as-menu-map (vector name)
+               (cons str-name
+                     `(lambda (file)
+                        (interactive (format "FWrite file (as %s): " ,name))
+                        (format-write-file file ',name))))
+             (define-key translate-to-menu-map (vector name)
+               (cons str-name
+                     `(lambda ()
+                        (interactive)
+                        (format-encode-buffer ',name))))
+             (define-key translate-from-menu-map (vector name)
+               (cons str-name
+                     `(lambda ()
+                        (interactive)
+                        (format-decode-buffer ',name))))))))))
 
 (provide 'iso-cvt)
 
+;; arch-tag: 64ae843f-ed0e-43e1-ba50-ffd581b90840
 ;;; iso-cvt.el ends here