http://www.dict.org/ 网页上看到的search type选项)
0. 自己搭一个dictd服务器
以Debian为例,先安装dictd包:
然后你得安装一些词典, 常用的英文词典是:
* wn (WordNet)
* gcide (GNU version of the Collaborative International Dictionary of English)
* foldoc (Free On Line Dictionary of Computing)
* jargon
* vera (Virtual Entity of Relevant Acronyms, computer related acronyms)
另外freedict项目提供一些其它语言的词典。这些包Debian都收录了,所以:
而中文词典包可以在这里找到: dict-zh-1.6
下一步是配置权限,因为Debian缺省的配置比较严格。但这里我就不细说了,只说说quick and dirty的方法: 如果你的dictd 服务器只是你一个人用不需要怎么考虑安全性问题的话,可以把/etc/dictd/dictd.conf里面的access配置为allow *;而且Debian缺省只允许本地访问,想让其它机器也能访问的话可把listen_to 127.0.0.1注释掉。
最后,启动dictd 服务器
https://github.com/emacsmirror/dictionary
这个包自行实现了DICT协议(RFC 2229),所以不需要外部程序。而且它支持http代理,这是dict命令行程序不支持的。
该包有5个.el文件, 主要入口都在dictionary.el。基本用法如下:
(setq dictionary-server "localhost") (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)
回到dict.el, 使用方法如下:
(setq dict-servers '("localhost"))
(setq dict-enable-key-bindings t)
(setq dict-databases '("gcide""pydict"))
(require 'dict)
dict-servers。
也因为上述原因,在Windows上使用的时候特别难搞:首先你没有dict程序,然后它加载时还需要调用gawk, cut,
sed等程序,又会碰到烦人的cmdproxy vs
bash问题。我用Cygwin自己移植了dict客户端过来,但Emacs里面的折腾了好久都没搞定,以后搞定了再补充说明吧(其实这个说了也白说,因为有更好的替代品
dictionary.el,纯粹是征服欲作祟:-)。
3. 其它
dictem
这个包只有一个文件dictem.el,也需要dict命令行程序,比dict.el 好用多了。
;;On Windows, first make sure cygwin binary path in env PATH (setenv "PATH"(concat "e:/cygwin2/bin;e:/cygwin2/usr/local/bin;"(getenv "PATH"))) (add-to-list 'exec-path"e:/cygwin2/bin") (add-to-list 'exec-path"e:/cygwin2/usr/local/bin") (require 'dictem) (setq dictem-server "localhost") (dictem-initialize) ;;Now you can ;;M-x dictem-run-search ;;M-x dictem-run-match