;From soc.culture.esperanto Fri Oct 15 10:51:12 1993 ;From: pfeiffer@cict.fr (Daniel Pfeiffer) ;Date: 13 Oct 93 11:18:33 ;Newsgroups: gnu.emacs.sources,comp.emacs,soc.culture.esperanto,soc.culture.german,soc.culture.french ;Subject: Hack for international codes/fonts using Emacs 19/X11 ; ;Handling of international character sets has been largely improved in ;Emacs 19, but is far from solved. I found a function something like ;`display-european' and happily bound it to C-x 8 , but to my ;disappointment it didn't. The problem is that there are three aspects ;to internationalism: ; ; - keyboards ; - codes ; - fonts ; ;each of which are abundant and potentially independent. For example ;on my PC I have a german keyboard, a PC, Windows, ISO 8859-1 or -3 ;code and PC, Windows or ASCII (X11R4 fixed width) fonts depepnding on ;my current environment. And I want to edit files from all of these, ;let alone from other machines (sometimes I get an Ebcdic file), in any ;of these. ; ;Here's a very flexible solution: ; ;To link these aspects we need a superset of all potential codes and ;fonts. Rather than introduce symbolic names for characters (codings ;exist, but would make Emacs explode in size) we might use Unicode ;codes (16bit integers) as a link between these. ; ; - The keyboard part can now be solved elegantly on ; window-systems with national language keys and now possible ; key sequences such as C-^ e which might be bound to their ; respective Unicode. Oddly not all of these work (e.g. C-' ; is recognized as such by Emacs, but is interpreted the same ; as ' -- bug?). The user would set those keys he ; actually uses. M-C-q might insert a character given in ; Unicode or from a lookup table (e.g. M-C-q ~ n would lookup ; the Unicode for ntilde). self-insert-command should follow ; this when code is completely differant (e.g. Ebcdic) ; ; - As a link from keyboard to buffer and from buffer to display ; there would be (autoloadable) maps between various codes and ; Unicode. The user would tell Emacs globally and sometimes ; locally what code he is using. ; ; - Emacs knows which font it is using on a frame/screen and it ; would have maps from Unicode (sparse ones mostly!) to ; various fonts. Characters not in the font would be assinged ; longer atomic strings as with `standard-display-ascii'. ; ; - This flexibilty has a price, so the normal display technique ; should still be the current one, with code = font. ; ;Something akin to this might be lisped but I think it should be done in C ;for performance. Hopefully before Emacs 20 :-) Volunteers? ; ; ;And here's a hack from my .emacs to set up my keyboard, three codes ;and display ASCII _or_ the code's font, while waiting for a real ;solution. ; ;What I recently posted didn't cover some languages I also like to edit ;(occitan and french) because I hadn't realized how I could bind for ;example C-` x to mean some character x with an acute accent. The most ;interesting one I now set is C-x 8 1 to set 8bit handling in ISO8859-1. ; ;The german umlaut keys may not work for you, and indeed don't unless ;you use a window system, but this should be fairly easy to accomodate ;to your needs. ; ; here's a very useful base function (put 'define-8bit 'lisp-indent-hook 1) (defun define-8bit (code key display &optional same S-code S-key S-display) "Character CODE, KEY to assign this to, ersatz DISPLAY for ascii. Optional args are SAME, i.e. display CODE as itself and the uppercase version of CODE if it exists: S-CODE may be absolute or `t' i.e. relative to CODE, S-KEY defaults to upcased KEY, S-DISPLAY defaults to upcased DISPLAY or S-CODE if SAME. Codes get word syntax and are coupled for up- and downcasing." (global-set-key key (format "\C-q%o" code)) (standard-display-ascii code (if same (char-to-string code) display)) (modify-syntax-entry code "w") (if S-code (progn (if (eq S-code t) (setq S-code (- code 32))) (aset (car (cdr (standard-case-table))) code S-code) (aset (car (standard-case-table)) S-code code) (global-set-key (or S-key (if (char-or-string-p key) (upcase key) (setq S-key (copy-sequence key) key (length key)) (while (> key 0) (setq key (1- key) code (aref S-key key)) (and (<= ?a code) (<= code ?z) (aset S-key key (- code 32)))) S-key)) (format "\C-q%o" S-code)) (standard-display-ascii S-code (if same (char-to-string S-code) (or S-display (upcase display)))) (modify-syntax-entry S-code "w")))) (define-key ctl-x-map "81" ; ISO 8859-1, Windows: Deutsch, '(lambda (arg) (interactive "P") ; occitan, fran,cais (define-8bit 228 [-28] "<\"a>" arg t [-60]) (define-8bit 246 [-10] "<\"o>" arg t [-42]) (define-8bit 252 [-4] "<\"u>" arg t [-36]) (define-8bit 223 [-33] "" arg) (define-8bit 224 [?\C-` ?a] "<`a>" arg t) (define-8bit 225 [?\C-' ?a] "<'a>" arg t) (define-8bit 226 "\C-^a" "<^a>" arg t) (define-8bit 231 [?\C-, ?c] "<,c>" arg t) (define-8bit 232 [?\C-` ?e] "<`e>" arg t) (define-8bit 233 [?\C-' ?e] "<'e>" arg t) (define-8bit 234 "\C-^e" "<^e>" arg t) (define-8bit 235 [?\C-\" ?e] "<\"e>" arg t) (define-8bit 237 [?\C-' ?i] "<'i>" arg t) (define-8bit 238 "\C-^i" "<^i>" arg t) (define-8bit 239 [?\C-\" ?i] "<\"i>" arg t) (define-8bit 242 [?\C-` ?o] "<`o>" arg t) (define-8bit 243 [?\C-' ?o] "<'o>" arg t) (define-8bit 244 "\C-^o" "<^o>" arg t) (define-8bit 249 [?\C-` ?u] "<`u>" arg t) (define-8bit 250 [?\C-' ?u] "<'u>" arg t) (define-8bit 251 "\C-^u" "<^u>" arg t))) (define-key ctl-x-map "83" ; ISO 8859-3: Esperanto '(lambda (arg) (interactive "P") (define-8bit 230 "\C-^c" "{^c}" arg t) (define-8bit 248 "\C-^g" "{^g}" arg t) (define-8bit 182 "\C-^h" "{^h}" arg 166) (define-8bit 188 "\C-^j" "{^j}" arg 172) (define-8bit 254 "\C-^s" "{^s}" arg t) (define-8bit 253 "\C-^u" "{^u}" arg t))) (define-key ctl-x-map "8p" ; PC: Deutsch '(lambda (arg) (interactive "P") ; im PC-Modus gehen die Tasten nicht (define-8bit 132 [-28] "\\\"a" arg 142 [-60]) (define-8bit 148 [-10] "\\\"o" arg 153 [-42]) (define-8bit 129 [-4] "\\\"u" arg 154 [-36]) (define-8bit 225 [-33] "\\3" arg)))