2012년 5월 23일 수요일

MAC OS X에서 Emacs 사용

출처 : http://nadagill.egloos.com/816704


Emacs 설치
http://emacsformacosx.com/ 에 접속하면 바로 설치할 수 있다.
color-theme 설치
첨부한 color-theme를 Download 받는다.
$ cd ~/.emacs.d/vendor
$ tar xzvf color-theme.tar.gz
auto-complete 설치
첨부한 auto-complete을 Download 받는다.
$ cd ~/.emacs.d/vendor
$ tar xzvf auto-complete.tar.gz
cscope 설치
여기에서 package를 Download 받는다.
$ cd ~/.emacs.d/vendor
$ tar xzvf cscope-15.7a.tar.gz
$ cd cscope-15.7a
$ ./configure --prefix=/usr/local
$ sudo make install
이 작업이 완료돼면 다음과 같이 실행파일을 copy해 준다.
$ cd ~/.emacs.d/vendor/cscope-15.7a/contrib
$ cd xcscope
$ sudo cp cscope-indexer /usr/local/bin
.emacs의 설정
vi ~/.emacs
;; Command key is meta key 설정
(setq mac-option-key-is-meta t)
(setq mac-command-key-is-meta nil)
;; 환영 메세지 안보이게 설정
(setq inhibit-startup-message t)
;; windows size 설정
(set-frame-width (selected-frame) 180)
(set-frame-height (selected-frame) 50)
;; windows position 설정
(set-frame-position (selected-frame) 0 0)
;; color theme load
(add-to-list 'load-path "~/.emacs.d/vendor/color-theme")
(require 'color-theme)
(color-theme-initialize)
(color-theme-deep-blue)
;; font 설정
(when window-systemauto-complete.tar.gz
 (set-face-font 'default "-outline-Courier New-normal-normal-normal-mono-12-*-*-*-c-*-iso10646-1") ; 영문
 (set-fontset-font "fontset-default" '(#x1100 . #xffdc)  '("NanumGothic" . "unicode-bmp")) ; 한글
 (set-fontset-font "fontset-default" '(#xe0bc . #xf66e)  '("NanumGothic" . "unicode-bmp")) ; 사용자
)
;; cscope load
(add-to-list 'load-path "~/.emacs.d/vendor/cscope-15.7a/contrib/xcscope")
(require 'xcscope)
;; auto complete 설정
(add-to-list 'load-path "~/.emacs.d/vendor/auto-complete")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/vendor/auto-complete/ac-dict")
(ac-config-default)
;; 화면 분할
(split-window-horizontally)
;; 화면 크기 동일하게 설정
(balance-windows)
;; line number 표시
(global-linum-mode 1)
;; backup file 생성하지 않기 설정
(setq make-backup-files nil)
;; indent 설정
(defun linux-c-mode ()
  "C mode with adjusted defaults for use with the Linux kernel."
  (interactive)
  (c-mode)
  (c-set-style "K&R")
  (setq c-basic-offset 4))
(setq auto-mode-alist (cons '("/Users/nadagill/Project/linux.*-.*\\.[ch]$" . linux-c-mode)
    auto-mode-alist))
;; 선택된 영역 delete로 지우기
(delete-selection-mode nil)
;; key binding
;; hyper key binding
(setq mac-command-modifier 'hyper)
;; meta + arrow 창 전환
(windmove-default-keybindings 'meta)
;; goto line 설정
(global-set-key [(hyper l)] 'goto-line)
;; undo 설정
(global-set-key [(hyper z)] 'undo)
;; paste 설정
(global-set-key [(hyper v)] 'yank)
;; copy 설정
(global-set-key [(hyper c)] 'copy-region-as-kill)
;; cut 설정
(global-set-key [(hyper x)] 'kill-region)
;; find file 설정
(global-set-key [(hyper o)] 'find-file)
;; save 설정
(global-set-key [(hyper s)] 'save-buffer)
;; save & quit 설정
(global-set-key [(hyper q)] 'save-buffers-kill-emacs)
;; shell mode 진입
(global-set-key [(hyper shift s)] 'eshell)
;; compile 설정
(global-set-key [(hyper shift c)] 'compile)
;; scroll 설정
(global-set-key [(meta up)] 'scroll-down)
(global-set-key [(meta down)] 'scroll-up)
(global-set-key [(meta left)] 'beginning-of-line)
(global-set-key [(meta right)] 'end-of-line)
;; cscope 관련 key binding 설정
;; index file 만들기 설정
(global-set-key [(hyper a)] 'cscope-index-files)
;; find symbol
(global-set-key [(hyper /)] 'cscope-find-this-symbol)
;; previous symbol
(global-set-key [(hyper ,)] 'cscope-prev-symbol)
;; next symbol
(global-set-key [(hyper .)] 'cscope-next-symbol)
;; exec path 설정
(custom-set-variables
 '(exec-path (quote ("/usr/bin" "/bin" "/usr/sbin" "/sbin" "/Applications/Emacs.app/Contents/MacOS/bin" "/usr/local/bin" ))))
(custom-set-faces)

댓글 없음:

댓글 쓰기