免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 878 | 回复: 0

[转载]一个比较好中文说明的emacs配置文件 [复制链接]

论坛徽章:
0
发表于 2008-05-05 17:46 |显示全部楼层
转载的
原贴地址
http://www.linuxsir.org/bbs/showthread.php?s=&threadid=112349
hvj的讨论和推广emacs贴0:
算是抛砖引玉吧,我把自己的emacs经历和配置文件贴上来,并稍作一些讲解,提出一些疑问,和兄弟姐妹们讨论和推广一下这个好东东。
这贴先给一些链接吧。
http://www.gnus.org/software/emacs GNU emacs的官方网站。
http://www.emacswiki.org Emacs用户大本营,有很多非常好的资料
http://learn.tsinghua.edu.cn/homepag...450/emacs.html 我学emacs的初始地,在这里表示对网站作者王垠的感激。
http://learn.tsinghua.edu.cn/homepag...cs24/index.htm 我学emacs的主要教程,sir里好像有人要翻译,不知道翻译完没。
http://www.dotemacs.de/ emacs配置文件的集中营,不过感觉梢旧了些。
http://zhdotemacs.sourceforge.net/emacs/ Emacs 中文化指南,有很多适合咱们中国人使用的技巧。
注:
1,配置文件是在我的配置文件基础上加上比较详细的注解,注解之前都用;;注释掉了,也就是说可以拷过去直接用
2,由于我的每个配置文件开头都有time stamp(在第2帖中有讲解),在第一贴贴了这个时间戳,后面就不贴了。
3,我所用的elisp包在王垠的网站或emacswiki.org里应该能找到,实在不行,我们还有google。
4,为了保存已有缩进,一些代码引用使用php源码引用,语法显示有问题,请大家不要误会。
5,欢迎大家指正错误,讨论修改,一起提高Emacs应用水准。
hvj的讨论和推广emacs贴1:
首先贴一下我得初始文件~/.emacs
引用:;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Hans Ve Joanphan's dotemacs file
;;; Last modified time
;;; Time-stamp:
;;; Life is a box of chocalates,
;;; you never know what you're gonna get.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;以上是我得time stamp,在后面将有详细讲解
;;设置你的全名和邮件,在发邮件时可以用到
(setq user-full-name "Hans Joanphan")
(setq user-mail-address "joanphan@citiz.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里的文件夹中,~/.emacs.d/elisp是我自己添加的Elisp包
(setq load-path (cons "~/.emacs.d/elisp" load-path))
;;设置info的路径,也可通过Shell的全局变量$INFOPATH设置
(add-to-list 'Info-default-directory-list "~/local/info/")
;;由菜单修改配置的东西将会保存在custom-file里,这里我设置他在我的elisp的集中营里
(setq custom-file "~/.emacs.d/elisp/hvj-custom.el")
;;设置gnus启动的文件。默认是为~/.gnus.el
(setq gnus-init-file "~/.emacs.d/elisp/hvj-gnus.el")
;;由于我的配置文件很长,所以按照分类分别放在不同的文件里,方便管理
(load "hvj-basic-config")
(load "hvj-language")
(load "hvj-calendar")
(load "hvj-folding")
(load "hvj-ido")
(load "hvj-dictionary")
(load "hvj-function")
(load "hvj-mew")
(load "hvj-w3m")
(load "hvj-erc.el")
(load "hvj-dired")
(load "hvj-mode")
(load "hvj-wiki")
(load "hvj-other-elisp")
(load "hvj-key-bindings")
;;这个东西必须放在最后
;;desktop.el是一个可以保存你上次emacs关闭时的状态,下一次启动时恢复为上次关闭的状态。就和vmware的suspend一样。
;;因为我要使用sawfish-mode,wiki-mode,html-helper-mode,放在这里才能保证下次启动时能正确辨认文件需要的模式。
(load "desktop")
(desktop-load-default)
(desktop-read)
注:为安全起因,我修改了我的email地址。我的准确email地址在签名中有
hvj的讨论和推广emacs贴2:
这次贴一下我hvj-basic-config.el的一部分,这里主要讲了颜色的设置,外观设置,备份设置、自动补全设置、time stamp设置以及时间显示设置。
引用:;;颜色设置,其实有个color-theme.el可以将Emacs设置丰富多彩,非常漂亮,不过启动有些慢(我得机器不行),我只是选择了一些颜色设置。
;; 指针颜色设置为白色
(set-cursor-color "white")
;; 鼠标颜色设置为白色
(set-mouse-color "white")
;; 设置背景颜色和字体颜色
(set-foreground-color "white")
(set-background-color "darkblue")
;; 设置另外一些颜色:语法高亮显示的背景和主题,区域选择的背景和主题,二次选择的背景和选择
(set-face-foreground 'highlight "white")
(set-face-background 'highlight "blue")
(set-face-foreground 'region "cyan")
(set-face-background 'region "blue")
(set-face-foreground 'secondary-selection "skyblue")
(set-face-background 'secondary-selection "darkblue")
;;设置日历的一些颜色
(setq calendar-load-hook
'(lambda ()
(set-face-foreground 'diary-face "skyblue")
(set-face-background 'holiday-face "slate blue")
(set-face-foreground 'holiday-face "white")))
;;外观设置
;;去掉工具栏
(tool-bar-mode nil)
;;去掉菜单栏,我将F10绑定为显示菜单栏,万一什么东西忘了,需要菜单栏了可以摁F10调出,再摁F10就去掉菜单
(menu-bar-mode nil)
;;不要滚动栏,现在都用滚轴鼠标了,可以不用滚动栏了
(scroll-bar-mode nil)
;;备份设置
;;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 5)
;;删掉不属于以上7中版本的版本
(setq delete-old-versions t)
;;设置备份文件的路径
(setq backup-directory-alist '(("." . "~/.emacs.tmp")))
;;备份设置方法,直接拷贝
(setq backup-by-copying 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
'(try-expand-line
try-expand-line-all-buffers
try-expand-list
try-expand-list-all-buffers
try-expand-dabbrev
try-expand-dabbrev-visible
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill
try-complete-file-name
try-complete-file-name-partially
try-complete-lisp-symbol
try-complete-lisp-symbol-partially
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 %02H02M02S")
;;将修改时间戳添加到保存文件的动作里。
(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)
hvj的讨论和推广emacs贴3:
这里继续帖我得hvj-basic-config.el,讲另外一些比较零碎的设置
引用:;;启用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)
;;当寻找一个同名的文件,自动关联上那个文件?
(setq uniquify-buffer-name-style 'forward)
;;在emacs读man文档时,使用当前buffer
(setq Man-notify-method 'pushy)
;;鼠标自动避开指针,如当你输入的时候,指针到了鼠标的位置,鼠标有点挡住视线了
(mouse-avoidance-mode 'animate)
;;允许自动打开图片,如wiki里面
(auto-image-file-mode)
;;可以操作压缩文档
(auto-compression-mode 1)
;;在minibuffer上面可以显示列号
(column-number-mode t)
;;显示默认的文档的宽度,看起来比较舒服?
(setq default-fill-column 60)
;;指针不要闪,我得眼睛花了
(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)
;;当指针移到另一行,不要新增这一行?d
(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的拼写检查成学
(setq-default ispell-program-name "aspell")
;;使用narrow功能时的一个设置
(put 'narrow-to-region 'disabled nil)
;;启动Emacs自动设置为两个窗口(上下各一个)
(split-window-vertically)
;;改变emacs标题栏的标题
(setq frame-title-format "%b@vj.org")
;;允许emacs和外部其他程序的粘贴
(setq x-select-enable-clipboard t)
hvj的讨论和推广emacs贴4:
这贴主要讲一下中文的设置,是我的配置文件hvj-language.el
我得Emacs中文配置由三部分组成:local设置,.Xdefault设置字体,hvj-language设置emacs环境。
我的locale设置很简单,如下:
引用:export LANG=en_US
export LC_CTYPE=zh_CN
我的.Xdefaults中有关emacs的配置是:
引用:Emacs.Font:fontset-global
Emacs.Fontset-0:-*-*-medium-r-*-*-14-*-*-*-*-*-fontset-global,\
ascii:-*-fixed-medium-r-*-*-14-*-*-*-*-*-iso8859-*,\
chinese-gb2312:-*-tangti-medium-r-normal-*-14-*-*-*-*-*-gb2312.1980-0,\
chinese-big5-1:-*-tangti-medium-r-*-*-14-*-*-*-*-*-big5-0,\
chinese-big5-2:-*-tangti-medium-r-*-*-14-*-*-*-*-*-big5-0, \
utf-8:-misc-fixed-medium-r-*-*-14-*-*-*-*-*-iso10646-1, \
mule-utf-8:-misc-fixed-*-r-*-*-14-*-*-*-*-*-iso10646-1, \
mule-unicode-0100-24ff:-misc-fixed-*-r-*-*-14-*-*-*-*-*-iso10646-1, \
korean-ksc5601:-*-*-medium-r-normal-*-20-*-*-*-*-*-ksc5601*-*, \
sjis:-*-*-medium-r-normal-*-20-*-*-*-*-*-jisx0208*-*
下面是我得hvj-language.el
引用:;;emacs环境设置
;;整体环境设置
(set-language-environment 'Chinese-GB)
;;应该和输入有关系
(set-keyboard-coding-system 'chinese-iso-8bit-with-esc)
;;终端下emacs的中文设置?
(set-terminal-coding-system 'chinese-iso-8bit-with-esc)
;;文件保存时的编码设置
(set-buffer-file-coding-system 'chinese-iso-8bit-with-esc)
;;下面两天是emacs和其他程序互相复制/粘贴的设置
;;在帖3(hvj-basicconfig.el)的最后一行中也有相关的一个设定
(set-selection-coding-system 'chinese-iso-8bit-with-esc)
(set-clipboard-coding-system 'chinese-iso-8bit-with-esc)
;;什么设置?忘了?有些人没用下面这些
(modify-coding-system-alist 'process "*" 'chinese-iso-8bit-with-esc)
(setq default-process-coding-system '(chinese-iso-8bit-with-esc . chinese-iso-8bit-with-esc))
(setq-default pathname-coding-system 'chinese-iso-8bit-with-esc)
;;字体解码优先顺序
;;从王垠那拷过来的,不用怎么再改吧。
(setq font-encoding-alist
(append '(("MuleTibetan-0" (tibetan . 0))
("GB2312" (chinese-gb2312 . 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))
一些其他的说明:
1,有些人使用gbk的locale,那么就需要安装mule-gbk扩展elisp包,我以前装过,配置不是很难。论坛里可以搜到,这次比较急,不再去搜了,下次在加到这贴里。
2,emacs目前对Unicode支持不是很好,虽然现在有mule-ucs包,我一直没用的很爽。对于Unicode解码的文件、email我都改用了别的工具。官方说emacs的下一版对unicode解码更好了,大家有兴趣可以去试用emacs-cvs版。
3,emacs在windows的中文设置,以及Xemacs在linux和Windows的设置我不清楚,没用过,不能保证这些方法能适用你们。
hvj的讨论和推广emacs贴5:
这次讲讲日历的设置。emacs的日历功能是很强大的,我只使用了万年历、生日功能。其实还有很多不错别的功能,如日记功能,以前学习emacs的时候就听有人用emacs的diary记日记和笔记。我的笔记都是用Wikij记录的,这在后面将会有介绍。
M-x calendar可以进入emacs中的日历,我将此功能绑定在一个键上了(在最后会将键的绑定)
小知识:M-x calendar是指Alt键和x键同时摁,然后在minibuffer输入calendar
下面就看看我的配置文件:
引用:;;日历基本配置
;;设置我所在地方的经纬度,calendar里有个功能是日月食的预测,和你的经纬度相联系的。
(setq calendar-latitude +39.9)
(setq calendar-longitude +116.4)
;;我的所在地北京,欢迎大家来找北京请我吃饭
(setq calendar-location-name "Beijing")
;;这个做什么的?忘了,有谁能告诉我,谢谢。
;;我的配置文件里很多东西忘了,欢迎大家来指正下
(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)
;;这个又忘了,我真是忘性好!
(setq appt-issue-message nil)
;;在日历中突出标记节日和生日
(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
["子" "丑" "寅" "卯" "辰" "巳" "戊" "未" "申" "酉" "戌" "亥"])
hvj的讨论和推广emacs贴6:
这贴主要讲hvj-folding.el,内容是关于编辑的。我目前用的不多,不好发表太多想法。这里主要引用王垠的一段话如下:
“我编辑了这么长一个 HTML 文件,你觉得一定很费力,不容易定位吧?其实我的屏幕看起来就是这个样子 。所有小节都被我折叠了起来,我很容易就可以调换小节的位置。我刚才把folding的大段的配置代码移动到了另一个文件,就像移动了一行。
folding 根据不同的文档有不同的标记,它都是基于注释的。本网页就是这样一个例子。”
我的配置文件也是直接从王垠那copy过来的,如下:
PHP 代码:
;;小知识: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)
;;修改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))))
;;设定各个模式下,折叠的具体内容和方式
(fold-add-to-marks-list 'sgml-mode
"" " --> ")
(fold-add-to-marks-list 'c-mode "/*  */" "*/")
(fold-add-to-marks-list 'c++-mode
"//" "")
(fold-add-to-marks-list 'LaTeX-mode "%%% {{{" "%%% }}}" " ")
(fold-add-to-marks-list 'latex2e-mode "%%% {{{" "%%% }}}" " ")
(fold-add-to-marks-list 'latex-mode "%%%% {{{" "%%%% }}}" " ")
(fold-add-to-marks-list 'BibTeX-mode "%%% {{{" "%%% }}}" " ")
(fold-add-to-marks-list 'lisp-mode ";;; {" ";;; }" "")
(fold-add-to-marks-list 'lex-mode" /* {{{ " " /* }}} */ " "*/")
(fold-add-to-marks-list 'html-mode "" "-->")
(fold-add-to-marks-list 'shell-script-mode "# {{{" "# }}}" nil)
(fold-add-to-marks-list 'sh-mode "# {{{ " "# }}}" nil)
hvj的讨论和推广emacs贴7:
这里讲讲切换buffer的扩展elisp包。Emacs默认的好象是C-c C-b,感觉不是很人性化。所以很多emacs爱好者写出了学多这方面的扩展包:ibuffer.el,swbuffer.el,ido.el,tabbar.el,等等。
在王垠的网站里对这些包都有具体的说明。
而我使用的是ido.el和tabbar.el。
这贴主要贴一下ido.el,我对应的配置文件是hvj-ido.el,差不多也是从王垠那拷过来的。不过我用的功能不多,也没用到其切换buffer的功能,只用到其查找文件时的超级匹配功能;我切换buffer在后面的tabbar.el的功能中有讲解。切换buffer的功能,大家可以自己去体验一下,也很不错的。这个ido.el包确实非常的强大。
以下是我的hvj-ido.el,主要是对键绑定的修改。其实Emacs中的键绑定是比较难记的,但又是完全可以自定义的。除开一些基本的操作键,我很多键都自己绑定了;这就像自己写的程序,不管格式多乱,自己都能看懂。
hvj-ido.el
PHP 代码:
(require 'ido)
(ido-mode t)
(add-hook 'ido-define-mode-map-hook 'ido-hvj-keys)
(defun ido-hvj-keys ()
"Set up the keymap for `ido'."
;; common keys
(define-key ido-mode-map "C-e" 'ido-edit-input)
(define-key ido-mode-map "t" 'ido-complete) ;; complete partial
(define-key ido-mode-map "C-j" 'ido-select-text)
(define-key ido-mode-map "C-m" 'ido-exit-minibuffer)
(define-key ido-mode-map "?" 'ido-completion-help) ;; list completions
(define-key ido-mode-map [(control ? )] 'ido-restrict-to-matches)
(define-key ido-mode-map [(control ?@)] 'ido-restrict-to-matches)
;; cycle through 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)
;; toggles
(define-key ido-mode-map "C-t" 'ido-toggle-regexp) ;; same as in isearch
(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)
;; keys used in file and dir environment
(when (memq ido-cur-item '(file dir))
(define-key ido-mode-map "C-b" 'ido-enter-switch-buffer)
(define-key ido-mode-map "C-d" 'ido-enter-dired)
(define-key ido-mode-map "C-f" 'ido-fallback-command)
;; cycle among directories
;; use [left] and [right] for matching files
(define-key ido-mode-map [down] 'ido-next-match-dir)
(define-key ido-mode-map [up] 'ido-prev-match-dir)
;; backspace functions
(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)
;; I can't understand this
(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)
;; search in the directories
;; use C-_ to undo this
(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)
))
hvj的讨论和推广emacs贴8:
相信大部分在使用stardict或在将要使用linuxfans某开发组(好像有baif)的cutedict,我这里向大家推荐另外一个字典工具dictd。
dictd是一个字典服务器,dict是一个文本界面客户端。其实这个大家也应该比较熟悉,如kdict就是KDE桌面的dictd客户端。dictd的官方地址为:http://www.dict.org 。这是一个免费的字典服务器,有很多字典数据库给我们使用。
dictd的安装我就不讲了,很简单的。一般会同时安装客户端和服务器端。将dictd设为电脑启动的一个程序,这样电脑可以随时去查字典。默认的客户端为dict,常见用法就是dict -h localhost whatyourwanttolookup
在emacs下也有一个dictd的客户端,叫做dictionary.el。常用的有两种模式,一种就是查字典dictionary-lookup-definition,一种是字典提示模式(dictionary-toolip-mode),也就是有屏幕取词功能,当然这里指在Emacsl里取词。还有单词匹配功能、单词搜索功能等等......
目前这个有一些问题就是:
1,我添加了一些英汉词典,我忘了在那个网站有找的,大家可以搜搜,找不到的话,我传到Sir的ftp里。
2,目前的有关中文的词典很少(只有cdict,xdict,和stardic的默认字典,都是英汉的),而stardict的好字典很多。我现在的想法是将Stardict的字典格式能够改一下适合dictd使用。由于最近比较忙,一直托着没做,希望暑假能够去做一下。baif兄为libdict(cutedict的内核)开发字典,转了一下,我前几天看了一下,感觉还是不适合dictd使用。希望有兴趣的朋友能够参与这个给dictd增加有关中文的词典。
hvj-dictionary.el
PHP 代码:
;;在需要的时候加载所需的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)
;;设定字典服务器为本地服务器
;;如果你在包月的宽带上,不妨设定为http://www.dict.org
;;如果你在局域网上,而局域网的某台机器有dictd服务器,你将服务器设定为他的IP即可。
(setq dictionary-server "localhost")
;;在字典提示模式中,使用wordnet字典数据库作为默认字典数据库
;;当然你可以修改,取决于你dictd服务器里的字典数据库
(setq dictionary-tooltip-dictionary "wn")
;; 设定中文词典的解码
;; 由qtjava兄告知,谢谢!
(setq dictionary-coding-systems-for-dictionaries '(("cdict" . gb2312)
("xdict" . gbk2312)
("stardic" . gb2312)))
hvj的讨论和推广emacs贴9:
这贴讲了一些网友们写的有意思和非常有用的elisp函数,可以方便很多工作,这也将是我以后完善我的配置文件的重点地方。不过目前配置文件里都只是我收集到的函数,和大家分享一下。
hvj-function.el
PHP 代码:
;;这个由王垠创作
;;如果你正在编辑一个东西(在位置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)))
;; 这个忘了是从哪个地方弄来的,在保存~/.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)
;;这个是从emacs-lisp-introduction的那个文档拷过来
;;功能同word的计算文字数相似,不过这个功能有待完善,对中文不大好使
(defun hvj-recursive-count-words (region-end)
"Number of words between point and REGION-END."
(if (and (


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/7270/showart_673964.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP