本人的linux emacs 配置文件

来源:互联网 发布:淘宝男装店排行 编辑:程序博客网 时间:2024/05/22 04:59

用过一段时间emacs后,还是建议大家直接用高手的配置,熟练之后可以自己定制,参考:一年成为Emacs高手(像神一样使用编辑器)


此配置文件需要下载以下插件:cscope、auto-complete、yasnippet


;;turn off the backup
(setq make-backup-files nil)
;; tab and space 
;; when true, emacs use mixture of tab and space to achieve offset 
(setq-default indent-tabs-mode nil) 
;; control length used to offset. 
(setq-default c-basic-offset 4) 
;; control how emacs explain TAB. 
(setq-default tab-width 4) 




;;最大化  
(defun my-maximized ()  
  (interactive)  
  (x-send-client-message  
    nil 0 nil "_NET_WM_STATE" 32  
    '(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0)  
  )  
  (x-send-client-message  
    nil 0 nil "_NET_WM_STATE" 32  
    '(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0)  
  )  
)  
;;启动时最大化  
(my-maximized) 




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




;;use cscope
(require 'xcscope)




;;use auto-complete
(add-to-list 'load-path "/usr/local/emacs_AC")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "/usr/local/emacs_AC/ac-dict")
(ac-config-default)








;;显示匹配括号
(show-paren-mode t)
(setq show-paren-style 'parentheses)








;;打开ido-mode
(ido-mode t)




;;gdb调试时,打开多窗口
(setq gdb-many-windows t)




;;先下载window-numbering.el,放到/usr/share/site-lisp
(require 'window-numbering)
(window-numbering-mode 1)






;;在buffer左侧显示行号
(dolist (hook (list
'c-mode-hook
'c++-mode-hook
'emacs-lisp-mode-hook
'lisp-interaction-mode-hook
'lisp-mode-hook
'emms-playlist-mode-hook
'java-mode-hook
'asm-mode-hook
'haskell-mode-hook
'rcirc-mode-hook
'emms-lyrics-mode-hook
'erc-mode-hook
'sh-mode-hook
'makefile-gmake-mode-hook
))
(add-hook hook (lambda () (linum-mode 1))))










;=============快捷键设置==================
(global-set-key [f7] 'compile)        ;;编译
(global-set-key [C-f7] 'gdb)        ;;调试
(global-set-key [C-f8] 'previous-error)    ;;上一个错误
(global-set-key [f8] 'next-error)    ;;下一个错误
























;;========================================================
;; Yasnippet and Auto-complete settings
;;========================================================
(require 'yasnippet)
(require 'auto-complete)
(require 'auto-complete-config)








;;启用默认ac设置
(ac-config-default)
(auto-complete-mode 1)
;;添加backspac触发列表
(setq ac-trigger-commands
      (cons 'backward-delete-char-untabify ac-trigger-commands))
;;使用帮助模式
(setq ac-use-quick-help t)
(setq ac-quick-help-delay 1.0)
;;开启ac-dwin
(setq ac-dwim t)
;;设置ac数据文件位置
;;(setq ac-comphist-file (expand-file-name "ac-comphist/ac-comphist.dat" prelude-savefile-dir))
;;(check-temp-dir (expand-file-name "ac-comphist/" prelude-savefile-dir))
;;添加ac补全源
(set-default 'ac-sources
             '(ac-source-semantic ;;ac使用semantic的分析结果
               ac-source-yasnippet
               ac-source-abbrev
               ac-source-words-in-buffer
               ac-source-words-in-all-buffer
               ac-source-imenu
               ac-source-files-in-current-dir
               ac-source-filename))








;;yasnippet补全源的界面显示设置,这里颜色是红色的,用来与ac本身的补全相区分
(defface ac-yasnippet-candidate-face
  '((t (:background "sandybrown" :foreground "black")))
  "Face for yasnippet candidate.")








(defface ac-yasnippet-selection-face
  '((t (:background "coral3" :foreground "white")))
  "Face for the yasnippet selected candidate.")








(defvar ac-source-yasnippet
  '((candidates . ac-yasnippet-candidate)
    (action . yas/expand)
    (candidate-face . ac-yasnippet-candidate-face)
    (selection-face . ac-yasnippet-selection-face))
  "Source for Yasnippet.")
;;========================================================



0 0
原创粉丝点击