现在的位置: 首页 > 综合 > 正文

my emacs configure

2013年10月07日 ⁄ 综合 ⁄ 共 8041字 ⁄ 字号 评论关闭

(setq split-height-threshold nil)
(setq split-width-threshold 0)

;;shell 乱码
(setq ansi-color-for-comint-mode t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)

;;compile  
(defun quick-compile ()  
"A quick compile funciton for C++"  
(interactive)  
(compile (concat "g++ " (buffer-name (current-buffer)) " -g -pg")))  
;;Short key F9  
(global-set-key [(f9)] 'quick-compile) 

(add-to-list 'load-path "~/.emacs.d/color-theme-6.6.0")

;; 去掉工具栏
(tool-bar-mode nil)

;;去掉菜单栏
;;(menu-bar-mode nil)

;; 设置字体
;; 方法为: emacs->options->Set Default Font->"M-x describe-font"查看当前使用的字体名称、字体大小
(set-default-font " -bitstream-Courier 10 Pitch-normal-normal-normal-*-19-*-*-*-m-0-iso10646-1")

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

(global-set-key [(f4)] 'speedbar-get-focus)  

;; 实现全屏效果,快捷键为f11
(global-set-key [f11] 'my-fullscreen) 
(defun my-fullscreen ()
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_FULLSCREEN" 0))
)

;; 最大化
(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))
)

;; 启动emacs时窗口最大化
(my-maximized)

(require 'color-theme)
(color-theme-initialize)

;===================== cedet设置 =====================================

(add-to-list 'load-path "/home/ben/Downloads/cedet-1.0/cedet-1.0/speedbar")
(add-to-list 'load-path "/home/ben/Downloads/cedet-1.0/cedet-1.0/eieio")
(add-to-list 'load-path "/home/ben/Downloads/cedet-1.0/cedet-1.0/semantic")
(add-to-list 'load-path "/home/ben/Downloads/cedet-1.0/cedet-1.0/common")
(require 'cedet)

;; Ecb的操作:
;; C-c . g d 目录列表窗口
;; C-c . g s 源码窗口
;; C-c . g m 方法和变量窗口
;; C-c . g h 历史窗口
;; C-c . g l 最后选择过的编辑窗口
;; C-c . g 1 编辑窗口1
;; C-c . g n 编辑窗口n
;; C-c . l c 选择版面
;; C-c . l r 重画版面
;; C-c . l t 拴牢版面(锁定版面)
;; C-c . l w 拴牢可见的ecb窗口
;; C-c . \   拴牢编绎窗口

;======================cedet设置结束==================================

(add-to-list 'load-path "/usr/share/emacs/mylisp")
(add-to-list 'load-path "/usr/share/emacs/site-lisp/ecb-2.40")
(add-to-list 'load-path "/usr/share/emacs/site-lisp/cscope-15.7a/contrib/xcscope") 
(require 'xcscope)

(define-key global-map [(control f3)]  'cscope-set-initial-directory)
(define-key global-map [(control f4)]  'cscope-unset-initial-directory)
(define-key global-map [(control f5)]  'cscope-find-this-symbol)
(define-key global-map [(control f6)]  'cscope-find-global-definition)
(define-key global-map [(control f7)]  'cscope-find-global-definition-no-prompting)
(define-key global-map [(control f8)]  'cscope-pop-mark)
(define-key global-map [(control f9)]  'cscope-next-symbol)
(define-key global-map [(control f10)] 'cscope-next-file)
(define-key global-map [(control f11)] 'cscope-prev-symbol)
(define-key global-map [(control f12)] 'cscope-prev-file)
(define-key global-map [(meta f9)]     'cscope-display-buffer)
(define-key global-map [(meta f10)]    'cscope-display-buffer-toggle)

;;Goto-line short-cut key                                                                                                   
(global-set-key "\C-l" 'goto-line)

(setq cscope-do-not-update-database t)

(require 'linum)                                                   
(global-linum-mode 1)

;; 设置缩进
(setq indent-tabs-mode nil)
(setq default-tab-width 4)
(setq tab-width 4)
(setq tab-stop-list ())
(loop for x downfrom 40 to 1 do
      (setq tab-stop-list (cons (* x 4) tab-stop-list)))

(defconst my-c-style
  '((c-tab-always-indent        . t)
    (c-comment-only-line-offset . 4)
    (c-hanging-braces-alist     . ((substatement-open after)
                                   (brace-list-open)))
    (c-hanging-colons-alist     . ((member-init-intro before)
                                   (inher-intro)
                                   (case-label after)
                                   (label after)
                                   (access-label after)))
    (c-cleanup-list             . (scope-operator
                                   empty-defun-braces
                                   defun-close-semi))
    (c-offsets-alist            . ((arglist-close . c-lineup-arglist)
                                   (substatement-open . 0)
                                   (case-label        . 4)
                                   (block-open        . 0)
                                   (knr-argdecl-intro . -)))
    (c-echo-syntactic-information-p . t)
    )
  "My C Programming Style")

;; offset customizations not in my-c-style
(setq c-offsets-alist '((member-init-intro . ++)))

;; Customizations for all modes in CC Mode.
(defun my-c-mode-common-hook ()
  ;; add my personal style and set it for the current buffer
  (c-add-style "PERSONAL" my-c-style t)
  ;; other customizations
  (setq tab-width 4
        ;; this will make sure spaces are used instead of tabs
        indent-tabs-mode nil)
  ;; we like auto-newline and hungry-delete
  (c-toggle-auto-hungry-state 1)
  ;; key bindings for all supported languages.  We can put these in
  ;; c-mode-base-map because c-mode-map, c++-mode-map, objc-mode-map,
  ;; java-mode-map, idl-mode-map, and pike-mode-map inherit from it.
  (define-key c-mode-base-map "\C-m" 'c-context-line-break)
  )

(add-hook 'c-mode-common-hook 'my-c-mode-common-hook) 
;; 回车缩进
(global-set-key "\C-m" 'newline-and-indent)
(global-set-key (kbd "C-<return>") 'newline)

(set-background-color "DarkSlateGray")
          (set-foreground-color "Wheat")
          (set-face-background 'modeline "lightgoldenrod2")
          (set-face-foreground 'modeline "DarkSlateGray")
          (set-cursor-color "Orchid")
          (set-face-foreground 'font-lock-comment-face "Gray")
          (set-face-foreground 'font-lock-string-face "Gold3")
          (set-face-foreground 'font-lock-function-name-face "LightBlue")
          (set-face-foreground 'font-lock-keyword-face "cyan1")
          (set-face-foreground 'font-lock-type-face "Violet")
          (set-face-foreground 'font-lock-builtin-face "Cyan")
          (set-face-foreground 'font-lock-variable-name-face "Gold")
          (set-face-foreground 'font-lock-constant-face "Magenta")
          (set-face-foreground 'scroll-bar "Wheat")
          (set-face-background 'scroll-bar "lightgoldenrod2")
          (set-face-foreground 'tool-bar "Wheat")
          (set-face-background 'tool-bar "lightgoldenrod2")
          (set-face-foreground 'font-lock-builtin-face "Cyan")

;; 显示时间,格式如下
(display-time-mode 1) 
(setq display-time-24hr-format t) 
(setq display-time-day-and-date t) 
(transient-mark-mode t) 
(setq inhibit-startup-message t)

;;;; 自动启动ecb,并且不显示每日提示
(setq ecb-auto-activate t
      ecb-tip-of-the-day nil)

;;trivial-mode
(defun define-trivial-mode(mode-prefix file-regexp &optional command)
  (or command (setq command mode-prefix))
  (let ((mode-command (intern (concat mode-prefix "-mode"))))
    (fset mode-command
          `(lambda ()
             (interactive)
             (toggle-read-only t)
         (start-process ,mode-prefix nil
                ,command (buffer-file-name))
         (let ((obuf (other-buffer (current-buffer) t)) ;; Select correct buffer
           (kbuf (current-buffer)))
           (set-buffer obuf)                ;; set it as current
           (kill-buffer kbuf))))                ;; kill temporary buffer
    (add-to-list 'auto-mode-alist (cons file-regexp mode-command))))

(define-trivial-mode "evince" "//.pdf$")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  设置日历 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;设置日历的一些颜色
(setq calendar-load-hook
'(lambda ()
(set-face-foreground 'diary-face "skyblue")
(set-face-background 'holiday-face "slate blue")
(set-face-foreground 'holiday-face "white")))

(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.
 '(ecb-options-version "2.40")
 '(truncate-partial-width-windows 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.
 )
 
 
 (setq semanticdb-project-roots 
(list
(expand-file-name "/")))
;;(global-set-key [(control tab)] 'senator-complete-symbol);
(global-set-key [(control tab)] ' senator-completion-menu-popup)
;; (global-set-key [(control tab)] 'semantic-ia-complete-symbol-menu)

(global-set-key [f1] 'delete-other-windows)
(global-set-key [f2] 'list-buffers)
(global-set-key [f3] 'calendar)
(global-set-key [f4] 'ibuffer)
(global-set-key [f11] 'undo)
(global-set-key [f12] 'eval-current-buffer)
(global-set-key [f5]  'ecb-maximize-window-directories)
(global-set-key [f6] 'ecb-maximize-window-sources)
(global-set-key [f7] 'ecb-maximize-window-methods)
(global-set-key [f8] 'ecb-maximize-window-history)
(global-set-key [f11] 'undo)
(global-set-key [f12] 'eval-current-buffer)

(global-set-key [M-left] 'windmove-left)
(global-set-key [M-right] 'windmove-right)
(global-set-key [M-up] 'windmove-up)
(global-set-key [M-down] 'windmove-down)

(define-key global-map [(control f1)] 'ecb-hide-ecb-windows)
(define-key global-map [(control f2)] 'ecb-show-ecb-windows)

抱歉!评论已关闭.