emacs推广,配置详细介绍

Vim、Emacs配置和使用
头像
jarodlau
帖子: 501
注册时间: 2005-09-06 20:34
联系:

emacs推广,配置详细介绍

#1

帖子 jarodlau » 2008-07-15 22:37

很多朋友使用emacs,但是emacs的起点比较高,没有经验的话,入门很难。

我这里给些比较好的链接,都是我初学的时候常看的资料:
GNU emacs的官方网站 http://www.gnus.org/software/emacs
王垠的主页http://docs.huihoo.com/homepage/shredderyin/--我学习emacs就是受他的影响
王纯业的主页http://ann77.stu.cdut.edu.cn/EmacsIndex.html--里面有几个很不错的扩展-比如中文日历
还有就是emacs的wiki主页http://www.emacswiki.org/cgi-bin/wiki--现在大部分的扩展都可以在这里找到
Emacs 中文化指南,有很多适合咱们中国人使用的技巧 http://zhdotemacs.sourceforge.net/emacs/
emacs.cn的wiki,也可以看看http://www.emacs.cn/Main/HomePage
再加一个emacs扩展的仓库http://www.damtp.cam.ac.uk/user/sje30/emacs/ell.html里面的东西很多哦

当然最权威的也就是emacs自带的manual手册了,如果你可以花点功夫读一读的话,会收获大增的。

注:
1,我很多配置都是在emacs22的时候使用的,也许现在的23不兼容,请大家自己测试一下。
2,以冒号;开头的都是注释,不需要删除,直接拷贝就可以使用。
3,如果我那里说错了,希望大家可以指正,一起提高。

下面给出我的配置,其前身是linuxsir上的推广帖,很多配置都没有变:

代码: 全选

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Jarod Lau's dotemacs file
;;; Last modified time
;;; Time-stamp: <jerry 07/15/2008 22:21:56>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;以上是我得time stamp,在后面将有详细讲解
;;设置你的全名和邮件,在发邮件时可以用到
(setq user-full-name "Jarod Lau")
(setq user-mail-address "jarodlau@163.com")
;;设置你的书签文件,默认是~/.emacs.bmk,我喜欢把有关emacs的文件尽量放在一个文件夹,所以就修改了。
(setq bookmark-default-file "~/.emacs.d/.emacs.bmk")
;;设置缩略词的文件
(setq abbrev-file-name "~/.emacs.d/.abbrev_defs")
;;load-path就同bash中的$PATH相似,emacs所需要的Elisp包都得在load-path里的文件夹中
(setq load-path (cons "~/lib/emacs-lisp" load-path))
;;设置info的路径,也可通过Shell的全局变量$INFOPATH设置,我原来的22因为是自己编译的所以这里就注释了
;(add-to-list 'Info-default-directory-list "~/local/info/")
;;由菜单修改配置的东西将会保存在custom-file里,这里我设置他在我的elisp的集中营里
(setq custom-file "~/lib/emacs-lisp/jerry-custom.el")
;;设置gnus启动的文件。默认是为~/.gnus.el
(setq gnus-init-file "~/lib/emacs-lisp/jerry-gnus.el")
;;由于我的配置文件很长,所以按照分类分别放在不同的文件里,方便管理
(load "jerry-basic")
(load "jerry-language")
(load "jerry-calendar")
(load "jerry-folding")
(load "jerry-ido")
(load "jerry-dictionary")
(load "jerry-function")
(load "jerry-mew")
(load "jerry-w3m")
(load "jerry-cedet")
(load "jerry-org")
(load "jerry-dired")
(load "jerry-mode")
(load "jerry-wiki")
(load "jerry-other-elisp")
(load "jerry-key-bindings")

;;这个东西必须放在最后
;;desktop.el是一个可以保存你上次emacs关闭时的状态,下一次启动时恢复为上次关闭的状态。就和vmware的suspend一样。
;;因为我要使用sawfish-mode,wiki-mode,html-helper-mode,放在这里才能保证下次启动时能正确辨认文件需要的模式。
(load "desktop")
(desktop-save-mode)
;;(desktop-read)
上次由 jarodlau 在 2008-07-19 22:57,总共编辑 3 次。
头像
jarodlau
帖子: 501
注册时间: 2005-09-06 20:34
联系:

#2

帖子 jarodlau » 2008-07-15 22:41

emacs配置文件之-jerry-basic.el
这里都是一些杂七杂八的设置,所以统统放到一起,找的时候也容易

代码: 全选

;;; jerry-basic.el ---

;;我还是使用color-theme.el修改颜色吧,天天看着电脑,视力下降的厉害啊
;;使用M-x color-theme-select就可以选择配色方案,在配色方案上按I就
;;可以改变当前frame的配色,按i就可以改变所有frame的配色
;;按p就可以把当前配色方案的lisp打印出来,加入你的.emacs,就可以不用加
;;载color-theme了,这样可以加快起动速度
;;(require 'color-theme);;不用了,真慢,如果上网的话,这个就很慢了,所以我注释掉了
;(load-file "/home/jerry/lib/emacs-lisp/color-theme-6.6.0/color-theme.el")
;(color-theme-initialize)
;;(color-theme-tty-dark)
;(color-theme-comidia)
;(color-theme-dark-laptop)
;(color-theme-arjen)
;(color-theme-euphoria);;颜色很好
;(color-theme-kingsajz)
;(color-theme-cooper-dark)
;(color-theme-oswald)
;(color-theme-hober)
;( my-color-theme t )
;(color-theme-pok-wob)
;(color-theme-whateveryouwant);;字体设置的很好

;;中文字体设定-这里是一部分,还有.Xresources中也有
;; 我是近视眼,喜欢大字体。这个pixelsize大多数人是设成13吧。
 (set-default-font "DejaVu Sans Mono:pixelsize=13")
  ;; 中文字体的设定,网上很多资料都是gb18030,但我的locale是UTF-8
 (set-fontset-font (frame-parameter nil 'font)
  'unicode '("WenQuanYi Bitmap Song" . "unicode-bmp"))


;;外观设置
;;去掉工具栏
(tool-bar-mode nil)
;;我将F10绑定为显示菜单栏,万一什么东西忘了
;;需要菜单栏了可以摁F10调出,再摁F10就去掉菜单
(menu-bar-mode nil)
;;不要滚动栏,现在都用滚轴鼠标了,可以不用滚动栏了
(scroll-bar-mode nil)

;;修改中文文本的行距,3个象素就可以了吧
(setq-default line-spacing 3)
;;启用C-x,C-v,C-s这些通用设置
;(cua-mode t)

;;备份设置
;;emacs还有一个自动保存功能,默认在~/.emacs.d/auto-save-list里,这个非常有用,我
;;这里没有改动,具体可以参见Sams teach yourself emacs in 24hours(我简称为sams24)
;;启用版本控制,即可以备份多次
(setq version-control t)
;;备份最原始的版本两次,记第一次编辑前的文档,和第二次编辑前的文档
(setq kept-old-versions 2)
;;备份最新的版本十次,理解同上
(setq kept-new-versions 10)
;;删掉不属于以上12中版本的版本
(setq delete-old-versions t)
;;设置备份文件的路径
(setq backup-directory-alist '(("." . "~/.emacs.d/backup")))
;;备份设置方法,直接拷贝
(setq backup-by-copying t)
(setq make-backup-file t)

;;自动补全功能,从王垠的网站直接Copy过来的,引用一些他对此的说明
;;你可以设置以下 hippie-expand 的补全方式。它是一个优先列表, hippie-expand 会优
;;先使用表最前面的函数来补全这是说,首先使用当前的buffer补全,如果找不到,就到别的可见
;;的窗口里寻找,如果还找不到,那么到所有打开的buffer去找,如果还那么到kill-ring
;;里,到文件名,到简称列表里,到list, 当前使用的匹配方式会在 echo 区域显示。
;;特别有意思的是 try-expand-line,它可以帮你补全整整一行文字。我很多时后有两行文字大致
;;相同,只有几个字不一样,但是我懒得去拷贝粘贴以下。那么我就输入这行文字的前面几个字。然后
;;多按几下 M-/ 就能得到那一行。
(global-set-key [(meta ?/)] 'hippie-expand)
(setq hippie-expand-try-functions-list
  '(
 ;senator-try-expand-semantic ;优先调用了senator的分析结果-很慢-还是使用吧
  try-expand-line ; 补全当前行
  try-expand-line-all-buffers
  try-expand-list ; 补全一个列表
  try-expand-list-all-buffers
  try-expand-dabbrev ; 搜索当前 buffer
  try-expand-dabbrev-visible ; 搜索当前可见窗口
  try-expand-dabbrev-all-buffers ; 搜索所有 buffer
  try-expand-dabbrev-from-kill ; 从 kill-ring 中搜索
  try-complete-file-name ; 文件名匹配
  try-complete-file-name-partially ; 文件名部分匹配
  try-complete-lisp-symbol ; 补全 lisp symbol
  try-complete-lisp-symbol-partially ; 部分补全 elisp symbol
  try-expand-whole-kill
  )
  )

;;时间戳设置(time-stamp),设定文档上次保存的信息
;;只要里在你得文档里有Time-stamp:的设置,就会自动保存时间戳
;;启用time-stamp
(setq time-stamp-active t)
;;去掉time-stamp的警告?
(setq time-stamp-warn-inactive t)
;;设置time-stamp的格式,我如下的格式所得的一个例子:
(setq time-stamp-format "%:u %02m/%02d/%04y %02H:%02M:%02S")
;;将修改时间戳添加到保存文件的动作里。
(add-hook 'write-file-hooks 'time-stamp)

;;时间显示设置
;;启用时间显示设置,在minibuffer上面的那个杠上
(display-time-mode 1)
;;时间使用24小时制
(setq display-time-24hr-format t)
;;时间显示包括日期和具体时间
(setq display-time-day-and-date t)
;;时间栏旁边启用邮件设置
(setq display-time-use-mail-icon t)
;;时间的变化频率
(setq display-time-interval 10)
;;显示时间的格式
(setq display-time-format "%m月%d日%A%H:%M")


;;将默认模式从fundemental-mode改为text-mode
(setq default-major-mode 'text-mode)
;;启用minibuffer,好像是默认设置吧
(minibuffer-electric-default-mode 1)
;;启用部分补全功能,如输入M-x q r r相当于M-x query-replace-regexp
(partial-completion-mode 1)
;;在minibuffer里启用自动补全函数和变量
(icomplete-mode 1)
;;所有的问题用y/n方式,不用yes/no方式。有点懒,只想输入一个字母
(fset 'yes-or-no-p 'y-or-n-p)
;;允许minibuffer自由变化其大小(指宽度)
(setq resize-mini-windows t)
;;当寻找一个同名的文件,改变两个buffer的名字,前面加上目录名
(setq uniquify-buffer-name-style 'forward)
;;在emacs读man文档时,使用当前buffer
(setq Man-notify-method 'pushy)
;;鼠标自动避开指针,如当你输入的时候,指针到了鼠标的位置,鼠标有点挡住视线了
;;不喜欢这种方式
(mouse-avoidance-mode 'animate)
;;允许自动打开图片,如wiki里面
(auto-image-file-mode t)
;;可以操作压缩文档
(auto-compression-mode 1)
;;在minibuffer上面可以显示列号,列号
(column-number-mode t)
(line-number-mode t)
;;显示默认的文档的宽度,看起来比较舒服?
;;latex90分钟介绍里说66是最大限度,看来不错.
(setq default-fill-column 60)
;不用 TAB 字符来indent, 这会引起很多奇怪的错误。编辑 Makefile 的时候也
;不用担心,因为 makefile-mode 会把 TAB 键设置成真正的 TAB 字符,并且加亮显示的。
(setq default-tab-width 8)
;; (setq tab-stop-list ())
;; (loop for x downfrom 40 to 1 do
;; (setq tab-stop-list (cons (* x 4) tab-stop-list)))
;;指针不要闪,我得眼睛花了
(blink-cursor-mode -1)
(transient-mark-mode 1)
;;当指针到一个括号时,自动显示所匹配的另一个括号
(show-paren-mode 1)
;;是用滚轴鼠标
(mouse-wheel-mode t)
;;去掉烦人的警告铃声
(setq visible-bell nil)
;;滚动页面时比较舒服,不要整页的滚动
(setq scroll-step 1
  scroll-margin 3
  scroll-conservatively 10000)
;;设定句子结尾,主要是针对中文设置
(setq sentence-end "\\([。!?]\\|……\\|[.?!][]\"')}]*\\($\\|[ \t]\\)\\)[ \t\n]*")
(setq sentence-end-double-space nil)
;;去掉Emacs和gnus启动时的引导界面
(setq inhibit-startup-message t)
(setq gnus-inhibit-startup-message t)
;;当指针移到另一行,不要新增这一行?
(setq next-line-add-newlines nil)
;;在文档最后自动插入空白一行,好像某些系统配置文件是需要这样的
(setq require-final-newline t)
(setq track-eol t)
;;使用C-k删掉指针到改行末的所有东西
(setq-default kill-whole-line t)
;;设定删除保存记录为200,可以方便以后无限恢复
(setq kill-ring-max 200)
;;增大使用查找函数和变量的寻找范围
(setq apropos-do-all t)
;;使用aspell程序作为Emacs的拼写检查程序
;;没有aspell的字典,还是用ispell吧
(setq-default ispell-program-name "ispell")
;;启动Emacs自动设置为两个窗口(上下各一个)
;(split-window-vertically)
;;改变emacs标题栏的标题,显示buffer的名字
(setq frame-title-format "emacs-snapshot@%b")
;;允许emacs和外部其他程序的粘贴
(setq x-select-enable-clipboard t)
;;启动Emacs Server,然后用emacsclient起动emacs
;;加快emacs的起动速度
(server-start)
;;把这些缺省禁用的功能打开。
(put 'set-goal-column 'disabled nil)
;;使用narrow功能时的一个设置
(put 'narrow-to-region 'disabled nil) ; C-x n n
(put 'narrow-to-page 'disabled nil) ; C-x n p
(put 'narrow-to-defun 'disabled nil) ; C-x n d

(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)

(put 'LaTeX-hide-environment 'disabled nil)
;;向左右滚动的命令激活:C-x < 和 C-x >
(put 'scroll-left 'disabled nil)
;;可以递归的使用 minibuffer。
(setq enable-recursive-minibuffers t)
;;Save bookmarks file each time a bookmark is added, not just on exit.
(setq bookmark-save-flag 1)
;;使用GTK风格的toolbar
(setq icon-map-list '(x-gtk-stock-map))
;;使用旧的dialog风格,不使用gtk的
;(setq x-gtk-use-old-file-dialog t)
;;自动重载更改的文件
(global-auto-revert-mode 1)
;;custome的风格改为单一的树状风格
(setq custom-buffer-style 'brackets)
;;发送mail的时候使用fortune添加amuses
;(add-hook 'mail-setup-hook 'spook)
;;当鼠标移动的时候自动转换frame,window或者minibuffer
(setq mouse-autoselect-window t)

(provide 'jerry-basic)

;;; jerry-basic.el ends here
头像
jarodlau
帖子: 501
注册时间: 2005-09-06 20:34
联系:

#3

帖子 jarodlau » 2008-07-15 22:47

我的配置文件中关于语言部分的设置--jerry-language.el
现在都使用emacs23了,使用点阵的很少了,不过,我还是喜欢小字体的时候使用点阵

这部分是我的.Xresources中关于emacs的字体设置的部分

代码: 全选

!! Emacs 23 font set
Emacs.FontBackend: xft
Emacs.font: DejaVu Sans Mono:pixelsize=12

代码: 全选

;;; jerry-language.el ---
;;; Code:

(set-language-environment 'UTF-8)
;;
(set-keyboard-coding-system 'utf-8)
;;终端的编码
(set-terminal-coding-system 'utf-8)
;;buffer内文字的编码
(set-buffer-file-coding-system 'utf-8)
;;
(set-selection-coding-system 'utf-8)
(set-clipboard-coding-system 'utf-8)
;;使用utf-8显示文件名
(set-file-name-coding-system 'utf-8)
;;
(modify-coding-system-alist 'process "*" 'utf-8)
(setq default-process-coding-system '(utf-8 . utf-8))
(setq-default pathname-coding-system 'utf-8)

;; Emacs 不支持 gb18030,如果 gb2312 能看到,就看到,看不到就看不到了,
;; 索性认为 gb18030 也是 gb2312 罢。
;(define-coding-system-alias 'gb18030 'gb2312)

;; ;;
; (set-language-environment 'utf-8)
;; ;;
;; (setq locale-coding-system 'utf-8)
;; (prefer-coding-system 'utf-8)
;; (set-keyboard-coding-system 'utf-8)
;; (set-terminal-coding-system 'utf-8)
;; (set-selection-coding-system 'utf-8)
;; (set-clipboard-coding-system 'ctext)
;; (set-buffer-file-coding-system 'utf-8)

;;字体解码
;;
(setq font-encoding-alist
  (append
  '(("MuleTibetan-0" (tibetan . 0))
  ("GB2312" (chinese-gb2312 . 0))
  ("GBK" (chinese-gbk . 0))
  ("JISX0208" (japanese-jisx0208 . 0))
  ("JISX0212" (japanese-jisx0212 . 0))
  ("VISCII" (vietnamese-viscii-lower . 0))
  ("KSC5601" (korean-ksc5601 . 0))
  ("MuleArabic-0" (arabic-digit . 0))
  ("MuleArabic-1" (arabic-1-column . 0))
  ("MuleArabic-2" (arabic-2-column . 0)))
  font-encoding-alist))


(provide 'jerry-language)

;;; jerry-language.el ends here
头像
jarodlau
帖子: 501
注册时间: 2005-09-06 20:34
联系:

#4

帖子 jarodlau » 2008-07-15 22:50

我的配置中关于日历部分的设置

代码: 全选

;;; jerry-calendar.el --- 日历设置
;;; Code:
;;日历基本配置
;;设置我所在地方的经纬度,calendar里有个功能是日月食的预测,和你的经纬度相联系的。
(setq calendar-latitude +39.9)
(setq calendar-longitude +116.4)
;;我的所在地-北京
(setq calendar-location-name "Beijing")
;;当退出日日历的时候把它自己建立的frame删除
(setq calendar-remove-frame-by-deleting t)
;;设定一周的开始为周一
(setq calendar-week-start-day 1)
;;节日和生日提醒设置
;;我不过基督徒的节日、希伯来人的节日和伊斯兰教的节日。
;;我是无神论者,不过我喜欢神话,大家有兴趣也可以探讨一下,发email给我吧
(setq christian-holidays nil)
(setq hebrew-holidays nil)
(setq islamic-holidays nil)
;;设定一些自定义的生日和节日
;;隐私需要,删掉朋友的生日
;;后面那些农历节日需要每年根据日历修改
;;有些可惜,没有中国传统农历,谁能写个扩展elisp包弄一下
(setq general-holidays '((holiday-fixed 1 1 "元旦")
  (holiday-fixed 3 8 "妇女节")
  (holiday-fixed 4 1 "愚人节")
  (holiday-fixed 4 11 "谁的生日")
  (holiday-fixed 5 1 "劳动节")
  (holiday-fixed 10 1 "国庆节")
  (holiday-fixed 12 25 "圣诞节")
  (holiday-fixed 2 5 "元宵节")
  (holiday-fixed 4 4 "清明节")
  (holiday-fixed 4 21 "鬼节")
  (holiday-fixed 6 22 "端午节")
  (holiday-fixed 9 28 "中秋节")
  (holiday-float 5 0 2 "母亲节")
  (holiday-float 6 0 3 "父亲节")
  ))
;;其他的一些设置
;;日历不和日记相连,我不用Calendar自带的diary记日记
(setq mark-diary-entries-in-calendar nil)
;我使用diary功能
;;这个又忘了,我真是忘性好!
;;emacs22抛弃了这个用法,使用appt-activate
;(setq appt-issue-message nil)
;(appt-activate 1)
;;在日历中突出标记节日和生日
(setq mark-holidays-in-calendar t)
;;打开calendar自动打开节日和生日列表
(setq view-calendar-holidays-initially t)

;;下面两个是设置年份为中国年,好像默认的是用英文写的,由王垠修改的。
;;这个设置在节日列表的春节那天能看到,如今年的春节他就写着
;;Thursday, January 22, 2004: Chinese New Year (甲-申)
(setq chinese-calendar-celestial-stem
  ["甲" "乙" "丙" "丁" "戊" "己" "庚" "辛" "壬" "癸"])
(setq chinese-calendar-terrestrial-branch
  ["子" "丑" "寅" "卯" "辰" "巳" "戊" "未" "申" "酉" "戌" "亥"])

(provide 'jerry-calendar)

;;; jerry-calendar.el ends here
头像
jarodlau
帖子: 501
注册时间: 2005-09-06 20:34
联系:

#5

帖子 jarodlau » 2008-07-15 22:54

这个是关于代码折叠的,当你编辑很大一段代码的时候,折叠起来或许更好一些

代码: 全选

;;; jerry-folding.el --- folding mode的配置
;;小知识:autoload和load相比,前者是在需要时启动folding.el,
;而在emacs启动时只加载这个函数名而已,也就是让Emacs知道有这个函数。
;而使用load,则在Emacs启动时便加载,如果加载东西很多,emacs启动会很慢。
(autoload 'folding-mode "folding"
  "Minor mode that simulates a folding editor" t)
(load-library  "folding")
(defun folding-mode-find-file-hook ()
  "One of the hooks called whenever a `find-file' is successful."
  (and (assq 'folded-file (buffer-local-variables))
       folded-file
       (folding-mode 1)
       (kill-local-variable 'folded-file)))
(setq fold-fold-on-startup t)
(folding-mode-add-find-file-hook)

;; ;; FIXME :是否通用,还没有试验
;; ;;使用通用的folding模式,只要有{{{和}}}就开启,挺好用吧
;; (defun my-folding-load-hook ()
;;   "Folding setup."
;;   (folding-install)  ;; just to be sure
;;   (defvar folding-mode-marks-alist nil)
;;   (let* ((ptr (assq 'text-mode folding-mode-marks-alist)))
;;     (setcdr ptr (list "# {{{" "# }}}")))
;;   )
;; (add-hook 'folding-load-hook 'my-folding-load-hook)

;;修改folding.el默认的快捷键,以方便自己使用
;;我大部分的快捷键在最后一帖中将会讲到
(setq fold-keys-already-setup nil)
(add-hook 'folding-mode-hook
	  (function (lambda()
		      (unless fold-keys-already-setup
			(setq fold-keys-already-setup t)
			(define-prefix-command 'ctl-f-folding-mode-prefix)
			(define-key 'ctl-f-folding-mode-prefix "f" 'fold-fold-region)
			(define-key 'ctl-f-folding-mode-prefix "e" 'fold-enter)
			(define-key 'ctl-f-folding-mode-prefix "x" 'fold-exit)
			(define-key 'ctl-f-folding-mode-prefix "b" 'fold-whole-buffer)
			(define-key 'ctl-f-folding-mode-prefix "o" 'fold-open-buffer)
			(define-key 'ctl-f-folding-mode-prefix "h" 'fold-hide)
			(define-key 'ctl-f-folding-mode-prefix "s" 'fold-show)
			(define-key 'ctl-f-folding-mode-prefix "t" 'fold-top-level)
			(define-key 'ctl-f-folding-mode-prefix "f" 'fold-fold-region)
			)
		      (local-set-key "C-f" 'ctl-f-folding-mode-prefix))))

;;设定各个模式下,折叠的具体内容和方式
(folding-add-to-marks-list 'sgml-mode
			"<!-- {"
			"<!-- } -->" " --> ")
(folding-add-to-marks-list 'c-mode "/* <" "/* > */" "*/")
(folding-add-to-marks-list 'c++-mode
			"//<" "//>" "")
(folding-add-to-marks-list 'LaTeX-mode "%%% {{{" "%%% }}}" " ")
(folding-add-to-marks-list 'latex2e-mode "%%% {{{" "%%% }}}" " ")
(folding-add-to-marks-list 'latex-mode "%%%% {{{" "%%%% }}}" " ")
(folding-add-to-marks-list 'BibTeX-mode "%%% {{{" "%%% }}}" " ")
(folding-add-to-marks-list 'lisp-mode ";;{{{" ";;}}}" "")
(folding-add-to-marks-list 'emacs-lisp-mode ";;{{{" ";;}}}" "")
(folding-add-to-marks-list 'lisp-mode ";;; {" ";;; }" "")
(folding-add-to-marks-list 'lex-mode" /* {{{ " " /* }}} */ " "*/")
(folding-add-to-marks-list 'html-mode "<!-- { " "<!-- } -->" "-->")
(folding-add-to-marks-list 'shell-script-mode "# {{{" "# }}}" nil)
(folding-add-to-marks-list 'sh-mode "# {{{ " "# }}}" nil)

(provide 'jerry-foldinging)

;;; jerry-folding.el ends here
头像
jarodlau
帖子: 501
注册时间: 2005-09-06 20:34
联系:

#6

帖子 jarodlau » 2008-07-15 22:57

这个ido模式很好,当你查找文件的时候,他会自动寻找,很方便

代码: 全选

;;; jerry-ido.el --- ido模式的配置
;; emacs 22,23都内含
(require 'ido)
;;; Code:
(ido-mode t)
(add-hook 'ido-define-mode-map-hook 'ido-jerry-keys)
(defun ido-jerry-keys ()
  "Set up the keymap for `ido'."
  ;; 基本配置
  (define-key ido-mode-map "C-e" 'ido-edit-input);;ido编辑模式
  ;(define-key ido-mode-map "t" 'ido-complete) ;; 部分补全 complete partial
  (define-key ido-mode-map "C-c" 'ido-complete)
  (define-key ido-mode-map "C-j" 'ido-select-text)
  (define-key ido-mode-map "C-m" 'ido-exit-minibuffer);;推出minibuffer
  (define-key ido-mode-map "?" 'ido-completion-help) ;; 列出符合的
  ;;逐步筛选你需要的文件
  (define-key ido-mode-map [(control ? )] 'ido-restrict-to-matches)
  (define-key ido-mode-map [(control ?@)] 'ido-restrict-to-matches)
  ;; 在符合条件的循环
  (define-key ido-mode-map "C-r" 'ido-prev-match)
  (define-key ido-mode-map "C-s" 'ido-next-match)
  (define-key ido-mode-map [right] 'ido-next-match)
  (define-key ido-mode-map [left] 'ido-prev-match)
  ;; 切换
  (define-key ido-mode-map "C-t" 'ido-toggle-regexp) ;;正则匹配
  (define-key ido-mode-map "C-p" 'ido-toggle-prefix) ;;部分匹配
  (define-key ido-mode-map "C-c" 'ido-toggle-case)   ;;切换大小写匹配
  (define-key ido-mode-map "C-a" 'ido-toggle-ignore) ;;忽略某些文件
  ;; 在文件和目录环境中的快捷键
  (when (memq ido-cur-item '(file dir))
    (define-key ido-mode-map "C-b" 'ido-enter-switch-buffer);;选择buffer模式
    (define-key ido-mode-map "C-d" 'ido-enter-dired) ;;Dired模式
    (define-key ido-mode-map "C-f" 'ido-fallback-command)
    ;; 目录里的循环
    ;; 使用[left]和[right]匹配文件
    (define-key ido-mode-map [down] 'ido-next-match-dir)
    (define-key ido-mode-map [up]   'ido-prev-match-dir)
    ;; backspace删除键的配置
    (define-key ido-mode-map [backspace] 'ido-delete-backward-updir)
    ;(define-key ido-mode-map "d"        'ido-delete-backward-updir)
    (define-key ido-mode-map [(meta backspace)] 'ido-delete-backward-word-updir)
    (define-key ido-mode-map [(control backspace)] 'ido-up-directory)
    ;; 搞不懂这些配置
    (define-key ido-mode-map [(meta ?d)] 'ido-wide-find-dir)
    (define-key ido-mode-map [(meta ?f)] 'ido-wide-find-file)
    (define-key ido-mode-map [(meta ?k)] 'ido-forget-work-directory)
    (define-key ido-mode-map [(meta ?m)] 'ido-make-directory)
    (define-key ido-mode-map [(meta down)] 'ido-next-work-directory)
    (define-key ido-mode-map [(meta up)] 'ido-prev-work-directory)
    (define-key ido-mode-map [(meta left)] 'ido-prev-work-file)
    (define-key ido-mode-map [(meta right)] 'ido-next-work-file)
    ;; 在directories目录中的搜索
    ;; 使用C-_来undo
    (define-key ido-mode-map [(meta ?s)] 'ido-merge-work-directories)
    (define-key ido-mode-map [(control ?\_)] 'ido-undo-merge-work-directory)
    )
  (when (eq ido-cur-item 'file)
    (define-key ido-mode-map "C-k" 'ido-delete-file-at-head)
    (define-key ido-mode-map "C-l" 'ido-toggle-literal)
    (define-key ido-mode-map "C-o" 'ido-copy-current-word)
    (define-key ido-mode-map "C-v" 'ido-toggle-vc)
    (define-key ido-mode-map "C-w" 'ido-copy-current-file-name)
    )

  (when (eq ido-cur-item 'buffer)
    (define-key ido-mode-map "C-b" 'ido-fallback-command)
    (define-key ido-mode-map "C-f" 'ido-enter-find-file)
    (define-key ido-mode-map "C-k" 'ido-kill-buffer-at-head)
    ))

(provide 'jerry-ido)

;;; jerry-ido.el ends here
头像
jarodlau
帖子: 501
注册时间: 2005-09-06 20:34
联系:

#7

帖子 jarodlau » 2008-07-15 23:00

大家现在都使用stardict,其实这个也可以用,我现在使用sdcv,为了完整,所以这部分也方上来,希望对一些朋友有帮助

代码: 全选

;;; jerry-dictionary.el --- dictionary字典配置
;;; Code:
;; Emacs 22内含的dictionary client
;(require 'eudc)
;;在需要的时候加载所需的elisp
(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)
(autoload 'global-dictionary-tooltip-mode "dictionary"
  "Enable/disable dictionary-tooltip-mode for all buffers" t)

;;查单词,只要将光标移到单词上,"C-c d"即可,Emacs会开辟一个buffer显示单词释义。鼠标右键也可以麻烦
;FIXME:鼠标和我的fvwm内的stroke冲突了
(global-set-key [mouse-3] 'dictionary-mouse-popup-matching-words)
(global-set-key [(control c)(d)] 'dictionary-lookup-definition)
(global-set-key [(control c)(s)] 'dictionary-search)
(global-set-key [(control c)(m)] 'dictionary-match-words)
;;设定字典服务器为本地服务器
;;如果你在包月的宽带上,不妨设定为[url]http://www.dict.org[/url]
;;如果你在局域网上,而局域网的某台机器有dictd服务器,你将服务器设定为他的IP即可。
(setq dictionary-server "localhost")
;;在字典提示模式中,使用wordnet字典数据库作为默认字典数据库
;;当然你可以修改,取决于你dictd服务器里的字典数据库
;(setq dictionary-tooltip-dictionary "wn")
;(require 'dictionary)
;; FIXME :使用这个全局tooltip很费内存啊
;(global-dictionary-tooltip-mode t)

;;在dictd中使用中文字典的时候,需要在~/.emacs中加入字典的编码格式。
;;我的locale用的是utf8的,就需要如下的设置,GB2312的类似:

;; 设定中文词典的解码
(setq dictionary-coding-systems-for-dictionaries
      '(("cdict" . utf-8)
	("xdict" . utf-8)
	("stardic" . utf-8)))

(provide 'jerry-dictionary)
;;; jerry-dictionary.el ends here
头像
jarodlau
帖子: 501
注册时间: 2005-09-06 20:34
联系:

#8

帖子 jarodlau » 2008-07-15 23:04

这一部分是我常用的lisp函数,有很多都是从别的地方抄过来的,能不能用就要考大家自己试用了

代码: 全选

;;; jerry-function.el --- my function

;;{{{ 如果你正在编辑一个东西(在位置A),突然想到别的某处(位置B)要修改或查看
;;或别的,总之你要过去看看,你可以用C-.来在当前位置做个标记,然后去你想去的
;;地方B,看了一会你觉的我可以回A去了,用C-,就回到刚才做标记的地方A,再用C-,又会回到B
;;这个由王垠创作
(global-set-key [(control ?.)] 'ska-point-to-register)
(global-set-key [(control ?\,)] 'ska-jump-to-register)
(defun ska-point-to-register()
  "Store cursorposition _fast_ in a register.
  Use ska-jump-to-register to jump back to the stored
  position."
  (interactive)
  (setq zmacs-region-stays t)
  (point-to-register 8))

(defun ska-jump-to-register()
  "Switches between current cursorposition and position
  that was stored with ska-point-to-register."
  (interactive)
  (setq zmacs-region-stays t)
  (let ((tmp (point-marker)))
    (jump-to-register 8)
    (set-register 8 tmp)))

;;}}}

;;{{{ 使用%就可以上下翻动,匹配的括号
;;如果没有括号就输入%
;;这个由王垠创作
(defun my-match-paren (arg)
  "Go to the matching paren if on a paren; otherwise insert %.
Argument ARG paren."
  (interactive "p")
  (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
	((looking-at "\\s\)") (forward-char 1) (backward-list 1))
	(t (self-insert-command (or arg 1)))))
;;}}}

;;{{{ go-to-char
(defun my-go-to-char (n char)
  "Move forward to Nth occurence of CHAR.
Typing `my-go-to-char-key' again will move forwad to the next Nth
occurence of CHAR."
  (interactive "p\ncGo to char: ")
  (search-forward (string char) nil nil n)
  (while (char-equal (read-char)
		     char)
    (search-forward (string char) nil nil n))
  (setq unread-command-events (list last-input-event)))
;;}}}
;; emacs-lisp-mode

;; 1. 再emacs中编译整个目录下的.el文件输入 [Alt]-x 。 当提示输入命令时,输入
;;        byte-force-recompile [Enter] 。
;; 2. 如何再emacs下编译整个目录下的*.el文件两个办法,一是在dired里面用m标记,
;;    然后用B编译还有就是用emacs的批处理:

;; emacs -batch -f batch-byte-compile *.el

;; 这个忘了是从哪个地方弄来的,在保存~/.emacs文件自动编译为.elc文件
;;目前只是对~/.emacs有效,其余的*.el文件还没有去弄,以后有空我会改的
;;小知识:由于配置文件越来越大,你的*.el配置文件最好都编译为*.elc文件,这样
;;在启动emacs速度会有很大的提升
;; (defun autocompile nil
;;   "Compile itself if ~/.emacs."
;;   (interactive)
;;   (if (string= (buffer-file-name) (concat default-directory ".emacs"))
;;       (byte-compile-file (buffer-file-name))))
;; (add-hook 'after-save-hook 'autocompile)

;;{{{  自动编译一个目录下的el文件
(defconst dotemacs-basic-conf-dir "~/lib/emacs-lisp/")
;(defconst dotemacs-ext-elisp-dir "~/.emacs.d/config/ext-elisp/")
;(defconst dotemacs-program-dir "~/.emacs.d/config/program/")

(defun autocompile nil
  "Automagically compile change to .emacs and other dotfiles."
  (interactive)
  (cond ((string= (buffer-file-name) (concat default-directory ".emacs"))
               (byte-compile-file (buffer-file-name)))

        ((string= (abbreviate-file-name (buffer-file-name))
               (concat dotemacs-basic-conf-dir
                       (replace-regexp-in-string "\\.el" "" (buffer-name)) ".el"))
               (byte-compile-file (buffer-file-name)))

	;;  ((string= (abbreviate-file-name (buffer-file-name))
	;;                (concat dotemacs-ext-elisp-dir
	;;                        (replace-regexp-in-string "\\.el" "" (buffer-name)) ".el"))
	;;                (byte-compile-file (buffer-file-name)))

	;;        ((string= (abbreviate-file-name (buffer-file-name))
	;;                (concat dotemacs-program-dir
	;;                        (replace-regexp-in-string "\\.el" "" (buffer-name)) ".el"))
	;;                (byte-compile-file (buffer-file-name)))
        )

  )
(add-hook 'after-save-hook 'autocompile)
;; emacs-lisp-mode
;; 1. 再emacs中编译整个目录下的.el文件输入 [Alt]-x 。 当提示输入命令时,输入
;;        byte-force-recompile [Enter] 。
;; 2. 如何再emacs下编译整个目录下的*.el文件两个办法,一是在dired里面用m标记,然后用B编译还有就是用emacs的批处理:
;; emacs -batch -f batch-byte-compile *.el
;;}}}
;;{{{ 自定义自动补齐命令,如果在单词中间就补齐,否则就是tab。
(defun my-indent-or-complete ()
  "在单词中间就补齐,否则就tab."
   (interactive)
   (if (looking-at "\\>")
       (hippie-expand nil)
     (indent-for-tab-command))
   )
;;}}}

;;这个是从emacs-lisp-introduction的那个文档拷过来
;;{{{ 功能同word的计算文字数相似,不过这个功能有待完善,对中文不大好使
(defun my-recursive-count-words (region-end)
  "Number of words between point and REGION-END."
  (if (and (< (point) region-end)
	   (re-search-forward "\\w+\\W*" region-end t))
    (1+ (my-recursive-count-words region-end))
    0))
(defun my-count-words-region (beginning end)
  "Print number of words in the region.
Words are defined as at least one word-constituent
character followed by at least one character that is
not a word-constituent.  The buffer's syntax table
determines which characters these are.
Argument BEGINNING region's beginning.
Argument END region's end."
  (interactive "r")
  (message "Counting words in region ... ")
  (save-excursion
    (goto-char beginning)
    (let ((count (my-recursive-count-words end)))
      (cond ((zerop count)
	     (message
	       "The region does NOT have any words."))
	    ((= 1 count)
	     (message "The region has 1 word."))
	    (t
	      (message
		"The region has %d words." count))))))
(defun my-count-words-buffer ()
  "Count the number of words in current buffer;
print a message in the minibuffer with the result."
  (interactive)
  (save-excursion
    (let ((count 0))
      (goto-char (point-min))
      (while (< (point) (point-max))
	(forward-word 1)
	(setq count (1+ count)))
      (message "buffer contains %d words." count))))
;;}}}

;;这也忘了是从哪弄来的了 ; replace C-u 0 C-l
;;{{{ 功能是将当前行设为本页第一行,同终端下的clear命令有点相似
(defun my-line-to-top-of-window ()
  "Move the line point is on to top of window."
  (interactive)
  (recenter 0))
;;}}}
;;{{{ 在文档里插入时间,用户名还有系统的信息
(defun my-stamp (&optional arg)
  "Insert current date, user, and system information.
With optional argument ARG, use \"*Created: -- *\" format."
  (interactive "*P")
  ;; Get this from time-stamp-format somehow?
  (let ((string (format " %s %s on %s "
                        (format-time-string " %04y-%02m-%02d %02H:%02M:%02S")
                        user-login-name
                        system-name)))
    (if arg (setq string (format "*Creation: %s*" string)))
    (if (interactive-p)
        (insert string)
      string)))
;;}}}
;;{{{ 时间戳设置,插入文档内的
(defun my-timestamp ()
  "Insert the \"Time-stamp: <>\" string at point."
  (interactive)
  (if (interactive-p)
      (insert " Time-stamp: <>")
    " Time-stamp: <>"))
;;}}}

;;{{{ 打开.sawfishrc的快捷方式,ctrl-f1
(defun my-open-dot-sawfishrc ()
  "Open the dot-sawfishrc file."
  (interactive)
  (find-file "~/.sawfishrc")
  )
;;}}}

;; NB :添加的几个函数
;;{{{ 打开.emacs的快捷方式,ctrl-f2
(defun my-open-dot-emacs ()
  "Open the dot-emacs file."
  (interactive)
  (find-file "~/.emacs")
  )
;;}}}

;;{{{ 打开.sawfishrc配置文件,ctrl-f3
(defun my-open-fvwmconfig ()
  "Open the fvwm's config file."
  (interactive)
  (find-file "~/.fvwm/config")
;(find-file "~/.fvwm/fvwm.strokes")
  )
;;}}}

;;{{{ 找到这个buffer里最长的一行,并且到达哪里,很不错的功能
(defun my-longest-line (&optional goto)
  "Find visual length (ie in columns) of longest line in buffer.
If optional argument GOTO is non-nil, go to that line."
  (interactive "p")                    ; NB not p
  (let ((maxlen 0)
        (line 1)
        len maxline)
    (save-excursion
      (goto-char (point-min))
      (goto-char (line-end-position))
      ;; Not necessarily same as line-end - line-beginning (eg tabs)
      ;; and this function is for visual purposes.
      (setq len (current-column))
      (if (eobp)                        ; 1 line in buffer
          (setq maxlen len
                maxline line)
        (while (zerop (forward-line))
          (goto-char (line-end-position))
          (setq line (1+ line)
                len (current-column))
          (if (> len maxlen)
              (setq maxlen len
                    maxline line)))))
    (if (not (interactive-p))
        maxlen
      (message "最长的一行是第%s行 (%s)" maxline maxlen)
      ;(message "Longest line is line %s (%s)" maxline maxlen)
      (if goto (goto-line maxline)))))
;;}}}

;;{{{ 给 Options 增加一个"去掉文件末尾空白"的菜单
(when (boundp 'show-trailing-whitespace)
  ;; Mode name must be same as mode variable.
  (define-minor-mode show-trailing-whitespace
    "Toggle display of trailing whitespace.
With optional numeric argument ARG, activate trailing whitespace display if
ARG is positive, otherwise deactivate it."
    :init-value nil
    :lighter " WS")

  (defun my-show-trailing-whitespace ()
    "Activate `show-trailing-whitespace' mode."
    (show-trailing-whitespace 1))

  (mapcar (lambda (hook) (add-hook hook 'my-show-trailing-whitespace))
          '(sh-mode-hook emacs-lisp-mode-hook f90-mode-hook
                         fortran-mode-hook awk-mode-hook
                         change-log-mode-hook c-mode-hook)))
;;}}}
;;{{{ TODO 去掉文件尾部的空白,在写文件的时候自动加载
;; Better functions than this exist in Emacs.
(defun my-delete-trailing-whitespace ()
  "Delete all trailing whitespace in buffer.
Return values are suitable for use with `write-file-functions'."
  (condition-case nil
      (progn
        ;; Don't want to do this to mail messages, etc.
        ;; Would an exclude list be better?
        ;; Error was occurring in VM-mode for some reason.
        (when (memq major-mode '(text-mode sh-mode emacs-lisp-mode
                                           f90-mode awk-mode c-mode))
          (message "Cleaning up whitespace...")
          (delete-trailing-whitespace)
          (message "Cleaning up whitespace...done")
          nil))
    (error (message "Cleaning up whitespace...ERROR")
           t)))
;;Too invasive?
(add-hook (if (boundp 'write-file-functions) 'write-file-functions
	    'write-file-hooks) 'my-delete-trailing-whitespace)
;;}}}

;;{{{ 删除一些临时的buffers,少占我的内存
(defvar my-clean-buffers-names
  '("\\*Completions" "\\*Compile-Log" "\\*.*[Oo]utput\\*$"
    "\\*Apropos" "\\*compilation" "\\*Customize" "\\*Calc""\\keywiz-scores"
    "\\*BBDB\\*" "\\*trace of SMTP" "\\*vc" "\\*cvs" "\\*keywiz"
    "\\*WoMan-Log" "\\*tramp" "\\*desktop\\*" ;;"\\*Async Shell Command"
    )
  "List of regexps matching names of buffers to kill.")

(defvar my-clean-buffers-modes
  '(help-mode );Info-mode)
  "List of modes whose buffers will be killed.")

(defun my-clean-buffers ()
  "Kill buffers as per `my-clean-buffer-list' and `my-clean-buffer-modes'."
  (interactive)
  (let (string buffname)
    (mapcar (lambda (buffer)
              (and (setq buffname (buffer-name buffer))
                   (or (catch 'found
                         (mapcar '(lambda (name)
                                    (if (string-match name buffname)
                                        (throw 'found t)))
                                 my-clean-buffers-names)
                         nil)
                       (save-excursion
                         (set-buffer buffname)
                         (catch 'found
                           (mapcar '(lambda (mode)
                                      (if (eq major-mode mode)
                                          (throw 'found t)))
                                   my-clean-buffers-modes)
                           nil)))
                   (kill-buffer buffname)
                   (setq string (concat string
                                        (and string ", ") buffname))))
            (buffer-list))
    (if string (message "清理buffer: %s" string)
    ;(if string (message "Deleted: %s" string)
       (message "没有多余的buffer"))))
      ;(message "No buffers deleted"))))
;;}}}

;;{{{ 打印出我的键盘图,很酷吧-全部热键都显示出来,呵呵
(defun my-keytable (arg)
  "Print the key bindings in a tabular form.
Argument ARG Key."
  (interactive "sEnter a modifier string:")
  (with-output-to-temp-buffer "*Key table*"
    (let* ((i 0)
           (keys (list "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n"
                       "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"
                       "<return>" "<down>" "<up>" "<right>" "<left>"
                       "<home>" "<end>" "<f1>" "<f2>" "<f3>" "<f4>" "<f5>"
                       "<f6>" "<f7>" "<f8>" "<f9>" "<f10>" "<f11>" "<f12>"
                       "1" "2" "3" "4" "5" "6" "7" "8" "9" "0"
                       "`" "~" "!" "@" "#" "$" "%" "^" "&" "*" "(" ")" "-" "_"
                       "=" "+" "\\" "|" "{" "[" "]" "}" ";" "'" ":" "\""
                       "<" ">" "," "." "/" "?"))
           (n (length keys))
           (modifiers (list "" "C-" "M-" "S-" "M-C-" "S-C-")))
      (or (string= arg "") (setq modifiers (list arg)))
      (setq k (length modifiers))
      (princ (format " %-10.10s |" "Key"))
      (let ((j 0))
        (while (< j k)
          (princ (format " %-50.50s |" (nth j modifiers)))
          (setq j (1+ j))))
      (princ "\n")
      (princ (format "_%-10.10s_|" "__________"))
      (let ((j 0))
        (while (< j k)
          (princ (format "_%-50.50s_|"
                         "__________________________________________________"))
          (setq j (1+ j))))
      (princ "\n")
      (while (< i n)
        (princ (format " %-10.10s |" (nth i keys)))
        (let ((j 0))
          (while (< j k)
            (let* ((binding
                    (key-binding (read-kbd-macro (concat (nth j modifiers)
                                                         (nth i keys)))))
                   (binding-string "_"))
              (when binding
                (if (eq binding 'self-insert-command)
                    (setq binding-string (concat "'" (nth i keys) "'"))
                  (setq binding-string (format "%s" binding))))
              (setq binding-string
                    (substring binding-string 0 (min (length
                                                      binding-string) 48)))
              (princ (format " %-50.50s |" binding-string))
              (setq j (1+ j)))))
        (princ "\n")
        (setq i (1+ i)))
      (princ (format "_%-10.10s_|" "__________"))
      (let ((j 0))
        (while (< j k)
          (princ (format "_%-50.50s_|"
                         "__________________________________________________"))
          (setq j (1+ j))))))
  (delete-window)
  (hscroll-mode)
  (setq truncate-lines t))              ; for emacs 21
;;}}}

;;{{{
;; ;; 调用 stardict 的命令行接口来查辞典
;; ;; 如果选中了 region 就查询 region 的内容,
;; ;; 否则就查询当前光标所在的词
;; (defun kid-star-dict ()
;;   "Serch dict in stardict."
;;   (interactive)
;;   (let ((begin (point-min))
;;         (end (point-max)))
;;     (if mark-active
;;         (setq begin (region-beginning)
;;               end (region-end))
;;       (save-excursion
;;         (backward-word)
;;         (mark-word)
;;         (setq begin (region-beginning)
;;               end (region-end))))
;;     ;; 有时候 stardict 会很慢,所以在回显区显示一点东西
;;     ;; 以免觉得 Emacs 在干什么其他奇怪的事情。
;;     (message "searching for %s ..." (buffer-substring begin end))
;;     (tooltip-show
;;      (shell-command-to-string
;;       (concat "sdcv -n "
;;               (buffer-substring begin end))))))

;; ;; 如果选中了 region 就查询 region 的内容,否则查询当前光标所在的单词
;; ;; 查询结果在一个叫做 *sdcv* 的 buffer 里面显示出来,在这个 buffer 里面
;; ;; 按 q 可以把这个 buffer 放到 buffer 列表末尾,按 d 可以查询单词
;; (defun kid-sdcv-to-buffer ()
;;   "Search dict in region or world."
;; (interactive)
;;   (let ((word (if mark-active
;;                   (buffer-substring-no-properties (region-beginning) (region-end))
;; 		(current-word nil t))))
;;     (setq word (read-string (format "Search the dictionary for (default %s): " word)
;;                             nil nil word))
;;     (set-buffer (get-buffer-create "*sdcv*"))
;;     (buffer-disable-undo)
;;     (erase-buffer)
;;     (let ((process (start-process-shell-command "sdcv" "*sdcv*" "sdcv" "-n" word)))
;;       (set-process-sentinel
;;        process
;;        (lambda (process signal)
;;          (when (memq (process-status process) '(exit signal))
;;            (unless (string= (buffer-name) "*sdcv*")
;;