First Draft July 19 1995 Greg Priest-Dorman Priestdo@cs.vassar.edu USING CYRILLIC WITH X11, EMACS AND EMACS PSGML MODE The following is a quick description of what I have been playing with the past week. I want to state at the onset that I am not familiar with the Cyrillic alphabet and that there where several choices that had to be made just to try this out. I have chosen to set up the key bindings to the Russian jcuken keyboard layout presented in Serge Vakulenko's Xcyrillic package and I have made key binding maps for both the koi8 and the ISO/GOSTCII font sets and ISOcyr1 entity maps for both koi and ISO/GOSTCII font sets. You may try others and you should be able to set up any of the options in the same way. The key idea here is to bind the sgml entities to the same keys that produce the desired letter. Doing this is independent of the particulars of this implementation and should work equally well with Hebrew, Cyrillic or isolatin-1. If you find any errors or typos in this document or have suggestions for improvement please write me, Greg Priest-Dorman priestdo@cs.vassar.edu THIS DOCUMENT WILL ATTEMPT TO SHOW YOU HOW TO DO THE FOLLOWING: Set up the Xcyrillic package which will allow you to type and display Latin and Cyrillic characters (ISO/GOSTCII, ALT, KOI7 or KOI8) under X11. I have done this on both a sun running 4.1.3 and X11R5 and a pc(486 dx2/50 ) running linux and X11R6. Set up key bindings for emacs sgml-mode (psgml) so that when in sgml-mode, key presses for the Cyrillic characters will generate, not the code for the Cyrillic character but instead the corresponding ISOcyr1 entity. YOU SHOULD ALREADY HAVE: A sun or linux box (although this should work on any X11 platform I have tried it on those two) running X11, emacs 19.19 or above, psgml for emacs installed and working, sgmls or nsgmls(sp) installed and working and an Internet connection so that you can ftp the files below. You will need root (su) privileges on the machine to install the fonts. BEFORE YOU START, FIND THE FOLLOWING FILES AND DIRECTORIES ON YOUR SYSTEM: I will call it: it is usually in: --------------- ----------------- fonts/misc /usr/X11/lib/X11/fonts/misc or /usr/local/X11/lib/X11/fonts/misc fonts/misc/fonts.dir /usr/X11/lib/X11/fonts/misc/fonts.dir or /usr/local/X11/lib/X11/fonts/misc/fonts.dir ~/ your home directory WHAT YOU NEED AND WHERE TO GET IT Xcyrillic.tar.Z - I got it from ftp.funet.fi in the directory /pub/culture/russian/comp/xwin ISOcyr1 - I got it from ftp.ifi.uio.no in the directory /pub/SGML/ENTITIES. You only need it if you want to create you own mappings. (Once you get this up and running you might want to add other fonts, there are some available from ftp.funet.fi.) add.to.dot.emacs - A small file uuencoded and sent with this document to be added to your .emacs file. ISOcyr1.koi.ent - The ISOcyr1 file with koi font bindings, sent with this document, it should be placed wherever you put entities on your system (and named accordingly). This is the file I will be using in this document. ISOcyr1.iso.ent - The ISOcyr1 file with ISO/GOSTCII font bindings, sent with this document, it should be placed wherever you put entities on your system if you choice to use it instead of ISOcyr1.koi.ent jcu.koi.to.cyr1.bindings - Sent with this document, it is the emacs key bindings mapping the Russian jcuken keyboard layout under a koi font to isocyr1 entities. It should be placed in your home directory, in your emacs_aux directory (if you have one) or in a public location if many people will be using it like /usr/local/lib/emacs/site-lisp. It is the binding file I will be using in this document. jcu.iso.to.cyr1.bindings - Sent with this document, it is the emacs key bindings mapping the Russian jcuken keyboard layout under a ISO/GOSTCII font to isocyr1 entities. It should be placed in your home directory, in your emacs_aux directory (if you have one) or in a public location if many people will be using it like /usr/local/lib/emacs/site-lisp. INSTALLING XCYRILLIC.TAR.Z I had some problems installing Xcyrillic as packaged. It installed the font .snf files and my system could not read those. Also, the default.xmm file did not work, so, follow the make and install instructions that came with Xcyrillic and then, while still root, do the following from the install directory (~priestdo/xcyr in my case): remove the default.xmm file that came with the distribution >rm default.xmm copy the *.bdf files to your fonts/misc directory >cp *.bdf /usr/local/X11/lib/X11/fonts/misc/ Change to that directory and remove the .snf files that this package installed; Alt8.snf alt6x10.snf altnil2.snf iso9x15.snf koi8x13.snf Iso8.snf alt6x13.snf iso6x10.snf isonil2.snf koi9x15.snf Koi7B16.snf alt8x13.snf iso6x13.snf koi6x10.snf koinil2.snf Koi88.snf alt9x15.snf iso8x13.snf koi6x13.snf All can be removed, if these are the only .snf files there you can do a rm *.snf, but if your system has .snf files and you want to keep them then do a rm -i *.snf and you will be prompted for each remove. >cd /usr/local/X11/lib/X11/fonts/misc >ls -la *.smf >rm -i *.snf make sure the permissions are the set correctly, everybody needs to be able to read the files. > chmod a+r *.bdf You might want to convert the .bdf files to .pcf or pcf.Z files to save space but this is not essential and will not work on all systems. So I leave that up to you. From within the fonts/misc directory, as root, do a mkfontdir. This sets up the file fonts.dir. >mkfontdir That is all you will need root privileges for so, leave root: >exit exit Xwindows (if you were in it) and restart it. change to the directory you installed Xcyrillic from > cd ~/xcyr/ make a copy of your existing xmodmap before changing it: > xmodmap -pke > default.xmm You will use this file to restore you default settings if you have/want to. Xcyrillic uses xmodmap to reassign the caps lock key to work as a mode switch key. It can either be set up to "lock" where once pressed it will stay in effect until pressed again, or you can set it up just like shift, where it will only effect what you do while it is being pressed. The line "remove lock = Caps_Lock" in the file jcuken.koi8.xmm makes the Caps Lock work like the shift key. I prefer it to work like the Caps Lock, so for now, comment out that line. ( If you want one of the .xmm files that does lock it not to, add that line to the file.) Edit jcuken.koi8.xmm and change the line remove lock = Caps_Lock to !remove lock = Caps_Lock save and exit your editor. Load in the new xmodmap: >xmodmap jcuken.koi8.xmm You are now done with the instillation of Xcyrillic. If you want to go back to your normal mapping load your default xmodmap with >xmodmap default.xmm If you want to try some of the other mapping that came with Xcyrillic, restore your default.xmm between tries. MAKING IT WORK WITH EMACS There are 2 sets of lines that need to be loaded into emacs for all this to work. One set tells emacs to display the upper ASCII characters rather than the key codes (\324) when those codes are generated. (See emacs info on European Display.) this is the file add.to.dot.emacs. You should do just that, add these lines to your .emacs file. The other set of lines is only needed when you are using the entities in sgml-mode. It is the file called jcu.koi.to.cyr1.bindings. If you are going to use Cyrillic in sgml-mode regularly you could add these lines to your .emacs file as well, but the rest of these instructions assumes them to be in a file. Set up these files now if you have not already done so. exit emacs (if you were in it) look at the fonts/misc/fonts.dir file and pick a koi font you want to try, say koi9x15, start emacs with that font: emasc -fn koi9x15 & (you can change to any font from within emacs with the command M-x set-default-font ) If all is well then typing Caps_Lock + any key should produce the desired Cyrillic key according to the jcuken keyboard. If this works you can skip the next section. A FEW THINGS TO TRY IF IT ISN'T WORKING PROBLEM: you see things like \342 \214 \256 when you type instead of Cyrillic characters. If so the "standard-display-european" command didn't work. Try setting that manually from within emacs by issuing the command M-x standard-display-european If that fixes it check the lines in your .emacs file and make sure they match the lines from the add.to.dot.emacs file. PROBLEM: You still see the Latin keys pressed even when the Caps Lock is pressed. Something is not working correctly with the xmodmap. Test it with xev. Check the xev man page. If the xmodmap loaded correctly the Caps Lock key should generate something like the text below, the important thing is that it generate "Mode_switch." KeyPress event, serial 17, synthetic NO, window 0x2400001, root 0x24, subw 0x2400002, time 2769034753, (31,38), root:(341,61), state 0x0, keycode 66 (keysym 0xff7e, Mode_switch), same_screen YES, XLookupString gives 0 characters: "" Still not working? Check the README file in with Xcyrillic and see if you can figure out what went wrong. If that doesn't help, please write me and I will try to help. OTHER PROBLEMS? If you do encounter problems please tell me about them so that I can include them here for the benefit of others INSTALL ISOCYR1 ENTITY SET Check that ISOcyr1.koi.ent is named correctly and in the proper location. Mine is called ISOcyr1 and in /usr/local/lib/sgml. PUT IT ALL TOGETHER Go into sgml-mode, issue the command M-x sgml-mode. load in the emacs entity bindings M-x load-file jcu.koi.to.cyr1.bindings Now when you type Caps_Lock + q you should see "й" the ISOcyr1 entity that maps to the "q" key. Include the isocyr1 file in your SGML document with the lines %ISOcyr1; or %ISOcyr1; You are done. When in sgml-mode you will get entities, when in any other mode you will get the Cyrillic characters themselves. When the document is parsed the entities will be replaced with there char. representation from the entity file. NOW THAT IT'S INSTALLED, WHAT DO I DO TO USE IT? Simple, for a new session, load the map, start emacs with a koi font, load the bindings. >xmodmap jcuken.koi8.xmm > emacs -fn koi9x15 & when in emacs, at any time, load the file jcu.koi.to.cyr1.bindings M-x load-file jcu.koi.to.cyr1.bindings You can make one of the .xmm files your default xmodmap if you like. Do the the variety of ways to do this, you can look for an xmodmap command in your .xinit and/or ask your sysop. KNOWN PROBLEMS For some reason, nsgmls does not print the character corresponding to code \377 (Caps Lock + Shift + "]" with the jcuken.koi8.xmm). I do not know why but I am looking into it. Once again, if you have any problems getting this working, please write me. Greg Priest-Dorman priestdo@cs.vassar.edu