Emacs 中文手册
====================================================

[符号]
--------------------------------------
C-                    意思是按住 Ctrol 键
M-                    意指 Meta 键 (键盘上若无Meta 键,则可以ALT 或 ESC 键来取而代之)
DEL                   意指退格键 (不是 删除(Delete) key)
RET                   意指回车键
SPC                   意指空格键
ESC                   意指Escape键
TAB                   意指Tab键

像 "C-M-" (or "M-C") 这样连在一起的意味着同时按住 Control 和 Meta 键不放.
 
 
 
 
[进入Emacs]
----------------------------------------
emacs                 要进入GNU Emacs,只需键入它的名字       
C-z                   挂起Emacs:                       
C-x C-c               永久离开Emacs                     
 
 


[用方向键]
---------------------------------------

        上一行 C-p (Prev line)
                .
                .
                .                
向左移 C-b .... 。.... 向右移 C-f (Forward character)
(Backward )   .
                .
                .
        下一行 C-n (Next line)



[文件]
----------------------------------------
C-x C-f                读取文件到Emacs
C-x r                  只读的方式打开一个文件
C-x C-q                清除一个窗口的只读属性                 
C-x C-s                保存文件到磁盘       
C-x s                  保存所有文件                       
C-x i                  插入其它文件的内容到当前缓冲           
C-x C-v                用将要读取的文件替换当前文件
C-x C-w                将当前缓冲写入指定的文件               
C-x C-q                Version control checkin/checkout             




[错误恢复]
---------------------------------------
C-g                    取消当前要执行的命令                 
M-x recover-file       恢复系统崩溃后丢失的文件               
C-x u或C-_             撤销更新                         
M-x revert-buffer      使缓冲回复到初始内容                 
C-l                    Redraw garbaged screen               




[增量查找]
---------------------------------------
C-s                    向前查找                         
C-r                    向后查找                         
C-M-s                  规则表达式查找                     
C-M-r                  反向规则表达式查找                   
M-p                    选择前一个查找字符串                 
M-n                    选择下一个查找字符串                 
RET                    退出增量查找                       
DEL(Backspace)         取消上一个字符的作用                 
C-g                    退出当前查找模式                   
                       可重复使用C-s和C-r来改变查找方向
                     

[替换]
---------------------------------------
M-%                    交互式地替换一个文本串               
M-x replace-regexp     交互式地替换一个规则表达式             
SPE                    替换当前的并移动到下一处               
,                      替换当前的但不移动到下一处             
L(Backspace)           不替换当前的并移动到下一处             
!                      替换所有剩下的符合条件的文本           
RET                    退出替换模式                       
C-r                    进入递归的编辑模式                   
C-M-c                  退出递归的编辑模式                   




[光标移动]
---------------------------------------
C-f                    向前一个字符                       
C-b                    向后一个字符                       
M-f                    向前一个字                       
M-b                    向后一个字                       
C-p                    向上一行                         
C-n                    向下一行                         
C-a                    到行首                           
C-e                    到行尾                           
M-a                    到句首                           
M-e                    到句尾                           
M-{                    到段首                           
M-}                    到段尾                           
C-x [                  到页首                           
C-x ]                  到页尾                           
C-M-f                  到表达式首部                       
C-M-b                  到表达式尾部
M-<                    到缓冲首部                       
M->                    到缓冲尾部                       
C-v                    滚动到下一屏                       
M-v                    滚动到上一屏                       
C-x <                  滚动到右边一屏(内容向左移动)           
C-x >                  滚动到左边一屏(内容向右移动)           
C-u C-l                滚动当前行到屏幕中央

C-M-n                  移到结尾的)、}或]
C-M-p                  移到开始的)、}或]
C-M-u                  向上移到父结构开始
C-M-d                  向下移到父结构开始



[复制、粘贴、剪切、删除]
-----------------------------
C-d                    向前delete字符                     
DEL(Backspace)         向后delete字符                     
M-d                    向前delete到字首                   
M-DEL(Backspace)       向后delete到字尾                   
M-0 C-k                向前delete到行首                   
C-k                    向后delete到行尾                   
C-x DEL(Backspace)     向前delete到句首                   
M-k                    向后delete到句尾                   
M-- C-M-k              向前delete到表达式首部               
C-M-k                  向后delete到表达式尾部               
C-w                    Kill区域                         
M-w                    拷贝区域到Kill Ring                   
M-z <char>             Kill到下一个给定字符出现的位置           
C-y                    拉回(yank)上次kill的内容             
M-y                    用更早kill的内容取代拉回的上次kill的内容   



[标记Marking]
-----------------------------
C-SPC或C-@             标记当前位置                       
C-x C-x                以字符为单位使用移动命令动态标记区域       
M-@                    以字为单位使用移动命令动态标记区域       
M-h                    标记一段                         
C-x C-p                标记一页                         
C-M-@                  标记一个表达式                     
C-M-h                  标记一个函数                       
C-x h                  标记整个缓冲区                     


[寄存器]
-----------------------------
C-x r s                存储区域到寄存器                   
C-x r i                插入矩形内容到缓冲                   
C-x r SPC <num>        存储光标位置到寄存器                 
 C-x r j <num>         跳跃到寄存器中存储的光标位置          



[矩形]
-----------------------------
C-x r r                拷贝一个矩形到寄存器                 
C-x r k                Kill矩形                         
C-x r y                拉回矩形                         
C-x r o                打开一个矩形, 将文本移动至右边           
C-x r c                清空矩形                         
C-x r t                为矩形中每一行加上一个字符串前缀
C-x r i r              从r缓冲区内插入一个矩形         






[标记Tags]
-----------------------------
M-.                    查找标记                         
C-u M-.                查找标记下一次出现的位置               
M-x visit-tags-table   指定一个新的标记文件                 
M-x tags-search        Regexp search on all files in tabs table         
M-x tags-query-replace 在所有文件中执行查询-替换             
M-,                    继续进行上一次标记查找或查询-替换         





[窗口与缓冲]
-----------------------------
C-x 1                  删除所有其它窗口

C-x 5 2                   
C-x 2                  上下分割当前窗口
                   
C-x 3                  左右分割当前窗口
 
C-x 5 0                  
C-x 0                  删除当前窗口 
                    
C-M-v                  滚动其它窗口                       
C-x o                  切换光标到另一个窗口                 
C-x 4 b C-x 5 b        选择另一个窗口中的缓冲

C-x 5 C-o               
C-x 4 C-o              显示另一个窗口中的缓冲

C-x 5 f              
C-x 4 f                在另一窗口中查找并打开文件             

C-x 5 r
C-x 4 r                在另一窗口中以只读方式打开文件           

C-x 5 d
C-x 4 d                在另一窗口中运行dired命令

C-x 5 .           
C-x 4 .                在另一窗口中查找tag
                 
C-x ^                  增加窗口高度                       
C-x {                  减小窗口宽度                       
C-x }                  增加窗口宽度                       


C-x b                  选择另一个缓冲                     
C-x C-b                列出所有的缓冲                     
C-x k                  Kill一个缓冲                       


[分栏编辑]

C-x 6                 2C-command
C-x 6 s                  2C-split
C-x 6 b    2             C-associate-buffer
C-x 6 2    2             C-two-columns



[格式]
-----------------------------
TAB                    缩进当前行(与模式相关)               
C-M-\                  缩进区域(与模式相关)              
C-M-q                  缩进表达式(与模式相关)               
C-x TAB                Indent region rigidly arg. Columns           
C-o                    在光标后插入一个新的行               
C-M-o                  静态地将一行下移                   
C-x C-o                删除光标附近的空行(留下一行)           
M-^                    与上一行合并成一行                   
M-                     删除光标附近的所有空格               
M-SPC                  删除光标附近的空格(留下一格)           
M-q                    Fill paragraph                       
C-x f                  Set fill column                       
C-x .                  设置每一行开始的前缀                 
M-g                    设置字体       

[!--empirenews.page--]                 



[置换]
-----------------------------
C-t                    字符置换                         
M-t                    字置换                           
C-x C-t                行置换                           
C-M-t                  表达式置换                       





[大小写]
-----------------------------
M-u                    将一个字设置为大写                   
M-l                    将一个字设置为小写                   
M-c                    将一个字首字母设置为大写               
C-x C-u                将一个区域设置为大写                 
C-x C-l                将一个区域设置为小写                 



[补全]
-----------------------------
TAB                    最大程度地补全命令                   
SPC                    补全命令中的一个字                   
RET                    完成并执行一个命令                   
?                      列出命令所有可能的后续部分             
M-p                    列出在当前命令之前输入的命令           
M-n                    列出在当前命令之后输入的命令           
M-r                    用规则表达式在命令历史记录中向后搜寻       
M-s                    用规则表达式在命令历史记录中向前搜寻       
C-x ESC ESC            重复执行上一条命令                   




[Shells]
-----------------------------
M-!                    执行一个shell命令                   
M-|                    在一个区域上执行sheel命令             
C-u M-|                通过shell命令过滤区域                 
M-x shell              在窗口中启动一个shell                 



[缩进]
-----------------------------
C-x TAB                indent-rigidly



[规则表达式]
-----------------------------
.                      除换行符外的所有单个字符               
*                      零个或多个重复                     
+                      一个以上的重复                     
?                      零个或一个重复                    
|                      选择(or)                       
(…)                    分组                           
n                      与第n个组相同的文本                 
b                      At work break                       
B                      Not at work break



[编程]
-----------------------------                
C-M-a                  到函数首部                       
C-M-e                  到函数尾部

C-M-h                  标记一个函数



[GDB调试]
-----------------------------
.启动gdb
 gdb bayonne
 gdb --args bayonne -vvv script.scr

.利用帮助
 help 命令类别名
 help 命令名

.调试指定程序
 file  /home/cnscn/a.out

.运行程序
 r[un]
 r[un] -vvv script.scr

.设置断点
 按照函数名设置断点
 b[reak] main
 b[reak] 'namespace::Class::func()'

.按照文件名和行数设置断点
 b[reak] methods.cpp:523

.检查状态
 检查堆栈
 b[ack]t[race]
 up
 down

 检查当前函数的源代码
 l[ist]

 检查/改变变量值
 p[rint] var
 p[rint] ptr->mem
 p[rint] *ptr
 p[rint] ('namespace::Class') *this
 p[rint] (('namespace::Class') *this)->a.b.c

 p[rint] var=value

 检查类
 ptype ptr

 set print object on
 whatis ptr

 检查并启用/禁用断点
 set breakpoint pending on
 info b[reakpoints]
 enable [N]
 disable [N]

 检查并切换线程
 info th[reads]
 thread N

 检查寄存器
 info reg
 info reg esp

 检查内存
 x/10s *0xaabbccdd
 x/5x var

.继续运行
 运行到某一行即停止,当前函数返回时也停止
 advance source.cpp:123

 运行到当前函数返回为止
 fin[ish]

 继续运行直到程序结束或下一个断点
 c[ontinue]


.信号
 检查当前的信号处理策略
 info signals

 改变信号处理策略
 handle SIGINT pass
 handle SIGINT nostop


.与Emacs配合使用
 建议使用Emacs-23。设定别名
  alias emacs='emacs --enable-font-backend -fn "Dejavu Sans Mono-12"'

 修改~/.emacs,把下面这一行加入
 (defvar gdb-many-windows t)

 在Emacs里启动gdb
 M-x gdb

 开启多窗口模式
 M-x gdb-many-windows

 进入gud-tooltip-mode
 M-x gud-tooltip-mode

                     



[自定义设置]
-----------------------------
.设定预设的输入法,将下面这一行加入到 ~/.emacs 档案中:
 (custom-set-variables '(default-input-method "chinese-array30"))
 在启动 Emacs 后,您就可以直接以 C-\ 指令在英文输入和行列输入法之间切换了
 


[FAQ]
-----------------------------
 
.但是有时候用行列打不出来,需要切换成注音输入法。
 有两种方式可以达成这个目的:

  a. C-x RET C-\ chinese-zozy RET
  b. C-u C-\ chinese-zozy RET

  作者建议您使用第二种方式,因为它同时也是作为两种输入法间切换的指令。
  接下来您只要键入 C-u C-\ RET 就可以在行列和注音这两者间作切换了。
 (注意:中英输入法间的切换还是以 C-\ 指令为之。)

  以后我们在不同中文输入法间作切换将可以 C-u C-u C-\ 达成,
  原本作者是建议以 M-\ 来补足这个想法,
  但是 M-\ 很不幸已经作为 delete-horizontal-space 指令了。
  不然 C-\ 搭配 M-\ 不是很漂亮吗?

  这样子您应该可以理解如何使用中文输入环境了吧!



. narrow 功能.用于隐藏文本,在进行string replace时十分有用选中要保留的文本, 然后C-x n n 或M-x narrow-to-region 要展开文本: C-x n w 或 M-x widen

. emacs的自动排版用M-q

. window下面用emacs远程编辑文件,可以用 ftp方式:

    C-x C-f RET /ftp:user@host:/path/test.txt
    ssh方式: 下载plink.exe,将其路径加入PATH变量
    C-x C-f RET /ftp:user@host:/path/test.txt

. emacs下的su 可以用C-x C-f安下列方式实现su文件编辑
    /su::/etc/foobar.conf

. 用空格代替tab (setq-default indent-tabs-mode nil)
    M-x untabify
  
. 指定文件的编码方式:C-x RET f


. 捕捉程序的输出可以用
    C-u M-! ls


. 如何在dos和unix文件类型之间转化
    C-x RET f unix   转化成Unix文件格式
    C-x RET f dos    转化成dos文件格式


. hexl   将二进制文件转化成emacs十六进制模式可以用的格式


.键绑定

  1. 记住在所有要绑定到快捷键的函数上面加上(interactive)关键字,否则,会发生(wrong-type-argument commandp my-command)的错误
    对于要绑定到鼠标的函数,要在函数声明中指定参数(event),在修饰段,加入(interactive "e"),然后才能绑定
  2. 对于要传递参数的函数,可以用lambda匿名函数来实现

    (global-set-key [(prior)]
        '(lambda () "Previous" (interactive) (scroll-down 1)))

    或则

    (global-set-key [(prior)]
        (function (lambda () "Previous" (interactive) (scroll-down 1))))

    记住对于 global-set-key函数需要的第二个参数是一个symble或者是list
  3. (read-event)可以得到emacs的键码的内部表示
  4. 如果你觉得每次为了关闭一个buffer都要按C-x k很麻烦,那么你可以这样绑定:

    (global-set-key (kbd "<M-f4>") (lambda () (interactive) (kill-buffer (current-buffer)))


http://www.xxlinux.com/linux/article/development/soft/20070119/7049.html==================================================================================================
from: http://pazu.512j.com/emacs_skill.htm

Emacs 技巧

发信人: dddkk (被淹死的鱼), 信区: Linux      
标  题: 用emacs看日出和日落的时间
发信站: BBS 水木清华站 (Tue Apr 29 08:40:47 2003), 转信

呵呵,感觉比较有趣,share一下 :)

在.emacs里面,或者site-lisp/default.el,加入:
(setq calendar-latitude 45.75) ;;纬度,正数北纬
(setq calendar-longitude 126.63) ;;经度,正数东经
(setq calendar-location-name "Harbin") ;;地名

在calendar里面,随便哪一天上,按 S

现在哈尔滨的日出日落时间是:
Apr 29, 2003:
  Sunrise 4:27am (CST), sunset 6:36pm (CST) at Harbin (14:09 hours daylight)



发信人: licro (蓝枫), 信区: Emacs
标  题: Re: emacs-wiki中怎么生成menu
发信站: BBS 水木清华站 (Wed Dec 22 19:34:27 2004), 站内

在~/.emacs中加上
(require 'emacs-wiki-menu)

在要加Menu的页面中加上
<lisp> (funcall emacs-wiki-menu-factory) </lisp
)


outline mode

M-x outline-mode

*标题
内容

C-c C-c 折起来
C-c C-o 展开

M-q 自动排版
glasses-mode 为了把  ThisIsASimpleVarInJava 变成
This_Is_A_Simple_Var_In_Jave

hide-ifdef-mode 可以把一些ifdef的代码先关闭掉,方便查看啊,
按键C-c @ C-c,hs-troggle-hiding,先打开 M-x hs-minor-mode

C-c @ d ,隐藏define的
C-c @ u ,隐藏undef的

ff-find-related-file 头文件


查找函数帮助C-h f 函数名
C-h v       describe-variable

C-c C-c注释掉整块已经选定的区域


C-x h选定整个buffer
C-M-\重新排版

C-c C-q 是{处,排版一个代码段



Emacs Outline Mode

全局hide操作

    * C-o C-q 全局隐藏hide-sublevels 前面可加参数:M-
    * C-o C-t 文档的所有 Entry 都被隐藏。只显示主干

全局Show操作

    * C-o C-a Show All.
    * C-o C-i show-children显示下一级子树。

子树hide操作

    * C-o C-d 子树被折叠起来hide-subtree
    * C-o C-o hide-other。除了本子树,其它子树全部被折叠起来。这个操作正好与 hide-subtree 互补。
    * C-o C-l hide-leaves。子树下的所有级别的entry被隐藏,只显示 branch。
    * C-o C-c hide-entry。本部分的Entry被隐藏,但是所有子树都不动。

子树Show操作

    * C-o C-e show-entry
    * C-o C-k show-branches.各级“树干”被显示,但是各级 entry 还是保持隐藏
    * C-o C-s show-subtree. 本部分所有子结构全部被扩展。

Move 操作

    * C-o C-n (outline-next-visible-heading) 移动到下一个可见标题。
    * C-o C-p (outline-previous-visible-heading) 移动到上一个可见标题。
    * C-o C-f (outline-forward-same-level) 移动到下一个同级可见标题。
    * C-o C-b (outline-backward-same-level) 移动到上一个同级可见标题。
    * C-o C-u (outline-up-heading) 到上一级标题。



发信人: ann77 (ann), 信区: Emacs
标  题: 原创:按照中国习惯的 calendar
发信站: BBS 水木清华站 (Wed Apr 14 12:50:08 2004)

没有想到中国的历法那么复杂,本来想增加
端午节,重阳节,等传统节日,但是发现很复杂,
于是作罢。

大多数的工作就是读懂程序,然后翻译。

主要支持中文习惯的日期表达方式.和部分节日,
例如
2004年4月12日 星期一

安装方法:
把下面的两行, 增加到  .emacs 中。
(add-to-path 'load-path "path/where/to/chinese-calendar.el"
(require 'chinese-calendar)

注意事项:一定要再配好中文环境之后,再调用(require 'chinese-calendar)

例如

(set-language-environment "Chinese-GB")
;;; Coding system
(set-default-coding-systems 'cn-gb-2312)
(set-buffer-file-coding-system 'cn-gb-2312)
(set-terminal-coding-system 'cn-gb-2312)
(set-keyboard-coding-system 'cn-gb-2312)
(set-selection-coding-system 'cn-gb-2312)
(setq locale-coding-system 'cn-gb-2312)
(add-to-path 'load-path "path/where/to/chinese-calendar.el"
(require 'chinese-calendar)



附上chinese-calendar.el,是水木上ann77的杰作


;;; chinese-calendar.el --- calendar for chinese

;; Copyright (C) 2004  Free Software Foundation, Inc.

;; Author: Charles Wang <charleswang@peoplemail.com.cn>
;; Keywords: calendar, i18n

;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Commentary:

;; installation:
;;  put the following line in your .emacs
;;
;;                (add-to-path 'load-path "path/where/to/chinese-calendar.el"
;;                (require 'chinese-calendar)
;;; Code:


(require 'calendar)
(require 'cal-china)

(defun wcy-calendar-remapkey())
(add-hook 'calendar-load-hook 'wcy-calendar-remapkey)

(defun wcy-calendar-move-hook ()
  (wcy-calender-set-mode-line))
(add-hook 'calendar-move-hook 'wcy-calendar-move-hook)

(defun wcy-calendar-init-windows-hook()
  (wcy-calender-set-mode-line))
(add-hook 'initial-calendar-window-hook 'wcy-calendar-init-windows-hook)


(setq chinese-calendar-celestial-stem
  ["甲" "乙" "丙" "丁" "戊" "已" "庚" "辛" "壬" "癸"])
(setq chinese-calendar-terrestrial-branch
  ["子" "丑" "寅" "卯" "辰" "巳" "午" "未" "申" "酉" "戌" "亥"])

(setq chinese-number ["一" "二" "三" "四" "五" "六" "七" "八" "九" "十"])
(defun wcy-chinese-day-name (date)
  (let ((day  (calendar-day-of-week date)))
    (concat "星期" 
            (if (eq day 0)
                "日"
              (aref chinese-number (1- day))))))

(defun wcy-calendar-display-form (date)
  (let* ((dayname (wcy-chinese-day-name date))
         (day   (extract-calendar-day date))
         (month (extract-calendar-month date))
         (year  (extract-calendar-year date)))
    (format "%4d年%2d月%2d日 %s" year month day dayname)))
;;

(setq chinese-date-diary-pattern 
      '(( year " *年" month " *月" day "日 *[^/年0-9]")
        ( year "-" month "-" day "[^0-9]")
        (day "/" month "[^/0-9]")
        (day "/" month "/" year "[^0-9]")
        (backup day " *" monthname "\\W+\\<\\([^*0-9]\\|\\([0-9]+[:aApP]\\)\\)")
        (day " *" monthname " *" year "[^0-9]")
        (dayname "\\W")))
(setq calendar-date-display-form '((wcy-calendar-display-form date)))
(setq diary-date-forms chinese-date-diary-pattern)

(defun wcy-count-chinese-character (string)
  (length (remq nil
                (mapcar 'multibyte-string-p 
                        (mapcar 'char-to-string string)))))

(setq wcy-chinese-month-name ["正月" "二月" "三月" "四月" "五月" "六月" "七月" "八月" "九月" "十月" "十一月" "腊月"])
(setq wcy-chinese-day-name 
      [
       "初一" "初二" "初三" "初四" "初五" "初六" "初七" "初八" "初九" "初十" 
       "十一" "十二" "十三" "十四" "十五" "十六" "十七" "十八" "十九"  "廿"
       "廿一" "廿二" "廿三" "廿四" "廿五" "廿六" "廿七" "廿八" "廿九" "三十"
       "卅一" "卅二" "卅三" "卅四" "卅五" "卅六" "卅七" "卅八" "卅九" "卅十"
       ])

(defun wcy-chinese-date-string (date)
  (let* ((a-date (calendar-absolute-from-gregorian date))
         (c-date (calendar-chinese-from-absolute a-date))
         (cycle (car c-date))
         (year (car (cdr c-date)))
         (month (car (cdr (cdr c-date))))
         (day (car (cdr (cdr (cdr c-date)))))
         (this-month (calendar-absolute-from-chinese
                      (list cycle year month 1)))
         (next-month (calendar-absolute-from-chinese
                      (list (if (= year 60) (1+ cycle) cycle)
                            (if (= (floor month) 12) (1+ year) year)
                            (calendar-mod (1+ (floor month)) 12)
                            1)))
         (m-cycle (% (+ (* year 5) (floor month)) 60)))
    (format "农历%s年%s%s%s"
            ;;cycle
            ;;year 
            (calendar-chinese-sexagesimal-name year)
            (if (not (integerp month))
                "润"
              (if (< 30 (- next-month this-month))
                  ""
                ""))
            (aref wcy-chinese-month-name (1- (floor month)))
            (aref wcy-chinese-day-name (1- day))
            )))

(defun wcy-calender-set-mode-line ()
  (let* ((date (calendar-cursor-to-date))
         (s1 (calendar-date-string date t))
         (s2 (wcy-chinese-date-string date))
         (x (list s1 s2))
         (y (make-string (apply '+  (mapcar 'wcy-count-chinese-character x )) ? )))
    (progn
      (setq calendar-mode-line-format 
            (append x (list y)))
      (update-calendar-mode-line)
      (force-mode-line-update))))
    
;;; the following function is copied from calendar.el or cal-china.el
;;; because they don't conform with the chinese traditional presentation.

(defun calendar-chinese-sexagesimal-name (n)
  "The N-th name of the Chinese sexagesimal cycle.
N congruent to 1 gives the first name, N congruent to 2 gives the second name,
..., N congruent to 60 gives the sixtieth name."
  (format "%s%s"
          (aref chinese-calendar-celestial-stem (% (1- n) 10))
          (aref chinese-calendar-terrestrial-branch (% (1- n) 12))))

 (defun generate-calendar-month (month year indent)
   "Produce a calendar for MONTH, YEAR on the Gregorian calendar.
 The calendar is inserted in the buffer starting at the line on which point
 is currently located, but indented INDENT spaces.  The indentation is done
 from the first character on the line and does not disturb the first INDENT
 characters on the line."
   (let* ((blank-days;; at start of month
           (mod
            (- (calendar-day-of-week (list month 1 year))
               calendar-week-start-day)
            7))
      (last (calendar-last-day-of-month month year)))
    (goto-char (point-min))
    (calendar-insert-indented
     (calendar-string-spread
      (list (format "%d年%d月" year month)) ?  20)
     indent t)
    (calendar-insert-indented "" indent);; Go to proper spot
    (calendar-for-loop i from 0 to 6 do
       (insert (calendar-day-name (mod (+ calendar-week-start-day i) 7)
                                  2 t))
       (insert "  "))
    (calendar-insert-indented "" 0 t);; Force onto following line
    (calendar-insert-indented "" indent);; Go to proper spot
    ;; Add blank days before the first of the month
    (calendar-for-loop i from 1 to blank-days do (insert "   "))
    ;; Put in the days of the month
    (calendar-for-loop i from 1 to last do
       (insert (format "%2d " i))
       (add-text-properties
        (- (point) 3) (1- (point))
        '(mouse-face highlight
      help-echo "mouse-2: menu of operations for this date"))
       (and (zerop (mod (+ i blank-days) 7))
            (/= i last)
            (calendar-insert-indented "" 0 t)    ;; Force onto following line
            (calendar-insert-indented "" indent)))));; Go to proper spot


(setq general-holidays 
      '((holiday-fixed 1 1 "元旦")
        (holiday-chinese-new-year )
        (holiday-fixed 3 8 "妇女节")
        (holiday-fixed 3 12 "植树节")
        (holiday-fixed 5 1 "劳动节")
        (holiday-fixed 5 4 "青年节")
        (holiday-fixed 6 1 "儿童节")
        (holiday-fixed 9 10 "教师节")
        (holiday-fixed 10 1 "国庆节")))

(setq local-holidays nil)
(setq christian-holidays nil)
(setq hebrew-holidays  nil)
(setq islamic-holidays nil)

(setq other-holidays 
      '((holiday-fixed 2 14 "情人节")
        (holiday-fixed 4 1 "愚人节")
        (holiday-fixed 12 25 "圣诞节")
        (holiday-float 5 0 2 "母亲节")
        (holiday-float 6 0 3 "父亲节")
        (holiday-float 11 4 4 "感恩节")))

(setq calendar-holidays
      (append general-holidays local-holidays other-holidays))

(defun holiday-chinese-new-year ()
  "Date of Chinese New Year."
  (let ((m displayed-month)
        (y displayed-year))
    (increment-calendar-month m y 1)
    (if (< m 5)
        (let ((chinese-new-year
               (calendar-gregorian-from-absolute
                (car (cdr (assoc 1 (chinese-year y)))))))
          (if (calendar-date-is-visible-p chinese-new-year)
          (list
           (list chinese-new-year
                 (format "%s年春节"
                         (calendar-chinese-sexagesimal-name (+ y 57))))))))))
(setq solar-n-hemi-seasons
  '( "春分" "夏至" "秋分"  "冬至"))
(setq solar-s-hemi-seasons
  '("秋分" "夏至" "春分" "冬至"))
(provide 'chinese-calendar)
;;; chinese-calendar.el ends here





如果你发现calendar显示对不齐星期(我就有这个问题),你可以把 generate-calendar-month 函数屏蔽掉就可以了



hex 编辑模式
M-x hexl-mode

M-x calculator       Calculator
This is a handy calculator. You can do number conversion with the following commands.
D - to decimal
X - to hexadecimal
O - to octal
B - to binary