我的 Emacs 配置文件

这里只是记录我用的 Emacs 的配置文件

(setq inhibit-startup-message t)
 
(add-to-list 'load-path "~/.emacs.d/elisp/color-theme")
(require 'color-theme)
(eval-after-load "color-theme"
  '(progn
     (color-theme-initialize)
     (color-theme-arjen)))
 
(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(default ((t (:inherit nil :stipple nil :background "black" :foreground "White" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 91 :width normal :foundry "bitstream" :family "Courier 10 Pitch")))))
 
(setq display-time-day-and-date t)
(setq display-time-24hr-format t)
(display-time-mode)
 
(show-paren-mode t)
(tool-bar-mode -1)
 
(setq scroll-margin 3 scroll-conservatively 10000)
 
(add-to-list 'load-path "~/.emacs.d/elisp")
(require 'mmm-mode)
 
(setq mmm-global-mode 'maybe)
;(mmm-add-mode-ext-class nil "\\.php\\'" 'html-php)
;(mmm-add-classes
; '((html-php
;    :submode php-mode
;    :front "<\\?\\(php\\)?"
 
;    :back "\\?>"
;    )))
(load "php-mode")
 
(add-to-list 'auto-mode-alist
	     '("\\.php[34]?\\'\\|]].phtml\\'" . php-mode))
 
(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(column-number-mode t))
 
(setq frame-title-format "emacs@%b")

在 Windows 下只启动一个 emacs 进程

下载的 emacs 包里,有两个用得着的可执行文件:runemacs.exe、emacsclientw.exe。平时运行 runemacs.exe 就可以启动 emacs 了,但每运行一次都打开一个新的窗口,文件一多,屏幕上就会很乱。为了让每次都在已经打开的 emacs 中新开一个 buffer 来处理文件,需要运行 emacs 的 server 模式。

1.设置环境变量

新建注册表项:HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs,新建字符串键 HOME,值设置为你自己的 HOME 目录就可以,如 E:\MyDoc

2.编辑 .emacs 文件

在 emacs 里 C-x C-f ~/.emacs,然后写入:

(server-start)
(add-hook 'kill-emacs-hook
(lambda()
(if (file-exists-p "~/.emacs.d/server/server")
(delete-file "~/.emacs.d/server/server"))))

3.创建 myemacs.vbs,这是最后我们调用的文件

Set fso = Wscript.CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
 
dim runcmd
 
if fso.FileExists(WshShell.ExpandEnvironmentStrings("E:\MyDoc\.emacs.d\server\server")) then
    runcmd = "d:\emacs-22.2\bin\emacsclientw.exe"
else
    runcmd = "d:\emacs-22.2\bin\runemacs.exe"
end if
 
if WScript.Arguments.Count > 0 then
    runcmd = runcmd & " """ & WScript.Arguments.Item(0) & """"
end if
 
WshShell.run runcmd
 
set WshShell = nothing
set fso = nothing

上面 emacs 的 bin 和 E:\MyDoc 目录要根据自己的情况修改。

4.把 myemacs.vbs 的快捷方式放到发送菜单里,或者以自己的方式运行 “myemacs.vbs 文件名” 就可以了。

运行之前最好重新启动一下。