Emacs 23(uncode-2)在debian/ubuntu模式下的基本安装及中文配置

Written by simon on July 28, 2008 – 8:59 pm

嗯,废话少说。来个摘要。我有一台笔记本thinkpad t43,装着ubuntu 8.04,有配置好的emacs23。现在又搞了个二手笔记本thinkpad t40,装了debian,打算把emacs23迁移过来。在t43上,我的emacs23源文件是通过cvs方式下载回来的,保存在/opt目录下。这次将源文件同样复制粘贴到x40的/opt目录下,准备如法炮制。

本文的目的是:在debian testing操作系统的x40上完成emacs 23(cvs版本)的基本安装和中文字题配置。

1.前期准备工作

1.1 dependencies

sudo apt-get install build-essential
sudo apt-get build-dep emacs21
sudo apt-get install xserver-xorg-dev xorg-dev libncurses5 libncurses5-dev libgtk2.0-dev

1.2 字体设置

如果没有安装过字体美化方面的工作,请按照这样的方法来作:
强烈推荐的是stheiti作为中文字体,lucida grande作为英文字体。这样屏幕看起来很舒服。
首先下载stheiti和lucida grande的字体包,这个网络上到处都有,随便找一下就行了。
然后顺便把windows下的字体simsun.ttf(或者叫做simsun.ttc)tahoma.ttf tahomabold.ttf挑出来,位置在windows操作系统盘的/WINDOWS/FONTS目录下(希望我没有记错)。
把上述字体复制粘贴到/usr/share/fonts/truetype目录下,赋予读权限

sudo chmod a+r /usr/share/fonts/truetype/*

系统升级后,原来的sudo gedit /etc/fonts/language-selector.conf文件应该是找不到的。不过就我在三台机器上的调整情况来看,这个文件不编辑也没有太大关系,可以直接进入下一步:
刷新字体缓存

sudo fc-cache -f -v

嗯,现在,如果你在用的是gnome,在gnome的menu bar中依次选择system-preference-appearance-fonts,将字体选择成stheiti即可,看看是否有效果?如果有的话,恭喜你,字体设置成功,可以进入下一个环节了。

2.cvs方式下载并安装emacs 23

这个没什么可说的了,慢慢下载吧。或者像我这样,将原有的emacs23源代码直接复制粘贴过来(懒人万岁!)

cd /opt

确定你有在/opt进行操作的权限,或者把文件放在你有权限的home目录下。以下都是默认放在/opt下的。
cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/emacs co -r emacs-unicode-2 emacs
要是系统提示没有找到cvs命令,就安装一下

sudo apt-get install cvs

(我就是因为没有进行1.1部分的工作,所以在卡在这里动弹不得,configure出现错误提示没办法通过--with-x的参数编译。错误提示是:

configure: error: You seem to be running X, but no X development libraries were found.  You should install the relevant development files for X and for the toolkit you want, such as Gtk+, Lesstif or Motif.  Also make sure you have development files for image handling, i.e. tiff, gif, jpeg, png and xpm. If you are sure you want Emacs compiled without X window support, pass   --without-x)

进入emacs目录

cd /opt/emacs

配置一下

./configure --host=i686-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --enable-debug --without-carbon --with-x --with-xpm --without-toolkit-scroll-bars --enable-font-backend --with-freetype --with-xft --with-jpeg --with-tiff --with-gif --with-png --with-x-toolkit=gtk --with-freetype2 

上述这段./configure后面的参数都是我复制粘贴过来的,大致作了一些改动。注意,现在的版本中 --with-gtk这样的参数都已经不再有效了。需要相应的改为--with-x-toolkit=gtk。其他的大家可以挨个试试看。

捎带着罗嗦一句。根据以前读过的一些关于linux系统上的中文显示及配置文档(如果我没记错的话),原本linux采用的是xft方式的中文字体,现在主要用freetype方式来显示中文。比如我们前面所安装的stheiti和lucida grande都属于后者。一些比较老的程序是不支持freetype而只支持xft的,比如putty。所以我们也要把simsun等字体安装上去,这样在不支持freetype字体格式的程序下可以用simsun等字体以xft方式显示中文(不知道这么说对不对)。

配置通过之后,运行下一段命令,OK。然后就让程序自己跑去吧,大概需要1个多小时,可以去吃个饭,或者给女朋友打个电话聊聊天,女人可比程序复杂得多:) ──啊?什么?还没有女朋友?握爪! 。。。。。。那就和我一样,洗洗衣服吧

make bootstrap

嗯,回来了,看看make有没有结束。如果结束了的话,可以安装了

sudo make make install

3.后期配置

首先还是在emacs下搞定字体。按照开始的设想,我们将stheiti搞到emacs中。
在你的根目录下建立一个.emacs文件,或者像我一样,将t43的~/.emacs直接搞到x40的~/.emacs中来

touch ~/.emacs

编辑之,加入如下内容

;; For my language code setting (UTF-8)
;; ;;
(setq current-language-environment "UTF-8")
(setq default-input-method "chinese-py")
(setq locale-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)

注意:这段是配合我的en locale环境的。中文环境的请根据情况作相应调整。

以下这段是关于字体配置的

;;=====================================================================
;;FONT CONFIGURATION
(set-default-font "STHeiti-14")
 (set-fontset-font (frame-parameter nil 'font)
              'unicode '("STHeiti" . "unicode-bmp"))
;;======================================================================

基本上来说,14号字体对我足够。
set-default-font "**"的**部分可以替换成你喜欢的英文字体,这个我懒得动了,就和下面关于unicode部分的一样都给搞成stheiti了,效果还都不错。大家可以看情况来适当调整。

4.运行emacs,纠错

进入terminal,并启动emacs的纠错模式

emacs --debug-init

看看有没有出现什么问题?呵呵,如果没有的话,恭喜你,这样就算是完成万里长征的第一步了。
如果有问题,就按照提示的错误所在去一点一点的修改,耐心点作,很快就会搞好了。

5.其他

本文主要是针对emacs 23的cvs模式安装及字体设置所展开。emacs的其他很有趣的内容,尤其是各种插件的安装和配置就不在讨论之列了。如果有时间的话,我可以将自己的阶段性学习成果一点一点发上来,但是眼下的首要任务是搞定后天的驾照交规考试...
呵呵,祝大家愉快。有什么问题欢迎和我这个菜鸟联系。我的email是caoanroad4800@gmail.com。

Share/Save/Bookmark

Tags: , , , , ,
Posted under linux, ubuntu | No Comments »

fglrx done finally

Written by simon on July 19, 2008 – 1:50 am

there used to be envy for ubuntu that automatically installs and configures 3d acceleration for ATI Video Card such as my ATI Raedon Mobility X300. With the help of envy i can appreciate beautiful compiz-fusion effects on my laptop Thinkpad T43. While unfortunately ubuntu release 8.04 LTS conflicted with Envy which means i had to configure the fglrx driver myself.

Sometimes it worked while other times it didn't. I mean, each time kernel got upgraded, for example, from 2.4.17 to 2.4.18, the fglrx had to be reconfigured once again. Not only is it annoying but also very confusing : i did the same configuration all the time, but it worked fine in 2.4.17 but not in 2.4.18. I've no idea what the problem is, and had to turn back into metacity. That makes me feel depressed.

Luckily today i find the upgrade version of Envy, the Envyng. Thanks god, it works fine in Ubuntu 8.04. And now i'm in compiz environment:)

a short HOWTO is shown here:

$sudo apt-get install envyng envyng-gtk

then just run envyng-gtk (graphic mode) or envyng (text mode), follow the instructions, and restart(REMEMBER! DO NOT ACTIVIATE THE SYSTEM--ADMINISTRATION--HARDWARE DRIVERS -- ATI ACCELERATED GRAPHICS DRIVER option! I tried several times with activiating it, getting black screen... Then i tried not to touch it and rebooted my ubuntu directly, realising that Envyng does it autumatically, and that's the only correct way to install fglrx driver on ati graphic cards).
good luck !

Share/Save/Bookmark

Tags: , , ,
Posted under ubuntu | No Comments »

have you mooed today ?

Written by simon on July 17, 2008 – 4:41 pm

Share/Save/Bookmark

Tags: , ,
Posted under ubuntu | No Comments »