(require 'session) (add-hook 'after-init-hook 'session-initialize) (load "desktop") (desktop-load-default) (desktop-read);
第一次使用的时候,要运行 M-x desktop-save 命令.
这种方法会导致 emacs 的启动速度极慢,因为加载所有文件,会导致加载对应的 mode,导致运行各种 hook ,加载很多 el 文件。所以我已经不用上面的配置了。
我做了一个改进,叫做 http://www.emacswiki.org/emacs/wcy-desktop.el
(add-hook 'after-init-hook 'session-initialize) (require 'wcy-desktop) (wcy-desktop-init)
(setq frame-title-format "%n%F/%b")
% 后面跟一个特殊字符表示特殊的意义。
(add-hook 'xxx-mode-hook (lambda ... ) 的形式并不 是一个好的方法,因为
建议如下做法:
(defun my-xxx-mode-hook () (interactive) ..... )然后把所有的功能的东西都写在 my-xxx-mode-hook中, 然后
(add-hook 'xxx-mode-hooks 'my-xxx-mode-hook)
;; Turn on font-lock mode for Emacs ;;No Visual feedback on selections (setq-default transient-mark-mode nil) ;; No end a file with a newline (setq require-final-newline nil) ;; Stop at the end of the file, not just add lines (setq next-line-add-newlines nil) ;; Enable wheelmouse support by default ;(cond (window-system ;)) ;; 我不想听见emacs 一个劲的叫 (setq visible-bell t); ;;在console 下 , 我也不想看到屏幕不停的闪 (setq ring-bell-function (lambda () t)) ;;我觉得这里的设置对我来说比缺省的设置方便。 ;; ;;关闭起动时的那个“开机画面”。 ;; (setq inhibit-startup-message t) ;;显示列号。 ;; (setq column-number-mode t) ;;不要在鼠标点击的那个地方插入剪贴板内容。我不喜欢那样,经常把 ;;我的文档搞的一团糟。我觉得先用光标定位,然后鼠标中键点击要好 ;;的多。不管你的光标在文档的那个位置,或是在 minibuffer,鼠标 ;;中键一点击,X selection 的内容就被插入到那个位置。 ;; ;;用一个很大的 kill ring. 这样防止我不小心删掉重要的东西。我很 ;;努莽的,你知道 :P ;; (setq kill-ring-max 200) ;;把 fill-column 设为 60. 这样的文字更好读。 ;; (setq default-fill-column 60) (setq sentence-end "\\([。!?]\\|……\\|[.?!][]\"')}]*\\($\\|[ \t]\\)\\)[ \t\n]*") (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) ;;把这些缺省禁用的功能打开。 ;; (mapcar (function (lambda (setting) (setq auto-mode-alist (cons setting auto-mode-alist)))) '(("\\.xml$". sgml-mode) ("\\\.bash" . sh-mode) ("\\.rdf$". sgml-mode) ("\\.session" . emacs-lisp-mode) ("\\.l$" . c-mode) ("\\.css$" . css-mode) ("\\.cfm$" . html-mode) ("gnus" . emacs-lisp-mode) ("\\.idl$" . idl-mode))) ;;一个简单的办法设置 auto-mode-alist, 免得写很多 add-to-list. ;; (setq user-full-name "ChunYe Wang") (setq user-mail-address "xxxx at xxx . com ") ;;设置有用的个人信息。这在很多地方有用。 ;; (setq dired-recursive-copies 'top) (setq dired-recursive-deletes 'top) ;;让 dired 可以递归的拷贝和删除目录。 ;; 有 toolbar (setq tool-bar-mode t); ;; 没有 menubar (setq menu-bar-mode nil); ;; use clipboard (setq x-select-enable-clipboard t) ;; 在退出 emacs 之前确认是否退出 (setq confirm-kill-emacs 'yes-or-no-p) ;; 设置 hippie-expand 很好用的功能。 M-x 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))