2008年8月29日星期五

用emacs编辑html网页

到这里下载html-helper-mode

http://www.nongnu.org/baol-hth/

http://download.savannah.gnu.org/releases/baol-hth/

.emacs:
(add-to-list 'load-path "d:/Emacs23/emacs/lisp/html-helper/" load-path)
(autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
(setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist))

也可以用NXHTML

在emacs23 win32版的最下面有下载

http://ourcomments.org/cgi-bin/emacsw32-dl-latest.pl

M-x nxhtml-minor-mode

windows下主题:
https://gna.org/projects/color-theme
http://download.gna.org/color-theme/

.emacs:
(load-file “C:/Program Files/Emacs/color-theme.el”)
(color-theme-blue-mood);选择 darkblue的配色方案

给emacs加行号
http://www.emacswiki.org/cgi-bin/emacs-de/LineNumbers
http://www.emacswiki.org/cgi-bin/wiki/line-num.el

firefox扩展

It's All Text

https://addons.mozilla.org/en-US/firefox/addon/4125

在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 文件名” 就可以了。

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

我的dotemacs配置文章

;关闭Emacs启动时提示信息
(setq inhibit-startup-message t)
;不要那个如此大的工具条
(tool-bar-mode -1)
;去掉烦人的警告铃声
(setq visible-bell nil)
;默认目录
(setq default-directory "d:/www/xhml/add8/newscio/")
;显示时间
(display-time)
;时间使用24小时制
(setq display-time-24hr-format t)
;时间显示包括日期和具体时间
(setq display-time-day-and-date t)
;显示行号
(setq column-number-mode t)
(setq line-number-mode t)
;高亮当前行
;(require 'hl-line)
;(global-hl-line-mode t)
;; 指针颜色设置为白色
(set-cursor-color "white")
;; 鼠标颜色设置为白色
(set-mouse-color "white")
;; 设置背景颜色和字体颜色darkblue,dark表示代亮度
(set-foreground-color "white")
(set-background-color "darkgreen")
;;指针不要闪,我得眼睛花了
(blink-cursor-mode -1)
(transient-mark-mode 1)
;记录修改时间
(add-hook 'write-file-hooks 'time-stamp)
;设置time-stamp的格式,我如下的格式所得的一个例子:
;(setq time-stamp-format "%:u %02m/%02d/%04y %02H02M02S")
(setq time-stamp-start "最后更新时间:[ ]+\\\\?")
(setq time-stamp-end: "\n")
(setq time-stamp-format: "%:y年%:m月%:d日 H时:M分:S秒")
;显示匹配的括号
(show-paren-mode t)
;匹配括号的时候, 不要跳到另一个括号那里
(setq show-paren-style 'parentheses)
;高亮显示要拷贝的区域
(transient-mark-mode t)
;允许emacs和外部其他程式的粘贴
(setq x-select-enable-clipboard t)
;支持中键粘贴
(setq mouse-yank-at-point t)
;开启语法高亮。
(global-font-lock-mode 1)
;当光标在行尾上下移动的时候,始终保持在行尾。
(setq track-eol t)
;防止删除东西,弄一个超大的kill ring
(setq kill-ring-max 200)
;文字行宽60个英文字母
(setq default-fill-column 60)
;;;;备份策略
;配置备份文档的路径
(setq backup-directory-alist '(("" . "../.emacs.d/auto-save-list/")))
;生成临时文件
(setq-default make-backup-file t)
(setq make-backup-file t)
(setq make-backup-files t)
;启用版本控制,即能够备份多次
(setq version-control t)
;备份最原始的版本两次,即第一次编辑前的文档,和第二次编辑前的文档
(setq kept-old-versions 2)
;备份最新的版本10次,理解同上
(setq kept-new-versions 3)
;删掉不属于以上版本的版本
(setq delete-old-versions t)
;自动存盘
(setq auto-save-mode t)
;改变emacs标题栏的标题
(setq frame-title-format "%b@Jose")
;; 在日历中使用天干地支
(setq chinese-calendar-celestial-stem
["甲" "乙" "丙" "丁" "戊" "己" "庚" "辛" "壬" "癸"])
(setq chinese-calendar-terrestrial-branch
["子" "丑" "寅" "卯" "辰" "巳" "戊" "未" "申" "酉" "戌" "亥"])
;基督徒的的节日
(setq christian-holidays t)
;;有些可惜,没有中国传统农历,谁能写个扩展elisp包弄一下
(setq general-holidays '((holiday-fixed 1 1 "元旦")
(holiday-fixed 1 2 "腊八节")
(holiday-fixed 1 26 "春节")
(holiday-fixed 3 8 "妇女节")
(holiday-fixed 4 1 "愚人节")
(holiday-fixed 5 1 "劳动节")
(holiday-fixed 6 1 "儿童节")
(holiday-fixed 10 1 "国庆节")
(holiday-fixed 12 25 "圣诞节")
(holiday-fixed 2 9 "元宵节")
(holiday-fixed 4 4 "清明节")
(holiday-fixed 5 28 "端午节")
(holiday-fixed 8 26 "七夕")
(holiday-fixed 9 14 "中秋节")
(holiday-fixed 10 7 "重阳节")
(holiday-float 5 0 2 "母亲节")
(holiday-float 6 0 3 "父亲节")
))
;;在日历中突出标记节日和生日
(setq mark-holidays-in-calendar t)
;; 自动显示图片
;(auto-image-file-mode)
;系统字体大小
(if window-system
(progn
(create-fontset-from-fontset-spec
(concat
;;前面部分为希望的英文字体名,mygbk可以任意命名,只要与后面使用对应即可
"-*-Courier New-normal-r-*-*-16-*-*-*-c-*-fontset-mygbk,"
;;下面是行楷的字体设置
"chinese-gb2312:-*-NSimSun-normal-r-normal-*-18-*-*-p-*-gb2312*-*,"
"chinese-cns11643-5:-*-NSimSun-normal-r-normal-*-18-*-*-p-*-gbk*-*,"
"chinese-cns11643-6:-*-NSimSun-normal-r-normal-*-18-*-*-p-*-gbk*-*,"
"chinese-cns11643-7:-*-NSimSun-normal-r-normal-*-18-*-*-p-*-gbk*-*"
))

;;不用后面的那句,用这句注释掉的也可以
;; (set-face-font 'default "fontset-mygbk")
(setq default-frame-alist
(append
'((font . "fontset-mygbk"))
default-frame-alist))
)
)