emacs配置文件

(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.
 '(show-paren-mode nil)
 '(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.
 )
(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-time-mode t)
'(show-paren-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.
)

;(setq visible-bell t);關閉出錯提示聲
(setq inhibit-startup-message t);關閉開啓畫面
(setq column-number-mode t);
;------------------------------- 設置界面-------------------------------
(set-cursor-color "Wheat")
(set-mouse-color "Wheat")
(set-foreground-color "Wheat")
(set-background-color "DarkSlateGray")
(if window-system
(setq default-frame-alist
(append
'( (top . 100)
(left . 100)                            
(width . 150)
(height . 50))
default-frame-alist))
)
;-----------------------------end of 設置界面--------------------------

;------------------------------- 設置顯示時間---------------------------
(display-time-mode 1)
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
;--------------------------------endof 設置顯示時間---------------------

;-------------------------------快捷鍵---------------------------------
; (define-key [(f7)] 'compile)
;;;;以下是我的快捷鍵設置

(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 快捷鍵 ---------------------


;(setq kill-ring-max 200);; 設置粘貼緩衝條目數量
(setq enable-recursive-minibuffers t);; 設置遞歸使用minibuffer
;;(setq scroll-margin 3
;;      scroll-conservatively 10000) ;;防止頁面滾動時跳動
(setq default-major-mode 'text-mode);;設置默認模式是text mode
(show-paren-mode t)
(setq show-paren-style 'parentheses) ;; 設置顯示括號匹配,但不跳轉
(mouse-avoidance-mode 'animate) ;;讓鼠標不要擋住光標

 

;------------------------------程序語言--------------------------------
;;;; 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)


(setq ansi-color-for-comint-mode t)
(customize-group 'ansi-colors)
(kill-this-buffer);關閉customize窗口


;自定義按鍵


(global-set-key [f8] 'other-window);F8窗口間跳轉
(global-set-key [C-return] 'kill-this-buffer);C-return關閉當前buffer
(global-set-key [f10] 'split-window-vertically);F10分割窗口
(global-set-key [f11] 'delete-other-windows);F11 關閉其它窗口
(global-set-key [f1] 'my-fullscreen);F1 全屏
(global-set-key (kbd "C-.") 'backward-page);文件首
(global-set-key (kbd "C-/") 'forward-page);文件尾


;普通設置


(setq make-backup-files nil);不產生備份文件

(global-font-lock-mode t);語法高亮
(auto-image-file-mode t);打開圖片顯示功能
(fset 'yes-or-no-p 'y-or-n-p);以 y/n代表 yes/no
(column-number-mode t);顯示列號
(show-paren-mode t);顯示括號匹配

(tool-bar-mode nil);去掉那個大大的工具欄
(scroll-bar-mode nil);去掉滾動條
;(mouse-avoidance-mode 'animate);光標靠近鼠標指針時,讓鼠標指針自動讓開
(setq mouse-yank-at-point t);支持中鍵粘貼
(transient-mark-mode t);允許臨時設置標記
(setq x-select-enable-clipboard t);支持emacs和外部程序的粘貼
(setq frame-title-format '("" buffer-file-name "@emacs" ));在標題欄顯示buffer名稱
(setq default-fill-column 80);默認顯示 80列就換行


;鼠標滾輪,默認的滾動太快,這裏改爲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)


(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))
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;C/C++設定;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;縮進策略
(defun my-indent-or-complete ()
(interactive)
(if (looking-at "//>")
(hippie-expand nil)
(indent-for-tab-command)))
;補全優先級
(autoload 'senator-try-expand-semantic "senator")
(setq hippie-expand-try-functions-list
'(
senator-try-expand-sematic
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))

(add-to-list 'load-path "~/.emacs.d/")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d//ac-dict")
(ac-config-default)

(add-hook 'semantic-init-hooks 'semantic-idle-completions-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)
(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)
;; 輸入左邊的括號,就會自動補全右邊的部分.包括(), '', [] , {} ,""
(setq auto-save-default nil);不生成名爲#filename# 的臨時文件
(require 'linum)
(global-linum-mode t)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章