--- /dev/null
+;;; latin1-disp.el --- display tables for other ISO 8859 on Latin-1 terminals -*- coding: emacs-mule -*-
+
+;; Copyright (C) 2000 Free Software Foundation, Inc.
+
+;; Author: Dave Love <fx@gnu.org>
+;; Keywords: i18n
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; 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.
+
+;;; Commentary:
+
+;; This package sets up display of ISO 8859-n for n>1 by substituting
+;; Latin-1 characters and sequences of them for characters which can't
+;; be displayed, either beacuse we're on a tty or beacuse we don't
+;; have the relevant window system fonts available. For instance,
+;; Latin-9 is very similar to Latin-1, so we can display most Latin-9
+;; characters using the Latin-1 characters at the same code point and
+;; fall back on more-or-less mnemonic ASCII sequences for the rest.
+
+;; For the Latin charsets the ASCII sequences are mostly consistent
+;; with the Quail prefix input sequences. Latin-4 uses the Quail
+;; postfix sequences as a prefix method isn't defined for Latin-4.
+
+;; A different approach is taken in the DOS display tables in
+;; term/internal.el, and the relevant ASCII sequences from there are
+;; available as an alternative; see `latin1-display-mnemonic'. Only
+;; these sequences are used for Cyrillic, Greek and Hebrew.
+
+;; If you don't even have Latin-1, see iso-ascii.el and use the
+;; complete tables from internal.el. The ASCII sequences used here
+;; are mostly in the same style as iso-ascii.
+
+;;; Code:
+
+(defconst latin1-display-sets '(latin-2 latin-3 latin-4 latin-5 latin-8
+ latin-9 cyrillic greek hebrew)
+ "The ISO8859 character sets with defined Latin-1 display sequences.
+These are the nicknames for the sets and correspond to Emacs language
+environments.")
+
+(defgroup latin1-display ()
+ "Set up display tables for ISO8859 characters using Latin-1."
+ :version "21.1"
+ :group 'i18n)
+
+(defcustom latin1-display-format "{%s}"
+ "A format string used to display the ASCII sequences.
+The default encloses the sequence in braces, but you could just use
+\"%s\" to avoid the braces."
+ :group 'latin1-display
+ :type 'string)
+
+;;;###autoload
+(defcustom latin1-display nil
+ "Set up Latin-1/ASCII display for ISO8859 character sets.
+This is done for each character set in the list `latin1-display-sets',
+if no font is available to display it. Characters are displayed using
+the corresponding Latin-1 characters where they match. Otherwise
+ASCII sequences are used, mostly following the Latin prefix input
+methods. Some different ASCII sequences are used if
+`latin1-display-mnemonic' is non-nil.
+
+Setting this variable directly does not take effect;
+use either M-x customize of the function `latin1-display'."
+ :group 'latin1-display
+ :type 'boolean
+ :require 'latin1-disp
+ :initialize 'custom-initialize-default
+ :set (lambda (symbol value)
+ (if value
+ (mapc (if value
+ #'latin1-display-setup
+ #'latin1-display-reset)
+ latin1-display-sets))))
+
+;;;###autoload
+(defun latin1-display (&rest sets)
+ "Set up Latin-1/ASCII display for the arguments character SETS.
+See option `latin1-display' for the method. The members of the list
+must be in `latin1-display-sets'. With no arguments, reset the
+display for all of `latin1-display-sets'. See also `latin1-display-setup'."
+ (if sets
+ (mapc #'latin1-display-setup sets)
+ (mapc #'latin1-display-reset latin1-display-sets)))
+
+(defcustom latin1-display-mnemonic nil
+ "Non-nil means to display potentially more mnemonic sequences.
+These are taken from the tables in `internal.el' rather than the Quail
+input sequences."
+ :type 'boolean
+ :group 'latin1-display)
+
+(defun latin1-display-char (char display &optional alt-display)
+ "Make an entry in `standard-display-table' for CHAR using string DISPLAY.
+If ALT-DISPLAY is provided, use that instead if
+`latin1-display-mnemonic' is non-nil. The actual string displayed is
+formatted using `latin1-display-format'."
+ (if (and (stringp alt-display)
+ latin1-display-mnemonic)
+ (setq display alt-display))
+ (if (stringp display)
+ (standard-display-ascii char (format latin1-display-format display))
+ (aset standard-display-table char display)))
+
+(defun latin1-display-identities (charset)
+ "Display each character in CHARSET as the corresponding Latin-1 character.
+CHARSET is a symbol naming a language environment using an ISO8859
+character set."
+ (if (eq charset 'cyrillic)
+ (setq charset 'cyrillic-iso))
+ (let ((i 32)
+ (set (car (remq 'ascii (get-language-info charset 'charset)))))
+ (while (<= i 127)
+ (aset standard-display-table
+ (make-char set i)
+ (vector (make-char 'latin-iso8859-1 i)))
+ (setq i (1+ i)))))
+
+(defun latin1-display-reset (language)
+ "Set up the default display for each character of LANGUAGE's charset.
+CHARSET is a symbol naming a language environment using an ISO8859
+character set."
+ (if (eq language 'cyrillic)
+ (setq language 'cyrillic-iso))
+ (let ((charset (car (remq 'ascii (get-language-info language
+ 'charset)))))
+ (standard-display-default (make-char charset 32)
+ (make-char charset 127)))
+ (sit-for 0))
+
+;; Is there a better way than this?
+(defun latin1-display-check-font (language)
+ "Return non-nil if we have a font with an encoding for LANGUAGE.
+LANGUAGE is a symbol naming a language environment using an ISO8859
+character set: `latin-2', `hebrew' etc."
+ (if (eq language 'cyrillic)
+ (setq language 'cyrillic-iso))
+ (if window-system
+ (let* ((info (get-language-info language 'charset))
+ (str (symbol-name (car (remq 'ascii info)))))
+ (string-match "-iso8859-[0-9]+\\'" str)
+ (x-list-fonts (concat "*" (match-string 0 str))))))
+
+(defun latin1-display-setup (set &optional force)
+ "Set up Latin-1 display for characters in the given SET.
+SET must be a member of `latin1-display-sets'. Normally, check
+whether a font for SET is available and don't set the display if it
+is. If FORCE is non-nil, set up the display regardless."
+ (cond
+ ((eq set 'latin-2)
+ (when (or force
+ (not (latin1-display-check-font set)))
+ (latin1-display-identities set)
+ (mapc
+ (lambda (l)
+ (apply 'latin1-display-char l))
+ '((?\82Æ "'C" "C'")
+ (?\82Ð "'D" "/D")
+ (?\82¦ "'S" "S'")
+ (?\82æ "'c" "c'")
+ (?\82ð "'d" "/d")
+ (?\82Å "'L" "L'")
+ (?\82ñ "'n" "n'")
+ (?\82Ñ "'N" "N'")
+ (?\82à "'r" "r'")
+ (?\82À "'R" "R'")
+ (?\82¶ "'s" "s'")
+ (?\82¼ "'z" "z'")
+ (?\82¬ "'Z" "Z'")
+ (?\82¡ "`A" "A;")
+ (?\82Ê "`E" "E;")
+ (?\82£ "`L" "/L")
+ (?\82ª "`S" ",S")
+ (?\82Þ "`T" ",T")
+ (?\82¯ "`Z" "Z^.")
+ (?\82± "`a" "a;")
+ (?\82³ "`l" "/l")
+ (?\82ê "`e" "e;")
+ (?\82º "`s" ",s")
+ (?\82þ "`t" ",t")
+ (?\82¿ "`z" "z^.")
+ (?\82ÿ "`." "'.")
+ (?\82Ã "~A" "A(")
+ (?\82È "~C" "C<")
+ (?\82Ï "~D" "D<")
+ (?\82Ì "~E" "E<")
+ (?\82ì "~e" "e<")
+ (?\82¥ "~L" "L<")
+ (?\82Ò "~N" "N<")
+ (?\82Õ "~O" "O''")
+ (?\82Ø "~R" "R<")
+ (?\82© "~S" "S<")
+ (?\82« "~T" "T<")
+ (?\82Û "~U" "U''")
+ (?\82® "~Z" "Z<")
+ (?\82ã "~a" "a(}")
+ (?\82è "~c" "c<")
+ (?\82ï "~d" "d<")
+ (?\82µ "~l" "l<")
+ (?\82ò "~n" "n<")
+ (?\82õ "~o" "o''")
+ (?\82ø "~r" "r<")
+ (?\82¹ "~s" "s<")
+ (?\82» "~t" "t<")
+ (?\82û "~u" "u''")
+ (?\82¾ "~z" "z<")
+ (?\82· "~v" "'<") ; ?\82¢ in latin-pre
+ (?\82¢ "~~" "'(")
+ (?\82ù "uu" "u^0")
+ (?\82Ù "UU" "U^0")
+ (?\82Ä "\"A")
+ (?\82ä "\"a")
+ (?\82Ë "\"E" "E:")
+ (?\82ë "\"e")
+ (?\82½ "''" "'")
+ (?\82· "'<") ; Lynx's rendering of caron
+ ))))
+
+ ((eq set 'latin-3)
+ (when (or force
+ (not (latin1-display-check-font set)))
+ (latin1-display-identities set)
+ (mapc
+ (lambda (l)
+ (apply 'latin1-display-char l))
+ '((?\83¡ "/H")
+ (?\83¢ "~`" "'(")
+ (?\83¦ "^H" "H^")
+ (?\83¶ "^h" "h^") (?\83© ".I" "I^.")
+ (?\83ª ",S")
+ (?\83« "~G" "G(")
+ (?\83¬ "^J" "J^")
+ (?\83¯ ".Z" "Z^.")
+ (?\83± "/h")
+ (?\83¹ ".i" "i^.")
+ (?\83º ",s")
+ (?\83» "~g" "g(")
+ (?\83¼ "^j" "j^")
+ (?\83¿ ".Z" "z^.")
+ (?\83Å ".c" "C^.")
+ (?\83Æ "^C" "C^")
+ (?\83Õ ".G" "G^.")
+ (?\83Ø "^G" "G^")
+ (?\83Ý "~U" "U(")
+ (?\83Þ "^S" "S^")
+ (?\83å ".C" "c^.")
+ (?\83æ "^c" "c^")
+ (?\83õ ".g" "g^.")
+ (?\83ø "^g" "g^")
+ (?\83ý "~u" "u(")
+ (?\83þ "^s" "s^")
+ (?\83ÿ "/." "^.")))))
+
+ ((eq set 'latin-4)
+ (when (or force
+ (not (latin1-display-check-font set)))
+ (latin1-display-identities set)
+ (mapc
+ (lambda (l)
+ (apply 'latin1-display-char l))
+ '((?\84¡ "A," "A;")
+ (?\84¢ "k/" "kk")
+ (?\84£ "R," ",R")
+ (?\84¥ "I~" "?I")
+ (?\84¦ "L," ",L")
+ (?\84© "S~" "S<")
+ (?\84ª "E-")
+ (?\84« "G," ",G")
+ (?\84¬ "T/" "/T")
+ (?\84® "Z~" "Z<")
+ (?\84± "a," "a;")
+ (?\84² "';")
+ (?\84³ "r," ",r")
+ (?\84µ "i~" "~i")
+ (?\84¶ "l," ",l")
+ (?\84· "'<")
+ (?\84¹ "s~" "s<")
+ (?\84º "e-")
+ (?\84» "g," ",g")
+ (?\84¼ "t/" "/t")
+ (?\84½ "N/" "NG")
+ (?\84¾ "z~" "z<")
+ (?\84¿ "n/" "ng")
+ (?\84À "A-")
+ (?\84Ç "I," "I;")
+ (?\84È "C~" "C<")
+ (?\84Ê "E," "E;")
+ (?\84Ì "E." "E^.")
+ (?\84Ï "I-")
+ (?\84Ñ "N," ",N")
+ (?\84Ò "O-")
+ (?\84Ó "K," ",K")
+ (?\84Ù "U," "U;")
+ (?\84Ý "U~" "~U")
+ (?\84Þ "U-")
+ (?\84à "a-")
+ (?\84ç "i," "i;")
+ (?\84è "c~" "c<")
+ (?\84ê "e," "e;")
+ (?\84ì "e." "e^.")
+ (?\84ï "i-")
+ (?\84ð "d/" "/d")
+ (?\84ñ "n," ",n")
+ (?\84ò "o-")
+ (?\84ó "k," ",k")
+ (?\84ù "u," "u;")
+ (?\84ý "u~" "~u")
+ (?\84þ "u-")
+ (?\84ÿ "^.")))))
+
+ ((eq set 'latin-5)
+ (when (or force
+ (not (latin1-display-check-font set)))
+ (latin1-display-identities set)
+ (mapc
+ (lambda (l)
+ (apply 'latin1-display-char l))
+ '((?\8dð "~g" "g(")
+ (?\8dÐ "~G" "G(")
+ (?\8dÝ ".I" "I^.")
+ (?\8dþ ",s")
+ (?\8dÞ ",S")
+ (?\8dê "^e" "e<") ; from latin-post
+ (?\8dì ".e" "e^.")
+ (?\8dï "\"i" "i-") ; from latin-post
+ (?\8dý ".i" "i.")))))
+
+ ((eq set 'latin-8)
+ (when (or force
+ (not (latin1-display-check-font set)))
+ (latin1-display-identities set)
+ (mapc
+ (lambda (l)
+ (apply 'latin1-display-char l))
+ '((?\8f¡ ".B" "B`")
+ (?\8f¢ ".b" "b`")
+ (?\8f¥ ".c" "c`")
+ (?\8f¤ ".C" "C`")
+ (?\8f¦ ".D" "D`")
+ (?\8f« ".d" "d`")
+ (?\8f¸ "`w")
+ (?\8f¨ "`W")
+ (?\8fº "'w" "w'")
+ (?\8fª "'W" "W'")
+ (?\8f¼ "`y")
+ (?\8f¬ "`Y")
+ (?\8f± ".f" "f`")
+ (?\8f° ".F" "F`")
+ (?\8f³ ".g" "g`")
+ (?\8f² ".G" "G`")
+ (?\8fµ ".m" "m`")
+ (?\8f´ ".M" "M`")
+ (?\8f¹ ".p" "p`")
+ (?\8f· ".P" "P`")
+ (?\8f¿ ".s" "s`")
+ (?\8f» ".S" "S`")
+ (?\8f¾ "\"w")
+ (?\8f½ "\"W")
+ (?\8fð "^w" "w^")
+ (?\8fÐ "^W" "W^")
+ (?\8f÷ ".t" "t`")
+ (?\8f× ".T" "T`")
+ (?\8fþ "^y" "y^")
+ (?\8fÞ "^Y" "Y^")
+ (?\8f¯ "\"Y")))))
+
+ ((eq set 'latin-9)
+ (when (or force
+ (not (latin1-display-check-font set)))
+ (latin1-display-identities set)
+ (mapc
+ (lambda (l)
+ (apply 'latin1-display-char l))
+ '((?\8e¨ "~s" "s<")
+ (?\8e¦ "~S" "S<")
+ (?\8e¤ "Euro" "E=")
+ (?\8e¸ "~z" "z<")
+ (?\8e´ "~Z" "Z<")
+ (?\8e¾ "\"Y")
+ (?\8e½ "oe")
+ (?\8e¼ "OE")))))
+
+ ((eq set 'greek)
+ (when (or force
+ (not (latin1-display-check-font set)))
+ (mapc
+ (lambda (l)
+ (apply 'latin1-display-char l))
+ '((?\86¡ "9'")
+ (?\86¢ "'9")
+ (?\86¯ "-M")
+ (?\86µ "'%")
+ (?\86¶ "'A")
+ (?\86¸ "'E")
+ (?\86¹ "'H")
+ (?\86º "'I")
+ (?\86¼ "'O")
+ (?\86¾ "'Y")
+ (?\86¿ "W%")
+ (?\86À "i3")
+ (?\86Ã "G*")
+ (?\86Ä "D*")
+ (?\86È "TH")
+ (?\86Ë "L*")
+ (?\86Î "C*")
+ (?\86Ð "P*")
+ (?\86Ó "S*")
+ (?\86Ö "F*")
+ (?\86Ø "Q*")
+ (?\86Ù "W*")
+ (?\86Ú "\"I")
+ (?\86Û "\"Y")
+ (?\86Ü "a%")
+ (?\86Ý "e%")
+ (?\86Þ "y%")
+ (?\86ß "i%")
+ (?\86à "u3")
+ (?\86á "a*")
+ (?\86â "b*")
+ (?\86ã "g*")
+ (?\86ä "d*")
+ (?\86å "e*")
+ (?\86æ "z*")
+ (?\86ç "y*")
+ (?\86è "h*")
+ (?\86é "i*")
+ (?\86ê "k")
+ (?\86ë "l*")
+ (?\86ì "m*")
+ (?\86í "n*")
+ (?\86î "c*")
+ (?\86ð "p*")
+ (?\86ñ "r*")
+ (?\86ò "*s")
+ (?\86ó "s*")
+ (?\86ô "t*")
+ (?\86õ "u")
+ (?\86ö "f*")
+ (?\86÷ "x*")
+ (?\86ø "q*")
+ (?\86ù "w*")
+ (?\86ú "\"i")
+ (?\86û "\"u")
+ (?\86ü "'o")
+ (?\86ý "'u")
+ (?\86þ "'w")))
+ (mapc
+ (lambda (l)
+ (aset standard-display-table (car l) (string-to-vector (cadr l))))
+ '((?\86Á "A")
+ (?\86Â "B")
+ (?\86Å "E")
+ (?\86Æ "Z")
+ (?\86Ç "H")
+ (?\86É "I")
+ (?\86Ê "J")
+ (?\86Ì "M")
+ (?\86Í "N")
+ (?\86Ï "O")
+ (?\86Ñ "P")
+ (?\86Ô "T")
+ (?\86Õ "Y")
+ (?\86× "X")
+ (?\86ï "o")))))
+
+ ((eq set 'hebrew)
+ (when (or force
+ (not (latin1-display-check-font set)))
+ ;; Don't start with identities, since we don't have definitions
+ ;; for a lot of Hebrew in internal.el. (Intlfonts is also
+ ;; missing some glyphs.)
+ (let ((i 34))
+ (while (<= i 62)
+ (aset standard-display-table
+ (make-char 'hebrew-iso8859-8 i)
+ (vector (make-char 'latin-iso8859-1 i)))
+ (setq i (1+ i))))
+ (mapc
+ (lambda (l)
+ (aset standard-display-table (car l) (string-to-vector (cadr l))))
+ '((?\88ß "=2")
+ (?\88à "A+")
+ (?\88á "B+")
+ (?\88â "G+")
+ (?\88ã "D+")
+ (?\88ä "H+")
+ (?\88å "W+")
+ (?\88æ "Z+")
+ (?\88ç "X+")
+ (?\88è "Tj")
+ (?\88é "J+")
+ (?\88ê "K%")
+ (?\88ë "K+")
+ (?\88ì "L+")
+ (?\88í "M%")
+ (?\88î "M+")
+ (?\88ï "N%")
+ (?\88ð "N+")
+ (?\88ñ "S+")
+ (?\88ò "E+")
+ (?\88ó "P%")
+ (?\88ô "P+")
+ (?\88õ "Zj")
+ (?\88ö "ZJ")
+ (?\88÷ "Q+")
+ (?\88ø "R+")
+ (?\88ù "Sh")
+ (?\88ú "T+")))))
+
+ ((eq set 'cyrillic)
+ (setq set 'cyrillic-iso)
+ (when (or force
+ (not (latin1-display-check-font set)))
+ (mapc
+ (lambda (l)
+ (apply 'latin1-display-char l))
+ '((?\8c¢ "Dj")
+ (?\8c£ "Gj")
+ (?\8c¤ "IE")
+ (?\8c© "Lj")
+ (?\8cª "Nj")
+ (?\8c« "Ts")
+ (?\8c¬ "Kj")
+ (?\8c® "V%")
+ (?\8c¯ "Dzh")
+ (?\8c± "B=")
+ (?\8c³ "â")
+ (?\8c´ "D")
+ (?\8c¶ "Z%")
+ (?\8c· "3")
+ (?\8c¸ "U")
+ (?\8c¹ "J=")
+ (?\8c» "L=")
+ (?\8c¿ "P=")
+ (?\8cà "Y")
+ (?\8cÄ "è")
+ (?\8cÆ "C=")
+ (?\8cÇ "C%")
+ (?\8cÈ "S%")
+ (?\8cÉ "Sc")
+ (?\8cÊ "=\"")
+ (?\8cË "Y=")
+ (?\8cÌ "%\"")
+ (?\8cÍ "Ee")
+ (?\8cÎ "Yu")
+ (?\8cÏ "Ya")
+ (?\8cÑ "b")
+ (?\8cÒ "v=")
+ (?\8cÓ "g=")
+ (?\8cÔ "g")
+ (?\8cÖ "z%")
+ (?\8c× "z=")
+ (?\8cØ "u")
+ (?\8cÙ "j=")
+ (?\8cÚ "k")
+ (?\8cÛ "l=")
+ (?\8cÜ "m=")
+ (?\8cÝ "n=")
+ (?\8cß "n")
+ (?\8cà "p")
+ (?\8câ "t=")
+ (?\8cä "f=")
+ (?\8cæ "c=")
+ (?\8cç "c%")
+ (?\8cè "s%")
+ (?\8cé "sc")
+ (?\8cê "='")
+ (?\8cë "y=")
+ (?\8cì "%'")
+ (?\8cí "ee")
+ (?\8cî "yu")
+ (?\8cï "ya")
+ (?\8cð "N0")
+ (?\8cò "dj")
+ (?\8có "gj")
+ (?\8cô "ie")
+ (?\8cù "lj")
+ (?\8cú "nj")
+ (?\8cû "ts")
+ (?\8cü "kj")
+ (?\8cþ "v%")
+ (?\8cÿ "dzh")))
+ (mapc
+ (lambda (l)
+ (aset standard-display-table (car l) (string-to-vector (cadr l))))
+ '((?\8c¡ "\81Ë")
+ (?\8c¥ "S")
+ (?\8c¦ "I")
+ (?\8c§ "\81Ï")
+ (?\8c¨ "J")
+ (?\8cñ "\81ë")
+ (?\8cý "\81§")
+ (?\8c "-")
+ (?\8c° "A")
+ (?\8c² "B")
+ (?\8cµ "E")
+ (?\8cº "K")
+ (?\8c¼ "M")
+ (?\8c½ "H")
+ (?\8c¾ "O")
+ (?\8cÀ "P")
+ (?\8cÁ "C")
+ (?\8c "T")
+ (?\8cÅ "X")
+ (?\8cÐ "a")
+ (?\8cÕ "e")
+ (?\8cÞ "o")
+ (?\8cá "c")
+ (?\8cã "y")
+ (?\8cå "x")
+ (?\8cõ "s")
+ (?\8cö "i")
+ (?\8c÷ "\81ï")
+ (?\8cø "j")))))
+
+ (t (error "Unsupported character set: %S" set)))
+
+ (sit-for 0))
+
+(provide 'latin1-disp)
+
+;;; latin1-disp.el ends here