注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

My Unix World

不要迷恋Unix,Unix只是计算世界很小的一部分!

 
 
 

日志

 
 

【Copy】Emacs配置文件整理版  

2009-01-02 17:47:07|  分类: L-Emacs |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
;;;;自动编译
  (add-hook 'after-save-hook (lambda () (mapcar (lambda (file)
          (setq file (expand-file-name file)) (when (string= file
          (buffer-file-name)) (save-excursion (byte-compile-file
          file)))) '("~/.emacs" "~/.gnus.el" "~/.wl"))))


;;;设置默认工作区
(setq default-directory "d:/emacs/")
(add-to-list 'load-path (expand-file-name "~/myemacs/site/myown"))
(add-to-list 'load-path (expand-file-name "~/myemacs/site/myown/mmm-mode-0.4.8"))
(add-to-list 'load-path (expand-file-name "~/myemacs/site/myown/dictionary"))
(add-to-list 'load-path (expand-file-name "~/myemacs/site/myown/wl"))
;(add-to-list 'load-path (expand-file-name "~/myemacs/site/myown/emacs-wiki"))
(setq load-path (add-to-list 'load-path "~/myemacs/site/myown/emacs-wiki"))
(setq load-path (add-to-list 'load-path "~/myemacs/site/mew"))
(setq load-path (add-to-list 'load-path "~/myemacs/site/myown/org-4.56"))
;;;定义新的prefix:
(define-prefix-command 'ctl-z-map)
(global-set-key (kbd "C-z") 'ctl-z-map)

;;;设置编码
(setq session-save-file-coding-system 'chinese-gbk)


;; 高亮显示选中区域
(transient-mark-mode t)

;;;;--------------基本设置区---------------------;;;;
;;;;;;;;tab browse;;;;;;;;;;
(require 'tabbar)
(tabbar-mode)
;(global-set-key (kbd "C-<") 'tabbar-backward-group)
;(global-set-key (kbd "C->") 'tabbar-forward-group)
(global-set-key  [C-tab] 'tabbar-forward)
(global-set-key  [C-S-tab] 'tabbar-backward)

;;;;去掉启动欢迎界面
(setq inhibit-startup-message t)

;; mini buffer 的大小保持不变。
(setq resize-mini-windows nil)

;;
;;(require 'html2text)
;;插入日期时间
;;{{{
;; insert current date
(defun baiy-insert-date ()
  (interactive)
  (insert (format-time-string "%Y-%m-%d %a")))

;; insert current time
(defun baiy-insert-time ()
  (interactive)
  (insert (format-time-string "%p %I:%M")))

(define-key ctl-z-map (kbd "d") 'baiy-insert-date)
(define-key ctl-z-map (kbd "t") 'baiy-insert-time)
;;}}}

;;;定义hideshow
(define-key ctl-z-map (kbd "h b") 'hs-hide-block)
(define-key ctl-z-map (kbd "h a") 'hs-show-all)
(define-key ctl-z-map (kbd "h s") 'hs-show-block)

;;;一些基本的设置
(display-time)

;;设置一些快捷键

(global-set-key "\C-w" 'backward-kill-word)
(global-set-key "\C-x\C-k" 'kill-region)
(global-set-key "\C-c\C-k" 'kill-region)

;;;speedbar快捷键
(global-set-key (kbd "") 'speedbar-get-focus)

;;;color-theme
(load "color-theme")
;(color-theme-jsc-light)
(color-theme-deep-blue)

;;;一秒以后显运行函数的绑定键
(setq suggest-key-bindings 1)

;;;windows下设置emacs只打开一个窗口
(require 'gnuserv)
(gnuserv-start)
(setq gnuserv-frame (selected-frame))
(setenv "GNUSERV_SHOW_EMACS" "1")

;;不要toolbar等
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))

;;为正则表达式查询定义alias
(defalias 'qrr 'query-replace-regexp)

;;(w32-send-sys-command #xf030);;窗口最大化
 (setq-default kill-whole-line t);;删除整行时,顺便把产生的空
                 ;;格行也删除掉。

;;;;设置移动窗口命令
  (define-key ctl-z-map [down] 'windmove-down)
  (define-key ctl-z-map [up] 'windmove-up)
  (define-key ctl-z-map [right] 'windmove-right)
(define-key ctl-z-map [left] 'windmove-left)

;;保存文件时在最后使用换行
(setq require-final-newline t)

;;;moccur搜索
(require 'color-moccur)
(require 'moccur-edit)

;;line number 列
(require 'wb-line-number)
(define-key ctl-z-map (kbd "l") 'wb-line-number-enable)
(define-key ctl-z-map (kbd "L") 'wb-line-number-disable)

;;pop up marks
 (define-key ctl-z-map (kbd "C-z") 'set-mark-command)
  (global-set-key "\C-x\C-p" 'pop-global-mark)

;;;;让emacs能识别中文标点,这样在中文中也能使用M-a,M-e移动
(setq sentence-end "\\([。!?]\\|……\\|[.?!][]\"')}]*\\($\\|[
\t]\\)\\)[ \t\n]*")

;;在标题栏显示buffer的名字,而不是 emacs@wangyin.com 这样没用的提示
;;(setq frame-title-format "emacs@%b")
(setq frame-title-format (list "%f ---- ★Emacs★--"
"--自由自在,我的emacs我作主----◆逝者如斯◆"))

;;;关闭buffer快捷键
(global-set-key [f9] (function (lambda ()
                                  (interactive)
                                  (kill-buffer (current-buffer)))))

 ;; for else自动补全
;(add-to-list 'load-path (expand-file-name "~/myemacs/site/myown/else"))
;(load "else-mode")

;;;所见即所得表格插入工具
(autoload 'table-insert "table" "WYGIWYS table editor")

;;改变tab缩进
(setq c-basic-offset 4)

;;;日历快捷键
(global-set-key (kbd "") 'calendar)

;;;设置c-o,这样在一行中的任何位置就可以直接新建一行了。相当于先c-e再enter
(global-set-key (kbd "C-o")
            '(lambda ()
               (interactive)
               (end-of-line 1)
               (newline-and-indent)))

;;;;矩形操作
(require 'rect-mark)
;;;自动补全
(global-set-key [(meta ?/)] '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))


;;;非常不错的buffer管理工具
(require 'ibuffer)
(global-set-key (kbd "C-x C-b") 'ibuffer)

;;;session管理,记住你打开的文件历史,在某个文件中的最后鼠标位置等
(require 'session)
(add-hook 'after-init-hook 'session-initialize)
 
;;;将emacs做为图片浏览器
(require 'thumbs)
(auto-image-file-mode t)

;; 你是不是经常按 C-y 放进一个 kill-ring 里的单元。然后 M-y,M-y,…… 来寻找你需要的很久以前剪切下来的东西?很费事吧?用了 browse-kill-ring 就好了。你只需要把它绑定到一个热键,比如 C-c k: 就能出现这样一个buffer
(require 'browse-kill-ring)
(global-set-key [(control c)(k)] 'browse-kill-ring)
(browse-kill-ring-default-keybindings)

;;;匹配括号
(global-set-key "%" 'match-paren)
         
(defun match-paren (arg)
  "Go to the matching paren if on a paren; otherwise insert %."
  (interactive "p")
  (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
    ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
    (t (self-insert-command (or arg 1)))))

;;括号高亮设置
;; show the matched parentheses
(show-paren-mode t)
;; no jump, just highlight
(setq show-paren-style 'parentheses)

;;有了这段代码之后,当你按 C-c a x (x 是任意一个字符) 时,光标就会到下一个 x 处。再次按 x,光标就到下一个 x。比如 C-c a w w w w ..., C-c a b b b b b b ...
(defun wy-go-to-char (n char)
  "Move forward to Nth occurence of CHAR.
Typing `wy-go-to-char-key' again will move forwad to the next Nth
occurence of CHAR."
  (interactive "p\ncGo to char: ")
  (search-forward (string char) nil nil n)
  (while (char-equal (read-char)
             char)
    (search-forward (string char) nil nil n))
  (setq unread-command-events (list last-input-event)))

(define-key global-map (kbd "C-c a") 'wy-go-to-char)


;; 设置时间戳,标识出最后一次保存文件的时间。
(setq time-stamp-active t)
(setq time-stamp-warn-inactive t)
(setq time-stamp-format "%:y-%02m-%02d %3a %02H:%02M:%02S baiy")

;;;;;;;;;;;;将fill-column设为72,这样更容易阅读;;;;
(setq default-fill-column 72)

;;;设置日记文件
(setq diary-file "D:/emacs/diary/diary")

;;;;;;;;;;;;;滚动时在距边界三行时自动滚动,不要跳转;;;;;;;;;;;
(setq scroll-margin 3
      scroll-conservatively 10000)

;; 当使用 M-x COMMAND 后,过 1 秒钟显示该 COMMAND 绑定的键。
(setq suggest-key-bindings 1)

;; 复制(删除)目录的时,第归的复制(删除)其中的子目录。
(setq dired-recursive-copies t)
(setq dired-recursive-deletes t)

;;;让ediff的窗口变成通常的emacs窗口
(setq ediff-window-setup-function 'ediff-setup-windows-plain)

;; 缺省的名字和邮件地址,很多地方用得到,比如 VC(version control) 中产生
;; ChangeLog 文件。
(setq user-full-name "Raphae")
(setq user-mail-address "raphael@workssys.com.cn")

;; Calendar 中 p C 可以看到我们的阴历有中文的天干地支。
(setq chinese-calendar-celestial-stem
      ["甲" "乙" "丙" "丁" "戊" "己" "庚" "辛" "壬" "癸"])
(setq chinese-calendar-terrestrial-branch
      ["子" "丑" "寅" "卯" "辰" "巳" "午" "未" "申" "酉" "戌" "亥"])

;;;;;;;;让Emacs自动显示图片;;;;
(auto-image-file-mode)

;;;;;;folding;;;;;;;
(load "folding")

;;;winner-mode
;(load "winner")
(define-key ctl-z-map (kbd "1") 'winner-undo)

;;窗口布局恢复
;;(require 'layoutrestore)

;;;字符集自动实别
;(require 'unicad)
;;;;;;;;yes or no To  y or n;;;;;;;
(fset 'yes-or-no-p 'y-or-n-p)

;;自动刷新缓存
;(global-auto-revert-mode 1)

;;刷新所有缓存
;;{{{
    (defun revert-all-buffers()
      "Refreshs all open buffers from their respective files"
      (interactive)
      (let* ((list (buffer-list))
          (buffer (car list)))
        (while buffer
          (if (string-match "\\*" (buffer-name buffer))
          (progn
            (setq list (cdr list))
            (setq buffer (car list)))
          (progn
            (set-buffer buffer)
            (revert-buffer t t t)
            (setq list (cdr list))
            (setq buffer (car list))))))
      (message "Refreshing open files"))
;;}}}

;;;;;;;;;Emacs版本控制;;;;;;;;;;;
  (setq kept-old-versions 5)
  (setq kept-new-versions 5)
  (setq delete-old-versions t)
  (setq backup-directory-alist '(("." . "~/myemacs/filetmp")))
  (setq backup-by-copying t)


;;;;;---------基本设置区结束---------------;;;


;;;-----------------jde 与 ECB配置开始--------------------------------
;;{{{
(add-to-list 'load-path "~/myemacs/site/semantic-1.4.4")
;(add-to-list 'load-path "~/myemacs/site/speedbar")
(add-to-list 'load-path "~/myemacs/site/eieio")
(setq semantic-load-turn-everything-on t)
;(setq semantic-load-turn-everything-on t)
;(setq global-semantic-show-parser-state-mode nil)
(setq semanticdb-default-save-directory "~/tmp")

                    ;(setq semanticdb-global-mode nil)
;(setq semanticdb-persistent-path (quote (never)))
;;(global-semantic-auto-parse-mode -1)
;;(global-semantic-show-unmatched-syntax-mode -1)

(add-to-list 'load-path "~/myemacs/site/ecb-2.32");;注:使用ecb时,java文件的tabbar会出问题  

;;jde配置
(add-to-list 'load-path (expand-file-name "~/myemacs/site/jde-2.3.5.1/lisp"))
(add-to-list 'load-path (expand-file-name "~/myemacs/site/cedet/common"))
(load-file (expand-file-name "~/myemacs/site/cedet/common/cedet.el"))
(add-to-list 'load-path (expand-file-name "~/myemacs/site/elib"))
;(require 'jde)
(setq defer-loading-jde t)
(if defer-loading-jde
    (progn
      (autoload 'jde-mode "jde" "jde mode." t)
      (setq auto-mode-alist
        (append
         '((".java" . jde-mode))
         auto-mode-alist)))
  (require 'jde)
  )
;;(require 'jde)
(require 'ecb)
(global-set-key [M-f12] 'ecb-activate)
(global-set-key [C-M-f12] 'ecb-deactivate)

(setq semantic-idle-scheduler-idle-time 432000)

;;一些与jde有关的设置
(add-hook 'jde-mode-hook 'my-java-mode)
;; 设置imenu的排序方式为按名称排序
(setq imenu-sort-function 'imenu--sort-by-name)

(defun my-java-mode()
  ;; 将回车代替C-j的功能,换行的同时对齐
  (define-key jde-mode-map [return] 'newline-and-indent)
  (interactive)
  ;; 设置C程序的对齐风格
  ;; (c-set-style "K&R")
  ;; 自动模式,在此种模式下当你键入{时,会自动根据你设置的对齐风格对齐
  ;; (c-toggle-auto-state)
  ;; 此模式下,当按Backspace时会删除最多的空格
  (c-toggle-hungry-state)
  ;; TAB键的宽度设置为8
  (setq c-basic-offset 4)
  ;; 在菜单中加入当前Buffer的函数索引
  (imenu-add-menubar-index)
  ;; 在状态条上显示当前光标在哪个函数体内部
  (which-function-mode)
  )

;;;-----------------jde 与 ECB配置结束--------------------------------

;;;-------------xref配置开始------------;;;;;;
(setq exec-path (cons "~/myemacs/site/xref" exec-path))
(setq load-path (cons "~/myemacs/site/xref/emacs" load-path))
(load "xrefactory")
;;(load "xrefprotocol")

;;;让xref的补全窗口不使用色彩
(setq xref-coloring nil)

;;;;------------xref配置结束-------------;;;;;;



;;;---------------dired设置-----------------------------

;;;让dired只打开一个buffer
(require 'dired)
(require 'dired-single)
;;绑定
     (defun my-dired-init ()
       "Bunch of stuff to run for dired, either immediately or when it's
        loaded."
       ;;
       (define-key dired-mode-map [return] 'joc-dired-single-buffer)
  ;     (define-key dired-mode-map [mouse-1] 'joc-dired-single-buffer-mouse)
       (define-key dired-mode-map "^"
             (function
              (lambda nil (interactive) (joc-dired-single-buffer ".."))))
      )

 ;; if dired's already loaded, then the keymap will be bound
     (if (boundp 'dired-mode-map)
             ;; we're good to go; just add our bindings
             (my-dired-init)
       ;; it's not loaded yet, so add our bindings to the load-hook
       (add-hook 'dired-load-hook 'my-dired-init))

;;;在dired中按文件字母即可跳到相应的文件
(require 'dired-isearch)

; keybindings:

(define-key dired-mode-map (kbd "C-s") 'dired-isearch-forward)
(define-key dired-mode-map (kbd "C-r") 'dired-isearch-backward)
(define-key dired-mode-map (kbd "ESC C-s") 'dired-isearch-forward-regexp)
(define-key dired-mode-map (kbd "ESC C-r") 'dired-isearch-backward-regexp)

;;;dired中快速定位到文件
;;;###autoload
(defun ywb-dired-jump-to-file ()
  "Quick jump to the file in dired-mode"
  (interactive)
  (goto-char (point-min))
  (dired-next-line 1)
  (let ((name "") input)
    (while
        (progn
          (setq input (read-char (format "Jump to: %s" name)))
          (cond ((= input ?\r)
                 (progn
                   (dired-advertised-find-file)
                   nil))
                (t (progn
                     (cond ((= input ?\d)
                            (progn (setq name (substring name 0 -1))
                                   (goto-char (point-min))
                                   (dired-next-line 1)))
                           ((= input ?\^N)
                            (dired-next-line 1))
                           ((= input ?\^P)
                            (while (progn
                                     (dired-previous-line 1)
                                     (not (or (looking-at name) (bobp))))))
                           (t
                            (setq name (concat name (char-to-string input)))))
                     (while (not (or (looking-at name) (eobp)))
                       (dired-next-line 1))
                     t)))))))
(define-key dired-mode-map "j" 'ywb-dired-jump-to-file)

;;dired中隐藏指定的文件或目录
;; (setq dired-backup-overwrite 'always)
;; (setq dired-listing-switches "-Aol")
;; (setq dired-omit-files-p t)
;; (setq dired-no-confirm
;;       '(byte-compile chgrp chmod chown compress copy delete hardlink load
;;              move print shell symlink uncompress))

;; (defun dired-load-dired-x ()
;;   (load "dired-x" nil t)
;;   (setq dired-omit-extensions '(".svn/" "CVS/" ".o" "~" ".bin" ".bak" ".obj"
;;                 ".map" ".ico" ".pif" ".lnk" ".a" ".ln" ".blg" ".bbl" ".dll" ".drv"
;;                 ".vxd" ".386" ".elc" ".lof" ".glo" ".idx" ".lot" ".fmt" ".tfm"
;;                 ".class" ".fas" ".lib" ".mem" ".x86f" ".sparcf" ".fasl" ".ufsl"
;;                 ".fsl" ".dxl" ".pfsl" ".dfsl" ".lo" ".la" ".gmo" ".mo" ".toc"
;;                 ".aux" ".cp" ".fn" ".ky" ".pg" ".tp" ".vr" ".cps" ".fns" ".kys"
;;                 ".pgs" ".tps" ".vrs" ".pyc" ".pyo" ".idx" ".lof" ".lot" ".glo"
;;                 ".blg" ".bbl" ".cps" ".fn" ".fns" ".ky" ".kys" ".pg" ".pgs" ".tp"
;;                 ".tps" ".vr" ".vrs" ".pdb" ".ilk"))
;;   (setq dired-omit-files "^\\.?#\\|^\\.$\\|^\\.\\.$\\|^\\.\\|^~")
;;   )
;; (add-hook 'dired-load-hook 'dired-load-dired-x)

(put 'dired-find-alternate-file 'disabled nil)

;;;find-name-dired
;;;一些有关目录操作的
;;;快速打开父目录
(add-hook 'dired-mode-hook (lambda ()
  (interactive)
  (define-key dired-mode-map (kbd "[M-p]" ) 'dired-up-directory)))

;; ;; C-x C-j open the directory of current buffer
(global-set-key (kbd "C-x C-j")
                (lambda ()
                  (interactive)
                  (if (buffer-file-name)
                      (dired default-directory))))
;;将目录排在前面
(defun sof/dired-sort ()
  "Dired sort hook to list directories first."
  (save-excursion
    (let (buffer-read-only)
      (forward-line 2) ;; beyond dir. header
      (sort-regexp-fields t "^.*$" "[ ]*." (point) (point-max))))
  (and (featurep 'emacs)
       (fboundp 'dired-insert-set-properties)
       (dired-insert-set-properties (point-min) (point-max)))
  (set-buffer-modified-p nil))
(add-hook 'dired-after-readin-hook 'sof/dired-sort)

;;;;;--------------------dired 设置结束----------------------


;;;;w32 browser设置
(require 'w32-browser)
(define-key dired-mode-map [C-f1] 'dired-w32-browser)

;;;;;--------------------ido 设置开始-------------------------
;;你可能用过 iswitchb。但是当有很多buffer时,iswitchb 还是很慢。你可以使用ido。这是我见过的最方便的切换buffer,寻找文件的扩展了

(require 'ido)
(ido-mode t)

;;ido绑定键
;;{{{ ido: fast switch buffers

(add-hook 'ido-define-mode-map-hook 'ido-my-keys)

(defun ido-my-keys ()
  "Set up the keymap for `ido'."

  ;; common keys
  (define-key ido-mode-map "\C-e" 'ido-edit-input)   
  (define-key ido-mode-map "\t" 'ido-complete) ;; complete partial
  (define-key ido-mode-map "\C-j" 'ido-select-text)
  (define-key ido-mode-map "\C-m" 'ido-exit-minibuffer)
  (define-key ido-mode-map "?" 'ido-completion-help) ;; list completions
  (define-key ido-mode-map [(control ? )] 'ido-restrict-to-matches)
  (define-key ido-mode-map [(control ?@)] 'ido-restrict-to-matches)

  ;; cycle through matches
  (define-key ido-mode-map "\C-r" 'ido-prev-match)
  (define-key ido-mode-map "\C-s" 'ido-next-match)
  (define-key ido-mode-map [right] 'ido-next-match)
  (define-key ido-mode-map [left] 'ido-prev-match)

  ;; toggles
  (define-key ido-mode-map "\C-t" 'ido-toggle-regexp) ;; same as in isearch
  (define-key ido-mode-map "\C-p" 'ido-toggle-prefix)
  (define-key ido-mode-map "\C-c" 'ido-toggle-case)
  (define-key ido-mode-map "\C-a" 'ido-toggle-ignore)

  ;; keys used in file and dir environment
  (when (memq ido-cur-item '(file dir))
    (define-key ido-mode-map "\C-b" 'ido-enter-switch-buffer)
    (define-key ido-mode-map "\C-d" 'ido-enter-dired)
    (define-key ido-mode-map "\C-f" 'ido-fallback-command)

    ;; cycle among directories
    ;; use [left] and [right] for matching files
    (define-key ido-mode-map [down] 'ido-next-match-dir)
    (define-key ido-mode-map [up]   'ido-prev-match-dir)

    ;; backspace functions
    (define-key ido-mode-map [backspace] 'ido-delete-backward-updir)
    (define-key ido-mode-map "\d"        'ido-delete-backward-updir)
    (define-key ido-mode-map [(meta backspace)] 'ido-delete-backward-word-updir)
    (define-key ido-mode-map [(control backspace)] 'ido-up-directory)

    ;; I can't understand this
    (define-key ido-mode-map [(meta ?d)] 'ido-wide-find-dir)
    (define-key ido-mode-map [(meta ?f)] 'ido-wide-find-file)
    (define-key ido-mode-map [(meta ?k)] 'ido-forget-work-directory)
    (define-key ido-mode-map [(meta ?m)] 'ido-make-directory)

    (define-key ido-mode-map [(meta down)] 'ido-next-work-directory)
    (define-key ido-mode-map [(meta up)] 'ido-prev-work-directory)
    (define-key ido-mode-map [(meta left)] 'ido-prev-work-file)
    (define-key ido-mode-map [(meta right)] 'ido-next-work-file)

    ;; search in the directories
    ;; use C-_ to undo this
    (define-key ido-mode-map [(meta ?s)] 'ido-merge-work-directories)
    (define-key ido-mode-map [(control ?_)] 'ido-undo-merge-work-directory)
    )

  (when (eq ido-cur-item 'file)
    (define-key ido-mode-map "\C-k" 'ido-delete-file-at-head)
    (define-key ido-mode-map "\C-l" 'ido-toggle-literal)
    (define-key ido-mode-map "\C-o" 'ido-copy-current-word)
    (define-key ido-mode-map "\C-v" 'ido-toggle-vc)
    (define-key ido-mode-map "\C-w" 'ido-copy-current-file-name)
    )

  (when (eq ido-cur-item 'buffer)
    (define-key ido-mode-map "\C-b" 'ido-fallback-command)
    (define-key ido-mode-map "\C-f" 'ido-enter-find-file)
    (define-key ido-mode-map "\C-k" 'ido-kill-buffer-at-head)
    ))

;;(ido-mode t)
;;}}}

;;;;;;---------------------------ido 设置结束--------------------


;;;------------------------------mew 配置开始---------------------
;; 设置 Mew
(autoload 'mew "mew" nil t)
(autoload 'mew-send "mew" nil t)
;; 下面的图标路径和安装路径有关,具体请看Mew的安装过程
(setq mew-icon-directory "~/myemacs/site/mew/etc")
(setq mew-use-cached-passwd t)
;; mew-pop-size设置成0时,pop邮件大小没有限制
(setq mew-pop-size 1)

;;不删除服务器上的邮件
(setq mew-pop-delete nil)
;; (setq mew-config-alist
;;       '(("default"
;;      ("name"         .  "49498445")
;;      ("user"         .  "49498445")
;;      ("mail-domain"  .  "163.com")
;;      ("pop-server"   .  "pop.163.com")
;;      ("pop-port"     .  "110")
;;      ("pop-user"     .  "49498445")
;;      ("pop-auth"     .  pass)
;;      ("smtp-server"  .  "smtp.163.com")
;;      ("smtp-port"    .  "25")
;;      ("smtp-user"    .  "49498445")
;;      ("smtp-auth-list"  .  ("PLAIN" "LOGIN" "CRAM-MD5"))
;; ;     ("inbox-folder" .  "+inbox")
;;      )
;;     ("worksys"
;;      ("name"         .  "raphae@workssys.com.cn")
;;      ("user"         .  "raphael@workssys.com.cn")
;;      ("mail-domain"  .  "workssys.com.cn")
;;      ("pop-server"   .  "pop.263xmail.com")
;;      ("pop-port"     .  "110")
;;      ("pop-user"     .  "raphael@workssys.com.cn")
;;      ("pop-auth"     .  pass)
;;      ("smtp-server"  .  "smtp.263xmail.com")
;;      ("smtp-port"    .  "25")
;; ;     ("inbox-folder" .  "work")
;;      ("smtp-user"    .  "raphael@workssys.com.cn")
;;                     ;("smtp-auth-list"  .  ("PLAIN" "LOGIN" "CRAM-MD5"))
;;      )
;;     ;;设置Gmail
;;     ("free49498445@gmail.com"
;;      ("name"  . "李劲柏Gmail")
;;      ("user"  . "free49498445")
;;      ("mail-domain"  . "gmail.com")
;;      ("pop-ssl"      . t)
;;      ("pop-ssl-port" . "995")
;;      ("prog-ssl"     . "~/myemacs/stunnel.exe")
;;      ("pop-auth"     . pass)
;;      ("pop-user"     . "free49498445")
;;      ("pop-server"   . "pop.gmail.com")
;;      ("smtp-ssl"     . t)
;;      ("smtp-ssl-port". "465")
;;      ("smtp-user"    . "free49498445")
;;      ("smtp-server"  . "smtp.gmail.com")
;; ;     ("inbox-folder" .  "gmailInbox")
;;      )
;;     ))

;; (setq mew-prog-ssl "~/myemacs/stunnel.exe")

;; (setq mew-ssl-verify-level 0)
;; ;;;查看html邮件
;; ;;{{{
;; (setq mew-prog-text/html 'etk-mime-text/html)
;; (defun etk-mime-text/html (begin end)
;;   (save-excursion
;;     (goto-char (point-min))
;;     (shell-command-on-region begin end "html2text -nobs" nil t)
;;     )
;;   )
;; ;;}}}
;; ;;;将mew的auth认证打开,像163邮箱就需要.
;; (setq mew-use-smtp-auth t)
;; ;; SMTP ;;
;; (setq message-send-mail-function 'smtpmail-send-it)
;; (setq smtpmail-smtp-server "smtp.163.com")

;; ;;;
;;  (setq mew-prog-text/html         'mew-mime-text/html-w3m) ;; See w3m.el
;; ;; (setq mew-prog-text/xml         'mew-mime-text/html-w3m) ;; See w3m.el

;;;;;;;----------------------mew 设置结束------------------------




;;;;;;;;-------------------wiki配置开始-------------------------
(load "emacs-wiki")

;; (add-hook 'emacs-wiki-mode-hook
;;           (lambda ()
;;             (define-key emacs-wiki-mode-map (kbd "C-c C-h") 'emacs-wiki-preview-html)
;;             (define-key emacs-wiki-mode-map (kbd "C-c C-c") 'emacs-wiki-preview-source)
;;             (define-key emacs-wiki-mode-map (kbd "C-c C-v") 'emacs-wiki-change-project)

;; ))

(setq emacs-wiki-directories '("d:/emacs/wiki"))
(setq emacs-wiki-meta-charset "gb2312")
(setq emacs-wiki-charset-default "gb2312")

;; 加上这一句可以使生成的页面默认编码为gb2312,不过我还不知道
;; utf-8怎么配置
(setq emacs-wiki-style-sheet
  "")

(setq emacs-wiki-inline-relative-to 'emacs-wiki-publishing-directory)

(defun emacs-wiki-preview-source ()
  (interactive)
  (emacs-wiki-publish-this-page)
  (find-file (emacs-wiki-published-file)))

(defun emacs-wiki-preview-html ()
  (interactive)
  (emacs-wiki-publish-this-page)
  (browse-url-generic (emacs-wiki-published-file)))

;;;;设置wiki工程
(setq emacs-wiki-projects

  `(("default" . (
      (emacs-wiki-directories . ("~/wiki/default"))
      (emacs-wiki-publishing-directory . "~/wiki/default/publish")
        ))
   ("williamxuuu" . (
         (emacs-wiki-directories . ("~/wiki/work"))
         (emacs-wiki-publishing-directory . "/work/")
        ))
   ("notes" . (
       (emacs-wiki-directories . ("~/wiki/notes"))
       (emacs-wiki-publishing-directory . "/notes")
        ))
   ))

;; 用于显示公式
;(load "latex2png.el")
;(push '("latex" t t t gs-latex-tag) emacs-wiki-markup-tags)
;(setq gs-latex2png-scale-factor 1.5)

;; 设置预览所用的WWW浏览器,我使用的opera,请把它改为你使用的浏览器的名字
;(setq browse-url-generic-program "Mozilla Firefox")

;;;;;-------------------------wiki 设置结束-----------------------


;;;---------------------------folding 设置开始----------------------
;;;听说比较强,不过现在我似乎还用不到
;;{{{
(load-library  "folding")
(declare (special fold-fold-on-startup
          fold-keys-already-setup
          ))
    
(setq fold-fold-on-startup t)
(folding-mode-add-find-file-hook)

(setq fold-keys-already-setup nil)
(add-hook 'folding-mode-hook
      (function (lambda()
              (unless fold-keys-already-setup
            (setq fold-keys-already-setup t)
            (define-prefix-command 'ctl-f-folding-mode-prefix)
            (define-key 'ctl-f-folding-mode-prefix "f" 'fold-fold-region)
            (define-key  'ctl-f-folding-mode-prefix "e" 'fold-enter)
            (define-key 'ctl-f-folding-mode-prefix "x" 'fold-exit)
            (define-key  'ctl-f-folding-mode-prefix "b" 'fold-whole-buffer)
            (define-key 'ctl-f-folding-mode-prefix "o" 'fold-open-buffer)
            (define-key 'ctl-f-folding-mode-prefix "h" 'fold-hide)
            (define-key 'ctl-f-folding-mode-prefix "s" 'fold-show)
            (define-key 'ctl-f-folding-mode-prefix "t" 'fold-top-level)
            (define-key 'ctl-f-folding-mode-prefix "f" 'fold-fold-region)
            )
              (local-set-key "\C-f" 'ctl-f-folding-mode-prefix))))

(fold-add-to-marks-list 'sgml-mode
            "" " --> ")
(fold-add-to-marks-list 'c-mode "/* <" "/* > */" "*/")
(fold-add-to-marks-list 'c++-mode
            "//<" "//>" "")
(fold-add-to-marks-list 'LaTeX-mode "%%% {{{" "%%% }}}" " ")
(fold-add-to-marks-list 'latex2e-mode "%%% {{{" "%%% }}}" " ")
(fold-add-to-marks-list 'latex-mode "%%%% {{{" "%%%% }}}" " ")
(fold-add-to-marks-list 'BibTeX-mode "%%% {{{" "%%% }}}" " ")
(fold-add-to-marks-list 'lisp-mode ";;; {" ";;; }" "")
(fold-add-to-marks-list 'lex-mode" /* {{{ " " /* }}} */ " "*/")
(fold-add-to-marks-list 'html-mode "" "-->")
(fold-add-to-marks-list 'shell-script-mode "# {{{" "# }}}" nil)
(fold-add-to-marks-list 'sh-mode "# {{{ " "# }}}" nil)

;;}}}



 
;;;临时记号
;;;当你按 C-. 时就做了一个记号。然后你可以到别处,按 C-, 就可以在这两点之间来回跳转了。这虽然没有 vi 的 26 个 mark 多,但是你仔细;;想想,vi的26个 mark,你通常能用到几个?
;;{{{
(global-set-key [(control ?\.)] 'ska-point-to-register)
(global-set-key [(control ?\,)] 'ska-jump-to-register)
(defun ska-point-to-register()
  "Store cursorposition _fast_ in a register.
Use ska-jump-to-register to jump back to the stored
position."
  (interactive)
  (setq zmacs-region-stays t)
  (point-to-register 8))

(defun ska-jump-to-register()
  "Switches between current cursorposition and position
that was stored with ska-point-to-register."
  (interactive)
  (setq zmacs-region-stays t)
  (let ((tmp (point-marker)))
        (jump-to-register 8)
        (set-register 8 tmp)))
;;}}}

;;;;使用这个,你就可以方便的在最近编辑的 buffer 之间切换了。切换的时候会出现一个小窗口显示附近的buffer,就像翻页一样.默认的键是
;;;;C-f6 为 swbuff-switch-to-next-buffer。 C-S-F6为 swbuff-switch-to-previous-buffer
;;{{{
(require 'swbuff)
(global-set-key [f10] 'swbuff-switch-to-previous-buffer)
(global-set-key [C-f10] 'swbuff-switch-to-next-buffer)
(setq swbuff-exclude-buffer-regexps
     '("^ " "\\*.*\\*"))

(setq swbuff-status-window-layout 'scroll)
(setq swbuff-clear-delay 1)
(setq swbuff-separator "|")
(setq swbuff-window-min-text-height 1)
;;}}}


;;;;;这两个函数可以分别把一个区域和匹配某个regexp的行都藏起来,就跟不存在一样……这样你就可以对某些内容进行任意的操作而不会影响到其它的部分。
;;hide-lines 在操作某些行的时候用起来特别方便。加一个前缀参数可以把不匹配的行都藏起来,只看到匹配的!
;;hide region
;(require 'hide-region)
;(global-set-key (kbd "C-c r") 'hide-region-hide)
;(global-set-key (kbd "C-c R") 'hide-region-unhide)


;; hide lines
(require 'hide-lines)
(global-set-key (kbd "C-c l") 'hide-non-matching-lines)
(global-set-key (kbd "C-c L") 'show-all-invisible)


;;;;-----------------------cygwin配置开始------------------------
(setenv "PATH" (concat "d:/common/cygwin/bin;" (getenv "PATH")))
(setq exec-path (cons "d:/common/cygwin/bin/" exec-path))
;;(require 'cygwin-mount)
;;(cygwin-mount-activate)

;;;使用cygwin telnet
(require 'telnet)

(defun telnet (host)
  "Open a network login connection to host named HOST (a string).
Communication with HOST is recorded in a buffer `*PROGRAM-HOST*'
where PROGRAM is the telnet program being used.  This program
is controlled by the contents of the global variable
`telnet-host-properties', falling back on the value of the
global variable `telnet-program'. Normally input is edited
in Emacs and sent a line at a time."
  (interactive "sOpen connection to host: ")
  (let* ((comint-delimiter-argument-list '(?\  ?\t))
         (properties (cdr (assoc host telnet-host-properties)))
         (telnet-program (if properties (car properties) telnet-program))
         (name (concat telnet-program "-" (comint-arguments host 0 nil) ))
         (buffer (get-buffer (concat "*" name "*")))
         (telnet-options (if (cdr properties)
                 (cons "-l" (cdr properties))))
         process)
    (if (and buffer (get-buffer-process buffer))
        (pop-to-buffer (concat "*" name "*"))
      (pop-to-buffer
       (apply 'make-comint name telnet-program nil telnet-options))
      (setq process (get-buffer-process (current-buffer)))
      ;;(set-process-filter process 'telnet-initial-filter)
      ;; Don't send the `open' cmd till telnet is ready for it.
      ;;(accept-process-output process)
      (erase-buffer)
      (send-string process (concat "open " host "\n"))
      (telnet-mode)
      (setq telnet-remote-echoes nil)
      (setq telnet-new-line "\n") ;; needed for cygwin 1.3.11
      (setq comint-input-sender 'telnet-simple-send)
      (setq telnet-count telnet-initial-count)
      (setq comint-process-echoes t)
      )))



;;;使用cygwin的ftp
(defun ftp (host)
  "03Mar01, sailor"
  "Run the ftp program using cygwin ftp."
  "Fixed the problem that the login prompt cannot be seen."
  (interactive "sFtp to Host :")
  (let ((bufname)
        (bufobject))
    (setq bufname (concat "*ftp-" host "*"))
    (setq bufobject (get-buffer bufname))

    (cond
     ((and bufobject (get-buffer-process bufobject))
      (pop-to-buffer bufname)
      )
     (t
      (let ((login)
            (process)
            (ftp-program "ftp.exe"))
        (setq bufobject (get-buffer-create bufname))
        (pop-to-buffer bufobject)
        (comint-mode)
        (setq login (read-from-minibuffer (format "%s - Login : " host)))
        (comint-exec bufobject bufname ftp-program nil
            (list "--prompt=ftp> " "-v" host))
        (message "Login in progress. Please wait ...")
        (send-invisible (format "%s" login))
        (setq process (get-buffer-process (current-buffer)))
        (accept-process-output process)
        )
      )
     )
    )
  )
;(require 'mule-gbk)
;; 如何使cygwin支持中文



;;;cygwin

;; -*- mode: Emacs-Lisp -*-
;; Time-stamp: <2004-03-23 17:54:19 Yu Li>

;; This assumes that Cygwin is installed in C:\cygwin (the
;; default) and that C:\cygwin\bin is not already in your
;; Windows Path (it generally should not be).

;; NT-emacs assumes a Windows command shell, which you change
;; here.
(defun cygwin-shell()
  (interactive)

  (setq old-process-coding-system-alist process-coding-system-alist)
  (setq old-shell-file-name shell-file-name)

  (setq process-coding-system-alist '(("bash" . undecided-unix)))
  (setq shell-file-name "bash")
  (setenv "SHELL" shell-file-name)
  (setq explicit-shell-file-name shell-file-name)

  (switch-to-buffer (shell "*cygwin-shell*"))
  (delete-other-windows)

  (setq process-coding-system-alist old-process-coding-system-alist)
  (setq shell-file-name old-shell-file-name)
  (setenv "SHELL" shell-file-name)
  (setq explicit-shell-file-name shell-file-name))

;; This removes unsightly ^M characters that would otherwise
;; appear in the output of java applications.
(add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m)

(global-set-key [C-M-f5] 'shell)
(global-set-key [C-M-f6] 'cygwin-shell)
;新建shell自动更改 buffer名
(defun wcy-shell-mode-auto-rename-buffer (text)
 (if (eq major-mode 'shell-mode)
    (rename-buffer  (concat "shell: " default-directory) t)))
(add-hook 'comint-output-filter-functions 'wcy-shell-mode-auto-rename-buffer)
 
;;;;;--------------------------cygwin 设置结束--------------------------


;; ;;;自动补全括号
;; ;;{{{
;; (add-hook 'c-mode-common-hook 'hs-minor-mode)

(defun my-c-mode-auto-pair ()
  (interactive)
  (make-local-variable 'skeleton-pair-alist)
  (setq skeleton-pair-alist  '(
    (?` ?` _ "''")
    (?\( _ ")")
    (?\[ _ "]")
    (?{ \n > _ \n ?} >)))
  (setq skeleton-pair t)
  (local-set-key (kbd "(") 'skeleton-pair-insert-maybe)
  (local-set-key (kbd "{") 'skeleton-pair-insert-maybe)
  (local-set-key (kbd "`") 'skeleton-pair-insert-maybe)
  (local-set-key (kbd "[") 'skeleton-pair-insert-maybe))
(add-hook 'c-mode-common-hook 'my-c-mode-auto-pair)
;; ;;}}}


;;;可以启动多个eshell,自动更改eshell名
;;{{{
(add-hook 'eshell-mode-hook
    (lambda ()
       (rename-buffer (concat "*EShell: " (concat default-directory "*")) t)))

(add-hook 'eshell-directory-change-hook
    (lambda ()
        (rename-buffer (concat "*EShell: " (concat default-directory "*")) t)))
;;}}}



;;设置copyright
;;{{{

(defun copyright-comment ()
  ;; insert a copyright code at the top of the class at cursor position
  (interactive)
  (insert
"
/*
 * Copyright (c) 2004, 2005 Works Systems (Tianjin) Co., Ltd.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Works Systems, Inc and Works Systems (Tianjin) Co., Ltd. (\"Confidential Information\").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Works Systems.
 *
 * @author Raphae
 */")(previous-line 13)(end-of-line))
  评论这张
 
阅读(808)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017