`

emacs插件以及配置 转

 
阅读更多
原文地址:http://blog.csdn.net/liang890319/article/details/6938453




本文转自网络 原文地址正在寻找中

当前的Emacs发行版是Emacs21,它的特点是中文的输入和显示的配置麻烦得很。终极的解决方法是安装Emacs23,它是正在开发中的不稳定版,所以打开后它警告你:

!! Thisversion is ALPHA status.It may lost your data !!

但是不用担心,这种事是不会发生的,因为在Linux的文化中有一句名言,就是:

The moststable version is unstable version.(最稳定的版本就是不稳定版。)

这是真理,人人都应把它谨记于心,作为选择Linux软件的基本原则。

如何安装配置Emacs23?在linuxfans.org上有一篇写得很详细的文章,原文地址:http://www.linuxfans.org/nuke/modules.php?name=Forums&file=viewtopic&t=136702

现在把它原文贴过来(棕色的字是我自己添加的,原文没有):

1、为什么要安装emacs23

Emacs21 是一个很常见的版本了。对于中文等语言内部字符表示方案,也就是所谓的Emacs Mule表示方案,这个方案是以iso2022为基础,并进行了适当的扩充。现在这个方案已经不敷使用,例如无法支持GBK和GB18030,其编码空间已经基本耗尽。因此,要想使用GBK扩充的汉字,就得用苏勇、詹剑等开发的mule-gbk软件包,比较麻烦。

Emacs22沿用了emacs21的方案,但在其它方面,Emacs22对Emacs21进行了很多改进,修正了很多bug,预计在短时间内,Emacs22将会是Emacs的最新release版本。

Emacs23,又称为emacs-unicode-2branch,它对Emacs内部字符的表示方案做了一次大手术:它以utf8编码方案为基础,并进行了适当的扩充和调整。目前这个手术尚未完成,bug比较多,但是这个版本已经基本达到了可用的程度,而且对中文(GBK/GB18030)的支持很好,不用再安装mule-gbk了。

作为一个新时代的弄潮儿,我们要装就装最新的,管他稳定与否呢,哈哈,这是开玩笑了,我的感受是稳定性一点不差。所以我们要安装Emacs23。(备注:我现在还是不知道如何输入中文,不过中文的显示已经非常的完美了)

废话少说,在我遍历互联网数次后(夸张!),终于……
2、安装前的准备

代码: apt-getinstall ssh
apt-get install texinfo
ssh主要使用来从cvs上拉代码的,texinfo主要是需要里面的makeinfo这个命令编译一些man包。

3、从CVS下载最新的代码

代码:
exportCVS_RSH="ssh"
cvs -z3-d:ext:anoncvs@savannah.gnu.org:/cvsroot/emacs co -remacs-unicode-2 emacs

也可用:

cvs -z3-d:pserver:anonymous@cvs.savannah.gnu.org:/sources/emacs co -remacs-unicode-2 emacs
整个需要下载约80M的文件,制作成bz2包后有19M.

4、编译安装

先配置一些编译环境 代码:
apt-get install build-essential
apt-get build-dep emacs21
apt-get install xserver-xorg-dev
apt-get install xorg-dev
apt-get install libncurses5
apt-get install libncurses5-dev
apt-get install libgtk2.0-dev

代码:
./configure--prefix=/usr --with-x-toolkit=gtk
make bootstrap
make info
sudo make install

这里,我看了其他的帖子,用的是下面的代码:

./configure--enable-font-backend  --with-freetype --with-xft--x-includes=/usr/include/X11 --x-libraries=/usr/lib/X11

其中--enable-font-backend  --with-freetype--with-xft三个参数让Emacs可以使用freetype字体和xft字体系统。以后就可以在.Xresources文件中这样设置Emacs字体:

Emacs.font:Bitstream Vera Sans Mono-8

比如设置中文字体时将下面的代码放到~/.Xresources中,没有这个文件的话就新建一个。


Emacs.Font:fontset-chinese
  Emacs.Fontset-0:-*-fixed-medium-r-*-*-14-*-*-*-c-*-fontset-chinese,\
   chinese-gb2312:-*-wenquanyi bitmapsong-*-*-normal--*-*-*-*-*-*-iso10646-1,\
  chinese-big5-1:-*-wenquanyi bitmapsong-*-*-normal--*-*-*-*-*-*-iso10646-1,\
  chinese-big5-2:-*-wenquanyi bitmapsong-*-*-normal--*-*-*-*-*-*-iso10646-1
我这里用的是文泉驿字体显示中文,用fixed字体显示英文,这样就可以正常的显示绝大多数的字体了。但是有些繁体还是不正常。另外,如果不想用wqy字体,也可以用其他的字体,比如arpl new sung等等的,只要在xlsfonts的列表中能够看到,就可以在这里的冒号后面使用,如果对其他的编码有要求的话,也可以指定字体。在emacs的Options->mule->describelanguage enviroment中可以看到对各个环境以的描述。要设置的话,很简单:把相应的环境放到冒号前面,把字体放到冒号后面就好。
写好后用 xrdb-load ~/.Xresources 然后再启动,看看,字体是不是漂亮多了~

然后还是:

makebootstrap
make info
sudo make install

要想同时使用自己编译的emacs和debian源里面的elisp包,可以在自己的.emacs里面加入下面的配置:

(let ((startup-file "/usr/share/emacs/site-lisp/debian-startup.el"))
(if (and (or (not (fboundp 'debian-startup))
(not (boundp  'debian-emacs-flavor)))
(file-readable-p startup-file))
(progn
(load-file startup-file)
(setq debian-emacs-flavor 'emacs21)
(debian-startup debian-emacs-flavor)
(mapcar '(lambda (f)
(and (not (string= (substring f -3) "/.."))
(file-directory-p f)
(add-to-list 'load-path f)))
(directory-files "/usr/share/emacs/site-lisp" t)))))
安装好的emacs23默认在/usr/local/bin下,需要将其链接到/usr/bin下:

ln -s /usr/local/bin/emacs /usr/bin/emacs-snapshot
ln -s /usr/local/share/emacs/23.0.0 /usr/share/emacs-snapshot
还要创建两个目录:

mkdir /etc/emacs-snapshot
mkdir /etc/emacs-snapshot/site-start.d
使用update-alternatives安装选项:

update-alternatives --install /usr/bin/emacs emacs /usr/bin/emacs-snapshot 25
for p in ctags etags emacsclient
do
update-alternatives --install "/usr/bin/$p" "$p" "$EMACSDIR/bin/$p" 25
done
为新的emacs重新编译debian的包:

/usr/lib/emacsen-common/emacs-install emacs-snapshot


5、运行

这一部分主要是给大家看看运行的效果,这个是最最最初的运行效果,连.emacs配置文件都没有的时候就是这个样子:



下面是Emacs23自带的简体中文版本的入门教材,还有繁体中文等很多语言:


6、安装speedbar

speed是干什么的呢?官方网站上说:
引用:
Speedbar is an Emacs Lispprogram which allows you to create a special skinny frame with aspecialized directory listing in it. This listing will have bothdirectories and filtered files in it. You can then load filesinto your emacs frame, or expand the files to display all thetags that are in them and jump to those tags. You can also expandmultiple directories into your speedbar frame.
其实就是显示一个文件目录列表,选择文件方便很多,不错,既然很多人都推荐,可能还有更好的用处吧

首先在下面的网址http://cedet.sourceforge.net/eieio.shtml下载最新的speedbar的代码

然后解压缩到/opt/speedbar-0.14beta4目录

代码:

make
make opt

修改自己家目录下的.emacs配置文件,对于我来说是,就不是修改而是新建了:

代码:

~$ cat .emacs
  (add-to-list 'load-path "/opt/speedbar-0.14beta4")
   (autoload 'speedbar-frame-mode "speedbar""Popup a speedbar frame" t)
   (autoload'speedbar-get-focus "speedbar" "Jump to speedbarframe" t)
   (define-key-after (lookup-keyglobal-map [menu-bar tools])
         [speedbar] '("Speedbar" . speedbar-frame-mode)[calendar])

   ;; Texinfo fancy chapter tags
  (add-hook 'texinfo-mode-hook (lambda () (require'sb-texinfo)))

   ;; HTML fancy chapter tags
  (add-hook 'html-mode-hook (lambda () (require 'sb-html)))

   ;; For any verison of emacs on a linux RPMbased system:
   ;; (autoload 'rpm "sb-rpm""Rpm package listing in speedbar.")

   ;;For any version of emacs where w3 is installed:

  ;; w3 link listings
   (autoload'w3-speedbar-buttons "sb-w3" "s3 specific speedbarbutton generator.")
如果你不是用的debian系列的发行版,而是给予RPM的发行版,那么把配置文件当中我注释掉的关于RPM的内容取消注释就可以了。

配置文件中还有关于W3的内容,W3是用Emacs-Lisp语言写的功能完整的网络浏览器,W3的网站http://www.cs.indiana.edu/elisp/w3/docs.html上写到W3现在对21版本的Emacs和XEmacs支持比较好,所以我还没有觉得是否安装,按照我的个性是一定要尝试一下的,所以干脆把配置的信息留在那里。




7、安装eieio

免不了要解释eieio是什么,官方网站上说

引用:
EIEIO is an Emacs lispprogram which implements a controlled object-oriented programmingmethodology following the CLOS standard. EIEIO also has objectbrowsing functions, and custom widget types. It has a fairlycomplete manual describing how to use it.

感觉上是说写程序的时候,尤其是C++这些面向对象语言的时候提示你有哪些方法可以使用吧,还没有用过呢,不清楚

解压缩到/opt/eieio-0.17

代码:

make"LOADPATH=/opt/speedbar-0.14beta4"

修改.emacs配置文件,添加一行:
代码:

(add-to-list 'load-path"/opt/eieio-0.17")
8、安装Semantic

免不了要解释Semantic是什么,官方网站上说

引用:
Semantic is an infrastructurefor parser based text analysis in Emacs. It is a lexer,parser-generator, and parser. It is written in Emacs Lisp and iscustomized to the way Emacs thinks about language files, and isoptimized to use Emacs' parsing capabilities.

干什么的我不懂就不乱说,但是我不懂,所以我不知道安装是不是真的完全正常可以使用

解压缩到/opt/semantic-1.4.4

代码:

make"LOADPATH=/opt/speedbar-0.14beta4 /opt/speedbar-0.14beta4"

修改.emacs配置文件,添加:
代码:

   (add-to-list'load-path "/opt/semantic-1.4.4")
   (require'semantic-load)
   (setqsemantic-load-turn-everything-on t)
9、安装ECB

在上面三个插件安装完成后可以安装ECB了,ECB把你的Emacs变成一个开发环境,也就是IDE啦,它的安装相对简单:

解压缩到/opt/ecb-2.32

修改.emacs配置文件,添加:
代码:

(add-to-list 'load-path"/opt/ecb-2.32")
(require 'ecb)
完后就是这个效果:



是不是很不错啊?

10、配置个性化Emacs

<1>中文输入法

Emacs23自带中文输入发,至于好不好用就看你自己了

Ctrl+x 回车 Ctrl+\回车

输入chinese-py回车

就可以输入中文了

当然我们完全可以用scim输入中文

但是因为ctrl+space被默认绑定成Markset,因此我们需要下面的代码把这个功能绑定到shift+space上:

代码:
(global-set-key [?\S-] 'set-mark-command)


现在看看是不是可以输入中文了?



<2>界面颜色主题color-theme

大家最喜欢做的一件事情就是设置自己的个性化配置。当中很重要的就是更换主题

我已经上传了color-theme,大家可以下载:

http://www.linuxfans.org/nuke/modules/Forums/files/color-theme.el.tar.bz2

我是解压缩到 /opt/myEmacs下的

然后修改配置文件.emacs

代码:
(load-file"/opt/myEmacs/color-theme.el")
(require 'color-theme)
(color-theme-gnome2)


第三行是我直接加载gnome2这个主题,我发现这个主题很适合我的品味

至于这个插件其他的操作,大家自己看文档吧


<3>语法高亮

没什么好说的,.emacs文件添加,以后修改.emacs文件我就不在专门说了,直接给代码:

代码:

(global-font-lock-mode t)



<4>Emacs当中实在不方便的地方这样调整
1.

不要打入 TAB 时总是听到PC喇叭嘀嘀嘀的叫

代码:
(setq visiable-bellt)


2.

不要总是没完没了的问yesor no, 为什么不能用y/n

代码:
(fset 'yes-or-no-p'y-or-n-p)


3.

为什么不能显示个时间什么的

代码:
(display-time)


4.

为什么不显示当前所在的行号和列号

代码:
(column-number-modet)


5.

为什么不能像Windows下编辑器那样,高亮显示要拷贝的区域
代码:

(transient-mark-mode t)


6.

我要显示匹配的括号

代码:
(show-paren-mode t)


7.

为什么使用语法显示的大文件在移动时如此之慢

代码:
(setqlazy-lock-defer-on-scrolling t)
(setq font-lock-support-mode'lazy-lock-mode)
(setq font-lock-maximum-decoration t)

8.

不要那个如此大的工具条

代码:
(tool-bar-mode -1)

9.

不要生成临时文件

代码:
(setq-defaultmake-backup-files nil)





首先安装emacs(费话么~~):
sudoapt-get install emacs

刚安装好的状态,我感觉是不很爽,可以参考网上很多关于emacs的配置文章修改一下.
我的配置文件在这里放:http://hi.baidu.com/liuhengloveyou/blog/item/681f7934f32abe48251f1443.html

安装ecb:
sudo apt-get install ecb

然后启动emacs,执行命令: M-xecb-activate
就可以调出ecb的那4个小窗口了.

ecb启动的时候会弹出一个提示窗口,如果不想看到它,可以在emacs配置文件(~/.emacs)里加这一句:
(setqecb-tip-of-the-daynil)

ecb的导航窗口里的东西默认不能用鼠标点选/打开,用键盘回车可以。如果想用鼠标,配置文件里加这一句:
'(ecb-primary-secondary-mouse-buttons(quote mouse-1--C-mouse-1)
搞不定,可以参照我的配置文件。

安装cscope:
sudoapt-get install cscope

然后在emacs配置文件里添加这一句:
(require'xcscope)

重启emacs以后,打开一个C文件,就有了Cscope菜单。(见图)
这个菜单里有很多查找代码的功能。
像上面那图里面的效果,我先中factorial这个函数名,然后执行FindSymbol菜单命令。
在下面的那个*cscope*Buffer里面就是查找的结果,可以用键盘选中打开。

配置成这样已经很方便了,ecb显示的目录结构,cscope的函数查找功能。。。
我还不知道怎么可以用鼠标点选查找的结果,哪位知道的话可以交流一下,呵呵。。。
至于cscope的快捷键~~点的多了就知道了。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics