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*")
;;              (setq kid-sdcv-window-configuration (current-window-configuration))
;;              (switch-to-buffer-other-window "*sdcv*")
;;              (local-set-key (kbd "d") 'kid-sdcv-to-buffer)
;;              (local-set-key (kbd "q") (lambda ()
;;                                         (interactive)
;;                                         (bury-buffer)
;;                                         (unless (null (cdr (window-list))) ; only one window
;;                                           (delete-window)))))
;;            (goto-char (point-min))))))))
;;}}}

;;{{{ lisp 里快速找到函数
(defvar my-defun-re
  (regexp-opt '("defun" "defsubst" "defmacro" "defadvice") 'paren)
  "Regular expression used to identify a defun.")

(defun my-jump-to-defun (func)
  "Jump to the definition of function FUNC in the current buffer, if found.
Return the position of the defun, or nil if not found."
  (interactive
   ;; From `describe-function'. *NB ?*
   (let ((fn (function-called-at-point)))
     (list (completing-read (if fn
                                (format "Find defun for (default %s): " fn)
                              "Find defun for: ")
                            obarray 'fboundp t nil nil (symbol-name fn)))))
  (let (place)
    (save-excursion
      (goto-char (point-min))
      (if (re-search-forward
           (concat "^[ \t]*(" my-defun-re "[ \t]+"
                   (regexp-quote func) "[ \t]+") (point-max) t)
          (setq place (point))))
    (if (not place)
        (if (interactive-p) (message "No defun found for `%s'" func))
      (when (interactive-p)
        (push-mark)
        (goto-char place)
        (message "Found defun for `%s'" func))
      place)))
;;}}}

;;{{{ 改变 tabbar-buffer-groups-function
;; 原来的 tabbar 强行对你的 buffer 进行分组,但是如果你想在你编辑的buffer间切换而不论它们是什么组,那么似乎没有
;; 一个好办法。但是 tabbar 本来提供了一个机制,让你可以自己确定 tab 属于哪组,只要修改
;; tabbar-buffer-groups-function 就行了。

;; 这样,我可以把每个 buffer 同时加入它所在的 major mode 的组和一个叫做 "default" 的组,这样我在 default 组里就
;; 可以方便的浏览到所有的 buffer 了。而切换到其它组就可以分组浏览。你还可以自行把某些 buffer 分到一组,比如我可
;; 以把 scheme-mode 的 buffer 和 inferer-scheme-mode 的 buffer 分到同一个组。
(setq tabbar-buffer-groups-function 'tabbar-buffer-ignore-groups)

(defun tabbar-buffer-ignore-groups (buffer)
  "Return the list of group names BUFFER belongs to.
Return only one group for each buffer."
  (with-current-buffer (get-buffer buffer)
    (cond
     ((or (get-buffer-process (current-buffer))
          (memq major-mode
                '(comint-mode compilation-mode)))
      '("Process")
      )
     ((member (buffer-name)
              '("*scratch*" "*Messages*"))
      '("Common")
      )
     ((eq major-mode 'dired-mode)
      '("Dired")
      )
     ((memq major-mode
            '(help-mode apropos-mode Info-mode Man-mode))
      '("Help")
      )
     ((memq major-mode
            '(rmail-mode
              rmail-edit-mode vm-summary-mode vm-mode mail-mode
              mh-letter-mode mh-show-mode mh-folder-mode
              gnus-summary-mode message-mode gnus-group-mode
              gnus-article-mode score-mode gnus-browse-killed-mode))
      '("Mail")
      )
     (t
      (list
       "default"  ;; no-grouping
       (if (and (stringp mode-name) (string-match "[^ ]" mode-name))
           mode-name
         (symbol-name major-mode)))
      )
     )))
;;}}}

;;{{{ TODO 让speedbar获得类似ECB的显示效果,把speedbar集成到emacs主窗口里
;; (require 'tramp)
;; (defconst my-junk-buffer-name "Junk")
;; (setq junk-buffer (get-buffer-create my-junk-buffer-name)
;;       )
;; (require 'speedbar)
;; (defconst my-speedbar-buffer-name "SPEEDBAR")
;; (setq speedbar-buffer (get-buffer-create my-speedbar-buffer-name)
;;       speedbar-frame (selected-frame)
;;       dframe-attached-frame (selected-frame)
;;       speedbar-select-frame-method 'attached
;;       speedbar-verbosity-level 0
;;       speedbar-last-selected-file nil)
;; (setq right-window (split-window-horizontally 24))
;; (setq left-window (frame-first-window))
;; ;;(walk-windows (lambda (w) (setq left-window w)) "nominibuffer" t)
;; (set-buffer speedbar-buffer)
;; (speedbar-mode)
;; (speedbar-reconfigure-keymaps)
;; (speedbar-update-contents)
;; (speedbar-set-timer 1)
;; (set-window-buffer left-window "SPEEDBAR")
;; (set-window-dedicated-p left-window t)
;; (toggle-read-only)   ; HACK, REQUIRED for Tramp to work ????
;; (select-window right-window)
;; (defun select-right-window () (select-window right-window))
;; ;;(defun reset-window-config () (interactive)
;; ;; (walk-windows (lambda (w) (when (not (or (eq w left-window) (eq w right-window))) (delete-window w))) "nominibuffer" t)
;; ;; )
;; (defun reset-window-config () (interactive)
;;   (delete-other-windows)
;;   (setq right-window (split-window-horizontally 24))
;;   (setq left-window (frame-first-window))
;;   (set-window-buffer left-window speedbar-buffer)
;;   (set-window-dedicated-p left-window t)
;;   (select-window right-window)
;;   (set-window-dedicated-p right-window nil)
;;   (when (eq speedbar-buffer (window-buffer right-window)) (set-window-buffer right-window (next-buffer)))
;;   (set-window-dedicated-p right-window nil)
;;   )
;; ;;(global-set-key "\C-x1" 'reset-window-config)
;;}}}

(provide 'jerry-function)

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

#9

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

我现在一般不用emacs看邮件了,但是这个mew很强大的说,我感觉比gnus收邮件要快点

代码: 全选

;;; jerry-mew.el --- mew的配置
;;;;;;;;;;;;;;;;;;;;;
;;启动和初始化mew的设置
;;将emacs收发邮件的默认设置为gnus改为mew
;;;;;;;;;;;;;;;;;;;;;
(autoload 'mew "mew" nil t)
(autoload 'mew-send "mew" nil t)
;;设定图表所在文件夹,这个和w3m类似,如果不正确,mew无法启动
;(setq mew-icon-directory "/usr/share/mew")
(if (boundp 'read-mail-command)
  (setq read-mail-command 'mew))
(autoload 'mew-user-agent-compose "mew" nil t)
(if (boundp 'mail-user-agent)
  (setq mail-user-agent 'mew-user-agent))
(if (fboundp 'define-mail-user-agent)
  (define-mail-user-agent
    'mew-user-agent
    'mew-user-agent-compose
    'mew-draft-send-message
    'mew-draft-kill
    'mew-send-hook))


;;;;;;;;;;;;;;;;;;;;;;
;;信件引用设置
;;;;;;;;;;;;;;;;;;;;;;
(setq mew-cite-fields '("From:" "Subject:" "Date:" "Message-ID:"))
(setq mew-cite-format "From: %s\nSubject: %s\nDate: %s\nMessage-ID: %s\n\n")
(setq mew-cite-prefix-function 'mew-cite-prefix-username)


;;;;;;;;;;;;;;;;;;;;;
;;用w3m来读html格式邮件
;;w3m的使用将在以后讲到
;;;;;;;;;;;;;;;;;;;;;
(setq mew-mime-multipart-alternative-list '("Text/Html" "Text/Plain" "*."))
(condition-case nil
		(require 'mew-w3m)
		(file-error nil))


;;;;;;;;;;;;;;;;;
;;一些其他设置,未归类
;;;;;;;;;;;;;;;;;
(setq mew-pop-size 0)
(setq toolbar-mail-reader 'Mew)
(set-default 'mew-decode-quoted 't)
;;设定公共钥匙所用程序,下面采用的是GnuPG
(setq mew-prog-pgp "gpg")


;;;;;;;;;;;;
;;设定用户信息
;;;;;;;;;;;;
(setq mew-name "Jarod Lau")
(setq mew-user "jerry")


;;;;;;;;;;;;
;;设定smtp服务器
;;个人原因,这里不列出我的正确Email
;;;;;;;;;;;;
(setq mew-smtp-user "jarodlau@163.com")
(setq mew-mail-domain "163.com")
(setq mew-smtp-server "smtp.163.com")
;;smtp服务器认证设定
(setq mew-smtp-auth-list (quote ("CRAM-MD5" "LOGIN" "PLAIN")))
;;smtp服务器不用认证采用下面设定
;(setq mew-smtp-auth-list nil)


;;;;;;;;;;;
;;设定pop3服务器
;;个人原因,这里不列出我的正确Email
;;;;;;;;;;;
(setq mew-pop-server "pop.163.com")
(setq mew-pop-user "jarodlau@163.com")
(setq mew-pop-auth 'pass) ;;认证方式
(setq mew-pop-delete nil) ;;将邮件留在服务器上

;;;;;;;;;;;;
;;设定将密码保存一段时间,默认20分钟
;;;;;;;;;;;;
(setq mew-use-cached-passwd t)
;;gnus可以将密码放在配置文件里,收邮件的时候就不用输入密码了
;;我找了一下,发现下面这个变量应该有类似功能,但没有搞掂,高人帮忙!
(setq mew-passwd-alist '(ilyjerry))

;;;;;;;;;;;;;;;;;;;;;
;;语言设置
;;这个不知道有用没,好像在下一版emacs对unicode支持好了就可以了
;;当然这个用emacs-cvs
;;;;;;;;;;;;;;;;;;;;;
(when (boundp 'utf-translate-cjk)
  (setq utf-translate-cjk t)
  (custom-set-variables
    '(utf-translate-cjk t)))
(if (fboundp 'utf-translate-cjk-mode)
  (utf-translate-cjk-mode 1))

(provide 'jerry-mew)

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

#10

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

这个适合喜欢终端界面的朋友用,看网页谁说一定要用firefox和opera呢?
呵呵

代码: 全选

;;; jerry-w3m.el --- emacs-w3m的配置
;;; Code:

;;启动和初始化w3m.el
(autoload 'w3m "w3m" "Interface for w3m on Emacs." t)
(autoload 'w3m-browse-url "w3m" "Ask a WWW browser to show a URL." t)
(autoload 'w3m-search "w3m-search" "Search words using emacs-w3m." t)
;;使用w3m作为默认的浏览器
(setq browse-url-browser-function 'w3m-browse-url)
;;使用mule-ucs,只有在你安装mule-ucs elisp扩展包时这个才有用,可以看Unicode解码的网页
;(setq w3m-use-mule-ucs t)
;;使用工具包
(setq w3m-use-toolbar t)
;;使用info的快件键绑定
;(set-default 'w3m-key-binding 'info)
;;启用cookie
(setq w3m-use-cookies t)
;;这个是作什么的?
(setq w3m-use-tab-menubar t)
;;设定w3m图标所在文件夹
;(setq w3m-icon-directory "/home/jerry/software/xemacs/w3m/emacs-w3m-1.4.4/icons")
;;显示图标
(setq w3m-show-graphic-icons-in-header-line t)
(setq w3m-show-graphic-icons-in-mode-line t)
;;设定w3m运行的参数,分别为使用cookie和使用框架
(setq w3m-command-arguments '("-cookie" "-F"))
;;用w3m浏览网页时也显示图片
(setq w3m-display-inline-image t)
;; ;;设定w3m的语言设置,以便方便使用和阅读中文-用了就乱码
;; ;;书签解码设置
;; (setq w3m-bookmark-file-coding-system 'chinese-iso-8bit)
;; ;;w3m的解码设置,后面最好都有,我也不详解了
;; (setq w3m-coding-system 'chinese-iso-8bit)
;; (setq w3m-default-coding-system 'chinese-iso-8bit)
;; (setq w3m-file-coding-system 'chinese-iso-8bit)
;; (setq w3m-file-name-coding-system 'chinese-iso-8bit)
;; (setq w3m-terminal-coding-system 'chinese-iso-8bit)
;; (setq w3m-input-coding-system 'chinese-iso-8bit)
;; (setq w3m-output-coding-system 'chinese-iso-8bit)
;;w3m是使用tab的,设定Tab的宽度
(setq w3m-tab-width 4)
;;设定w3m的主页,同mozilla的默认主页一样
;(setq w3m-home-page "file://home/jerry/.w3m/bookmark.html")
(setq w3m-home-page "file://home/jerry/.mozilla/firefox/ydr93vef.default/bookmarks.html")
;;当用 shift+RET 打开新链接时将不自动跳转到新的页面,等提示已经完全打开,才用 C-c C-n ,
;;C-c C-p 打开,这个好用
(setq w3m-view-this-url-new-session-in-background t)
(add-hook 'w3m-fontify-after-hook 'remove-w3m-output-garbages)
;;好像是有利于中文搜索的
(defun remove-w3m-output-garbages ()
  "去掉w3m输出的垃圾."
  (interactive)
  (let ((buffer-read-only))
    (setf (point) (point-min))
    (while (re-search-forward "[\200-\240]" nil t)
      (replace-match " "))
    (set-buffer-multibyte t))
  (set-buffer-modified-p nil))
;;颜色设置
;(setq w3m-
;;;;;;;;;;;;;;;;;;;;;
;;语言设置
;;这个不知道有用没,好像在下一版emacs对unicode支持好了就可以了
;;当然这个是用emacs-cvs
;;;;;;;;;;;;;;;;;;;;;
(when (boundp 'utf-translate-cjk)
  (setq utf-translate-cjk t)
  (custom-set-variables
    '(utf-translate-cjk t)))
(if (fboundp 'utf-translate-cjk-mode)
  (utf-translate-cjk-mode 1))

(provide 'jerry-w3m)

;;; jerry-w3m.el ends here
上次由 jarodlau 在 2008-07-31 20:10,总共编辑 1 次。
头像
jarodlau
帖子: 501
注册时间: 2005-09-06 20:34
联系:

#11

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

CEDET是一些使用emacs开发软件的时候常用的插件几何,其中的ECB,semantic,speedbar,都很实用

代码: 全选

;;; jerry-cedet.el --- cedet-ECB,semantic的设置
;;
;;; Code:
;;模板文件目录
(setq template-home-directory "~/lib/templates")
;;导入CEDET的各个插件
;;
;;Load CEDET
(load-file "~/lib/emacs-lisp/cedet-1.0pre4/common/cedet.el")
;;Eieio
(add-to-list 'load-path (expand-file-name "~/lib/emacs-lisp/cedet-1.0pre4/eieio"))
;;Semantic
(add-to-list 'load-path (expand-file-name "~/lib/emacs-lisp/cedet-1.0pre4/semantic"))
;(load-file "~/lib/emacs-lisp/cedet-1.0pre4/eieio/eieio.el")
(require 'cedet)
;; Enabling various SEMANTIC minor modes.  See semantic/INSTALL for more ideas.
;; Select one of the following
;; (semantic-load-enable-code-helpers)
;; (semantic-load-enable-guady-code-helpers)
;; (semantic-load-enable-excessive-code-helpers)

;; Enable this if you develop in semantic, or develop grammars
;; (semantic-load-enable-semantic-debugging-helpers)
;; ---------------------------------------

;; 配置 Emacs Code Browser
(add-to-list 'load-path
	     "~/lib/emacs-lisp/ecb-2.32")
(require 'ecb)

;;配置Sementic的检索范围

(setq semanticdb-project-roots
      (list
	(expand-file-name "/")))
;;配置semanticdb分析文件的目录
(setq semanticdb-default-save-directory
      (expand-file-name "~/.emacs.d/semantic.cache/semanticdb"))

(provide 'jerry-cedet)

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

#12

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

其实用emacs作日程安排最好了,利用org-mode,你可以把你的日程安排输出为html,pdf等格式的文件,我感觉这个比muse,plan好用,因为org就是在emacs内置的outline-mode的基础上建立的,一些outline的快捷键在这里都可以用,我尤其喜欢C-tab来变换视图


;

代码: 全选

;; jerry-org.el --- org模式的配置
;;; Code:
(add-to-list 'load-path "~/lib/emacs-lisp/org-6.01d/lisp")
(add-to-list 'load-path "~/lib/emacs-lisp/org-6.01d/contrib/lisp")

(require 'org-install)

(setq org-agenda-files
      (list "~/.emacs.d/org/work.org"
	  ;  "~/org/sparetime.org"
	    "~/.emacs.d/org/home.org"
	  ;  "~/org/fortune.org"
	    ))

(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))

;; ;(define-key global-map "\C-cl" 'org-store-link)
;; ;(define-key global-map "\C-ca" 'org-agenda)
(setq org-log-done 'time)

;; Face for TODO keywords
(setq org-todo-keyword-faces
      '(
	("TODO"      . (:foreground "red" :weight bold))
	;("TODO"      . org-warning)
	("DEFERRED"  . shadow)     ;; 延缓执行
	("CANCELED"  . (:foreground "blue" :weight bold));;取消
	))
(setq org-todo-keywords '("TODO" "FEEDBACK" "VERIFY"
			  "DEFERRED" "CANCELED"  "DONE")
      org-todo-interpretation 'sequence)

;; OrgMode & Remember
(org-remember-insinuate)
(setq org-directory "~/org")
(setq org-default-notes-file "~/org/notes.org")
(setq remember-annotation-functions '(org-remember-annotation))
(setq remember-handler-functions '(org-remember-handler))
(add-hook 'remember-mode-hook 'org-remember-apply-template)

;; ;; org project
;; (setq org-publish-project-alist
;;       '(("org"
;; 	 :base-directory "~/org/"
;; 	 :publishing-directory "~/org/public_html"
;; 	 :section-numbers nil
;; 	 :table-of-contents nil
;; 	 :style "<link rel=stylesheet
;;       href=\"../other/mystyle.css\"
;;       type=\"text/css\">")))

;; ;; 一些有用的命令
;; ;; C-c a W/w 找WAITING
;; ;; C-C a U/v/u 找BOSS-URGENT
;; ;; C-c a f 找 FIXME
;; (setq org-agenda-custom-commands
;;       '(("w" todo "WAITING")
;; 	("W" todo-tree "WAITING")
;; 	("u" tags "+BOSS-URGENT")
;; 	("v" tags-todo "+BOSS-URGENT")
;; 	("U" tags-tree "+BOSS-URGENT")
;; 	("f" occur-tree "\\<FIXME\\>")))


;; 关联上Emacs的diary
;; (setq org-agenda-include-diary t)
;; open appt message function
(add-hook 'diary-hook 'appt-make-list)
(setq appt-display-diary nil)

;; org to appt
(setq appt-display-format 'window)
(setq appt-display-duration 60)
(setq appt-audible t)
(setq appt-display-mode-line t)
(appt-activate 1)
;(setq appt-msg-countdown-list '(10 0))
      ;(org-agenda)
(org-agenda-to-appt )
;; 只要你在任务中,C-c C-s后,把Schedule的单词删除,那么就是
;; 一个时间戳的概念,那么OrgMode就知道你是要让这个任务中特定的
;; 时间跳出来,提醒你。这时,需要你使用我之前注释掉的代码:

;; 来让OrgMode将这个任务条转换为appt。就是到时间提醒你,很实用的功能
(provide 'jerry-org)
;;; jerry-org.el ends here
头像
jarodlau
帖子: 501
注册时间: 2005-09-06 20:34
联系:

#13

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

下面是一些关于dired模式的配置,其中我更改了很多默认的配置,还加载了一些比较不错的扩展,这些扩展可以大大强化dired的功能

代码: 全选

;;; jerry-dired.el --- dired的配置
;;; Code:
;;设定显示文件的参数,以版本/人性化的显示 就是ls的参数
(setq dired-listing-switches "-vhl")
;; NB C-u s 就可以编辑 dired 的 dired-listing-switches
;;    这个变量,从而达到控制排序的方法的目的。
;;允许复制和删除时将文件夹里所有内容一起带上
(setq dired-recursive-copies t)
(setq dired-recursive-deletes t)
;;cvs时的一个浏览设置
(setq cvs-dired-use-hook 'always)
;;主要可以详细设置的地方
;;对于特定的文件,用什么程序打开
;;记住是用!,而不是enter键,enter键表示编辑,同v
;;记住在后面带上&,为后台运行,我们还要用Emacs做别的事情呢
;;下面的文件用的是正则表达式,要表达清楚
(add-hook 'dired-load-hook
          (lambda ()
	    ;;记住这里要加载另一个有关文件管理器的包dired-x.el,这个是dired的扩展,非常强大
	    (load "dired-x")
	    (setq dired-guess-shell-alist-user
		  (list
		   (list "\\.tar\\.bz2$" "tar jxvf *   &")
		   '("\\.tar\\.gz$" "tar zxvf *   &")
		   '("\\.chm$" "chmsee *  &")
		   '("\\.tar$" "tar xvvf *  &")
		   '("\\.ps$" "gv *   &")
		   '("\\.html?$" "firefox *   &" "urxvt -e w3m *   &")
		   '("\\.pdf$"  "acroread *  &" "evince *   &")
		   '("\\.\\(jpe?g\\|gif\\|png\\|bmp\\|xbm\\|xpm\\|fig\\|eps\\)$" "gthumb * &" "gqview *  &" "display *   &" "xloadimage *   &" )
		   '("\\.\\([Ww][Mm][Vv]\\|[Vv][Oo][Bb]\\|[Mm][Pp][Ee]?[Gg]\\|asf\\|[Rr][Aa]?[Mm]\\)$" "mplayer *   &")
		   '("\\.rmvb$" "mplayer * &")
		   '("\\.RMVB$" "mplayer * &")
		   ))
	    ;; 可以使用 M-o 来方便地切换忽略与显示。
	    ;; 使用dired-x,忽略所有以.开头的文件,隐藏文件
	    ;; omit all hidden file which starts with `.'
	    ;; initially omit unintrested files
	    (setq dired-omit-files "^#\\|^\\..*")
            (dired-omit-mode 1)
	    ;;加载dired+增强模式
	    ;(require 'dired+)
	    ;; NB 使用图形化的sort menu
	    (require 'dired-sort-menu+)
	    ;; NB  让dired只使用一个buffer
	    (require 'dired-single)
	    ;; NB 能够在 dired 里面使用只对文件名部分执行 i-search
	    (require 'dired-isearch)
	    ;; 输入文件名的首字母快速定位到文件
	    ;;他是重新定义了所有的字母以及数字键说绑定的函数,所以如果文件名
	    ;;是中文的话也没有办法,而且按键会和 dired 本身的很多按键冲突
	    (require 'dired-view)
	    (define-key dired-mode-map (kbd "RET") 'joc-dired-single-buffer)
            (define-key dired-mode-map (kbd "<mouse-1>") 'joc-dired-single-buffer-mouse)

	    (define-key dired-mode-map (kbd "C-s") 'dired-isearch-forward)
	    (define-key dired-mode-map (kbd "C-r") 'dired-isearch-backward)
	    (define-key dired-mode-map (kbd "M-C-s") 'dired-isearch-forward-regexp)
	    (define-key dired-mode-map (kbd "M-C-r") 'dired-isearch-backward-regexp)
	    (define-key dired-mode-map (kbd ";") 'dired-view-minor-mode-toggle)
	    (define-key dired-mode-map (kbd "^")
              (lambda ()
                (interactive)
                (joc-dired-single-buffer "..")))
            (setq joc-dired-use-magic-buffer t)
            (setq joc-dired-magic-buffer-name "*dired*")
	    ))

(provide 'jerry-dired)

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

#14

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

这些是关于编程的配置,现在编程少了,所以不怎么全,如果你是个programmer,那这里你就要好好配置一下了

代码: 全选

;;; jerry-mode.el --- 编程模式mode的配置

(add-hook 'text-mode-hook 'turn-on-auto-fill)

;;{{{ Menu ;;;;

(if (boundp 'vc-menu-map)
    (add-to-list 'minor-mode-map-alist
                 `(vc-mode keymap
                           (menu-bar keymap
                                     (VC menu-item "VC" ,vc-menu-map)))))

(define-key-after menu-bar-tools-menu [server-start]
  '("(重新)启动server" . server-start) t)
  ;;'("(Re)start Server" . server-start) t)


(defun my-menu-bar-find-file (file doc help)
  "Make a menu-item to visit a file read-only.
FILE is the file to visit, relative to `data-directory'.
DOC is the text to use the menu entry.
HELP is the text to use for the tooltip."
  `(menu-item ,doc
              (lambda () (interactive)
                (find-file-read-only
                 (expand-file-name ,file data-directory)))
              :help ,help))

(let ((last 'emacs-problems)           ; start point in menu
      file doc this)
  (mapcar (lambda (elem)
            (setq file (car elem)
                  doc (cdr elem)
                  ;; NB how make symbol on the fly. Not `make-symbol'.
                  this (intern (concat "emacs-" (downcase file))))
            (define-key-after menu-bar-help-menu `[,this]
              (my-menu-bar-find-file file doc doc)
              last)
            (setq last this))
	  '(("TODO"       . "Emacs的TODO")
            ("DEBUG"      . "Emacs调试信息")
            ("JOKES"      . "Emacs笑话")
            ("future-bug" . "Emacs未来的bug"))))
          ;; '(("TODO"       . "Emacs TODO List")
	  ;;   ("DEBUG"      . "Emacs Debugging Information")
	  ;;   ("JOKES"      . "Emacs Jokes")
	  ;;   ("future-bug" . "Emacs Future Bug"))))


;; cf menu-bar-make-mm-toggle.
(defmacro my-menu-bar-make-local-mm-toggle (fname doc help &optional props)
  "Make a menu-item for a local minor mode toggle.
FNAME is the minor mode's name (variable and function).
DOC is the text to use the menu entry.
HELP is the text to use for the tooltip.
PROPS are additional properties."
  `'(menu-item ,doc ,fname
	       ,@(if props props)
	       :help ,help
	       :button (:toggle . (and (boundp ',fname)
				       ,fname))))

(or (fboundp 'menu-bar-make-mm-toggle)  ; for 21.3
    (defmacro menu-bar-make-mm-toggle (fname doc help &optional props) ""
      `'(menu-item ,doc ,fname
		   ,@(if props props)
		   :help ,help
		   :button (:toggle . (and (default-boundp ',fname)
					   (default-value ',fname))))))


(when (boundp 'menu-bar-options-menu)

  ;; Note that an error in a definition of this kind caused Emacs to exit
  ;; after "loading tooltip" portion of startup.
  (define-key-after menu-bar-options-menu [show-trailing-whitespace]
    (my-menu-bar-make-local-mm-toggle
     show-trailing-whitespace
     "高亮句子结尾的空格"
     "高亮句子结尾的空格(显示结尾的空白)")
     ;;"Trailing Whitespace Highlighting"
     ;;"Highlight whitespace at line ends (Show Trailing Whitespace)")
    'highlight-paren-mode)

  (define-key-after menu-bar-options-menu [toggle-auto-image]
    (menu-bar-make-mm-toggle auto-image-file-mode
                             "自动显示图片文件"
			     "以查看图片的方式显示图片")
			     ;; "Automatic Display of Image Files"
			     ;;  "Visit image files as images")
    'toggle-auto-compression)

  (define-key-after menu-bar-options-menu [debug-on-signal]
    (menu-bar-make-toggle
     toggle-debug-on-signal debug-on-signal
     "以信号的方式进入Debugger" "在 %s 信号上调试"
     "不管条件处理模式,进入Lisp的调试模式")
     ;; "Enter Debugger on Signal" "Debug on Signal %s"
     ;;  "Enter Lisp debugger regardless of condition handlers")
    'debug-on-error)

  (if (boundp 'menu-bar-showhide-menu)
      (define-key menu-bar-showhide-menu [ruler]
        (my-menu-bar-make-local-mm-toggle ruler-mode
					  "Ruler" "ruler显示/不显示"))
					  ;;"Ruler" "Turn ruler on/off"))

    (define-key-after menu-bar-options-menu [tool-bar-separator]
      '("--") 'debug-on-quit)

    (define-key-after menu-bar-options-menu [tool-bar]
      (menu-bar-make-mm-toggle tool-bar-mode "收起工具条"
			       "切换工具条的显示")
			       ;;"Toggle Tool Bar"
                               ;;"Toggle display of the tool-bar")
      'tool-bar-separator)

    (define-key-after menu-bar-options-menu [display-time]
      (menu-bar-make-mm-toggle
       display-time-mode "切换显示 时间/邮件"
       "切换显示 时间/邮件 的指示器"))))
       ;;"Toggle Display Time/Mail"
       ;;"Toggle display of the time and mail indicator"))))

;;}}} Menu ;;;;

;;{{{ Font-lock ;;;;
;;;
;;启动语法高亮模式
(global-font-lock-mode t)
;;使用gdb的图形模式
(setq gdb-many-windows t)
(global-font-lock-mode 1)
;;一些具体的设置,从别的地方拷过来的,目前编程较少,所以也没具体改了,感觉目前配置还是非常不错的
;;如果你是一个程序员,这块你可以仔细改改
(setq font-lock-maximum-decoration t
      ;; Removed text-mode from this exclusion list for 21.
      ;; Otherwise yanking preserves font-lock attributes of kill buffer,
      ;; which is annoying. Still need hook to actually enable
      ;; font-lock mode for text-mode - see below.
      ;; Then put back in as it messes up latex mode as well.
      font-lock-global-modes '(not shell-mode text-mode)
      font-lock-verbose t
      font-lock-maximum-size '((t . 1048576) (vm-mode . 5250000)))

;; Extra highlighting.
(mapcar '(lambda (element)
	   (let ((mode (car element))
		 (comment (cdr element)))
	     (font-lock-add-keywords
	      mode
	      '((,comment ("\\<\\(GM\\|NB\\|TODO\\|FIXME\\)\\>" nil nil
			   (0 'font-lock-warning-face t)))
		(,comment ("[* ]\\*\\([a-zA-Z].*\\)\\*" nil nil
			   (1 'font-lock-warning-face t)))
		(,comment ("`\\([^`']+\\)'" nil nil
			   (1 'font-lock-constant-face t)))))))
	'((awk-mode      . "#")
	  (sh-mode       . "#")
	  (fortran-mode  . "^C")
	  (f90-mode      . "!")
	  (makefile-mode . "#")))

;; Support mode.
;; jit-lock doesn't seem to work for MIME messages in VM.
(setq font-lock-support-mode
      (if (boundp 'jit-lock-mode)
          '((vm-mode . fast-lock-mode) (t . jit-lock-mode))
        'fast-lock-mode))

;; Jit-lock.
(setq jit-lock-stealth-verbose nil
      jit-lock-stealth-time 2
      ;; If system load rises above this value, pause stealth fontification.
      jit-lock-stealth-load 90
      ;; Seconds to pause between chunks of stealth fontification.
      jit-lock-stealth-nice 0.5
      ;; If nil, deferred fontification only on lines directly modified.
      ;; If t, on those line plus any following.
      ;; Any other value, only if syntactic fontification for that buffer.
      jit-lock-defer-contextually 'syntax-driven)

;; Fast-lock. Caches font-lock information to speed up loads.
(setq fast-lock-minimum-size 50000 ; but not for small files
      fast-lock-verbose      50000 ; so keep quiet
      ;; Or kill-buffer, kill-emacs. If did not save, do not care.
      fast-lock-save-events '(save-buffer)
      fast-lock-save-others nil	; no font-caching for others' files
      ;; Prefer all information to be in one place rather than ./
      fast-lock-cache-directories `(,(expand-file-name "flc" "~/.emacs.d/")))

(mapcar '(lambda (element)
	   (let ((dir (if (listp element) (cdr element) element)))
	     (or (file-directory-p dir) (make-directory element))))
	fast-lock-cache-directories)
;;;
;;}}} Font-lock ;;;;

;;{{{ 缩写词abbrev mode
;; ensure abbrev mode is always on
(setq-default abbrev-mode t)
;; do not bug me about saving my abbreviations
(setq save-abbrevs nil)
;; load up msf-abbrevs for these modes
(require 'msf-abbrev)
(setq msf-abbrev-verbose t) ;; optional
(setq msf-abbrev-root "~/.emacs.d/mode-abbrevs")
;; (global-set-key (kbd "C-c ml") 'msf-abbrev-goto-root)
;; (global-set-key (kbd "C-c ma") 'msf-abbrev-define-new-abbrev-this-mode)
(msf-abbrev-load)
;;}}}

;;{{{ c-mode 的配置,专门为kernel的编程风格做一个模块

;; face
(font-lock-add-keywords
 'c-mode
 `(("/\\*" ("\\<\\(GM\\|NB\\|FIXME\\|TODO\\)\\>"
            nil nil (0 'font-lock-warning-face t)))
   ;; More complex than usual to avoid comments commented by coment-region.
   ("/\\*" ("\\*\\([^ ][^*]*[^ ]*\\)\\*[^//]"
            nil nil (1 'font-lock-warning-face t)))
   ("/\\*" ("`\\([^`']+\\)'" nil nil (1 'font-lock-constant-face t)))
   (,(regexp-opt '("&&" "||" "<=" ">=" "==" "!=" ; overkill?
                   "++" "--" "+=" "-=" "*=" "/=") t) .
                   font-lock-constant-face)))
;; This will define the M-x my-linux-c-mode command.  When hacking on a
;; module, if you put the string -*- linux-c -*- somewhere on the first
;; two lines, this mode will be automatically invoked. Also, you may want
;; to add
;; (add-hook 'c-mode-hook
;;           '(lambda () (hs-minor-mode 1)
;;              (or (file-expand-wildcards "[Mm]akefile")
;;                  (set (make-local-variable 'compile-command)
;;                       (format "gcc %s" buffer-file-name)))))

;; (setq auto-mode-alist (cons '("/usr/src/linux.*/.*\\.[ch]$" . my-linux-c-mode)
;;                             auto-mode-alist))
;; (setq auto-mode-alist (cons '("/home/jerry/linux.*/.*\\.[ch]$" . my-linux-c-mode)
;;                             auto-mode-alist))

;; 我的linux的kernel的编辑策略

(defun my-linux-c-mode ()
  "C mode with adjusted defaults for use with the Linux kernel."
  (interactive)
  (c-mode)
  (c-set-style "k&r")
  (setq tab-width 8)
  (setq indent-tabs-mode t)
  (setq c-basic-offset 8))

;; FIXME 我的C/C++语言编辑策略

(defun my-c-mode-common-hook()
  (c-set-style "k&r")
  (setq tab-width 4 indent-tabs-mode t)
;;;(setq tab-width 4 indent-tabs-mode nil)
;;; hungry-delete and auto-newline
  (c-toggle-auto-hungry-state 1)
  (hs-minor-mode 1)
  (setq abbrev-mode 1)
  ;;按键定义
  (define-key c-mode-base-map [(control \`)] 'hs-toggle-hiding)
  (define-key c-mode-base-map [(return)] 'newline-and-indent)
  (define-key c-mode-base-map [(f7)] 'compile)
  (define-key c-mode-base-map [(f8)] 'ff-get-other-file)
  (define-key c-mode-base-map [(meta \`)] 'c-indent-command)
  ;;  (define-key c-mode-base-map [(tab)] 'hippie-expand)
  (define-key c-mode-base-map [(tab)] 'my-indent-or-complete)
  (define-key c-mode-base-map [(meta ?/)] 'semantic-ia-complete-symbol-menu)
  ;;预处理设置
  (setq c-macro-shrink-window-flag t)
  (setq c-macro-preprocessor "cpp")
  (setq c-macro-cppflags " ")
  (setq c-macro-prompt-flag t)
  ;; (require 'xcscope)
  ;;   ;;显示C的typedef
  ;;   (require 'ctypes)
  ;;   (ctypes-auto-parse-mode 1)
  )
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

(add-hook 'c-mode-hook 'imenu-add-menubar-index)

;; (defun my-ctypes-load-hook ()
;;   (ctypes-read-file "~/.ctypes_std_c" nil t t))
;; (add-hook 'ctypes-load-hook 'my-ctypes-load-hook)

;;打开c mode的时候打开cscope,和type define

;;;;我的C++语言编辑策略
(defun my-c++-mode-hook()
  (setq tab-width 4 indent-tabs-mode nil)
  ;; (require 'xcscope)
  ;;   ;;显示C的typedef
  ;;   (require 'ctypes)
  ;;   (ctypes-auto-parse-mode 1)
  (c-set-style "stroustrup")
  ;;  (define-key c++-mode-map [f3] 'replace-regexp)
  )

(add-hook 'c++-mode-hook 'my-c++-mode-hook)

;;;;C/C++语言启动时自动加载semantic对/usr/include的索引数据库
(setq semanticdb-search-system-databases t)
(add-hook 'c-mode-common-hook
          (lambda ()
	     (setq semanticdb-project-system-databases
		   (list (semanticdb-create-database
			  semanticdb-new-database-class
			  "/usr/include")))))
;;}}} c mode

;;{{{ 我的Java语言编辑策略
(defun my-java-mode-hook()
  (setq tab-width 4 indent-tabs-mode nil)
  )

(add-hook 'java-mode-hook 'my-java-mode-hook)
;;}}}

;;{{{ Python Mode设置
;; (add-to-list 'load-path "/home/jerry/lib/emacs-lisp/python-mode-1.0")
;; (require 'python-mode)
;; ;;(require 'pycomplete)
;; (require 'doctest-mode)
;;}}}

;;{{{ 注释配置
;; (load-file "/home/jerry/lib/emacs-lisp/gnome-doc.el")
;;}}}


;;{{{ makefile-mode ;;;;
(add-hook 'makefile-mode-hook 'imenu-add-menubar-index)
;;}}} makefile-mode ;;;;

;;{{{ Lisp-mode ;;;;

;; 增加一些常用的高亮颜色
(font-lock-add-keywords
 'emacs-lisp-mode
 '((";" ("\\<\\(GM\\|NB\\|TODO\\|FIXME\\)\\>"  nil nil
         (0 'font-lock-warning-face t)))
   (";" ("[* ]\\*[ \t]*\\(\\w.*\\)\\*" nil nil
         (1 'font-lock-warning-face t)))))


;; (mapcar (function (lambda (elem)
;;                     (add-hook 'emacs-lisp-mode-hook elem)))
;;         '(imenu-add-menubar-index turn-on-eldoc-mode))
;; 				  ;; checkdoc-minor-mode))

;; lisp 开发用的
(defun my-emacs-lisp-mode-hook-fn ()
  "Function added to `emacs-lisp-mode-hook'."
  (local-set-key "\C-cd" 'my-jump-to-defun)
  ;;(hs-minor-mode 1)
  ;; A little shorter than "Emacs-Lisp".
  ;; Avoid lisp-interaction and other derived modes.
  (if (eq major-mode 'emacs-lisp-mode)
      (setq mode-name "Elisp"))
  (when (boundp 'comment-auto-fill-only-comments)
    (setq comment-auto-fill-only-comments t)
    (kill-local-variable 'normal-auto-fill-function)))

(add-hook 'emacs-lisp-mode-hook 'my-emacs-lisp-mode-hook-fn)

(defun my-lisp-interaction-mode-hook-fn ()
  "Function added to `lisp-interaction-mode-hook'."
  (setq mode-name "Lisp Int"))
(add-hook 'lisp-interaction-mode-hook 'my-lisp-interaction-mode-hook-fn)

(setq eval-expression-print-level  10
      eval-expression-print-length 100)

;;}}} Lisp-mode ;;;;

;;{{{ WoMan ;;;;
(setq
 woman-cache-filename (expand-file-name "woman.cache" "~/.emacs.d/")
 woman-bold-headings nil
 woman-imenu-title "WoMan-imenu"
 woman-imenu t
 woman-use-own-frame nil		;不使用单独的frame
 woman-use-topic-at-point nil
 woman-fill-frame nil
 woman-show-log nil)

;;配置一下woman的颜色设置
(defun my-woman-pre-format-fn ()
  "."
  (face-spec-set 'woman-bold-face '((t (:foreground "white" :weight normal))))
  (face-spec-set 'woman-italic-face   '((t (:foreground "yellow"))))
  (face-spec-set 'woman-addition-face '((t (:foreground "orange"))))
  (face-spec-set 'woman-unknown-face  '((t (:foreground "cyan"))))
  ;; TODO can a function know its name?
  (remove-hook 'woman-pre-format-hook 'my-woman-pre-format-fn))

(add-hook 'woman-pre-format-hook 'my-woman-pre-format-fn)

;; So that each instance will pop up a new frame.
;; Maybe `special-display-regexps' would be better?
(add-hook 'woman-post-format-hook (lambda () (setq woman-frame nil)))
;;}}} WoMan ;;;;

;;{{{ eshell ;;;;

(defface my-eshell-code-face
  '((t (:foreground "Green")))
  "Eshell face for code (.c, .f90 etc) files.")

(defface my-eshell-img-face
  '((t (:foreground "magenta" :weight bold)))
  "Eshell face for image (.jpg etc) files.")

(defface my-eshell-movie-face
  '((t (:foreground "white" :weight bold)))
  "Eshell face for movie (.mpg etc) files.")

(defface my-eshell-music-face
  '((t (:foreground "magenta")))
  "Eshell face for music (.mp3 etc) files.")

(defface my-eshell-ps-face
  '((t (:foreground "cyan")))
  "Eshell face for PostScript (.ps, .pdf etc) files.")

(setq my-eshell-code-list '("f90" "f" "c" "bash" "sh" "csh" "awk" "el")
      my-eshell-img-list
      '("jpg" "jpeg" "png" "gif" "bmp" "ppm" "tga" "xbm" "xpm" "tif" "fli")
      my-eshell-movie-list '("mpg" "avi" "gl" "dl")
      my-eshell-music-list '("mp3" "ogg")
      my-eshell-ps-list    '("ps" "eps" "cps" "pdf")
      eshell-ls-highlight-alist nil)

(let (list face)
  (mapcar (lambda (elem)
            (setq list (car elem)
                  face (cdr elem))
            (add-to-list 'eshell-ls-highlight-alist
                         (cons `(lambda (file attr)
                                  (string-match
                                   (concat "\\." (regexp-opt ,list t) "$")
                                   file))
                               face)))
          '((my-eshell-code-list  . my-eshell-code-face)
            (my-eshell-img-list   . my-eshell-img-face)
            (my-eshell-movie-list . my-eshell-movie-face)
            (my-eshell-music-list . my-eshell-music-face)
            (my-eshell-ps-list    . my-eshell-ps-face))))

(defun my-tidy-pwd (string)
  "Replace leading ~ by $HOME in output of pwd.
Argument STRING pwd."
  (replace-regexp-in-string "^~" (getenv "HOME") string))

(defun my-eshell-prompt-function ()
  "Return the prompt for eshell."
  (format "[%s@%s %s]%s "
          (eshell-user-name)
          (replace-regexp-in-string "\\..*" "" (system-name))
          (eshell/basename (eshell/pwd))
          (if (zerop (user-uid)) "#" "$")))

(defun my-eshell-line-discard ()
  "Eshell implementation of C-u."
  (interactive)
  (eshell-bol)
  (kill-line))


(defun my-eshell-clear-buffer ()
  "Eshell clear buffer."
  (interactive)
  (let ((eshell-buffer-maximum-lines 0))
    (eshell-truncate-buffer)))

(defalias 'eshell/clear 'my-eshell-clear-buffer)


(setq eshell-directory-name (expand-file-name "eshell" "~/.emacs.d/")
      eshell-pwd-convert-function 'my-tidy-pwd
      eshell-prompt-function 'my-eshell-prompt-function
      eshell-prompt-regexp "^\\[.*\\][#$] "
      eshell-ask-to-save-history 'always
      eshell-banner-message `(format-time-string
                              "Eshell startup: %T, %A %d %B %Y\n\n"))


(defun my-eshell-first-time-mode-hook-fn ()
  "Function added to `eshell-first-time-mode-hook'."
  (face-spec-set 'eshell-ls-backup-face '((t(:foreground "Goldenrod"))))
  (face-spec-set 'eshell-ls-archive-face '((t(:foreground "red" :weight bold))))
  (face-spec-set 'eshell-ls-missing-face '((t(:foreground "orchid"))))
  (define-key eshell-mode-map "\C-ca" 'eshell-bol)
  (define-key eshell-mode-map "\C-c\C-u" 'my-eshell-line-discard)
  (mapcar (lambda (elem)
            (add-to-list 'eshell-visual-commands elem))
          '("pico" "nano")))

(add-hook 'eshell-first-time-mode-hook 'my-eshell-first-time-mode-hook-fn)

;;}}} eshell ;;;;


;;{{{ Shell-mode ;;;;
;;; Prefer terminal-mode really. Eshell even better.
(setq explicit-shell-file-name "bash"
;;;      shell-file-name "/bin/bash"
      ;; Auto-generated variable name.
      explicit-bash-args '("--login")
      comint-scroll-to-bottom-on-input t
      comint-scroll-show-maximum-output t
      comint-scroll-to-bottom-on-output 'all
      comint-input-ignoredups t	; 1 copy only of identical input
      comint-completion-autolist t
      comint-completion-addsuffix t
      comint-buffer-maximum-size 200    ; lines
      comint-highlight-input nil  ; highlight previous input
      comint-highlight-prompt nil)

(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)

(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)


(defun my-shell-mode-hook-fn ()
  "Function added to `shell-mode-hook'."
  ;; M-p by default.
  (define-key shell-mode-map [up] 'comint-previous-input)
  ;; M-n by default.
  (define-key shell-mode-map [down] 'comint-next-input)
  (define-key shell-mode-map [backspace] 'my-shell-backspace))

(add-hook 'shell-mode-hook 'my-shell-mode-hook-fn)


;; Passing with lambda expression not liked.
(add-hook 'comint-output-filter-functions 'comint-watch-for-password-prompt)
(add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m)
(add-hook 'comint-output-filter-functions 'comint-truncate-buffer)

;;}}} Shell-mode ;;;;

;;{{{ 对相应的文件设定相应的模式,以便正确的语法显亮
;;文件名用正则表达式表示,注意不要后面覆盖了前面的而引起的误会
;;修改这个之前先C-h v auto-mode-alist查查已有的设置
;;一个简单的办法设置 auto-mode-alist, 免得写很多 add-to-list
(mapcar
 (function (lambda (setting)
	     (setq auto-mode-alist
		   (cons setting auto-mode-alist))))
 '(
   ("\\.\\(xml\\|rdf\\)\\'" . sgml-mode)
   ("\\.\\([ps]?html?\\|cfm\\|asp\\)\\'" . html-helper-mode)
   ("\\.html$" . html-helper-mode)
   ("\\.css\\'" . css-mode)
   ("\\.\\(emacs\\|el\\|session\\|gnus\\)\\'" . emacs-lisp-mode)
   ("\\.wiki\\'" . emacs-wiki-mode)
   ("\\.\\(jl\\|sawfishrc\\)\\'" . sawfish-mode)
   ("\\.scm\\'" . scheme-mode)
   ("\\.py\\'" . python-mode)
   ("\\.\\(ba\\)?sh\\'" . sh-mode)
   ("\\.l\\'" . c-mode)
   ("\\.max\\'" . maxima-mode)
   ;;("\\config" . fvwm-mode)
   ("\\.fvwm2rc$" . fvwm-mode)
   ("\\.fvwmrc$" . fvwm-mode)
   ("\\.strokes$" . fvwm-mode)
   ("\\.conkyrc$" . fvwm-mode)
   ))

;;}}}auto-list-mode

(provide 'jerry-mode)

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

#15

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

这部分是关于wiki的配置,使用wiki管理你的笔记发布网站很方便,比html语言简单了很多

代码: 全选

;;; jerry-wiki.el --- wiki的设置

;;加载emacs-wiki
(require 'emacs-wiki)
;;设置wiki所在文件夹
(setq emacs-wiki-directories '("~/wiki"))
;;设置wiki转换为html后所在的文件夹
(setq emacs-wiki-publishing-directory "publish")
;;设置wiki转为html用的解码
;;但好像仍然有些问题,用firefox打开时有时仍需手动调整解码
(setq emacs-wiki-meta-charset "gb2312")
;;GBK中文设置
;; (setq emacs-wiki-meta-content-coding "gbk")
;; (setq emacs-wiki-charset-default "gbk")
;; (setq emacs-wiki-coding-default 'gbk)

;;设置wiki转为html的样式,不过目前我还没用
(setq emacs-wiki-style-sheet
      "")
;;设置Wiki内图片的路径
(setq emacs-wiki-inline-relative-to 'default-directory)

;;现面两个函数,是由王垠编写的
;;预览生成网页的源码,即html源码
;;不过先将wiki生成html
(defun emacs-wiki-preview-source ()
  "生成wiki的预览."
  (interactive)
  (emacs-wiki-publish-this-page)
  (find-file (emacs-wiki-published-file)))
;;这个函数是预览在浏览器中所生成的网页
;;这里用的是emacs-w3m浏览器,你也可使用外部浏览器,如firefox,这可能稍复杂点
(defun emacs-wiki-preview-html ()
  "生成wiki的himl代码."
  (Interactive)
  (emacs-wiki-publish-this-page)
  (w3m-browse-url (emacs-wiki-published-file)))

;;设定你的Wiki项目,有时候你可能拥有几个,一个给个人整理笔记用,一个用来发表为网站形式
(setq emacs-wiki-projects
      '(("default" . ((emacs-wiki-directories . ("~/wiki"))))
	("work" . ((fill-column . 65)
		   (emacs-wiki-directories . ("~/wiki/workwiki/"))))))

(provide 'jerry-wiki)

;;; jerry-wiki.el ends here
回复