长弓无敌
===========================================================
My .emacs
===========================================================
(global-set-key [f1] 'cvs-examine)      ; 开始 PCL-CVS
(global-set-key [f5] 'undo) ; 或许 C- 或 C-/ 更方便
(global-set-key [f6] 'eshell) ; 一个 elisp 写的 shell
(global-set-key [f7] 'calendar) ; Emacs 的日历系统
(global-set-key [f9] 'view-mode) ; 只读方式查看文件
(global-set-key [f8] 'other-window) ; 跳转到 Emacs 的另一个窗口
(global-set-key [f11] 'compile) ; 在 Emacs 中编译
(global-set-key [f12] 'gdb) ; 在 Emacs 中调试
;; 这些功能键有时候还是很有用的。除了直接设置之外,还可以配合 Shift, Ctrl 设
;; 置,比如:

;;
(global-set-key [(shift f1)] 'goto-line)
;;
;; 实际上 Shift-F1 也可以用 F13 表示。

(global-set-key "C-xC-b" 'electric-buffer-list)

;; C-x C-b 缺省的绑定很不好用,改成一个比较方便的 electric-buffer-list,执行
;; 之后:
;; 光标自动转到 Buffer List buffer 中;
;; n, p 上下移动选择 buffer;
;; S 保存改动的 buffer;
;; D 删除 buffer。
;; 除此之外,不错的选择还有 ibuffer,不妨试试 M-x ibuffer。

(global-set-key "C-xC-j" 'dired-jump)
;; Dired-x 在 Dired 之上又提供了很多有用的功能,这是其中之一。可以方便的在任
;; 何时候跳转到当前目录的 Dired buffer 中。

(global-set-key "C-xk" 'kill-this-buffer)
;; 按下 C-x k 立即关闭掉当前的 buffer,需要关闭掉别的 buffer 时,按C-x C-b
;; 用 D 就 ok 了。

(global-set-key "C-cC-o" 'occur)
;; occur 功能,列出当前 buffer 中匹配的行。如果你在 Emacs 阅读这篇说明,试试
;; M-x occur RET chunyu RET 和 C-u 2 M-x occur RET chunyu RET。

(global-set-key "C-cC-v" 'view-mode)
;; 查看文件,翻页比较方便,不用 C-v M-v 了。

(global-set-key "C-cC-z" 'pop-global-mark)
;; 很多文件的时候,在几个文件中跳转到曾经用过的 mark 地方。

(global-set-key "C-" 'toggle-truncate-lines)
;; 基本不用 Emacs 的输入法,绑定给折行命令吧

(global-set-key "C-z" 'set-mark-command)
;; C-SPC 多数时候都是操作系统的输入法切换,set-mark-command 无论如何都要设置
;; 在一个方便的位置。而用来挂起 Emacs 的命令可以用 C-x C-z,也很方便。

(global-set-key "M-/" 'hippie-expand)
;; 自动补全,M-/ 原来的绑定 dabbrev-expand 也是这个功能,然而 hippie-expand
;; 功能更强而且可以扩展。

(global-set-key "M-o" 'other-window)
;; 除了在 Dired buffer 中,基本都可以用来 other-window。

;(global-set-key "M-n" 'gnus)
;; 启动新闻组客户端 gnus。

;;(global-set-key [(home)] 'beginning-of-buffer)
;;(global-set-key [(end)] 'end-of-buffer)
;; 以前的 Emacs 都是如此绑定的,Emacs 21 之后反而使我不习惯了。不过现在我已
;; 经基本不用了,因为 M-< 和 M-> 更方便。而且,如果你是新手,还是行首和行尾
;; 更直观。

;;(global-set-key [(insertchar)] 'overwrite-mode)
;; 平时用 PuTTY 登陆到 Linux 机器上使用,但是不知道为什么 INSERT 键到了
;; Emacs 中变成 insertchar 了,索性从新绑定一下。

(define-prefix-command 'ctl-x-m-map)
(global-set-key "C-xm" 'ctl-x-m-map)
;; 定义了一个新的前缀,并且绑定到 C-x m,后面给这个前缀绑定一些键。而原来的
;; mail 对我基本没用处,或许都是因为 gnus :)。

(define-key ctl-x-m-map "s" 'dictionary-search)
;; 【dictionary.el】查词典。

(define-key ctl-x-m-map "c" 'boxquote-shell-command)
(define-key ctl-x-m-map "f" 'boxquote-describe-function)
(define-key ctl-x-m-map "i" 'boxquote-insert-file)
(define-key ctl-x-m-map "k" 'boxquote-describe-key)
(define-key ctl-x-m-map "p" 'boxquote-paragraph)
(define-key ctl-x-m-map "r" 'boxquote-region)
(define-key ctl-x-m-map "t" 'boxquote-title)
(define-key ctl-x-m-map "u" 'boxquote-unbox)
(define-key ctl-x-m-map "v" 'boxquote-describe-variable)
(define-key ctl-x-m-map "y" 'boxquote-yank)
;;【boxquote.el】在邮件或新闻组中做出漂亮的引用。

(define-key ctl-x-m-map "e" 'cvs-examine)
;; 开始 PCL-CVS。

(define-key ctl-x-m-map "m" 'man-follow)
;; 查看光标处的单词的 man page。

(define-key ctl-x-m-map "g" 'run-scheme)
;; 启动 scheme 交互环境。

(define-key ctl-x-m-map "b" 'list-bookmarks)
;; 列出所有书签。
;; C-x r m BOOKMARK RET 将当前文档的当前位置,设置为名字是 BOOKMARK 的书签;
;; C-r r b BOOKMARK RET 跳转到名字为 BOOKMARK 的书签。

(define-key ctl-x-m-map "l" 'browse-kill-ring)
;;【browse-kill-ring.el】查看 kill-ring,都曾经 kill 过哪些文本。

(define-key ctl-x-m-map "a" 'align-current)
;; 重新排列为整齐的格式。参考 EMACSDIR/lisp/align.el 的注释。

(define-key ctl-x-m-map "w" 'ibuffer)
;; 管理 Emacs 所打开的 buffer。

(define-prefix-command 'meta-m-map)
(global-set-key "M-m" 'meta-m-map)
(define-key meta-m-map "M-m" 'back-to-indentation)
;; 原来 M-m 所绑定的键,现在放在 M-m M-m,同时 M-m 成为了另一个前缀。

(define-key meta-m-map "M-i" 'imenu)
;; 用当前缓冲中所定义的函数之类移动光标。imenu 自动的扫描所打开的文件,根据
;; 内容以及相应的模式判断那些可以作为索引项。打开一个已经写的差不多的 C 文件,
;; M-x imenu RET 试试。
;; 环境的设置 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(setq inhibit-startup-message t)
;; 不显示 Emacs 的开始画面。

(setq default-major-mode 'text-mode)
;; 任意的打开一个新文件时,缺省使用 text-mode。

(setq next-line-add-newlines nil)
;; Emacs 21 中已经时缺省设置。按 C-n 或向下键时不添加新行。

(setq require-final-newline t)
;; 存盘的时候,要求最后一个字符时换行符。

(setq resize-mini-windows nil)
;; mini buffer 的大小保持不变。

(setq track-eol t)
;; 当光标在行尾上下移动的时候,始终保持在行尾。

(setq Man-notify-method 'pushy)
;; 当浏览 man page 时,直接跳转到 man buffer。

(setq uniquify-buffer-name-style 'forward)
;; 当有两个文件名相同的缓冲时,使用前缀的目录名做 buffer 名字,不用原来的
;; foobar<?> 形式。

(setq suggest-key-bindings 1)
;; 当使用 M-x COMMAND 后,过 1 秒钟显示该 COMMAND 绑定的键。

(setq line-number-display-limit 1000000)
;; 当行数超过一定数值,不再显示行号。

(setq kill-ring-max 200)
;; kill-ring 最多的记录个数。

(setq ring-bell-function 'ignore)
;; 彻底的消除 ring-bell 的效果。

(setq apropos-do-all nil)
;; M-x apropos 时多查询些结果,但需要更多的 CPU。

(setq bookmark-save-flag 1)
;; 每当设置书签的时候都保存书签文件,否则只在你退出 Emacs 时保存。

(setq bookmark-default-file "~/.emacs.d/.emacs.bmk")
;; 缺省书签文件的路径及文件名。

(setq dired-listing-switches "-avl")
;; Dired buffer 中列出文件时传递给 ls 的参数。加个 "l" 可以使大写的文件名在
;; 顶部,临时的改变可以用 C-u s。

(setq dired-recursive-copies t)
(setq dired-recursive-deletes t)
;; 复制(删除)目录的时,第归的复制(删除)其中的子目录。

(setq cvs-dired-use-hook 'always)
;; 在一个 CVS 本地拷贝目录的 Dired buffer 中时,如果进入 CVS 目录,自动进入
;; PCL-CVS 界面。

(setq abbrev-file-name "~/.emacs.d/.abbrev_defs")
;; 缺省的定义缩写的文件。

(setq custom-file "~/.emacs.d/.emacs_custom.el")
;; M-x customize 功能保存设置的文件。默认的是 Emacs 的初始化文件 .emacs。

(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)
;; 在 mode-line 上显示时间。

(setq gnus-inhibit-startup-message t)
(setq gnus-init-file "~/.emacs.d/.gnus.el")
;; 设置 gnus 的初始化文件。

(setq mail-signature-file "~/.sig/default")
(setq mail-user-agent 'gnus-user-agent)
(setq mail-alias-file "~/.mailrc")
;; 关于 mail 的简单设置,其他的和 mail 相关的东西都在 .gnus.el 中。

(setq user-full-name "Zhang Junsheng")
(setq user-mail-address "junsheng365@163.com")
;; 缺省的名字和邮件地址,很多地方用得到,比如 VC(version control) 中产生
;; ChangeLog 文件。

(setq time-stamp-active t)
(setq time-stamp-warn-inactive t)
(setq time-stamp-format "%:y-%02m-%02d %3a %02H:%02M:%02S chunyu")
;; 设置时间戳,标识出最后一次保存文件的时间。

(setq diary-file "~/.emacs.d/.diary")
;; 默认的日记文件

(setq calendar-latitude +39.54)
(setq calendar-longitude +116.28)
(setq calendar-location-name "Beijing")
;; 设置所在地的经纬度和地名,calendar 可以根据这些信息告知你每天的日出和日落
;; 的时间。

(setq calendar-remove-frame-by-deleting t)
(setq calendar-week-start-day 1)
(setq christian-holidays nil)
(setq hebrew-holidays nil)
(setq islamic-holidays nil)
(setq solar-holidays nil)
(setq general-holidays '((holiday-fixed 1 1 "元旦")
(holiday-fixed 4 1 "愚人节")
(holiday-float 5 0 2 "母亲节")
(holiday-float 6 0 3 "父亲节")))
;; 去掉了我不感兴趣的节日。

(setq mark-diary-entries-in-calendar t)
(setq appt-issue-message nil)
(setq mark-holidays-in-calendar nil)
(setq view-calendar-holidays-initially nil)

(setq chinese-calendar-celestial-stem
["甲" "乙" "丙" "丁" "戊" "己" "庚" "辛" "壬" "癸"])
(setq chinese-calendar-terrestrial-branch
["子" "丑" "寅" "卯" "辰" "巳" "午" "未" "申" "酉" "戌" "亥"])
;; Calendar 中 p C 可以看到我们的阴历有中文的天干地支。

(setq todo-file-do "~/.emacs.d/todo-do")
(setq todo-file-done "~/.emacs.d/todo-done")
(setq todo-file-top "~/.emacs.d/todo-top")
;; Emacs TODO 模式的相关文件。

(setq version-control t)
(setq kept-old-versions 2)
(setq kept-new-versions 5)
(setq delete-old-versions t)
(setq backup-directory-alist '(("." . "~/var/tmp")))
(setq backup-by-copying t)
;; Emacs 中,改变文件时,默认都会产生备份文件(以 ~ 结尾的文件)。可以完全去掉
;; (并不可取),也可以制定备份的方式。这里采用的是,把所有的文件备份都放在一
;; 个固定的地方("~/var/tmp")。对于每个备份文件,保留最原始的两个版本和最新的
;; 五个版本。并且备份的时候,备份文件是复本,而不是原件。

(setq font-lock-maximum-decoration t)
(setq font-lock-global-modes '(not shell-mode text-mode))
(setq font-lock-verbose t)
(setq font-lock-maximum-size '((t . 1048576) (vm-mode . 5250000)))
;; 语法高亮。除 shell-mode 和 text-mode 之外的模式中使用语法高亮。

(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))
;; hippie-expand 所使用的补全函数及使用的顺序。

(setq ido-enable-tramp-completion t)
;; ido 模式中,使用 tramp 的补全方式。
(setq ido-save-directory-list-file nil)
;; ido 模式中不保存目录列表。

(setq tramp-unified-filenames t)
(setq ange-ftp-generate-anonymous-password "user@cyber.net")
(setq ange-ftp-default-user t)
;; 用于编辑远程文件的 tramp 和 ange-ftp 的设置。

(setq quack-default-program "guile")
(setq quack-fontify-style nil)
;;【quack.el】scheme 的交互环境。

(setq bbdb-file "~/.emacs.d/.bbdb")
;;【bbdb】一个很好用的地址簿,保存你的联系人信息。

(setq-default kill-whole-line t)
;; 在行首 C-k 时,同时删除该行。

(set-register ?e '(file . "~/.emacs.d/.emacs.el"))
(set-register ?g '(file . "~/.emacs.d/.gnus.el"))
;; C-x r j e 就打开了我的 .emacs 配置文件。

(setenv "DISPLAY" "chunyu:0")
;; 设置显示变量,到我的 Windwos 机器,上面装了 X-Win32,用来显示 Linux 机器
;; 上的 X 程序。

;; (set-language-environment 'Chinese-GB)
;; ;; 默认的语言。
;; (set-keyboard-coding-system 'chinese-iso-8bit)
;; ;; 键盘输入,用于输入法。
;; (set-terminal-coding-system 'chinese-iso-8bit)
;; ;; 终端显示的编码方式。
;; (set-clipboard-coding-system 'chinese-iso-8bit)
;; ;; 剪切板,用于和其他程序之间复制内容

(fset 'yes-or-no-p 'y-or-n-p)
;; 改变 Emacs 固执的要你回答 yes 的行为。按 y 或空格键表示 yes,n 表示 no。

(minibuffer-electric-default-mode 1)

(partial-completion-mode 1)
;; M-x t-t-l RET 就可以执行 M-x toggle-truncate-lines。其中的 "-" 除按空格键
;; 就可以。

(global-font-lock-mode 1) ; 开启语法高亮。
(auto-compression-mode 1) ; 打开压缩文件时自动解压缩。
(column-number-mode 1) ; 显示列号。
(blink-cursor-mode -1) ; 光标不要闪烁。
(display-time-mode 1) ; 显示时间。
(show-paren-mode 1) ; 高亮显示匹配的括号。
;(menu-bar-mode -1) ; 不要 menu-bar。
(icomplete-mode 1) ; 给出用 M-x foo-bar-COMMAND 输入命令的提示。
(ido-mode 1) ; 打开文件和转换 buffer 的方便模式。

(add-hook 'diary-hook 'appt-make-list)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
;; shell 中打开 ansi-color 支持。

(add-hook 'comint-output-filter-functions 'comint-watch-for-password-prompt)

(add-hook 'write-file-hooks 'time-stamp)
;; 自动更新 time-stamp。

(add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
;; Dired 中 C-c C-a 作为附件发送。

(add-hook 'dired-load-hook
(lambda ()
(load "dired-x")
(setq dired-view-command-alist
'(("[.](ps|ps_pages|eps)'" . "gv -spartan -color -watch %s")
("[.]pdf'" . "xpdf %s")
("[.](jpe?g|gif|png)'" . "ee %s")
("[.]dvi'" . "xdvi -sidemargin 0.5 -topmargin 1 %s")))))
;; 开启 Dired-x 所提供的新功能,设置 Dired 中 v 使用的相应程序。

(add-hook 'message-setup-hook
(lambda ()
(define-key message-mode-map "M-/" 'chunyu-message-expand)))
(defun chunyu-message-expand (&optional arg)
"message mode expand."
(interactive)
(if (message-point-in-header-p)
(bbdb-complete-name arg)
(hippie-expand arg)))
;; Message buffer 中的 M-/ 使用自己定义的补全方法 chunyu-message-expand。
;; 当在邮件头中的时候,使用 bbdb-complete-name 补全;而在其他地方,使用缺省
;; 的 hippie-expand 补全。
(add-hook 'ido-define-mode-map-hook
(lambda ()
(define-key ido-mode-map "M-d" 'ido-delete-backward-updir)))
;; 由于使用 ido 之前的习惯,经常用 M-Backspace 来删除 mini-buffer 中的文件名,
;; 而 ido 的绑定中虽然有却不好用,索性从新绑定一下。

(add-hook 'c-mode-common-hook
(lambda ()
(c-toggle-auto-hungry-state 1)
(which-func-mode 1)))
;; auto-newline 子模式,自动换行缩进;
;; hungry-delete 子模式,一个 Backspace 删除尽可能多的空白;
;; which-func-mode 在模式行中显示当前行在哪个函数中。

(cond ((not window-system)
;; 如果不在 window 环境中(字符界面时)
(setq frame-background-mode 'dark)
;; 设置背景为黑的,这样 Emacs 的很多缺省颜色会和黑色背景协调。
(eval-after-load "log-view"
;; 设置 log-view 的颜色。
'(progn
(set-face-attribute 'log-view-file-face nil :foreground "blue" :weight 'bold)
(set-face-attribute 'log-view-message-face nil :foreground "yellow" :weight 'bold))))

((eq window-system 'x)
;; 如果在 X Window 中
(global-set-key (kbd "C--") 'undo)
;; Console 中习惯了 C-_ 作为 Undo,不妨把这个也改过来。

(setq visible-bell t)
;; X Window 中的 visible-bell 还是很好看的。

(setq x-stretch-cursor nil)
;; 如果设置为 t,光标在 TAB 字符上会显示为一个大方块 :)。

(scroll-bar-mode -1)
(tool-bar-mode -1)
;; 不要 tool-bar 和 scroll-bar。

(setq default-frame-alist
;; 缺省的颜色设置。
`((vertical-scroll-bars)
(top . 0) (left . 0) (width . 111) (height . 48)
(background-color . "DarkSlateGrey")
(foreground-color . "Wheat")
(cursor-color . "gold1")
(mouse-color . "gold1")
(font . "9x15")))

;; 其他颜色设置。
(if (facep 'mode-line)
(set-face-attribute 'mode-line nil :foreground "DarkSlateGrey" :background "Wheat"))
(if (facep 'fringe)
(set-face-attribute 'fringe nil :foreground "limegreen" :background "gray30"))
(if (facep 'tool-bar)
(set-face-background 'tool-bar "DarkSlateGrey"))
(if (facep 'menu)
(face-spec-set 'menu '((t (:foreground "Wheat" :background "DarkSlateGrey")))))
(if (facep 'trailing-whitespace)
(set-face-background 'trailing-whitespace "SeaGreen1"))
(if (facep 'minibuffer-prompt)
(face-spec-set 'minibuffer-prompt '((t (:foreground "cyan")))))))
(autoload 'big5togb-region "big5togb" "Big5 to GB2312" t)
;;【big5togb.el】ZSH 写的将 big5 文本转为 gb2312 的包。

(autoload 'css-mode "css-mode" "CSS editing mode" t)
;;【css-mode.el】编辑 css 文件。

(autoload 'python-mode "python-mode" "Python editing mode." t)
(autoload 'py-shell "python-mode" "Python shell" t)
;;【python-mode.el】www.python.org 上面的 python-mode

(autoload 'run-scheme "quack" "Quack scheme editing mode" t)
(autoload 'scheme-mode "quack" "Quack scheme editing mode" t)
;;【quack.el】scheme 模式和交互模式。

(autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
;;【html-helper-mode.el】一个不错的 html 编辑模式。

(autoload 'htmlize-buffer "htmlize" "HTMLize mode" t)
;;【htmlize.el】把 buffer 中的内容连同颜色转为 html 格式。

(autoload 'browse-kill-ring "browse-kill-ring" "Browse kill ring" t)
;;【browse-kill-ring.el】查看 kill-ring,都曾经 kill 过哪些文本。

(autoload 'folding-mode "folding" "Folding mode" t)
(autoload 'turn-off-folding-mode "folding" "Folding mode" t)
(autoload 'turn-on-folding-mode "folding" "Folding mode" t)
;;【folding.el】编辑文本的一部分,将其他部分折叠起来。

(setq auto-mode-alist
;; 将文件模式和文件后缀关联起来。
(append '((".py'" . python-mode)
(".s?html?'" . html-helper-mode)
(".asp'" . html-helper-mode)
(".phtml'" . html-helper-mode)
(".css'" . css-mode))
auto-mode-alist))

(add-to-list 'load-path "~/.emacs.d/elisp")
(add-to-list 'load-path "~/.emacs.d/elisp/tramp")
(add-to-list 'backup-directory-alist (cons tramp-file-name-regexp nil))
;(require 'gnus-load)
;(require 'tex-site)
(require 'boxquote)
(require 'compile)
;(require 'dired-tar)
;;【dired-tar.el】Dired 中用 T 就把一个目录压缩为一个 .tar.gz 文件。

(require 'uniquify)
(require 'flyspell)

(put 'dired-find-alternate-file 'disabled nil)
(put 'downcase-region 'disabled nil)
(put 'narrow-to-page 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'set-goal-column 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'rmail 'disabled t)

(add-to-list 'load-path "~/.templetes")
(add-to-list 'load-path "~/site-lisp")

(defun my-insert-date ()
(interactive)
(insert (format-time-string "%Y/%m/%d %H:%M:%S" (current-time))))

;;; wiki source code
(require 'emacs-wiki-srctag)

;;example: add perl support
(add-to-list 'emacs-wiki-src-tag-modes-alist
'("perl" . perl-mode))

(global-set-key (kbd "C-c m d") 'my-insert-date)

;; show the file name
(setq frame-title-format "%n%F/%b")

;;auto publish the emacs wiki
(defun sacha-emacs-wiki-auto-publish ()
(when (derived-mode-p 'emacs-wiki-mode)
(unless emacs-wiki-publishing-p
(let ((emacs-wiki-publishing-p t)
(emacs-wiki-after-wiki-publish-hook nil))
(emacs-wiki-publish-this-page)))))
(add-hook 'emacs-wiki-mode-hook
(lambda () (add-hook 'after-save-hook
'sacha-emacs-wiki-auto-publish
nil t)))
;; When enter emacs wiki then auto use outline minor mode
(add-hook 'emacs-wiki-mode-hook
(function (lambda ()
(outline-minor-mode)
(turn-on-auto-fill))))

(defun emacs-wiki-unlink-toggle ()
"Toggle <nop> string in the beginning of the current word, to
un/make a word emacs-wiki link. The current word depends on the
point: if the cursor is on a non-whitespace character, it's
considered a word surrounded by whitespace. If the cursor is on a
whitespace character, the next word is looked up. This way
addressing a word works intuitively after having arrived on the
spot using forward-word."
(interactive)
(save-excursion
(with-current-buffer (current-buffer)
(if (looking-at "[ t]")
(goto-char (- (re-search-forward "[A-Za-z<>]") 1))
(goto-char (+ (re-search-backward "[^A-za-z<>]") 1)))
(if (looking-at "<nop>")
(delete-char 5)
(insert "<nop>")))))
;;}}}

(add-hook 'emacs-wiki-mode-hook
(lambda ()
(define-key emacs-wiki-mode-map (kbd "C-c C-n") 'emacs-wiki-unlink-toggle)))

;;; add style sheet
(setq emacs-wiki-style-sheet "<link rel="stylesheet" type="text/css" href="mainwy.css">")

;; preview the text
(defun emacs-wiki-preview-source ()
(interactive)
(emacs-wiki-publish-this-page)
(find-file (emacs-wiki-published-file)))

(defun emacs-wiki-preview-html ()
(interactive)
(emacs-wiki-publish-this-page)
(browse-url (emacs-wiki-published-file)))

(add-hook 'emacs-wiki-mode-hook
(lambda ()
(define-key emacs-wiki-mode-map (kbd "C-c C-h") 'emacs-wiki-preview-html)
(define-key emacs-wiki-mode-map (kbd "C-c C-c") 'emacs-wiki-preview-source)
(define-key emacs-wiki-mode-map (kbd "C-c C-v") 'emacs-wiki-change-project)
(define-key emacs-wiki-mode-map (kbd "C-c C-n") 'emacs-wiki-unlink-toggle)

))


;; use abbreviation
(setq-default abbrev-mode t)
(read-abbrev-file "~/.abbrev_defs")
(setq save-abbrevs t)

(add-hook 'tex-mode-hook
(function (lambda ()
(outline-minor-mode))))

(add-hook 'latex-mode-hook
(function (lambda ()
(outline-minor-mode))))


;;;进入LaTeX-mode的时候就会自动加载outline-minor-mode
(add-hook 'LaTeX-mode-hook
(function (lambda ()
(outline-minor-mode))))

;;; add update timestamp
(add-hook 'write-file-hooks 'time-stamp)
(setq time-stamp-format "%:u %02m/%02d/%04y %02H:%02M:%02S")

(transient-mark-mode t)

(setq lazy-lock-defer-on-scrolling t)
(setq font-lock-support-mode 'lazy-lock-mode)
;; (setq font-lock-maximum-decoration t)

;; ==================================================
(add-to-list 'load-path "~/emacs-wiki/")
(add-to-list 'load-path "~/planner/")
(add-to-list 'load-path "~/remember/")

(require 'planner)

;;(global-set-key (kbd "<f9> t") 'planner-create-task-from-buffer)

(require 'remember-planner)
(setq remember-handler-functions '(remember-planner-append))
(setq remember-annotation-functions planner-annotation-functions)

;;;;emacs wiki=============================================================================
(require 'emacs-wiki)
;;==;;;; emacs wiki template
(setq emacs-wiki-charset-default "gb2312")
(setq emacs-wiki-coding-default "gb2312")

;;emacs wiki menu
(require 'emacs-wiki-menu)



;;; enable template property, junsheng 2006年3月8日 9:32:19
(require 'template)
(template-initialize)


;; line number
(set-scroll-bar-mode nil) ; no scroll bar, even in x-window system (recommended)

(require 'wb-line-number)
(wb-line-number-toggle)

;; table
(if window-system
(autoload 'keisen-mode "keisen-mouse" "MULE table" t)
(autoload 'keisen-mode "keisen-mule" "MULE table" t))

;;; set outline mode
(setq outline-minor-mode-prefix [(control o)])

;;set the defautl directory;
(setq default-directory "~/wiki/draft")

;;; here to show image
(auto-image-file-mode t)


;;; session.el
(require 'session)
(add-hook 'after-init-hook 'session-initialize)

;;; desktop.el
(load "desktop")
(desktop-load-default)
(desktop-read)

;;; ibuffer.el: list the buffers
(require 'ibuffer)
(global-set-key (kbd "C-x C-b") 'ibuffer)

;; browse-kill-ring.el
(require 'browse-kill-ring)
(global-set-key [(control c)(k)] 'browse-kill-ring)
(browse-kill-ring-default-keybindings)

;;; tabbar.el
(require 'tabbar)
(tabbar-mode)
(global-set-key (kbd "") 'tabbar-backward-group)
(global-set-key (kbd "") 'tabbar-forward-group)
(global-set-key (kbd "") 'tabbar-backward)
(global-set-key (kbd "") 'tabbar-forward)

;;;table.el
(autoload 'table-insert "table" "WYGIWYS table editor")

;;;bad;;; recentf.el
;;;bad(require 'recentf)
;;;bad(recentf-mode 1)
;;;bad
;;; hippie-expand
(global-set-key [(meta ?/)] 'hippie-expand)

(setq hippie-expand-try-functions-list
'(try-expand-dabbrev
try-expand-dabbrev-visible
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill
try-complete-file-name-partially
try-complete-file-name
try-expand-all-abbrevs
try-expand-list
try-expand-line
try-complete-lisp-symbol-partially
try-complete-lisp-symbol))

;;; 括号

(global-set-key "%" 'match-paren)

(defun match-paren (arg)
"Go to the matching paren if on a paren; otherwise insert %."
(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 wy-go-to-char (n char)
"Move forward to Nth occurence of CHAR.
Typing `wy-go-to-char-key' again will move forwad to the next Nth
occurence of CHAR."
(interactive "pncGo 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)))

(define-key global-map (kbd "C-c a") 'wy-go-to-char)


;;; color-theme
;;; (load-library "color-theme")
(require 'color-theme)
;;;(color-theme-classic)
;;;(color-theme-dark-blue)
;;;(color-theme-word-perfect)
(color-theme-gnome2)
;;new color==========
;;backup;; ;; Set cursor color
;;backup;; (set-cursor-color "white")
;;backup;; ;; Set mouse color
;;backup;; (set-mouse-color "white")
;;backup;; ;; Set foreground and background
;;backup;; (set-foreground-color "white")
;;backup;; (set-background-color "darkblue")
;;backup;; ;;; Set highlighting colors for isearch and drag
;;backup;; (set-face-foreground 'highlight "white")
;;backup;; (set-face-background 'highlight "blue")
;;backup;; (set-face-foreground 'region "cyan")
;;backup;; (set-face-background 'region "blue")
;;backup;; (set-face-foreground 'secondary-selection "skyblue")
;;backup;; (set-face-background 'secondary-selection "darkblue")
;;backup;; ;; Set calendar highlighting colors
;;backup;; (setq calendar-load-hook
;;backup;; '(lambda ()
;;backup;; (set-face-foreground 'diary-face "skyblue")
;;backup;; (set-face-background 'holiday-face "slate blue")
;;backup;; (set-face-foreground 'holiday-face "white")))

;;new color end =====

;;;2006年3月8日9:49:40 good above====================
;;把 fill-column 设为 60. 这样的文字更好读。
;;
(setq default-fill-column 60)

(setq sentence-end "([。!?]|……|[.?!][]"')}]*($|[ t]))[ tn]*")
(setq sentence-end-double-space nil)
;;设置 sentence-end 可以识别中文标点。不用在 fill 时在句号后插
;;入两个空格。
;;
(setq enable-recursive-minibuffers t)
;;可以递归的使用 minibuffer。我经常需要这么做。
;;
(setq scroll-step 1
scroll-margin 3
scroll-conservatively 10000)
;;防止页面滚动时跳动, scroll-margin 3 可以在靠近屏幕边沿3行时
;;就开始滚动,可以很好的看到上下文。
;;
(setq default-major-mode 'text-mode)
;;把缺省的 major mode 设置为 text-mode, 而不是几乎什么功能也
;;没有的 fundamental-mode.
;;

(show-paren-mode t)
(setq show-paren-style 'parentheses)
;;括号匹配时显示另外一边的括号,而不是烦人的跳到另一个括号。
;;
(mouse-avoidance-mode 'animate)
;;光标靠近鼠标指针时,让鼠标指针自动让开,别挡住视线。
;;
(auto-image-file-mode)
;;让 Emacs 可以直接打开和显示图片。
;;
(global-font-lock-mode t)
;;进行语法加亮。
;;
(put 'set-goal-column 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(put 'LaTeX-hide-environment 'disabled nil)
;;把这些缺省禁用的功能打开。
;;

;; load multi-mode of emacs2006年3月17日11:24:57
(autoload 'multi-mode
"multi-mode"
"Allowing multiple major modes in a buffer."
t)

(defun multi-c-fundamental-mode () (interactive)
(multi-mode 1
'c-mode
'("/*" fundamental-mode my-fundamental-setup)
'("*/" c-mode)))

(defun multi-jsp-fundamental-mode () (interactive)
(multi-mode 1
'html-mode
'("/*" fundamental-mode my-fundamental-setup)
'("*/" html-mode)))

(defun jsp-mode () (interactive)
(multi-mode 1
'html-mode
'("" html-mode)))

(defun asp-mode () (interactive)
(multi-mode 1
'html-mode
'("" html-mode)))

;; (setq auto-mode-alist
;; (cons '(".[ch]$" . multi-c-fundamental-mode)
;; (cons '(".jsp$" . jsp-mode)
;; auto-mode-alist)


;; (setq auto-mode-alist
;; (cons '(".(xml|xsl|rng|xhtml)'" . nxml-mode)
;; auto-mode-alist))
;; auto load mode ends 2006年3月17日11:26:58

(mapcar
(function (lambda (setting)
(setq auto-mode-alist
(cons setting auto-mode-alist))))
'(
;;(".xml$". nxml-mode)
(".(xml|xsl|rng|xhtml)'" . nxml-mode)
(".bash" . sh-mode)
(".rdf$". sgml-mode)
(".session" . emacs-lisp-mode)
(".l$" . c-mode)
(".css$" . css-mode)
(".cfm$" . html-mode)
(".jsp$" . html-helper-mode)
("gnus" . emacs-lisp-mode)
(".idl$" . idl-mode)))
;;一个简单的办法设置 auto-mode-alist, 免得写很多 add-to-list.
;;


(setq dired-recursive-copies 'top)
(setq dired-recursive-deletes 'top)

;;让 dired 可以递归的拷贝和删除目录。

;;; load folding 2006年3月3日
(load-library "folding")
(declare (special fold-fold-on-startup
fold-keys-already-setup
))

(setq fold-fold-on-startup t)
(folding-mode-add-find-file-hook)

(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)

;;; end of folding

;;; buffer group
(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)))
)

)))

;;; end of buffer group

;; emacs to do mode
(setq todo-file-do "~/.emacs.d/todo-do")
(setq todo-file-done "~/.emacs.d/todo-done")
(setq todo-file-top "~/.emacs.d/todo-top")

;; Emacs 中,改变文件时,默认都会产生备份文件(以 ~ 结尾的文件)。可以完全去掉
;; (并不可取),也可以制定备份的方式。这里采用的是,把所有的文件备份都放在一
;; 个固定的地方("~/var/tmp")。对于每个备份文件,保留最原始的两个版本和最新的
;; 五个版本。并且备份的时候,备份文件是复本,而不是原件。
(setq version-control t)
(setq kept-old-versions 2)
(setq kept-new-versions 5)
(setq delete-old-versions t)
(setq backup-directory-alist '(("." . "~/var/tmp")))
(setq backup-by-copying t)

(setq bbdb-file "~/.emacs.d/.bbdb")
;;【bbdb】一个很好用的地址簿,保存你的联系人信息。

(setq-default kill-whole-line t)
;; 在行首 C-k 时,同时删除该行

(fset 'yes-or-no-p 'y-or-n-p)
;; 改变 Emacs 固执的要你回答 yes 的行为。按 y 或空格键表示 yes,n 表示 no。

;;;mmm
(autoload 'mmm-mode "mmm-mode" "Multiple Major Modes" t)
(autoload 'mmm-parse-buffer "mmm-mode" "Automatic MMM-ification" t)

;;;ctypes.el
(require 'ctypes)
(ctypes-auto-parse-mode 1)


;;; prefix
(setq adaptive-fill-regexp "[ t]+|[ t]*([0-9]+.|*+)[ t]*")
junsheng 发表于:2006.04.24 15:07 ::分类: ( Linux ) ::阅读:(1587次) :: 评论 (0)

发表评论
标题

在此添加评论
表情符号: smile laughing tongue angry crying sad wassat wink

称呼

邮箱地址(可选)

个人主页(可选)

 authimage


自我介绍
切换风格
新闻聚合
博客日历
文章归档...
最新发表...
最新评论...
最多阅读文章...
最多评论文章...
博客统计...
Blog信息
网站链接...