Sunday, February 15, 2009

在emacs中查字典

实验环境:windows下的emacs22.3,dictionary-1.8.7
1.下载dict mode支持包。

2.安装Windows下的make:
http://sourceforge.net/projects/gnuwin32/
这个开源项目就是要移植一些linux下的常用工具到windows下,其中包括make,grep等等。

3.然后安装dict mode。注意两点:
(1)为方便起见,应先把make的路径加到系统的环境变量中;
(2)修改dictionary-1.8.7的makefile中的EMACS变量的值为你的runemacs的路径。
2.在配置文件init.el或(.emacs)中添加如下代码:
;;-----------------dictionary------------------
(autoload 'dictionary-search "dictionary"
"Ask for a word and search it in all dictionaries" t)
(autoload 'dictionary-match-words "dictionary"
"Ask for a word and search all matching words in the dictionaries" t)
(autoload 'dictionary-lookup-definition "dictionary"
"Unconditionally lookup the word at point." t)
(autoload 'dictionary "dictionary"
"Create a new dictionary buffer" t)
(autoload 'dictionary-mouse-popup-matching-words "dictionary"
"Display entries matching the word at the cursor" t)
(autoload 'dictionary-popup-matching-words "dictionary"
"Display entries matching the word at the point" t)
(autoload 'dictionary-tooltip-mode "dictionary"
"Display tooltips for the current word" t)
(unless (boundp 'running-xemacs)
(autoload 'global-dictionary-tooltip-mode "dictionary"
"Enable/disable dictionary-tooltip-mode for all buffers" t))
;; key bindings
(global-set-key "\C-cs" 'dictionary-search)
(global-set-key "\C-cm" 'dictionary-match-words)
(global-set-key [mouse-3] 'dictionary-mouse-popup-matching-words)
(global-set-key "\C-cd" 'dictionary-lookup-definition)
;; for dictionary tooltip mode
;; "web1913" for Webster's Revised Unabridged Dictionary(1913)
;; 貌似在emacs 22.3中不支持tooltip,即鼠标取词,故去掉,节省内存
;;(setq dictionary-tooltip-dictionary "web1913")
;(global-dictionary-tooltip-mode t)
(setq dictionary-default-dictionary "web1913")

OK了,上面几个操作函数意思如下:
dictionary-search:请求输入一个单词,输出所有的解释条目。
dictionary-lookup-definition:查当前鼠标处的单词。
dictionary-match-words:输入一个匹配模式,输出匹配的单词。
dictionary-popup-matching-words:弹出一个菜单,显示各个字典中相的匹配单词(匹配策略点击按钮Select Match Strategy中选择)。
在查询结果窗口中,输入h可查看快捷键。

有了这个,看起英文文档来就方便多了,而且用的是原汁原味的英语词典,对英语水平的提升也很有帮助啦。

No comments:

Post a Comment

Insist On

English words
Go to bed at 23:30

About Me

Gtalk:l0he1g at gmail
Location:Beijing,China