我的emacs配置
----------持续更新中


;;普通设置
(setq inhibit-startup-message t);关闭起动时闪屏
(setq visible-bell t);关闭出错时的提示声
(show-paren-mode t);显示括号匹配
;(set-default-font "-adobe-courier-medium-r-normal--14-100-100-100-m-90-iso10646-1");;字体设置
(column-number-mode t);显示列号
(setq frame-title-format "%n%F/%b");在窗口的标题栏上显示文件名称
(mouse-avoidance-mode 'animate);光标靠近鼠标指针时,让鼠标指针自动让开
(setq default-frame-alist
'((height . 25) (width . 80) (menu-bar-lines . 80) (tool-bar-lines . 80)));设置窗口启动大小
(fset 'yes-or-no-p 'y-or-n-p);以 y/n代表 yes/no
(setq-default make-backup-files nil);;不要生成临时文件




;(show-paren-mode 't); 高亮显示匹配括号
;;自动插入匹配的括号
;; enable skeleton-pair insert globally
;(setq skeleton-pair t)
;(global-set-key (kbd "(") 'skeleton-pair-insert-maybe)
;(global-set-key (kbd "[") 'skeleton-pair-insert-maybe)
;(global-set-key (kbd "{") 'skeleton-pair-insert-maybe)







;;热键设置
(global-set-key [f9] 'delete-window);F9 关闭d当前窗口
(global-set-key [f8] 'other-window);F8窗口间跳转
(global-set-key [(f2)] 'ansi-term);F2 切换到shell模式
;(global-set-key [f3] 'split-window-vertically);F3分割窗口
(global-set-key [f12] 'my-fullscreen);F12 全屏
(global-set-key [(f4)] 'compile);编译
(global-set-key [f5] 'gdb);启动gdb
(global-set-key [(f6)] 'gdb-many-windows);启动窗口gdb
(global-set-key [f1] 'goto-line);设置M-g为goto-line
;(global-set-key [f7] 'other-frame);跳到其它窗格
(global-set-key [(f3)] 'speedbar);打开speedbar






;;显示行号
(load-file "/dos/emacs/display-line-number.el")
;;(autoload `display-line-number-mode-on "display-line-number" "display mode" t)
(require 'display-line-number)
(global-display-line-number-mode t)




;;鼠标滚轮,默认的滚动太快,这里改为3行
(defun up-slightly () (interactive) (scroll-up 3))
(defun down-slightly () (interactive) (scroll-down 3))
(global-set-key [mouse-4] 'down-slightly)
(global-set-key [mouse-5] 'up-slightly)



;;style I want to use in c mode
(c-add-style "my-style"
         '("stroustrup"
           (indent-tabs-mode . nil)        ; use spaces rather than tabs
           (c-basic-offset . 4)            ; indent by four spaces
           (c-offsets-alist . ((inline-open . 0)  ; custom indentation rules
                   (brace-list-open . +)
                   (statement-case-open . +)))))

(defun my-c-mode-hook ()
  (c-set-style "my-style")        ; use my-style defined above
 ;(c-toggle-auto-hungry-state 1)开启自动缩进
  (auto-fill-mode))

(defun my-c++-mode-hook ()
  (c-set-style "my-style")        ; use my-style defined above
 ;(c-toggle-auto-hungry-state 1)开启自动缩进
  (auto-fill-mode))
       
(add-hook 'c-mode-hook 'my-c-mode-hook)
(add-hook 'c++-mode-hook 'my-c++-mode-hook)



;;导入cscope
(load-file "//dos/emacs/cscope-15.6/contrib/xcscope/xcscope.el")
(require 'xcscope) ;;加载xcscope




;全屏
(defun my-fullscreen ()
  (interactive)
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(2 "_NET_WM_STATE_FULLSCREEN" 0)))



;;导入cedet
(load-file "/dos/emacs/cedet-1.0pre4/common/cedet.el")
;(add-to-list 'load-path "/dos/emacs/cedet-1.0pre4/common/cedet.el")
(require 'cedet) ;;加载cedet
(semantic-load-enable-minimum-features)
;(semantic-load-enable-code-helpers)
;(semantic-load-enable-guady-code-helpers)
;(semantic-load-enable-excessive-code-helpers)
;(semantic-load-enable-semantic-debugging-helpers)



;;自动补全
(load-file "/dos/emacs/msf-abbrev.el")
;; ensure abbrev mode is always .
(setq-default abbrev-mode t)
;; do not bug me about saving my abbreviations
(setq save-abbrevs nil)
;; load up modes I use
(require 'cc-mode)
(require 'perl-mode)
(require 'cperl-mode)
(require 'sh-.)
(require 'shell)
;(require 'tex-site) ;; I use AUCTeX
;(require 'latex)    ;; needed to define LaTeX-mode-hook under AUCTeX
;(require 'tex)      ;; needed to define TeX-mode-hook under AUCTeX
;; (require 'python)   ;; I use python.el from Emacs CVS, uncomment if you do also
;; load up abbrevs for these modes
(require 'msf-abbrev)
(setq msf-abbrev-verbose t) ;; optional
(setq msf-abbrev-root "/dos/emacs/mode-abbrevs")
(global-set-key (kbd "C-c l") 'msf-abbrev-goto-root)
(global-set-key (kbd "C-c a") 'msf-abbrev-define-new-abbrev-this-mode)
(msf-abbrev-load)




(load-file "/dos/emacs/doxymacs-1.8.0/lisp/doxymacs.el")
(require 'doxymacs)
(add-hook 'c-mode-common-hook 'doxymacs-mode)
(add-hook 'c++-mode-common-hook 'doxymacs-mode)
(put 'scroll-left 'disabled nil)


;; read pdf
(load-file "/dos/emacs/doc-view.el")
(require 'doc-view)


(load-file "/dos/emacs/display-line-number.el")

;;maxima
;;这个实现emaxima写的公式转化到maxima中计算
;(setq emaxima-use-maxima-mode-flag t)
(add-hook 'emaxima-mode-hook 'emaxima-mark-file-as-emaxima)








;; author: pluskid
;; 调用 stardict 的命令行接口来查辞典
;; 如果选中了 region 就查询 region 的内容,
;; 否则就查询当前光标所在的词
(global-set-key (kbd "C-c C-d") 'kid-star-dict)
(defun kid-star-dict ()
  (interactive)
  (let ((begin (point-min))
        (end (point-max)))
    (if mark-active
        (setq begin (region-beginning)
              end (region-end))
      (save-excursion
        (backward-word)
        (mark-word)
        (setq begin (region-beginning)
              end (region-end))))
    ;; 有时候 stardict 会很慢,所以在回显区显示一点东西
    ;; 以免觉得 Emacs 在干什么其他奇怪的事情。
    (message "searching for %s ..." (buffer-substring begin end))

(tooltip-show
     (shell-command-to-string
      (concat "sdcv -n "
              (buffer-substring begin end))))))
(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 .ly .e such instance.
  ;; If there is more than .e, they won't work right.
 '(ecb-options-version "2.32"))
(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 .ly .e such instance.
  ;; If there is more than .e, they won't work right.
 )






;;-----------------------Email mew-----------------------;;
(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mew")
(autoload 'mew "mew" nil t)
(autoload 'mew-send "mew" nil t)







;;teach yourself emacs in 24 hours
(setq load-path (cons "~/Emacs" load-path))
(require 'sams-lib)









;;自动插入匹配的括号
(defun my-c-mode-auto-pair ()
  (setq skeleton-pair t)
  (local-set-key (kbd "(") 'skeleton-pair-insert-maybe)
  (local-set-key (kbd "[") 'skeleton-pair-insert-maybe))
(add-hook 'c++-mode-hook 'my-c-mode-auto-pair)
(add-hook 'c-mode-hook 'my-c-mode-auto-pair)
(put 'upcase-region 'disabled nil)







;;meta在常用PC键上就是Alt键
;;这三个绑定主要是光标移动的
;(global-set-key [(meta down)] 'goto-line)
;(global-set-key [(meta left)] 'backward-sexp)
;(global-set-key [(meta right)] 'forward-sexp)









;;配色方案
(load-file "/dos/emacs/color-theme.el")
(require 'color-theme)
;(add-hook 'c-mode-common-hook 'color-theme-taylor)
;(add-hook 'c++-mode-common-hook 'color-theme-taylor)








;; For my language code setting (UTF-8)
(setq current-language-environment "UTF-8")
(setq default-input-method "chinese-py")
(setq locale-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)







;;用emacs-wiki写笔记
(add-to-list 'load-path "/dos/emacs/emacs-wiki-2.72")
(require 'emacs-wiki)
(require 'emacs-wiki-menu)
;;设置css样式
(setq emacs-wiki-style-sheet "")
;预览
(defun emacs-wiki-preview-html ()
(interactive)
(emacs-wiki-publish-this-page)
(browse-url (emacs-wiki-published-file)))
(add-hook 'emacs-wiki-mode-hook
      (lambda ()
        (define-key emacs-wiki-mode-map (kbd "C-c C-h") 'emacs-wiki-preview-html)))
(setq emacs-wiki-maintainer "mailto:[email protected]")
;;自动发布
(defun sacha-emacs-wiki-auto-publish ()
  (when (derived-mode-p 'emacs-wiki-mode)
    (unless emacs-wiki-publishing-p
      (let ((emacs-wiki-publishing-p t)
        (emacs-wiki-after-wiki-publish-hook nil))
    (emacs-wiki-publish-this-page)))))
(add-hook 'emacs-wiki-mode-hook
      (lambda () (add-hook 'after-save-hook
                   'sacha-emacs-wiki-auto-publish
                   nil t)))