我的Emacs配置存放

Emacs配置详解

把网上乱七八糟的东西集合了一下^_^文件位置:~/.emacs

 

(set-language-environment 'Chinese-GB)
(set-keyboard-coding-system 'euc-cn)
;;(set-keyboard-coding-system 'chinese-iso-8bit)
(set-clipboard-coding-system 'euc-cn)
(set-terminal-coding-system 'euc-cn)
(set-buffer-file-coding-system 'euc-cn)
(set-selection-coding-system 'euc-cn)
(modify-coding-system-alist 'process "*" 'euc-cn)
(setq default-process-coding-system 
             '(euc-cn . euc-cn))
(setq-default pathname-coding-system 'euc-cn)

(setq inhibit-startup-message t)


;; 字体设置
;;(set-default-font "Bitstream Vera Sans Mono")
;;(set-fontset-font (frame-parameter nil 'font)
;;    'han '("WenQuanYi Bitmap Song-12" . "unicode-bmp"))

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

;;;;color-theme
(require 'color-theme)
;;(color-theme-comidia)
;;(color-theme-vim-colors)
;;(color-theme-tty-dark)
;;(color-theme-comidia)
(color-theme-dark-laptop)

;;;; 显示行号:
(setq column-number-mode t)
(setq line-number-mode t)


;;;;自动补齐策略

(defun my-indent-or-complete ()
   (interactive)
   (if (looking-at "//>")
     (hippie-expand nil)
     (indent-for-tab-command))
)

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

(autoload 'senator-try-expand-semantic "senator")

(setq hippie-expand-try-functions-list
     '(
        senator-try-expand-semantic
        try-expand-dabbrev
        try-expand-dabbrev-visible
        try-expand-dabbrev-all-buffers
        try-expand-dabbrev-from-kill
        try-expand-list
        try-expand-list-all-buffers
        try-expand-line
        try-expand-line-all-buffers
        try-complete-file-name-partially
        try-complete-file-name
        try-expand-whole-kill
        )
)
;;;; CC-mode配置 http://cc-mode.sourceforge.net/
(require 'cc-mode)
(c-set-offset 'inline-open 0)
(c-set-offset 'friend '-)
(c-set-offset 'substatement-open 0)

;;;;根据后缀判断所用的mode
;;;;注意:我在这里把.h关联到了c++-mode
(setq auto-mode-alist
    (append '(("//.h$" . c++-mode)) auto-mode-alist))


;;;;我的C/C++语言编辑策略

(defun my-c-mode-common-hook()
(setq tab-width 4 indent-tabs-mode nil)
;;; hungry-delete and auto-newline
(c-toggle-auto-hungry-state 1)
;;按键定义
(define-key c-mode-base-map [(control /`)'hs-toggle-hiding)
(define-key c-mode-base-map [(return)'newline-and-indent)
(define-key c-mode-base-map [(f7)'compile)
(define-key c-mode-base-map [(f8)'ff-get-other-file)
(define-key c-mode-base-map [(meta /`)'c-indent-command)
;; (define-key c-mode-base-map [(tab)] 'hippie-expand)
(define-key c-mode-base-map [(tab)'my-indent-or-complete)
(define-key c-mode-base-map [(meta ?/)'semantic-ia-complete-symbol-menu)
;;预处理设置
(setq c-macro-shrink-window-flag t)
(setq c-macro-preprocessor "cpp")
(setq c-macro-cppflags " ")
(setq c-macro-prompt-flag t)
(setq hs-minor-mode t)
(setq abbrev-mode t)
(setq tab-width 4 indent-tabs-mode nil)
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

;;;;我的C++语言编辑策略
(defun my-c++-mode-hook()
(setq tab-width 4 indent-tabs-mode nil)
(c-set-style "stroustrup")
;; (define-key c++-mode-map [f3] 'replace-regexp)
)

(add-hook 'c++-mode-hook 'my-c++-mode-hook)

;;;;C/C++语言启动时自动加载semantic对/usr/include的索引数据库
(setq semanticdb-search-system-databases t)
(add-hook 'c-mode-common-hook
          (lambda ()
            (setq semanticdb-project-system-databases
                  (list (semanticdb-create-database
                           semanticdb-new-database-class
                           "/usr/include")))))
;;;;我的Java语言编辑策略
(defun my-java-mode-hook()
(setq tab-width 4 indent-tabs-mode nil)
)

(add-hook 'java-mode-hook 'my-java-mode-hook)


;;;; 注释配置
;;(load-file "/home/caole/lib/emacs-lisp/gnome-doc.el")




;;配置一下shell的颜色
(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
(setq ansi-color-for-comint-mode t)
;;;;以下是我的快捷键设置
;; ----------------------- Short Cut -------------------------
(global-set-key [(meta g)'goto-line)
;;(global-set-key [(meta ?/)] 'hippie-expand)

;; F12 t 从当前缓冲区建立任务
(global-set-key (kbd "<f12> t") 'planner-create-task-from-buffer)
;; F12 g 切换到当日的任务
;;(global-set-key (kbd "<f12> g") 'planner-goto-today)
(global-set-key (kbd "<f12> g") 'planner-goto-today)
(global-set-key (kbd "<f12> p") 'plan)
;; F12 r 添加当前备忘录
(global-set-key (kbd "<f12> r") 'remember)
;; F12 c 切换到日历
(global-set-key (kbd "<f12> c") 'calendar)

;;;F2:进入wiki-mode模式
(global-set-key [(f2)'emacs-wiki-find-file)

;;;F3:切换到dired模式
(global-set-key [(f3)'dired)

;;;F4:切换到shell模式

(global-set-key [(f4)'ansi-term)


;;;F5:打开speedbar
(global-set-key [(f5)'speedbar)

;;;;F7:调用compile
(global-set-key (kbd "<f7>") 'compile)

;;;Alt+s : 让speedbar获得焦点
(global-set-key (kbd "M-s") 'speedbar-get-focus)

;;;F9:列举我的书签
(global-set-key (kbd "<f9>") 'list-bookmarks)

;;;F10:添加当前页到书签中
(global-set-key [(f10)'bookmark-set)

;;;F12 u 更新当前版本
(global-set-key (kbd "<f12> u") 'vc-next-action)

;;------------------------End of Short Cut ---------------------

;; 语法高亮。除 shell-mode 和 text-mode 之外的模式中使用语法高亮。

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


;; 1. 不要打入 TAB 时总是听到 PC 喇叭嘀嘀嘀的叫

      (setq visible-bell t)

      (column-number-mode t)

      (setq-default make-backup-files nil)

;;开启tabbar
(require 'tabbar)
(tabbar-mode)
(global-set-key (kbd "") 'tabbar-backward-group)
(global-set-key (kbd "") 'tabbar-forward-group)
(global-set-key (kbd "") 'tabbar-backward)
(global-set-key (kbd "") 'tabbar-forward)


(global-font-lock-mode 1)

;;开启图片浏览
(require 'thumbs)
(auto-image-file-mode t)

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

;;set c++ style as stroustrup style
(add-hook 'c++-mode-hook
'(lambda()
(c-set-style "stroustrup")))
(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.
 '(column-number-mode t)
 '(display-battery-mode t)
 '(display-time-mode t)
 '(ecb-options-version "2.32")
 '(imaxima-fnt-size "large")
 '(imaxima-image-type (quote png))
 '(imaxima-max-scale 0.85)
 '(imaxima-pt-size 12)
 '(line-spacing 5)
 '(scroll-bar-mode (quote right))
 '(show-paren-mode t)
 '(speedbar-frame-parameters (quote ((minibuffer) (width . 20) (border-width . 0) (menu-bar-lines . 0) (tool-bar-lines . 0) (unsplittable . t) (set-background-color "black"))))
 '(transient-mark-mode 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.
 '(background "blue")
 '(font-lock-builtin-face ((((class color) (background dark)) (:foreground "Turquoise"))))
 '(font-lock-comment-face ((t (:foreground "#FF8000"))))
 '(font-lock-constant-face ((((class color) (background dark)) (:bold t :foreground "DarkOrchid"))))
 '(font-lock-doc-string-face ((t (:foreground "green2"))))
 '(font-lock-function-name-face ((t (:foreground "Purple"))))
 '(font-lock-keyword-face ((t (:bold t :foreground "Red"))))
 '(font-lock-preprocessor-face ((t (:italic nil :foreground "CornFlowerBlue"))))
 '(font-lock-reference-face ((t (:foreground "DodgerBlue"))))
 '(font-lock-string-face ((t (:foreground "#9933FF"))))
 '(font-lock-type-face ((t (:foreground "#9290ff"))))
 '(font-lock-variable-name-face ((t (:foreground "PaleGreen"))))
 '(font-lock-warning-face ((((class color) (background dark)) (:foreground "yellow" :background "red"))))
 '(highlight ((t (:background "CornflowerBlue"))))
 '(list-mode-item-selected ((t (:background "gold"))))
 '(makefile-space-face ((t (:background "wheat"))))
 '(mode-line ((t (:background "Navy"))))
 '(paren-match ((t (:background "darkseagreen4"))))
 '(region ((t (:background "DarkSlateBlue"))))
 '(show-paren-match ((t (:foreground "black" :background "wheat"))))
 '(show-paren-mismatch ((((class color)) (:foreground "Orange" :background "red"))))
 '(speedbar-button-face ((((class color) (background dark)) (:foreground "green4"))))
 '(speedbar-directory-face ((((class color) (background dark)) (:foreground "khaki"))))
 '(speedbar-file-face ((((class color) (background dark)) (:foreground "cyan"))))
 '(speedbar-tag-face ((((class color) (background dark)) (:foreground "Springgreen"))))
 '(vhdl-speedbar-architecture-selected-face ((((class color) (background dark)) (:underline t :foreground "Blue"))))
 '(vhdl-speedbar-entity-face ((((class color) (background dark)) (:foreground "darkGreen"))))
 '(vhdl-speedbar-entity-selected-face ((((class color) (background dark)) (:underline t :foreground "darkGreen"))))
 '(vhdl-speedbar-package-face ((((class color) (background dark)) (:foreground "black"))))
 '(vhdl-speedbar-package-selected-face ((((class color) (background dark)) (:underline t :foreground "black"))))
 '(widget-field ((((class grayscale color) (background light)) (:background "DarkBlue")))))


;;2. 安装setnu.el
;;在.emacs中添加
(require 'setnu)
(setnu-mode t)

(autoload 'imaxima "imaxima" "Image support for Maxima." t)
(autoload 'imath-mode "imath" "Interactive Math minor mode." t)
(require 'xcscope) ;;加载cscope
(require 'ecb);;加载ecb
(global-set-key [f12] 'ecb-activate) ;;定义F12键为激活ecb
(global-set-key [C-f12] 'ecb-deactivate) ;;定义Ctrl+F12为停止ecb

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值