博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

EMACS笔记

Posted on 2014-09-02 18:29  corda  阅读(206)  评论(0)    收藏  举报

环境

Ubuntu版本:14.04

EMACS版本:24.3.1

cedet

(require 'cedet)

;;待续

显示行号

(global-linum-mode t)

C语言排版

全选:Ctrl-x h

排版:Ctrl-Alt-\          

配置cscope

apt-get install cscope

apt-get install cscope-el

cp /usr/share/emacs/site-lisp/cscope/xcscope.el ~/.emacs.d/site-lisp/

 

;;LOAD_PATH                                                                                                                                                   
(add-to-list 'load-path' "~/.emacs.d/site-lisp")
(add-to-list 'load-path' "/usr/share/emacs/site-lisp/")
(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)
建立索引:
cscope-indexer -r3
 
快捷键:
;; * Keybindings:
;;
;; All keybindings use the "C-c s" prefix, but are usable only while
;; editing a source file, or in the cscope results buffer:
;;
;;      C-c s s         Find symbol.
;;      C-c s d         Find global definition.
;;      C-c s g         Find global definition (alternate binding).
;;      C-c s G         Find global definition without prompting.
;;      C-c s c         Find functions calling a function.
;;      C-c s C         Find called functions (list functions called
;;                      from a function).
;;      C-c s t         Find text string.
;;      C-c s e         Find egrep pattern.
;;      C-c s f         Find a file.
;;      C-c s i         Find files #including a file.
;;
;; These pertain to navigation through the search results:
;;
;;      C-c s b         Display *cscope* buffer.
;;      C-c s B         Auto display *cscope* buffer toggle.
;;      C-c s n         Next symbol.
;;      C-c s N         Next file.
;;      C-c s p         Previous symbol.
;;      C-c s P         Previous file.
;;      C-c s u         Pop mark.
;;
;; These pertain to setting and unsetting the variable,
;; `cscope-initial-directory', (location searched for the cscope database
;;  directory):
;;
;;      C-c s a         Set initial directory.
;;      C-c s A         Unset initial directory.
;;
;; These pertain to cscope database maintenance:
;;
;;      C-c s L         Create list of files to index.
;;      C-c s I         Create list and index.
;;      C-c s E         Edit list of files to index.
;;      C-c s W         Locate this buffer's cscope directory
;;                      ("W" --> "where").
;;      C-c s S         Locate this buffer's cscope directory.
;;                      (alternate binding: "S" --> "show").
;;      C-c s T         Locate this buffer's cscope directory.
;;                      (alternate binding: "T" --> "tell").
;;      C-c s D         Dired this buffer's directory.
 

 颜色与主题

color-theme下载地址(后者未经验证):

http://download.gna.org/color-theme/

http://download.savannah.gnu.org/releases/color-theme/

 

(require 'color-theme)
;;少了下面这句不行,网上很多资料里没有。。(in EMACS 24)
(color-theme-initialize)
(color-theme-hober)

 

 

;;其他配置

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

;; 设置默认tab宽度为2
(setq tab-width 2
indent-tabs-mode t
c-basic-offset 2)

;; 回车缩进
(global-set-key "\C-m" 'newline-and-indent)
(global-set-key (kbd "C-<return>") 'newline)

;; 实现全屏效果,快捷键为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)

 

;; 一打开就起用 text 模式。
;;(setq default-major-mode 'text-mode)


;; 语法高亮
;;(global-font-lock-mode t)

 

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

 

 
;; 启动窗口大小

(setq default-frame-alist
'((height . 35) (width . 125) (menu-bar-lines . 20) (tool-bar-lines . 0)))

 

speedbar

下载一个将speedbar嵌入EMACS的插件(打开这个网址后复制里面的代码,不能直接wge。。。):

http://www.emacswiki.org/emacs/sr-speedbar.el

 

 

 (require 'sr-speedbar)  

 (setq speedbar-show-unknown-files t)  

 (setq speedbar-use-images nil)  

 (setq sr-speedbar-width 30)  

(setq sr-speedbar-right-side nil)  

(global-set-key (kbd "<f5>") (lambda()  

                               (interactive)  

                               (sr-speedbar-toggle)))