emacs的安装、配置

1.       下载

A) Emacs

这里有更多

B) gnuserv

2.       配置

A) .emacs

;; Begin work - around  for  Emacs  20.3  bug in lazy - lock .  See the FAQ under 
;; upgrading from 
19.34 . 6  to  20.3 . 1 .  When doesn ' t work on 19.34.6 
(if (>= emacs-major-version 20) 
(when (and (= emacs-major-version 20) (= emacs-minor-version 3)) 
       (let ((emacs-minor-version 2)) 
  (require 
' lazy - lock )))) 
;; End work
- around  for  Emacs  20.3  bug in lazy - lock  

;; Face Setting
(
require   ' color-theme)

(color-theme-arjen)

(mapc 
' load (directory - files  " ~/config/my-site-start.d "  t  " .el' " ))
(put 
' upcase-region  ' disabled nil)
(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.
 
' (case - fold - search t)
 
' (column-number-mode t)
 
' (current - language - environment  " Chinese-GB " )
 
' (default-input-method "chinese-py-punct")
 
' (flyspell - abbrev - " nil " )
 
' (flyspell-default-delayed-commands "nil")
 
' (flyspell - default - deplacement - commands  " nil " )
 
' (flyspell-default-dictionary "nil")
 
' (flyspell - deplacement - commands  " nil " )
 
' (flyspell-dictionaries-that-consider-dash-as-word-delimiter "nil")
 
' (flyspell - duplicate - distance  " nil " )
 
' (flyspell-incorrect-hook "nil")
 
' (flyspell - large - region  " nil " )
 
' (flyspell-sort-corrections "nil")
 
' (flyspell - tex - command - regexp  " nil " )
 
' (flyspell-use-global-abbrev-table-p "nil")
 
' (font - lock - maximum - decoration  1 )
 
' (global-font-lock-mode t nil (font-lock))
 
' (inhibit - startup - message t)
 
' (normal-erase-is-backspace t)
 
' (show - paren - mode t nil (paren))
 
' (show-paren-style (quote parenthesis))
 
' (transient - mark - mode t)
 
' (unify-8859-on-encoding-mode t nil (ucs-tables))
 
' (uniquify - buffer - name - style (quote forward) nil (uniquify))
 
' (visible-bell t))

(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 Load CUA Mode
-  Jalen  2006 / 9 / 28
(cua
- mode)


;; Sam Library
 (
require   ' sams-lib)
 (load-library "yic-buffer")
;; End Same Library

;; Desktop support
(load "desktop") 
(desktop-load-default) 
(desktop-read) 
;; End Desktop suppoprt

(defun my-delete-frame ()
  "Deletes the current frame. If this is the last frame, quit Emacs."
  (interactive)
  (if (cdr (frame-list))
    (delete-frame)
    (save-buffers-kill-emacs)))

(defun my-make-frame ()
  "Make a new frame and maximize it."
  (interactive)
  (w32-send-sys-command 61488 (make-frame)))


;; GnuServ Management
(load "gnuserv")
;;(require 
' gnuserv)
(setq gnuserv
- frame (car (frame - list)))
(gnuserv
- start)

(defadvice server
- find - file (around ignore - percent - one (file) activate)
  (
if  (or (not (string =   " %1 "  (file - name - nondirectory file)))
          (file
- exists - p file))
    ad
- do - it))
;; End GnuServ Management



;;把title设置为“文件名
@LC ' s Emacs"
(setq frame-title-format "%b")

;设置默认的列数是110
(setq default-fill-column 110)


;;设置kill-ring-max(我不知道怎么翻译这个词:)为200,以防不测:)
(setq kill-ring-max 200)


;;设置缺省模式是text,而不是基本模式
(setq default-major-mode 
' text - mode)


;;设置tab为4个空格的宽度,而不是原来的2
(setq default
- tab - width  4 )


(add
- hook  ' text-mode-hook  ' turn - on - auto - fill)
(setq user
- full - name  " WangJiayue " )

(global
- font - lock - mode t)


;;把c语言风格设置为k
& r风格
(add
- hook  ' c-mode-hook
   
' (lambda ()
    (c
- set - style  " k&r " )))


;;c
++  mode custome
(add
- hook  ' c++-mode-hook
   
' (lambda()
   (c
- set - style  " stroustrup " ) ;; Set c ++  style
   (outline
- minor - mode)    ;;outline mode
   (c
- toggle - auto - hungry - state  1 )
  ;;(hide
- sublevels  1 )
 ))

;; (add
- hook  ' python-mode-hook
;;           
' (lambda()
;;              (outline
- minor - mode)
;; )


(setq special
- display - buffer - names  ' ("*Help*" "*Apropos*" "*compilation*" "*grep*" "*igrep*")) 

(setq save-abbrevs t)              ;; save abbrevs when files are saved
                                     ;; you will be asked before the abbreviations are saved

(quietly-read-abbrev-file)       ;; reads the abbreviations file on startup

(abbrev-mode 1)

(setq default-abbrev-mode t)

(read-abbrev-file)

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




(defun w32
- restore - frame ( & optional arg)
    
" Restore a minimized frame "
     (interactive)
     (w32
- send - sys - command  61728  arg))
(defun w32
- maximize - frame ( & optional arg)
    
" Maximize the current frame "
     (interactive)
     (w32
- send - sys - command  61488  arg))
(w32
- maximize - frame)
(add
- hook  ' after-make-frame-functions  ' w32 - maximize - frame)

;;时间管理
(setq display
- time - 24hr - format  t)
(setq display
- time - day - and - date t)
(display
- time )

(setq todo
- file - do   " ~/emacs/todo/do " )
(setq todo
- file - done  " ~/emacs/todo/done " )
(setq todo
- file - top  " ~/emacs/todo/top " )

(setq diary
- file  " ~/emacs/diary/diary " )
(setq diary
- mail - addr  " [email protected] " )
(add
- hook  ' diary-hook  ' appt - make - list)

;;约会提醒
(setq appt
- issue - message t)



;; 让emacs能计算日出日落的时间,在 calendar 上用 S 即可看到
(setq calendar
- latitude  + 39.54 )
(setq calendar
- longitude  + 116.28 )
(setq calendar
- location - name  " 北京 " )

;; 设置阴历显示,在 calendar 上用 pC 显示阴历
(setq chinese
- calendar - celestial - stem
  [
" "   " "   " "   " "   " "   " "   " "   " "   " "   " " ])
(setq chinese
- calendar - terrestrial - branch
  [
" "   " "   " "   " "   " "   " "   " "   " "   " "   " "   " "   " " ])

;; 设置 calendar 的显示
(setq calendar
- remove - frame - by - deleting t)
(setq calendar
- week - start - day  1 )            ; 设置星期一为每周的第一天
(setq mark
- diary - entries - in - calendar t)     ; 标记calendar上有diary的日期
(setq mark
- holidays - in - calendar nil)        ; 为了突出有diary的日期,calendar上不标记节日
(setq view
- calendar - holidays - initially nil) ; 打开calendar的时候不显示一堆节日 

;; 去掉不关心的节日,设定自己在意的节日,在 calendar 上用 h 显示节日
(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 2 14 "情人节")
                         (holiday-fixed 3 14 "白色情人节")
                         (holiday-fixed 4 1 "愚人节")
                         (holiday-fixed 5 1 "劳动节")
                         (holiday-float 5 0 2 "母亲节")
                         (holiday-fixed 6 1 "儿童节")
                         (holiday-float 6 0 3 "父亲节")
                         (holiday-fixed 7 1 "建党节")
                         (holiday-fixed 8 1 "建军节")
                         (holiday-fixed 9 10 "教师节")
                         (holiday-fixed 10 1 "国庆节")
                         (holiday-fixed 12 25 "圣诞节")))


(setq printer-name "HP LaserJet 2300 Series PCL 6 (22f)")
(setq ps-printer-name "HP LaserJet 2300 Series PCL 6 (22f)")

;; Send message to let the maximinus
(w32-send-sys-command #xf030)

(tool-bar-mode nil)

(defun my-indent-or-complete ()
  "如果在词尾,那就hippie-expand,否则就indent"
  (interactive)
  (if (looking-at "/>")
      (hippie-expand nil)
    (indent-for-tab-command)
    ))


(require 
' gnus)
(setq gnus
- startup - file  " ~/emacs/config/newsrc " )
(setq gnus
- init - file  " ~/emacs/config/gnus-config " )


(
require   ' tabbar)
(tabbar-mode)

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

(setq tabbar-buffer-groups-function 
' tabbar - buffer - ignore - groups)

;; 
---------------- Global Key Setting --------------

;; Frame Management
(global
- set - key [ M - f4]  ' my-delete-frame)

(global-set-key "M-n" 
' my - make - frame)
;; End

(global
- set - key (kbd  " <f11> " ' calendar)
(global-set-key (kbd "<f12>") 
' list - bookmarks)
(global
- set - key (kbd  " <f9> " )   ' todo-show)

(global-set-key [(tab)] 
' my - indent - or - complete)

(global
- set - key [(control  shift  tab)]  ' tabbar-backward)
(global-set-key [(control tab)]       
' tabbar - forward)

;; 
--------------- End Global Key Setting ---------


;;Ending

B) 配置右键菜单

注册表/HKEY_CLASSES_ROOT/<nop>AllFilesystemObjects/shell/下面新建一项Emacs(或者你想在右键菜单中出现的字样,比如Emacs打开),再在下面新建command项,看起来应该是这样:

/HKEY_CLASSES_ROOT/AllFilesystemObjects/shell/Emacs/command/

然后把command项右边的默认值设为Path/gnuclientw.exe,并加上"%1",看起来像这样:

C:/emacs/bin/gnuclientw.exe "%1"

注意%1上面要加引号,以免无法正确的将含有空格的文件名传给gnuclientw

完成这一步,就在所有类型的文件(包括文件夹)的右键菜单中加入了一个名为Emacs的选项。

如果也想在我在电脑下的分区的右键菜单上加上Emacs,则对hkey_class_root下的Driver作同样的事即可。

C) LISP程序

color-theme.el

tabbar.el

yic-buffer.el

你可能感兴趣的:(calendar,command,File,emacs,lisp,hook)