Random Tech Thoughts

The title above is not random

发现Gentoo里面还有jargon file,LFS的文档

eix dri时偶然发现app-doc里面有linux-device-drivers,当时觉得奇怪,就进到/usr/portage/app-doc里面看了一下,发现除了制作文档的一些工具以外还有jargon file和linux from scratch的文档。呵呵,本来想以后有机会要试试看LFS,分区都一直空在那里准备着,没想到Gentoo竟然已经连文档都帮我准备好了,这下子要做LFS文档就不用自己去找文档了。呵呵,Gentoo真是太好了!

Jargon File是Eric S. Raymond(别告诉我你没有听说过他,他还写了The art of UNIX programming)编辑维护的黑客用语和幽默等方面的辞典(可能不可以称之为辞典),我的palm上的Free OnLine Computer Dictionary里面就有很多词条是从jargon file里面来的。

XGL 给你最炫的桌面 :-)

http://www.novell.com/linux/xglrelease/

看这里,去下一个视频下来看看吧,绝对眩目的桌面。什么是XGL? Google吧。

想要自己试试看的话,看看Gentoo里的这篇文章吧。不过注意了,刀锋级的东西弄不好会伤到自己啊!我暂时还是不试了,要更改系统的太多东西了。Xorg7不敢随便装啊,ATI的显卡驱动装了以后如果启用dri就没办法休眠,还是以后再说吧,到时我的显卡就有用武之地了……

Emacs Wiki — 很好的做笔记的工具

前段时间的笔记都是用Emacs Wiki做的,放在自己电脑里了,真的很方便。Gentoo里面安装很方便:

emerge -avt emacs-wiki

Gentoo不仅是提供了非常多的软件包,而且对这些软件的管理也很不错。像Emacs Wiki这样的Emacs插件安装以后他自动更新了一个文件:site-gentoo.el。这是一个维护新插件的文件,你只要在你的.emacs文件里面load这个文件就可以使用了,都不用自己去编辑。

Emacs Wiki提供了一些默认的标记语法,语法很简单,一下就可以学会的。这里给出一些我当时学习时遇到的有用的链接。

Liyu的主页里的介绍 薛瑞妮的主页里的介绍

Junk Characters in Emacs

The newly installed Emacs 23 on my Gentoo displays some junk characters in the emacs shell when I use “ls” in it.(some thing like “^[01[03m…”) Really annoying at first but after gooled, I found the solution, just add this in .emacs file:

(add-hook ’shell-mode-hook ‘ansi-color-for-comint-mode-on)

All goes well then and you can see different colors to indicate different kinds of files in emacs shell when you use “ls”. I didn’t see this feature when I were using Emacs 23 on SuSE.

From Windows to Linux

This article was written when I was installing Gentoo on my notebook. The compiling time was really looong (I installed it from stage 1, because I wanted to use gcc 3.4.5 to build my system.) And then I began to thought whether I should switch to Linux and whether it deserved to spend so much time on this lovely operating system Obviously, you know my answer is positively “YES”. In this article, I looked back the time when I was switching from Windows to Linux, I tried to write down the reason why I switch to Linux and the experience I had on some Linux distributions I’ve used. I am not good at writing and I should write this article in Chinese to make it batter, but there is no Chinese input method at that time, so I used my poor English and this is just an record of my personal experience. It’s a little long though I have used Linux for only 4 months so far. It’s sure there will be many mistakes, forgive me

Windows — Begin to feel it boring.

I owned my own computer when I was 18 because my parents were afraid that computer will have some bad influnce on my study. So they bought me one after I finished the National Colleage Entrance Examination. Then I began to use Windows a lot since this is the only OS on my computer. In fact, before I had my own computer, I had been using Windows for much time. At that time, computer games were my favourate(Star Craft, War Craft & Need for speed, I just like the three and never play RPG or online games). On my 19 year’s birthday(2005), I had my own note book, an acer TravelMate 3202. Again the OS on it is Windows. At that time, I had been less interested in computer games though I choose this notebook is because it has an ATI 9700 graphic card which should be good for playing 3D games.

Maybe I am a strange person. Since when I could play computer games any time I wanted to, I began to found that I was losing interest in them. And later in 2005.6, I seldom played computer games any more and then I found Windows is boring. Yes, Windows can meet all my needs, but as my major is software engineering, I want to know more about an OS and I want get more control over the system. To me, the OS itself is also a computer game.(not very suitable) And then, just before the summer vocation began, I downloaded Fedora Core 4 and installed it on my notebook. That’s that’s the first time I saw a computer whose OS is not MS Windows or MS-DOS. (shamed)

Fedora Core — the begin of my Linux experience

I have no experience on Linux/Unix, and when I’ve installed FC4 on my notebook, all I did was to find the count-parter software which I used on Windows, not to learn the basic commands used on Linux/Unix. Lots of painful experience because I was doing things in a wrong way! Very soon I found it’s hard to install these software because of the dependencies. And very soon I go back to Windows and just left FC4 on my notebook just because… I’m afraid I can’t boot Windows if I delete the Linux partition.

Just after the Nation Day of 2005, I read the article written by Ying Wang titled “Do all the job under Linux, throw away Windows completely” (I don’t know is this translation correct.) This article says a lot of benefits about using Linux and Linux itself. The article is a little bit over rating Linux but is really convince-able. And I also read an article in “Joel on software” which compared Windows and UNIX. The conclusion of this article is that UNIX is good for programmers while Windows is good for the general users.(hope I didn’t misunderstand it.) And in this article I found Eric S. Raymond. I visited his web site and read some of his excellent articles(like “How to become a hacker”, “How to ask questions”). All these things made me decide to switch to Linux. Special thanks to those authors, it’s them that made me take the decision and it’s that decision made me found a great world of sharing!

As I decided to switch to Linux, I decide to learn from scratch. I borrowed “Unix The text book” and began to read it. At the same time I tried to install some software that are really needed for my daily use. Still I encountered some problems but fortunately they were all solved. (When you have problem using Linux, you can always find people who’d like to help you, while if you’re using Windows, I don’t know whether MS will treated you seriously.) These basic commands made life easier and I began to be used to manipulate files at the console instead of using Natuils and I thought it’s much efficient. Gradually, I logged in Windows less than Linux. Though there were still something awful, I can bear them. But these small awful things made me switch to SuSE.

SuSE Linux 10 — Let’s throw away Windows!

I DO NOT mean SuSE is better than FC4 here! I just think FC4 is not so suitable for beginners like me, while SuSE is really suitable for people who want to switch from Windows to Linux or are finding an substitute for Windows. (It’s also suitable for development.) It’s not fair to compare SuSE and FC4 because the FC4 is released long before SuSE 10.

The first time I saw SuSE is on my roommate’s computer. He installed SuSE in VMWare. And when I saw it, the first idea comes in mind is that it’s much more beautiful than my FC4(though my roommate used GNOME, but KDE under SuSE is even more beautiful). And what better, the default Chinese input method is SCIM, the Chinese characters displayed very well. Hesitated for a couple of days, I decided to delete FC4 and install SuSE on my notebook. At first I chose GNOME, and later I tried KDE and I immediately reinstalled SuSE choosing KDE.(I reinstalled it because I want to have a cleaner system.) GNOME is simple, but to me KDE is more suitable(at that time ). While reinstalling some software I used under FC4, I found that the GUI package management tool YaST in SuSE is quite good. When there are dependency problems, it will tell you where is the problem and suggest you how to solve the problem. You can just ignore the problem and take the risk yourself! It’s simple to use and is also flexible in some degree. In addition, the repository is easy to find, this makes life really much easier. I used those repositories to install many software, like mplayer, xmms-mad, bluefish… The problem with this tool is that it takes a long time to start up, so I installed apt4rpm(it is included in the SuSE Linux CD sets) and then use apt-get when I like. After using SuSE for some time and successfully solved some problems, I seldomly used Windows. Only when I have to visit some web site which can only be visited by IE will I use Windows.(Damn those web sites! I will never visit them any more unless they fix the problem) It’s about the time to complete throw away Windows, there will be no needs to it.(In fact, I deleted Windows just before I began to install Gentoo.)

Gentoo — want to know more about Linux and get more control

Yes, SuSE is great and I love it! It’s almost perfect for every day use and especially for those who want to switch from Windows to Linux. But to me, it still has a problem. The reason I switch to Gentoo is that I want know more about the OS, and I want to get more control over it. SuSE does a lot of configuration for you and you don’t need to do them yourself because the default one is usually OK. And when I was using it, I relay on the graphic tools too much to do the configuration so that I don’t know how to edit the configuration file manully and even didn’t know where it is stored. I think I have to know how to edit these configuration file by myself because this is the common way and can get more control.(Maybe I am wrong.) Then I heard Gentoo and know the soul of it is to give you the choice. And this article made me even sure that I should give Gentoo a try. And later I found Gentoo perfectly meets my needs.(LFS can give you more control over the system, but it’s too hard for me)

The installation took me a long time. One was because I had to compile almost every thing. From the compiler to the base system, and then the kernel, xorg-x11 and other software I needed like Emacs, firefox(I love them ) The more important reason was that I was not so experienced. I began to install Gentoo on Jan 15, 2006, and at that time I had used Linux for only 4 months. What worse, I chose the harder way: install from stage 1. I spent about 2 weeks time to set up the whole system.(shamed, but this includes the software I need to use) Of course I had a lot of problems during the installation, or I wouldn’t have to spent so much time. Luckily, Gentoo’s document is excellent! Really excellent!! These document helped a lot. And when the document didn’t help, I could google and could always find something helpful in the Gentoo forum. Without these things, I can’t imagine how I can set up Gentoo on my notebook. Most time troubleshooting is painful, but once you solved the problem you will be really happy! During the installation, I had much painful time and also much pleasant time. The more important thing is, I learnt a lot!

The first thing is about the compiler. Gentoo’s stage 1 tar-ball contains gcc-3.3.5 but I want to use gcc-3.4.5. I noticed that during the bootstrap, portage used gcc-3.3.5(this time use the flag march=pentium3) to built gcc-3.4.5. And when I emerge the system, portage used gcc-3.4.5(this time use the flag march=pentium-m) to build another gcc-3.4.5 so I will get an optimized compiler for my system!

Another thing is the kernel configuration. At first I used the configuration file the installation CD used to make things easier and to have a working system as soon as possible. And later I read a lot of articles about the kernel configuration in order to have an tailored configuration for my kernel and take full advantage of my hardware.(Most of them are Gentoo’s document, these articles includes things about alsa, wireless network, dri, power management, usb devices, software suspend and something else.) When I am not sure about one hardware support is needed for my notebook, I will compile it as a module and later use “lsmod” to see whether it is really needed. Now I think my kernel is some what tailored for my system.(Of cause there will be some thing that is not needed, but won’t be much and that’s OK) And I make the wireless card work, and successfully installed the ATI’s video card driver which I failed to when I was using SuSE.(Though SuSE’s document points out how to install the driver.)

Other things includes how to configure the Xorg, how to modify the font configuration file and many other things.

Many many thanks to the authors of these documents and these articles! They did really a great job! Portage is the most flexible software management tool I’ve used! It’s simple to use, just one command “emerge” and it will do things automatically. It’s flexible to use, just edit some flags and the software will be tailored for you. Gentoo gives you the choice, you just make the decision and wait for some time for the downloading and compiling. I really LOVE it! And I don’t think I will switch to any other distribution for my own use. What about Windows? Are you joking? I am not a fool and I like the feeling to control my system!

Emacs 23 and Unicode Support

I am using UTF-8 encoding on my system. I have to do so because: (1) I speak Chinese and I have to mix Chinese and English. (2) I have a FAT32 partition which uses UTF-8 encoding and I have some files using Chinese names in it. I don’t know how to change it’s encoding. (3) UTF-8 encoding has many benefits and I hope it will become the mainstream. But here comes the problem. Emacs 21 doesn’t have support for Chinese UTF-8 encoding, when I open a Chinese text file which is encoded in UTF-8, all I got are backslashes and digitals… Luckily enough, there is already Emacs supporting what I need though not very stable stable—that’s Emacs 23. It’s internal encoding is based on UTF-8. So far, it can only be got from the Emacs CVS repository. Using the following command:

$: export CVS_RSH=ssh

$: cvs -z3 -d:ext:[email protected]:/cvsroot/emacs co -r emacs-unicode-2 emacs

After getting the source code, use “make bootstrap && make install” to compile and install it. Now it’s working quite well on my system. Really great! But I still don’t know how to make LaTeX work with UTF-8 encoded Chinese text files, so sometimes I have to use iconv to convert from UTF-8 to GB2312 or directly edit files encoded in GB2312 with Emacs. It’s not so convenient but I can bear it :–( . Things will be even greater if I can use UTF-8 encoding for all my files!

JDEE Compile Time Error: Buffer Is Read Only

JDEE compile time error: “buffer is read only”

I use JDEE to write Java programs in emacs. The problem I encountered is that when I compile the program(C-c C-v C-c), the JDEE compile buffer has nothing to display and actually nothing was compiled. The mini buffer is saying “buffer is read only”. After googled some articles, I solved the problem.

Open the file compile.el in /usr/share/emacs/lisp/progmodes, search “buffer-read-only”, change all the value to nil, then byte compile and reload it, things will be right now.

This solution surely is not very good. The compile buffer should be read only after things is displayed. I don’t know whether this is the problem of JDEE or of emacs, but since I can get things done now, it’s OK. Hope to find better solution later.

LaTeX and CJK, How to Use the TrueType Fonts

First I should tell you that I am using teTeX 3.0 and I am not sure whether the steps I discribed below works for other TeX distribution. You may change something to get things work correct.

  1. Get the TrueType fonts.(May be you have done this.) This shouldn’t be difficult. You can find some free TT fonts on CTAN. One thing should be noticed is that if you want to get Unicode support, you should get the Cyberbit.ttf(it’s free, more details about Unicode and CJK, click here, I didn’t use it since it’s a little troublesome, when needed I use iconv to convert).

  2. Download gbkfonts.(Other versions, see here, thanks to the authors) I think it should also be able to work on other TT fonts other than Chinese TT fonts. I didn’t test it. If it doesn’t work on other TT fonts like Korean, Japanese TT fonts, you may have to use ttf2afm and some other programs. Read the pdfTeX manual for details.

  3. Uncompress gbkfonts you just downloaded. Copy the file “go“, “gbkfonts-glibc” to /usr/local/bin, change the file name “gbkfonts-glibc” to “gbkfonts“. Edit the script go, find these lines like “gbkfonts ${opts[*]} $dir/FZSongTi.ttf song“, change it to the fonts name you want use. Then “cd /usr/local/share/texmf”(if you run the program in your locale texmf directory, you need to move less files later), type “go yourfonts directory“(need to have the write right in this directory), wait… and the program will create the afm, tfm, type1, enc files and some other configuration files for divpdfm, pdftex and dvips.

ADDED ON JULY 31st, 2006.

I installed TeXLive on Arch and reinstalled the CJK fonts. This time I find that in teTeX 3.0 the map files should be put in TEXMF/fonts/map, while enc files should also put in TEXMF/fonts/enc, so what I’ve written in the past is right though I don’t know this yet at that time. Maybe I’ve read the texmf.cnf that time so I know where to put these files. I can’t remeber now.

gbkfonts shoud be modified to accomadate these changes. May be I can have a try?

ADDED ON DEC 11st, 2006. Other people have already noted this long time before, why didn’t I found these articles at that time? Wast so many time on this problem … :–( A summary for font path change in teTeX 3.0

dvipdfm/config/*.map –> fonts/map/dvipdfm/*.map dvips/cjk.map –> fonts/map/dvips/cjk.map pdftex/config/*.map –> fonts/map/pdftex/*.map ttf2pk/ttfonts.map –> fonts/map/ttf2pk/ttfonts.map dvips/chinese/*/*.enc –> fonts/enc/dvips/chinese/*/*.enc pdftex/enc/* –> fonts/enc/pdftex/*

See 何勃亮’s website for more information. He also have modified gbkfonts to accormodate these changes and simplify the procedure for generating files needed to use with CJK. I’ve visited 薛瑞妮’s website many times but ignored things about teTeX 3.0 … You will also find some information there.

  1. Some articles talking about using CJK and TrueType fonts stops here. Of course you need “mktexlsr”, but things just don’t work on my system. You can now make some test, if things don’t work, read on. Below are additional steps I did on my system to get things work. I had a look at my texmf.cfg(in TEXMF/web2c, you may need to change the variable TEXMF to let TeX search local TEXMF first) and check out some path on my TeX system. Then first create the map files directory: “mkdir /usr/local/texmf/fonts/map/{dvips,dvipdfm,pdftex}”(using bash), mv all the map files gbkfonts created to the corresponding direcrory. Then create the enc files directory “mkdir /usr/local/texmf/fonts/enc/dvips“, mv the directory which contains enc files in the directory “dvips” just created here. You should keep the directory structure and TeX will search these directories recursively.

  2. If you use “updmap” to mantain the font map information, I suggest you just add one line in updmap.cfg(also in TEXMF/web2c) “Map cjk.map“. Run “mktexlsr”(If you don’t run this, updmap will not find the map file you just created) and then “updmap” to update the font map information. You can have a look at cjk.map, it contains a lot of lines ending with *.pfb, so this is in fact using Type1 fonts gbkfonts just created.( In Type1 directory. ) dvipdfm, dvips and pdftex all supports Type1 fonts, this works well. You should be able to get things works correctly now. Make some test?

ADDED ON JULY 31st, 2006. For dvipdfmx to use TT fonts directory, add “f cid-x.map” in TEXMF/dvipdfm/dvipdfmx.cfg. The cid-x.map is created by gbkfonts. If you use other map files created be gbkfonts in the dvipdfm directory, dvipdfmx still can’t create pdf files that support searching Chinese.

One more thing is that dvipdfm and dvips do read the map files specified in the config file. ( TEXMF/dvipdfm/config/config and TEXMF/dvips/config/config.ps respectfully.) But I don’t know which is the config file for pdftex, so to make pdftex use the TT fonts or Type 1 fonts, you still need to append the map file to pdftex.map manually. For dvipdfm and dvips, you can just add some line to the config file to tell the program to include the map file.

  1. But there is still some problem. I use dvipdfmx to create pdf files which can be searched even it contains CJK fonts, but it should be configured to use TT fonts directly. The problem with updmap is that it updates font map information for the three program at the same time using the same map files :–( That’s not what I wanted, but I am not able to modify the script now so I use the stupid method—add font map manully. “cd /var/lib/texmf/fonts/map”, keep dvipdfm untouched. “cd to dvips/updmap“, append cjk.map to psfonts_t1.map.(the file which symbolic link psfonts.map points to) Then “cd pdftex/updmap”, append all the map files in the directory pdftex which was created by gbkfonts to pdftex.map.(this is also a symbolic link, you can directly edit the file it points to) For dvipdfm(x), you just need to mv cid.map and some other map files created by gbkfonts to /usr/local/share/texmf/fonts/map/dvipdfm. Then dvipdfm(x) and pdftex will both use TT fonts directly, while dvips uses Type1 fonts. That’s all.

So many words… I do think these artiles stops at step 3 are right, and I don’t need to write so many words. I don’t know why :–( After running gbkfonts we get the map files and the configuration files, if pdftex and dvips read these configuration files, then we can just stop at step 3. But I didn’t find pdftex.cfg in /usr/share/texmf/pdftex/config, in fact there is no such directory at all! So I wonder whether pdftex read the configuration file.(This seems not likely to happen, but the brutal fact makes me think so) There is the file config.ps in /usr/share/texmf/dvips/config, but it also seems that dvips also didn’t read it because unless I manully add cjk.map to psfonts_t1.map it won’t wok, though I have added “p +cjk.map” in config.ps. But it’s strange thar dvipdfm(x) read the configuration files since I keep it’s font map files in /var/lib… untouched. I will ask for help about this problem later. It is very likely that it is because I made some mistakes. If you know, please tell me, I do appreciate!