'분류 전체보기'에 해당되는 글 167건

  1. 2010.06.28 SVN 사용법 고급
  2. 2010.06.25 Makefiles on Xcode
  3. 2010.06.24 CEDET ECB
  4. 2010.06.22 Pretty Print source code
  5. 2010.06.15 Summer Intern (See this after 2010.Dec)
  6. 2010.06.11 ACM ICPC 2003 Online Preliminary Contest
  7. 2010.06.10 .emacs
  8. 2010.06.07 지능형 휠체어 동향
  9. 2010.06.06 Mac Keyboard Shortcuts
  10. 2010.06.03 OpenCV on OSX

SVN 사용법 고급

카테고리 없음 2010. 6. 28. 12:39

SVN(subversion) 사용법 : 고급(Advanced)

Contents:

  1. SVN(subversion) 사용법 : 고급(Advanced)
    1. 브랜치(가지) 구성하기
    2. 참고 문헌

브랜치(가지) 구성하기

  • 브랜치(가지)를 구성하는 목적은 크게 두 가지이다.
    • 특 정 시점의 snapshot을 만들기 위한 것이다. svn은 cvs와는 다르게 따로 tag를 붙일 수 있는 방법을 가지고 있지 않다. 리비전 번호가 전체적으로 적용되는 것도 아니어서 특정 시점의 상태를 기억해둘 필요가 있을 때에는 /tags/REL-1.0.0 과 같이 태그 디렉토리를 만든다.
    • 개발의 기본 가지(줄기, trunk)에서 따로 분리된 개발을 진행하고자 할 때이다. 말 그대로 브랜치(branch)를 만들기 위해서다. /branches/RB-1.0 과 같이 브랜치 디렉토리를 복사해서 만든다.
  • 태그 브랜치를 만드는 예
    work> svn copy -m "Tag release 1.0.0" \
          http://svn_server.com/svn_repo/project_name/trunk \
          http://svn_server.com/svn_repo/project_name/tags/REL-1.0.0
    
    
  • 브랜치와 꼬리표(tag) 명명 관례
이름 붙일 대상 이름 스타일
릴리스 가지 (Release Branch) RB-릴리스번호 RB-1.0
RB-1.0.1a
릴리스 (Release) REL-릴리스번호 REL-1.0
REL-1.0.1a
버그 교정 가지 (Bug Fix Branch) BUG-추적번호 BUG-3035
BUG-10871
버그 교정 이전 (Bug Fix Pre) PRE-추적번호 PRE-3035
PRE-10871
버그 교정 이후 (Bug Fix Post) POST-추적번호 POST-3035
POST-10871
개발자 실험 (Try) TRY-약자-설명 TRY-MGM-cache-pages
TRY-MR-neo-persistence
  • 추 적번호: tracking number : Trac과 같은 버그 추적 시스템에서 부여된 버그 추적 번호

참고 문헌

http://blog.naver.com/joycestudy?Redirect=Log&logNo=100097622001

:

Makefiles on Xcode

카테고리 없음 2010. 6. 25. 15:04
:

CEDET ECB

카테고리 없음 2010. 6. 24. 21:53

소개

Emacs 로 코딩을 하다보면 CEDETECB 를 만나게 된다. 처음에는 너무 무겁길래 그냥 깔았다가 지웠고, 후에 Emacs 를 본격적으로 쓰면서 vim 의 TagList 가 필요해서 다시 깔게 되었다. 내가 원한것이 TagList 정도의 기능뿐이었기 때문에, 이 페이지에 나온내용은 CEDET 와 ECB 의 일부만을 다룬다.

CEDET 와 ECB 를 설치하기 위해서는 MSYS 가 필요하다(또는 cygwin) mingw, msys 는 여러모로 쓸모있으니 깔아두자

CEDET 설정

  • ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; cedet 설정
    ;; http://cedet.sourceforge.net/ 에서 받을수 있다.
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (when (file-exists-p "~/.emacs_plugin/cedet-1.0beta3b")
      (progn
        (setq semantic-load-turn-useful-things-on t)
        (load-file "~/.emacs_plugin/cedet-1.0beta3b/common/cedet.el")
    
        (setq semantic-default-c-path
          (cond
           (officep
            '("c:/MinGW/include" "C:/MinGW/include/c++/3.2")) ; 사무실에서는 mingw 를 c:/ 에 깔았다
           (homep
            '("c:/bin/MinGW/include" "C:/bin/MinGW/include/c++/3.2")) ; 집에서는 mingw 를 c:/bin 에 깔았다
           (t "/usr/include" "/usr/local/include" "/usr/dt/include" "/usr/X11R6/include" ))) ; 그외 장비는 유닉스라고 생각하자
    
        ;; semantic database
        (require 'semanticdb)
        (global-semanticdb-minor-mode 1)
        (setq semanticdb-project-roots
              (list "d:/src/rrun"
                    "d:/src/Cleopatra/chairking"))
        ))
    
    

semantic-default-c-path 를 지정하는것을 잊지 말자. 이놈은 ffap 의 ffap-c-path 와 유사한 역할을 한다. 이놈을 안해주면 ECB 의 메서드뷰에서 include 파일들을 열지 못하는 일이 생긴다. (이것을 해주더라도, 프로젝트별로 쓰고있는 include 의 헤더를 열어주지는 못한다. 음.. 방법을 찾아봐야겠다. 프로젝트 관리해주는 패키지들이 몇개 있던데 그쪽부터 찾아봐야지 ToDo)

그리고 semanticdb 를 적당히 세팅해 주는것도 잊지 말자. 이놈이 빠지면, 다른 파일에 있는 심볼을 completion 해주거나 ECB 의 메서드 뷰에서 부모 클래스를 찾아가는것이 불가능해진다. emanticdb-project-roots 를 .emacs 에 지정하는것은 좀 모양이 안나는 일이 긴 한데.. 이거 따로 뽑을 궁리를 해봐야 겠다.

cedet 의 semantic 을 ctags 대용으로 써볼려고 했는데, 아무래도 좀 아니더라. 태그는 ctags 로 쓰는것이 더 나을듯.

이 패키지가 completion 을 지원하는데, 위처럼 세팅해놓으면 자동적으로 completion 이 활성화 된 상태이다. 적당히 메서드이름을 치다가 잠시 쉬면(idle) 후보들이 툴팁으로 뜨고 그때 TAB 으로 completion 이 가능하다. 또는 semantic-ia-complete-symbol,semantic-ia-complete-symbol-menu, semantic-ia-complete-tip 를 명시적으로 불러줘도 된다. 하지만 그다지 똘똘한 편은 못되는듯. 후에 더 개선되면 . 이나 -> 를 저놈들로 bind 하면 편하겠다. completion 에 관심있다면 IntellisenseOnEmacs 또는 http://cedet.sourceforge.net/intellisense.shtml 를 살펴보자.

ECB

  • (when (file-exists-p  "~/.emacs_plugin/ecb-2.32")
        (add-to-list 'load-path "~/.emacs_plugin/ecb-2.32")
        (require 'ecb-autoloads)
    
        ;; 윈도스럽게, 왼쪽버튼과 오른쪽 버튼을 쓰는게 편하다.
        (setq ecb-primary-secondary-mouse-buttons (quote mouse-1--mouse-2))
    
        ;; 초기 팁 알려주는거 끈다
        (setq ecb-tip-of-the-day nil)
    
        ;; ecb-source-path 를 세팅해두면 좀더 편해진다.
        ;; cedet 와 같이 ffap-c-path 를 재사용했다.
        (add-hook 'ecb-activate-hook
                  '(lambda ()
                     (setq ecb-source-path
                           (append ecb-source-path ffap-c-path))))
    
        ;; method-buffer 외에는 별 필요가 없어보인다.(vim 의 TagList 를 원하고 있기 때문에)
        ;; 음 ecb-layout-name 은 setq 로 지정하지 말고 customize 로만 바꿔야 한다고 문서에 있네..
        ;; 일단 주석처리 한다.
        ;;(setq ecb-layout-name "left9")
        )
    
    

ECB 는 마우스클릭만 바꿔주면 바로 쓸만하다. 모니터가 작은경우는 레이아웃을 left9 로 쓰도록 하자. vim 의 TagList 와 유사한 느낌으로 쓸수 있다. TagList 정도로 쓸거라면 단축키도 몇개만 알면 충분하다.

C-c .

ECB 커맨드들의 prefix

C-c . g m

메서드뷰 를 본다. go method 정도로 기억해두자

C-c . r

메서드뷰가 깨지는 경우가 있는데 그때 불러주자. rebuild 한다고 기억하면 된다.

C-c . e

eshell 을 연다

C-c . p

웹브라우저의 back 과 유사하다.

C-c . n

웹브라우저의 Foward 와 유사하다.

C-c . l w

ecb 창들을 켜고 끌수 있다. ECB 창들이 거슬리면 deactive 하지 말고 이걸 써보자.

C-c . g m 을 C-c C-c 로

  • (defun my-c-mode-common-hook ()
      (c-add-style "PERSONAL" my-c-style t)
      (setq tab-width 4
            indent-tabs-mode t
            c-basic-offset 4)
      (c-toggle-auto-state -1)              ; disable auto-newline mode
      (c-toggle-hungry-state 1)             ; enable hungry-delete mode
    
      ;; return 으로 indent 까지 같이 하도록했다
      (define-key c-mode-base-map "\C-m" 'newline-and-indent)
    
      ;; C-c RET 로 .h .cpp 간의 전환을 하도록 했다.
      (define-key c-mode-base-map [(control c)(return)] 'ff-find-other-file)
    
      ;; ecb 가 켜진 상태라면, C-c C-c 를 ecb-goto-window-methods 에 바인딩했다.
      (when (fboundp 'ecb-goto-window-methods)
        (define-key c-mode-base-map [(control c)(control c)] 'ecb-goto-window-methods))
    
      (c-set-offset 'substatement-open 0)
      (c-set-offset 'member-init-intro '++)
      (c-set-offset 'inline-open 0)
      (c-set-offset 'comment-intro 0)
      (c-set-offset 'label 0)
      (c-set-offset 'arglist-intro '++)
    
      (hs-minor-mode 1)
      )
    
    
    

핵심은 이것

  • ;; ecb 가 켜진 상태라면, C-c C-c 를 ecb-goto-window-methods 에 바인딩했다.
      (when (fboundp 'ecb-goto-window-methods)
        (define-key c-mode-base-map [(control c)(control c)] 'ecb-goto-window-methods))
    
    



http://oldpie.yoonkn.com/cgi-bin/moin.cgi/CEDET%EC%99%80ECB




emacs 를 사용한 이후로 emacs 설정파일 묶음은 내 개발역사나 마찬가지다.
org 모드에 블로그보다 많은 정보를 들고 있고 이걸 .emacs 들과 함께 hg 로 버전관리중이니 뭐 그 이상이지...

오래 전 위키에 올렸던 페이지가 어쩌다 오늘 내눈에 보이길래 지금 쓰는 dot emacs 파일을 올려봤다. 예전 위키에 적을때하고 다른점은.. 그때는 주로 윈도에서 놀았으나 지금은 거의 리눅스에서만 개발을 하고 있다는 점? 그리고 그때는 재미삼아 common lisp 을 주로 구경했는데 지금은 haskell 에 좀더 관심있다는 정도...

그때나 지금이나 허접한 개발자란건 변함이 없구만.

아래 소스를 올리긴 하는데 내가 워낙 게으른놈이라 코드가 정리가 전혀안됐다. 주석도 처음에 주절주절 적어둔거 그대로.. 심지어는 svn 쓰던 시절의 $Id$ 이것까지 남아있네. 이거 전부 정리해야 할 글인데.. 지금도 몇몇 코드들은 다픈 파일로 따로 뽑아낸 상태인데 언제 시간내서 싹 정리를 해야겠다.

접어두기..

;; -*- mode: Emacs-Lisp; outline-regexp: "^;;;; .*";  -*-

;; yoonkn at gmail
;; $Id: emacs.el 751 2008-05-09 11:02:29Z yoonkn $

;; vim을 쓰다가 emacs 를 쓰면서 만들고 있는 .emacs
;; 각 섹션마다 ;;;;어쩌구 를 쓰고, 이를 outline-regexp 에 걸리도록 해서
;; outline-minor-mode 와 같이 쓰기 편하도록 했다.

;; emacs 가 최초로 읽어들이는 설정은 ~/.emacs 이다.
;; ( site-lisp 의 el 을 먼저 읽지만, 그건 개인이 건드릴만한게 아니니 제외 )
;;
;; .emacs 를 바로 수정해도 되지만, 커스텀변수가 그곳에 저장되는곳이기도 하고
;; (emacs 가 알아서 써준다), svn 에 넣으려면 따로 폴더를 만들어야 하기 때문에
;; ~/emacs/emacs.el 을 만들게 되었다.

;; ~/.emacs 의 내용은 다음과 같은 형식이다.
;;
;; (load "~/emacs/emacs.el")
;; (load "~/emacs/office.el") ; 집이라면 home.el
;;
;; 이런식으로 만들어서 쓰니 편하더라.

(require 'cl)


;;;; 여러 환경에서 쓰기 위한 설정값들

(defconst win32p (eq system-type 'windows-nt) "윈도머신이면 참")
(defconst unixp (eq system-type (or 'gnu/linux 'berkeley-unix)) "FreeBSD 머신이면 참")
(defconst homep (string-match "MOONFIRE" system-name)"집의 pc 라면 참")
(defconst officep (not homep)"사무실의 pc 라면 참")
(defconst extra-packages "~/.emacs.d" "내가 추가로 설치한 el 패키지들의 위치")


(defmacro with-extra-package (path &rest body)
"path 가 있으면, load-path 에 추가한다, 단 리눅스인 경우는
경로를 무시하고 있는것으로 간주한다. 지금 우분투를 데스크탑으로
쓰고있는데, 우분투에서는 내가 쓰는 대부분의 el 들이 패키지로
제공이 되니 이런식으로 해결했다."

`(let ((fullpath (format "%s/%s" extra-packages ,path)))
(when (or unixp (file-accessible-directory-p fullpath))
(message "%s 패키지를 찾았습니다" fullpath)
(add-to-list 'load-path fullpath)
,@body)))

;;;; 마이너 모드들, 그외 eye-candy 세팅들

(global-font-lock-mode 1) ; syntanx highlight
(transient-mark-mode t) ; marking highlight
(show-paren-mode t) ; 짝이 맞는 괄호 보여준다
(if (functionp 'global-hi-lock-mode) ; C-x w h 등으로 특정 단어들을 빛내준다
(global-hi-lock-mode 1)
(hi-lock-mode 1))
;;(global-hl-line-mode 1) ; 현재줄을 빛내준다. 이거 좀 불편해서 뺐다.
(setq ring-bell-function (lambda () nil)) ; bell 무시

(line-number-mode 1) ; mode line 에 라인수를 표시한다
(column-number-mode 1) ; mode line 에 컬럼을 표시한다(기본이 아니더라)

(setq scroll-step 1) ; 윈도스런 스크롤을 위해서..
(setq scroll-conservatively 4096)

; 윈도우처럼, 선택된 regeion 을 DEL 로 지우거나, 다른 글자를 타이핑 할때 즉시 지운다.
(delete-selection-mode 1)

(setq-default truncate-lines t) ; 화면을 벗어나는 긴 줄처리 toggle-truncate-lines 참고

;;(dynamic-completion-mode) ; 음 이게 뭐드라? M-/ 던가 M-RET 던가

;; Set the text for titlebar and icons, %f=filename, %b=buffername
(setq frame-title-format (list "GNU Emacs " emacs-version "@" system-name " - " '(buffer-file-name "%f" "%b")))
(setq icon-title-format frame-title-format)

(which-function-mode 1) ; 어떤 함수를 수정중인지 표현 semantic-stickyfunc-mode 보다는 이게 보기 좋다

(tool-bar-mode -1) ; toolbar 는 거의 안쓰니 꺼버린다

(auto-compression-mode 1) ; 가끔 필요해서..

(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1)) ; 스크롤바눈에거슬린다

;; (load "~/emacs/dirvars.el") ; 프로젝트 관리에 써먹자


(setq-default indent-tabs-mode nil) ; TAB 보다 space 가 더 좋아졌다.


; lisp 등에서 괄호를 흐리게 보여주는 모드 M-x customize-face
; paren-face 로 적절한 값으로 조절해서 쓰자. 지금은 흰색 바탕화면에서
; grey80 을 쓰고 있다.
(load "~/emacs/parenface")
(require 'parenface)


;; http://emacswiki.org/cgi-bin/wiki?InteractiveSearch
;; isearch 중 붙여넣기를 하려면 C-y 가 아닌 M-y 를 해야 하는데
;; 이건 뭔가 아니다. C-y 로 바꾸자
(define-key isearch-mode-map (kbd "C-y") 'isearch-yank-kill)

;;;; X 에서 휠마우스 버튼 쓰기
;;(global-set-key [(mouse-4)] 'scroll-down)
;;(global-set-key [(mouse-5)] 'scroll-up)


;;;; 윈도에서는 윈도키를 잘 써먹자
(when win32p
(setq w32-pass-lwindow-to-system nil
w32-pass-rwindow-to-system nil
w32-pass-apps-to-system nil
w32-lwindow-modifier 'super ;; Left Windows
w32-rwindow-modifier 'super ;; Rigth Windows
w32-apps-modifier 'hyper) ;; App-Menu (right to Right Windows)
(global-set-key [(super g)] 'goto-line))


;;;; 폰트 설정
;; http://www.emacswiki.org/cgi-bin/wiki/ChangeFontsPermanentlyOnWindows
;; http://www.emacswiki.org/cgi-bin/wiki/GoodFonts 에 다른이들이 쓰는 폰트들이 소개되어있다.
;; 폰트를 고른후 (frame-parameter nil 'font) 를 실행하면 폰트를 알수 있다.

;; (create-fontset-from-fontset-spec
;; "-*-Consolas-normal-r-*-*-12-*-*-*-c-*-fontset-consolas12,
;; korean-ksc5601:-*-malgun-normal-r-*-*-12-*-*-*-c-*-ksc5601.1987-*")

;; http://www.emacswiki.org/cgi-bin/wiki/FontSets
;; Finegrained Fontset Control 참고
;; 원래의 폰트셋에서 korean-ksc5601 부분의 폰트만 굴림으로 바꿨다.
(when nil;win32p
;; consolas 에 굴림체 적용 폰트셋
;; 시프트 클릭으로 적당한 폰트를 고르고
;; (frame-parameter nil 'font) 를 이용해서 폰트 이름을 얻어서
;; 그 이름을 이용 create-fontset-from-ascii-font 으로 폰트셋을 만들고,
;; set-fontset-font 으로 korean-ksc5601 에 대해서만 굴림체를 적용시켜줬다.
;; 단 이때 사이즈가 홀수 인경우 커서의 잔상이 남는등 오동작을 하길래 14 로 바꿔주니 잘되더라.
(setq w32-enable-italics t)
(create-fontset-from-ascii-font "-outline-Consolas-normal-r-normal-normal-14-97-96-96-c-*-iso8859-1")
(set-fontset-font "-outline-consolas-normal-r-normal-normal-14-105-96-96-c-*-fontset-iso8859_1" 'korean-ksc5601 "-*-맑은 고딕-normal-r-*-*-14-*-*-*-c-*-ksc5601.1987-*")
(set-face-font 'default "-outline-consolas-normal-r-normal-normal-14-105-96-96-c-*-fontset-iso8859_1")

;; 좀더 작은 크기
;; (create-fontset-from-ascii-font "-outline-Consolas-normal-r-normal-normal-13-97-96-96-c-*-iso8859-1")
;; (set-fontset-font "-*-*-normal-r-normal-normal-13-97-96-96-c-*-fontset-iso8859_1_13" 'korean-ksc5601 "-*-Gulimche-normal-r-*-*-13-*-*-*-c-*-ksc5601.1987-*")
;; (set-face-font 'default "-*-*-normal-r-normal-normal-13-97-96-96-c-*-fontset-iso8859_1_13")
)

;; sun 라운드고딕을 한글로, fixed 를 영문으로
(when (and unixp window-system)
;;(set-face-font 'default "-sun-roundgothic-medium-r-normal--12-120-75-75-c-120-ksc5601.1987-0")
(set-face-font 'default "fixed")
)


;;;; 버퍼 전환 설정(http://www.emacswiki.org/cgi-bin/wiki/CategoryBufferSwitching)

;; from http://www.emacswiki.org/cgi-bin/wiki/BufferMenu
(global-set-key (kbd "C-x C-b") 'buffer-menu)

;; ido 써볼까...
(require 'ido)
(ido-mode t)
(ido-everywhere 1)
(setq ido-use-filename-at-point 'guess
ido-use-url-at-point t)
;;(iswitchb-mode 1)

;;;; home 키를 비쥬얼 스튜디오 처럼
;; from http://www.emacswiki.org/cgi-bin/wiki/BackToIndentationOrBeginning
;;
;; 이거 지워버렸다.
;; 공백이 아닌 첫 문자로 point 를 위치시킬때는 M-m 을 하면 된다.




;;;; 한글 설정( 이거 안해주니 grep mode 등에서 한글이 안되더라..)

(when (and enable-multibyte-characters win32p)
(setq-default coding-system 'euc-kr)
(setq file-coding-system 'euc-kr)
(setq display-coding-system 'euc-kr)
(setq-default buffer-coding-system 'euc-kr)
(setq sendmail-coding-system 'euc-kr)
(setq keyboard-coding-system 'euc-kr)
(setq terminal-coding-system 'euc-kr)

(set-language-environment "Korean")
(setq-default file-name-coding-system 'euc-kr)
(setq input-method-verbose-flag nil
input-method-highlight-flag nil)
(prefer-coding-system 'euc-kr)
(set-default-coding-systems 'euc-kr)
;; Hangul Mail setting
(setq-default sendmail-coding-system 'euc-kr))



;;;; gnus 설정


;; 뉴스서버, 집에서는 kornet. 그외엔 프리뉴스서버.
;; 회사에서는 news.dacom.co.kr 을 썼었는데, 데이콤 서버가 아주 안좋아서
;; 그냥 전부 프리서버로
(setq gnus-select-method
(if homep '(nntp "news.kornet.net")
'(nntp "news.bora.net")))

;; 사용자 설정
(setq user-full-name "Yoon Ki-nam"
user-mail-address "yoonkn@gmail.com"
message-from-style 'parens)
(setq mail-yank-prefix "> ")

;; gnus-article-mode 에서는 goto-address 를 쓴다
(add-hook 'gnus-article-mode-hook 'goto-address)


;; RSS 를 볼때 S-return 으로 브라우저를 띄우도록 했다.
(require 'gnus)
(require 'nnrss)
(require 'browse-url)
(defun browse-nnrss-url( arg )
(interactive "p")
(let ((url (assq nnrss-url-field
(mail-header-extra
(gnus-data-header
(assq (gnus-summary-article-number)
gnus-newsgroup-data))))))
(if url
(progn
(browse-url (cdr url))
(gnus-summary-mark-as-read-forward 1))
(gnus-summary-scroll-up arg))))

(eval-after-load "gnus"
#'(define-key gnus-summary-mode-map
(kbd "S-<return>") 'browse-nnrss-url))
(add-to-list 'nnmail-extra-headers nnrss-url-field)

;;;; cc-mode 설정


;; 몇몇 확장자 추가
(add-to-list 'auto-mode-alist '("\\.hpp\\'" . c++-mode))
(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode)) ; 난 주로 c++ 쓰니까.

;; c++ indentation
(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 . 0)
(block-open . 0)
(namespace-open . 0)
(namespace-close . 0)
(innamespace . 0)
(inextern-lang . 0)
(knr-argdecl-intro . -)))
(c-echo-syntactic-information-p . t)
)
"My C Programming Style")

;; Customizations for all modes in CC Mode.
(defun my-c-mode-common-hook ()
(c-add-style "PERSONAL" my-c-style t)
(setq tab-width 4
;;indent-tabs-mode t
c-basic-offset 4)
(c-toggle-auto-state -1) ; disable auto-newline mode
(c-toggle-hungry-state 1) ; enable hungry-delete mode

;; return 으로 indent 까지 같이 하도록했다
(define-key c-mode-base-map "\C-m" 'newline-and-indent)

;; C-c RET 로 .h .cpp 간의 전환을 하도록 했다.
(define-key c-mode-base-map [(control c)(return)] 'ff-find-other-file)

;; ecb 가 켜진 상태라면, C-c C-c 를 ecb-goto-window-methods 에 바인딩했다.
(when (fboundp 'ecb-goto-window-methods)
(define-key c-mode-base-map [(control c)(control c)] 'ecb-goto-window-methods))

;; cedet 가 로딩된상태라면 META-Ret 를 semantic-analyze-possible-completions 로 매핑했다.
;; semantic-ia-complete-symbol 등 여러선택이 있지만 이놈이 맘에들었다.
;; ...다가 다시 semantic-ia-complete-symbol 로 바꿨다. 새로 버퍼가 열리면서 인자까지 보여주는게 맘에 들었었는데,
;; 버퍼가 다시 사라지지 않은게 이유
(when (fboundp 'semantic-analyze-possible-completions)
(define-key c-mode-base-map [(meta return)] 'semantic-ia-complete-symbol-menu))


(c-set-offset 'substatement-open 0)
(c-set-offset 'member-init-intro '++)
(c-set-offset 'inline-open 0)
(c-set-offset 'comment-intro 0)
(c-set-offset 'label 0)
(c-set-offset 'arglist-intro '+)

(hs-minor-mode 1)
(hide-ifdef-mode 1)
(setq hide-ifdef-lines t) ; #if 등까지 가려버리자
(setq hide-ifdef-read-only t) ; hide-ifdef-mode 에선 readonly 로 사용해야지
)

(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)


;; TODO, BUG 등에 강조표시
(font-lock-add-keywords 'c++-mode
'(("\\<\\(FIXME\\):" 1 c-nonbreakable-space-face prepend)
("\\<\\(TODO\\):" 1 c-nonbreakable-space-face prepend)
("\\<\\(BUG\\):" 1 c-nonbreakable-space-face prepend)
("\\<\\(NOTE\\):" 1 c-nonbreakable-space-face prepend)))


;;;; eshell 설정
;; http://www.emacswiki.org/cgi-bin/wiki/CategoryEshell

;; From http://www.emacswiki.org/cgi-bin/wiki.pl?EshellFunctions
(defun eshell/emacs (&rest args)
"Open a file in emacs. Some habits die hard."
(if (null args)
;; If I just ran "emacs", I probably expect to be launching
;; Emacs, which is rather silly since I'm already in Emacs.
;; So just pretend to do what I ask.
(bury-buffer)
;; We have to expand the file names or else weird stuff happens
;; when you try to open a bunch of different files in wildly
;; different places in the filesystem.
(mapc #'find-file (mapcar #'expand-file-name args))))


;; from http://www.emacswiki.org/cgi-bin/wiki.pl/EshellInteractivelyRemove
(setq eshell-cp-interactive-query t
eshell-ln-interactive-query t
eshell-mv-interactive-query t
eshell-rm-interactive-query t
eshell-mv-overwrite-files nil)


;; http://www.emacswiki.org/cgi-bin/wiki.pl/EshellWThirtyTwo
(when win32p
(defun eshell/start (FILE)
"Invoke (w32-shell-execute \"Open\" FILE) and substitute slashes for backslashes"
(w32-shell-execute "Open"
(subst-char-in-string ?\\ ?/ (expand-file-name FILE))) nil))

;; eshell 스크롤, 아직 원하는대로 돌지 않는다.
;; http://www.emacswiki.org/cgi-bin/wiki/EshellScrolling
(setq eshell-scroll-show-maximum-output t
eshell-scroll-to-bottom-on-output nil)

;; 종료시에 히스토리 세이브 할거냐고 물어보지 말고 걍 세이브해라
(setq eshell-save-history-on-exit t)

;; 용량 보기 좋게
(setq eshell-ls-initial-args '("-h"))

;; win32 에서 ls -al 이 모양이 깨지는 문제

;; 음 이것참. 그럴듯한 방법을 모르겠네. 그냥 소스를 수정해버렸다.
;; em-ls.el 의 eshell-ls-file 코드중 format-time-string 을 만드는
;; 부분이 있는데 이중 "%b %e " 로 된 부분을 "%2b-%d " 로 바꿔버렸다.




;;;; word count
;; from http://www.emacswiki.org/cgi-bin/wiki/WordCount
;; 자주 쓰지 않는거라 그냥 지웠다. 필요하면 위 링크를 보자





;;;; planner mode 설정(planner 파일이 있을때만 로딩되도록 했다)
;; http://www.emacswiki.org/cgi-bin/wiki/PlannerMode

;; muse port 를 쓰면서 이쪽은 주석처리 했다. muse port 설정은 아랫부분을 찾아볼것
;; (when (file-exists-p "~/.emacs_plugin/planner")
;; (add-to-list 'load-path "~/.emacs_plugin/emacs-wiki")
;; (add-to-list 'load-path "~/.emacs_plugin/planner")
;; (require 'planner)
;; (planner-option-customized 'planner-directory "~/emacs/plans")
;; (planner-option-customized 'planner-publishing-directory
;; "~/emacs/published_plans")
;; (setq planner-carry-tasks-forward t)
;; (add-hook 'planner-mode-hook 'turn-on-auto-fill))



;;;; browse-url 설정(windows 환경일때는 iexplore 를 쓰도록)

(when win32p
(setq
html-viewer "C:/Program Files/Internet Explore/IEXPLORE.exe"
browse-url-generic-program "C:/Program Files/Internet Explore/IEXPLORE.exe"))
;;(goto-address) ; 요 모드 기억해두자



;;;; FFAP(Finding Files and URLs at Point)
;; ido 를 쓰면서 이놈 뺀다.
;;(ffap-bindings)

;; ffaq-c-path 는 vim 의 includeexpr 같은놈으로, ffap 시의 path 를 지정해 준다
;; ffap-bindings 을 뺐지만 ido 가 ffap 의 코드를 그대로 썼다 하니 ffap-c-path 값은 살려둔다.
(setq ffap-c-path
(cond (win32p
'("C:/Program Files/Microsoft Platform SDK/Include"
"C:/Program Files/Microsoft Visual Studio 8/VC/include"
"C:/Program Files/Microsoft Visual Studio 8/VC/atlmfc/include"
"C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include"))
(t ; win32 가 아니면 유닉스라고 생각.
'("~/boost/include/boost-1_38"
"/usr/include"
"/usr/include/c++/4.3"
"/usr/local/include"
"/usr/X11R6/include"
))))

;;;; putty 를 통해 접속한경우를 위해서(미완성)
;; 아직은 코딩할때 vim 쓰기 때문에.. 이부분 업데이트는 최후에 한다.

(unless window-system
(global-hl-line-mode -1)

(global-set-key "\C-h" 'backward-delete-char)
(global-set-key "\M-?" 'help-command)
(menu-bar-mode nil)

(global-set-key "\e[A" 'previous-line) ; VT100 small keypad up arrow
(global-set-key "\e[B" 'next-line) ; VT100 small keypad down arrow
(global-set-key "\e[C" 'forward-char) ; VT100 small keypad right arrow
(global-set-key "\e[D" 'backward-char) ; VT100 small keypad left arrow

(global-set-key "\e[2~" 'overwrite-mode) ; insert
(global-set-key "\e[1~" 'beginning-of-line) ; home
(global-set-key "\e[4~" 'end-of-line) ; end
(global-set-key "\e[5~" 'scroll-down) ; page up
(global-set-key "\e[6~" 'scroll-up)) ; page down



;;;; vxml 편집을 위해( 확장자별로 뭔가 해줄때의 샘플)
(add-to-list 'auto-mode-alist
(cons (concat "\\." (regexp-opt '("vxml" "vxml" "vxml") t) "\\'")
'xml-mode))


;;;; word-at-point 로 영어사전 검색
;; 햐.. 몇줄안되지만 elisp 처음 써보는거라 힘들었다.
;; thingatpt 의 word-at-point ( thing-at-point 의 alias ) 의 존재를 모르고
;; word-at-point 를 만들어 볼려고 고생했었는데.. thingatpt 의 존재를 알게되서 다행이다
;; 키바인딩을 해야 하는데.. 뭘로 할까? vim 이면 <Leader>dic 정도로 했을텐데..

(require 'thingatpt)
;;(setq yoonkn-dic-dicurl "http://kr.engdic.yahoo.com/search/engdic?p=%s")
;;(setq yoonkn-dic-dicurl "http://dic.naver.com/search.naver?query=%s")
(setq yoonkn-dic-dicurl "http://dic.yahoo.co.kr/search/all/search.html?p=%s")
(defun yoonkn-dic-at-point ()
(interactive)
(browse-url (format yoonkn-dic-dicurl (word-at-point))))
(defun yoonkn-cdic ()
"직접 만든 cdic.exe 를 써먹기위한 함수
cdic 소스는 svn://yoonkn.dyndns.org/scratch/trunk/cdic 에 있다"

(interactive)
(let ((command (format "cdic.exe \"%s\"" (word-at-point))))
(save-excursion
(set-buffer (get-buffer-create "*cdic*"))
(local-set-key (kbd "q") '(lambda () (interactive) (kill-buffer (current-buffer))))
(erase-buffer)
(insert (shell-command-to-string command))
(beginning-of-buffer)
(switch-to-buffer "*cdic*"))))
(when win32p
(global-set-key [(super shift w)] 'yoonkn-dic-at-point)
(global-set-key [(super w)] 'yoonkn-cdic)
)




;;;; backup 설정
;; 나는 작업 디렉토리에 백업파일이 남는것을 싫어한다
;; backup-by-coping 이라는 중요한 변수가 있는데, 메뉴얼을 봐라

(setq backup-directory-alist '(("." . "~/.emacs_backup")))
(setq
version-control t ; 백업을 여러벌한다
kept-old-versions 2 ; oldest 백업 2개는 유지
kept-new-versions 3 ; newest 백업 3개 유지
delete-old-versions t) ; 지울때마다 묻지 않도록



;;;; M-x compile 설정

(require 'compile)


;; 내가 원하는 빌드 과정을 간단히 적으면
;;
;; 1. 어떤 코드를 수정을 하다가 빌드를 하려는 마음이 생기면
;; 2. Makefile ( 또는 *.sln ) 이 존재하는 디렉토리로 가서
;; 3. 적절한 빌드 명령 (make 또는 devenv) 을 내리고
;; 4. 원래의 코드 작성으로 돌아온다.
;;
;; 위와 같다.
;; 아래 함수는 그런 일을 해주는데 간단히 설명을 적으면
;;
;; .emacs-dirvars 등을 통해 yoonkn-build-option 의 값을
;; (:wc "c:/tmp/a/build" :cmd "make -k ")
;; 이런식으로 지정을 해두고 아래 함수를 실행하면
;; 현재 작업 디렉토리를 기억해두고 wc 로 지정된 디렉토리로 가서
;; cmd 로 지정된 명령을 실행후 기억해둔 작업디렉토리로 돌아오게 된다.
;;
;; 2008/12/19
;; dirvars 에 해당하는 기능이 emacs 에 정식으로 들어와서 그쪽을 쓰도록
;; 했다. 뭐 사실 yoonkn-build 는 안바꿔도 되지만 수정 하는 김에 plist
;; 에서 alist 형태로 바꿨다.
;;
;; 세팅은 아래 코드 참고
;;
;; (setq project-directory-alist nil)
;; (define-project-bindings 'mao
;; '((nil . ((yoonkn-build-option . ((source-directory . "~/scratch/voceweb/libbrpc")
;; (build-directory . "/tmp/mao")
;; (build-command . "make ")))))))
;; (set-directory-project "~/scratch/voceweb/libbrpc" 'mao)
;;
(defun yoonkn-build ()
(interactive)
(if (and (boundp 'yoonkn-build-option)
(not (null yoonkn-build-option)))
(let ((pwd (substring (pwd) (length "Directory ")))
(wc (cdr (assq 'build-directory yoonkn-build-option)))
(compile-command (cdr (assq 'build-command yoonkn-build-option))))
(unwind-protect
(progn
(cd wc)
(call-interactively 'compile))
(cd pwd)))
(call-interactively 'compile)))

(global-set-key [f7] 'yoonkn-build) ; visual studio 처럼 f7 매핑
(global-set-key [(f4)] 'next-error) ; M-x grep 에서도 쓸만하다
(global-set-key [(shift f4)] 'previous-error)

(defmacro yoonkn-enable-flymake-mode (pattern hook)
"hook 에 pattern 을 검사해서 통과한 경우에만 flymake-mode 를 켜는 함수를 추가한다.

사용예:
(yoonkn-enable-flymake-mode \"\\`/home/yoonkn/scratch/voceweb/mao\" 'c-mode-common-hook)"

`(add-hook ,hook '(lambda ()
(let ((path (buffer-file-name)))
(when (and path (string-match ,pattern path))
(flymake-mode-on))))))

(defmacro defproject/yoonkn (name root builddir buildcmd &optional flymake-enable-modes)
"per-directory 로컬변수 세팅이 반복되는 작업이라 매크로를 만들었다.

사용예:
(defproject/yoonkn 'mao \"~/scratch/voceweb/mao\" \"~/tmp/mao\" \"make \" '(c-mode-common-hook))
(defproject/yoonkn 'boost \"~/scratch/boost\" \"~/tmp/boost\" \"make \")
"

`(progn
(define-project-bindings ,name
'((nil . ((yoonkn-build-option . ((build-directory . ,builddir)
(build-command . ,buildcmd)))))))
(set-directory-project ,root ,name)
;; flymake-enable-modes 가 지정된경우 각각의 모드마다 후킹함수 추가
(loop for mode in ,flymake-enable-modes
collect (yoonkn-enable-flymake-mode (concat "\\`" (expand-file-name ,root)) mode))))


;;;; cmake-mode
(add-to-list 'auto-mode-alist '("\\`CMakeLists\\.txt\\'" . cmake-mode))
(add-to-list 'auto-mode-alist '("\\.cmake\\'" . cmake-mode))
(autoload 'cmake-mode "~/emacs/cmake-mode.el" t)


;;;; psvn.el subversion 지원
;; ~/emacs 폴더 안에 psvn.el(http://www.xsteve.at/prg/emacs/psvn.el) 을 집어넣었다.
;; vim 의 subversion 지원 플러그인보다 불편한것 같다
;; http://www.xsteve.at/prg/index.html 는 좋은 내용이 많으니 한번씩 가보자
;; 이곳의 .emacs 는 내가 지금까지 본것중에는 가장 방대하더라

(add-to-list 'load-path "~/emacs")
(require 'psvn)
(setq svn-status-default-log-arguments "--verbose")


;;;; F12 키를 누르면 *svn-status* 를 바로 보도록
;; 내가주로 코딩을 할때 svn-status 를 자주 쓰기때문에 이렇게 만들어 둔다.
;; F12 에 매핑할 가치가 있다..
;;
;; (mapcar #'buffer-name (buffer-list)) 로 현재 버퍼들의 이름을 따오고
;; (remove-if-not .. ) 로 *svn-statur* 를 찾아서
;; 있다면, switch-to-buffer
;; 없다면 svn-status 를 실행
;;
(defun switch-to-svn-status-buffer ()
"if there is a buffer named *svn-statys*, switch to it.
or execute svn-status"

(interactive)
(if (remove-if-not #'(lambda (x) (string-equal "*svn-status*" x))
(mapcar #'buffer-name (buffer-list)))
(switch-to-buffer "*svn-status*")
(call-interactively 'svn-status)))
;; (global-set-key [(f12)] 'switch-to-svn-status-buffer)


;;;; 이건 C-u F12 로 현재 버퍼 기억, F12 로 그 버퍼로 점프
(defun yoonkn/quick-switch-buffer ()
"f12 에 매핑을 했다면 C-u f12 를 눌러서 현재 버퍼를 기억해두고
f12 를 누르면 그 버퍼로 뿅"

(interactive)
(if current-prefix-arg
(setq yoonkn/quick-switch-buffer-registered (current-buffer))
(switch-to-buffer yoonkn/quick-switch-buffer-registered)))
(global-set-key [(f12)] 'yoonkn/quick-switch-buffer)



;;;; darcsum.el
;; http://chneukirchen.org/repos/darcsum/
;; http://darcs.net/DarcsWiki/DarcsumMode
;;
;; 전에는 에러가 나서 못쓰고있었는데, 갑자기 생각나서 새버전을 받아보니
;; 잘 돌아가더라. M-F12 를 darcsum-whatsnew 에 매핑도 해둔다.
;; (require 'darcsum)
;; (defun switch-to-darcsum-buffer ()
;; (interactive)
;; (if (remove-if-not #'(lambda (x) (string-equal "*darcs*" x))
;; (mapcar #'buffer-name (buffer-list)))
;; (switch-to-buffer "*darcs*")
;; (call-interactively 'darcsum-whatsnew)))
;; (global-set-key [(meta f12)] 'switch-to-darcsum-buffer)




;;;; ediff 설정

(setq ediff-window-setup-function 'ediff-setup-windows-plain)
(setq ediff-split-window-function 'split-window-horizontally)


;;;; auto-insert 설정들
;; http://www.emacswiki.org/cgi-bin/wiki/AutoInsertMode
;; 의 내용을 바탕으로 한다.

(require 'autoinsert)
(auto-insert-mode)
(setq auto-insert-directory "~/emacs/autoinsert/")
(setq auto-insert-query nil)
(define-auto-insert "\\<Makefile\\'" "autoinsert.makefile")
(define-auto-insert "\\.py\\'" "autoinsert.py")
(define-auto-insert "\\.pyw\\'" "autoinsert.py")
(define-auto-insert "\\TODO\\'" "autoinsert.org")
(define-auto-insert "\\README\\'" "autoinsert.org")
;;(define-auto-insert ".emacs-dirvars" "emacs-dirvars")
(define-auto-insert "\\<CMakeLists\\.txt\\'" "CMakeLists.txt")
(define-auto-insert "\\<version\\.cmake\\'" "version.cmake")
(define-auto-insert "\\<misc\\.cmake\\'" "misc.cmake")
(define-auto-insert "\\.erl\\'" "foo.erl")
(define-auto-insert "\\.hgignore\\'" "hgignore")
(define-auto-insert "^\\.dired$" "autoinsert.dired")
(define-auto-insert "\\<build.xml\\'" "build.xml")
(define-auto-insert "\\<minunit\\.h\\'" "minunit.h")
;; (define-auto-insert "\\<\\.dir-settings.el\\'" "autoinsert.dir-settings.el")

(setq auto-insert-alist
(append auto-insert-alist
`((("\\.\\([Hh]\\|hh\\|hpp\\)\\'" . "C / C++ header")
"" (yoonkn-auto-insert-cpp-header))
(("\\.\\([Cc]\\|cc\\|cpp\\)\\'" . "C / C++ body")
"" (yoonkn-auto-insert-cpp-body))
(("\\.emacs-dirvars\\'" . ".emacs-dirvars")
"" (yoonkn-auto-insert-emacs-dirvars)))))

(defun yoonkn-auto-insert-cpp-header ()
"__HEADER_H__ 형태의 가드를 삽입한다"
(let ((guard (upcase
(replace-regexp-in-string "\\." "_"
(file-relative-name (buffer-file-name))))))
(format "#pragma once
#ifndef __%s__
#define __%s__


#endif // #ifndef __%s__"
guard guard guard)))

(defun yoonkn-auto-insert-cpp-body ()
(let*
((stem
(file-name-sans-extension buffer-file-name))
(header (cond
((file-exists-p (concat stem ".h"))
(file-name-nondirectory (concat stem ".h")))
((file-exists-p (concat stem ".hpp"))
(file-name-nondirectory (concat stem ".hpp")))
((file-exists-p (concat stem ".hh"))
(file-name-nondirectory (concat stem ".hh"))))))
(format "#include \"%s\"

"
header)))



;; yoonkn-build 를 주로 windows, msvc 에서만 쓰다 보니 .emacs-dirvars
;; 생성시 msvc 용의 yoonkn-build-option 을 만들도록 했다.
(defun yoonkn-auto-insert-emacs-dirvars ()
(let* ((dir default-directory)
(sln (concat (file-name-nondirectory (directory-file-name dir)) ".sln"))
(cmd (format "run-devenv /build Debug %s" sln)))
(format "yoonkn-build-option: ((source-directory . \"%s\") (build-directory . \"%s\") (build-command . \"%s\"))"
dir dir cmd)))


;;;; cedet 설정
;; http://cedet.sourceforge.net/ 에서 받을수 있다.
;; http://xtalk.msk.su/~ott/en/writings/emacs-devenv/EmacsCedet.html 참고
(let ((cedet-mode-path "~/.emacs.d/cedet-1.0pre6"))
(when (file-accessible-directory-p cedet-mode-path)
(load-file (format "%s/common/cedet.el" cedet-mode-path))
(global-ede-mode 1)
(semantic-load-enable-code-helpers)
(global-srecode-minor-mode 1)
(require 'semantic-ia)
(require 'semantic-gcc)
(semantic-add-system-include "/home/yoonkn/boost/include/boost-1_38" 'c++-mode)
(require 'semanticdb)
(global-semanticdb-minor-mode 1)
;(require 'semanticdb-global)
;(semanticdb-enable-gnu-global-databases 'c-mode)
;(semanticdb-enable-gnu-global-databases 'c++-mode)
;(semantic-load-enable-all-exuberent-ctags-support)

(global-semantic-tag-folding-mode 1)
))

(when nil
(with-extra-package
"cedet-1.0pre4"
(setq semantic-load-turn-useful-things-on t)
(if unixp
(require 'cedet) ; ubuntu 에서는 require 로 충분
(load (format "%s/cedet-1.0pre4/common/cedet" extra-packages))) ; require 가 안되서 드럽네
;; 보기 흉한것들은 꺼버렸다
(global-semantic-decoration-mode -1)
(global-semantic-stickyfunc-mode -1)
;; semantic 이 쓰는 includepath 인데, ffap 의 설정과 유사하니 재사용한다.
(setq semantic-default-c-path ffap-c-path)
;;imenu 와 semantic
(add-hook 'semantic-init-hooks (lambda ()
(imenu-add-to-menubar "Tokens")))
;; semantic database
;; 이부분은 머신마다 다르니, office.el 또는 home.el 등에서 설정하자.
(require 'semanticdb)
(global-semanticdb-minor-mode 1)
(setq semanticdb-project-roots
(list "d:/src/rrun"
"d:/src/Cleopatra/chairking"))))

;;;; ecb 설정
;; http://ecb.sourceforge.net/

(with-extra-package
"ecb-2.32"
(require 'ecb-autoloads)

;; 윈도스럽게, 왼쪽버튼과 오른쪽 버튼을 쓰는게 편하다.
(setq ecb-primary-secondary-mouse-buttons (quote mouse-1--mouse-2))

;; 초기 팁 알려주는거 끈다
(setq ecb-tip-of-the-day nil)

;; ecb-source-path 를 세팅해두면 좀더 편해진다.
;; cedet 와 같이 ffap-c-path 를 재사용했다.
(add-hook 'ecb-activate-hook
'(lambda ()
(setq ecb-source-path
(append ecb-source-path ffap-c-path))))

;; method-buffer 외에는 별 필요가 없어보인다.(vim 의 TagList 를 원하고 있기 때문에)
;; 음 ecb-layout-name 은 setq 로 지정하지 말고 customize 로만 바꿔야 한다고 문서에 있네..
;; 일단 주석처리 한다.
;;(setq ecb-layout-name "left9")
)



;;;; renumber regeion
;; http://www.emacswiki.org/cgi-bin/wiki/RenumberList
;; 주석문 안의 region 에는 적용안되는게 좀 아쉽다.
;; 그냥 정규식에 * 이후도 포함하게 해버릴까?
;; 모드마다 주석인지 감지해서 돌아갔으면 좋겠는데..

(defun renumber-list (start end &optional num)
"Renumber the list items in the current START..END region.
If optional prefix arg NUM is given, start numbering from that number
instead of 1."

(interactive "*r\np")
(save-excursion
(goto-char start)
(setq num (or num 1))
(save-match-data
(while (re-search-forward "^[0-9]+" end t)
(replace-match (number-to-string num))
(setq num (1+ num))))))




;;;; vim 의 % 처럼, 짝이 맞는 괄호를 찾아주는 놈
;; http://www.emacswiki.org/cgi-bin/wiki/MatchParenthesis
;; 에서 가져왔다.
(defun match-paren ()
"% command of vi"
(interactive)
(let ((char (char-after (point))))
(cond ((memq char '(?\( ?\{ ?\[))
(forward-sexp 1)
(backward-char 1))
((memq char '(?\) ?\} ?\]))
(forward-char 1)
(backward-sexp 1))
(t (call-interactively 'self-insert-command)))))

;; (defun match-paren (arg)
;; "Go to the matching paren if on a paren; otherwise insert %."
;; (interactive "p")
;; (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
;; ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
;; (t (self-insert-command (or arg 1)))))

;; % 에 바로 바인딩했다.
;; 필요하다면, C-q % 를 쓰자
(global-set-key (kbd "%") 'match-paren)



;;;; timestamp 입력
;; 나중에 주석을 달고 자동으로 넣는다던지.. 등등할때 쓸려고 만들어 둔다.
;; howm-mode 인경우엔 [2005-06-08] 의 형태로 입력하도록 했다.
;; 추후에도 특별한 상황에 특별한 포맷스트링을 쓰려면, cond 부분에 적당히 추가해주면 된다.
(defun yoonkn-insert-timestamp ()
(interactive)
(insert (format-time-string
(cond ((and (featurep 'howm) howm-mode) "[%Y-%m-%d]")
(t "%Y/%m/%d %H:%M:%S")))))
(global-set-key (kbd "ESC ESC tm") 'yoonkn-insert-timestamp) ; tm 은 time 의 tm


;;;; emacs-lisp-mode 설정

(add-hook 'emacs-lisp-mode-hook
(lambda ()
(progn
(eldoc-mode 1)

;; hs-minor-mode 가 더 어울리겠지만, 주석 ;;;; 로 아웃아리닝을 하기위해서
;; outline-minor-mode 를 골랐다. hs-minor-mode 를 켜고 정규식을 바꿔주려고 했는데
;; 방법을 아직 못찾았다.
(outline-minor-mode 1)
(local-set-key (kbd "RET") 'newline-and-indent)
(setq indent-tabs-mode nil))))


;;;; Xref 설정. 이거 아주 좋은데 상용인게 문제

;; (when (file-exists-p "~/.emacs_plugin/xref")
;; (setq exec-path (cons "~/.emacs_plugin/xref" exec-path))
;; (setq load-path (cons "~/.emacs_plugin/xref/emacs" load-path))
;; (load "xrefactory"))



;;;; python-mode 설정
;; http://sourceforge.net/projects/python-mode/ 의 python-mode 를 받아 설치해야만 한다.
(when win32p
(with-extra-package
"python-mode-1.0"
(setq auto-mode-alist (cons '("\\.py\\'" . python-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.pyw\\'" . python-mode) auto-mode-alist))

(setq interpreter-mode-alist (cons '("python" . python-mode)
interpreter-mode-alist))
(autoload 'python-mode "python-mode" "Python editing mode." t)))

;; emacs 22 부터는 eldoc-mode 가 python 지원
(add-hook 'python-mode-hook
'(lambda () (eldoc-mode 1)) t)

;;; python flymake
;; pylint 와 http://www.emacswiki.org/cgi-bin/wiki/PythonMode 의 epylint 스크립트가 필요
(when (load "flymake" t)
(defun flymake-pylint-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "epylint" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-pylint-init)))
(add-hook 'python-mode-hook
'(lambda () (flymake-mode 1)))


;; ffap 에 python module 을 찾는 기능을 넣기 위해서, 구글링해서 가져온 코드들
;;
;; ffap.py 의 내용은 아래와 같다.
;; import imp, sys, string
;;
;; def find(parts, path=None):
;; top = parts[0]
;; file, pathname, stuff = imp.find_module(top, path)
;; if not parts[1:]:
;; return pathname
;; mod = imp.load_module(top, file, pathname, stuff)
;; return find(parts[1:], mod.__path__)
;;
;; if __name__ == '__main__':
;; try:
;; sys.stdout.write(find(string.split(sys.argv[1], '.')))
;; except ImportError:
;; pass

(defun ffap-python ()
(interactive)
(let ((keyword (word-at-point))) ; word-at-point 가 어쩌구.저쩌구 에서 저쩌구 만 가져오기 때문에 깔끔하게 돌지 못하더라.
(let ((text (shell-command-to-string
(format "cmd.exe /c \"%s\" %s"
(expand-file-name "~/emacs/ffap.py")
(read-from-minibuffer "module? " keyword)))))
(find-file text))))


;;;; scons
(add-to-list 'auto-mode-alist '("\\`SConstruct\\'" . python-mode))
(define-auto-insert "\\`SConstruct\\'" "SConstruct")

;;;; ispell 설정
;; 영어로 주석을 달기 위해서 flyspell-prog-mode 를 쓰고싶었는데,
;; 이거 켜니까 너무 느리구나.
;; 그냥 aspell 깔아만 둔다.
;; aspell 은 http://aspell.sourceforge.net/ 에서 윈도용 포트도 받을수 있다.

(when win32p
(setq-default ispell-program-name "C:\\Program Files\\Aspell\\bin\\aspell"))
(when unixp
(setq-default ispell-program-name "aspell"))




;;;; table.el 사용
;; http://table.sourceforge.net/
;; 테이블 작성할때 괜찮아 보이길래 주워왔다.
;; M-x table-insert 로 사용시작.
;; 역시 한글은 잘 안된다.
;; 폰트를 다른것으로 바꿔보면 제대로 보이게 되는데,
;; 음 왜 쿠리어로는 안되지?
;; 프비에서 fixed 폰트를 쓰면 정상으로 보이더라.
;; 내가 주로 쓰는 쿠리어뉴, 루시다, 선 라운드고딕은 모두 비정상이다.

;; (require 'table)




;;;; RSS reader, newsticker.el 설정

;; SharpReader 로 대체했다.
;; newsticker.el 은 많은 사이트를 등록했을때 느려지는 현상이 있더라.
;; 동작하는 방식은 newsticker.el 에 만족을 하지만
;; 어쩔수 없이 SharpReader 로 옮겨갔다

;; http://www.nongnu.org/newsticker/ (http://savannah.nongnu.org/projects/newsticker/)
;; M-x newsticker-start 로 시작
;; M-x newsticker-show-news 로 뉴스를 보면 된다.
;; newsticker-url-list 는 4개의 element 를 가지는데, 각각
;; (이름 주소 시작시각 인터벌)
;; 이다.( \C-h v newsticker-url-list 로 좀더 자세한 도움말)

;; (autoload 'newsticker-start "newsticker" "Emacs Newsticker" t)
;; (setq newsticker-url-list
;; '(
;; ;;; 한글 사이트
;; ;;("bbs.kldp.org" "http://bbs.kldp.org/rss.php" nil 1800)
;; ("gpwiki" "http://gpwiki.org/index.php?title=Special:Recentchanges&feed=rss" nil 3600)
;; ("bsdforum.or.kr" "http://bsdforum.or.kr/rss.php" nil 3600)
;; ("GPG" "http://www.gpgstudy.com/forum_rdf.php" nil 3600)
;; ;;("database.sarang.net" "http://database.sarang.net/rss.php" nil 3600) ; 으.. 이거 깨진다. 인코딩문제인듯?
;; ("bbspython" "http://bbs.python.or.kr/rss.php" nil 3600)
;; ;;("hanbit" "http://www.hanbitbook.co.kr/sync/rss.php" nil 3600)

;; ;;; 개발관련(영문)
;; ("SlashdotDeveloperSection" "http://developers.slashdot.org/developers.rss" nil 3600)
;; ("codeguru" "http://www.codeguru.com/icom_includes/feeds/codeguru/rss-cpp.xml" nil 3600)
;; ("codeproject" "http://www.codeproject.com/webservices/articlerss.aspx?cat=2" nil 3600)

;; ;;; MS 관련 http://msdn.microsoft.com/aboutmsdn/rss/
;; ("MSDN" "http://msdn.microsoft.com/rss.xml" nil 3600)
;; ("VisualC++" "http://msdn.microsoft.com/visualc/rss.xml" nil 3600)
;; ("MSDNTV" "http://msdn.microsoft.com/msdntv/rss.xml" nil 3600)
;; ("channel9" "http://channel9.msdn.com/rss.aspx" nil 3600)

;; ;;; 게임개발관련(영문)
;; ("gamasutra-news" "http://www.gamasutra.com/include/news_xml_include.xml" nil 3600)
;; ("gamasutra-fetures" "http://www.gamasutra.com/include/articles_xml_include.xml" nil 3600)
;; ("gamedev" "http://www.gamedev.net/xml/" nil 3600)

;; ;;; 뉴스
;; ("zdnet-news" "http://www.zdnet.com/2509-1_22-0-20.xml" nil 3600)
;; ))

;; ;; 읽지 않은 아이템들이 old 로 마킹되는것을 막았다.
;; (setq newsticker-automatically-mark-items-as-old nil)

;; ;; 헤더는 * 붙이고 로고이미지를 뺐다. 아이템마다는 ** 를 붙여서 outline-mode 삘이 나도록 했다.
;; ;; M-x customize-group newsticker 로 세팅한후 가져온값
;; ;; face 조절은 적당히 모니터에따라 커스터마이징해서 쓰자
;; (setq newsticker-heading-format "* %t %d %s")
;; (setq newsticker-item-format "** %t %d")

;; ;; wget 이 맛가는 경우가 있길래.
;; (setq newsticker-wget-arguments '("--timeout=30" "-q" "-O" "-"))

;; ;; 사무실과 집에서는 newsticker 처음부터 띄우자
;; ;;(when (or officep homep) (newsticker-start))

;; ;; ESC ESC rss 를 newsticker-show-news 에 바인딩
;; (global-set-key (kbd "ESC ESC rss") 'newsticker-show-news)



;;;; lua-mode 설정
;; lua-mode.el 은 구글링해서 lua 관련페이지에서 주워왔다.
;; 나중에 emacs 에 정식으로 lua-mode 가 지원되면 지우자
(require 'lua-mode)



;;;; w32-find-dired
;; http://www.emacswiki.org/cgi-bin/wiki/WThirtyTwoFindDired
;; w32-find-dired.el 때문에 findr.el 도 추가되었는데,
;; 이놈이 쏠쏠하다.
(require 'w32-find-dired)


;;;; Makefile.* 를 열때 makefile-mode 로 뜨도록
(add-to-list 'auto-mode-alist '("\\`Makefile\\.[[:alpha:]]*" . makefile-mode))


;;;; yoonkn-grep-project
;;
;; 아래 주석의 세줄은 이전버전의 yoonkn-grep-semantic-project-root 에서 배운것들로,
;; 힘들게 찾았던것이니 주석에 남겨둔다.
;;
;; convert-standard-filename 가 유닉스 스타일 path 를 윈도 스타일 path 로 바꿔주는 함수
;; elt 는 시퀀스(배열) 에서 n 번째 엘리먼트를 얻을때
;; 그리고 백쿼트, `(이건평가안되고 ,(이건평가된다)) 는 꼭 외워두자
;;

;; (defun yoonkn-grep-project ()
;; "현재 디렉토리, 또는 project-root 를 대상으로 gre-find(strfind.exe 를 이용한) 을 한다.

;; 만약 current-prefix-arg 가 지정되었거나, 현재 디렉토리가
;; 프로젝트관리하에 없다면 현재 디렉토리로 grep-find 를 하고,

;; current-prefix-arg 가 없고 현재 디렉토리가
;; semanticdb-project-roots 의 root 중 하나의 아래디렉토리라면 그
;; root 를 중심으로 findstr 를 한다"
;; (interactive)
;; (let ((project-root)
;; (command))
;; (setq project-root
;; (if current-prefix-arg
;; default-directory
;; (or
;; (let ((root nil)
;; (roots semanticdb-project-roots))
;; (while (and roots (not root))
;; (if (string-match
;; (concat "^" (regexp-quote (expand-file-name (car roots))))
;; (expand-file-name default-directory))
;; (setq root (car roots))
;; (setq roots (cdr roots))))
;; root)
;; default-directory)))
;; (setq command
;; (format "findstr /snD:\"%s\" *.el *.h *.cpp *.c *.py *.lisp *.org" project-root))
;; (set 'grep-find-command `(,command . ,(+ 17 (length project-root))))
;; (call-interactively 'grep-find)))

(defun yoonkn-grep-project ()
"yoonkn-build 에 지정된 src 디렉토리, 또는 현재 디렉토리를
대상으로 grep-find 를 한다. current-prefix-arg 가 있는경우엔 :src
를 무시하고 현재디렉토리를 대상으로 검색한다."

(interactive)
(let* ((project-root (expand-file-name (if current-prefix-arg
default-directory
(or (and (boundp 'yoonkn-build-option)
(cdr (assq 'source-directory yoonkn-build-option)))
default-directory))))
(grep-find-command (if win32p
(cons (format "findstr /snD:\"%s\" *.el *.h *.c *.cpp *.py *.lisp *.erl *.org " project-root)
(+ 17 (length project-root)))
(format "find %s -type f -print0 | xargs -0 -e grep -nH -e " project-root))))
(call-interactively 'grep-find)))


;; visual studio 의 키바인딩을 빌려왔다.
(global-set-key (kbd "C-S-f")
(if win32p
'yoonkn-grep-project
'grep-find))



;;;; ilisp-mode
;; gcl 을 과 함께 쓰기위한 ilisp 설정

;; (when (file-exists-p "~/.emacs_plugin/ilisp-20021222")

;; (add-to-list 'load-path "~/.emacs_plugin/ilisp-20021222")

;; (autoload 'gcl "ilisp" "Inferior GNU Common Lisp." t)

;; ;; 기본적으로 깔리는 gcl.bat 는 gcl binary 를 start 를 이용해 띄우고
;; ;; 있는데, 이럴경우 새창으로 떠버리기 때문에, emacs 내에서 같이 쓰지
;; ;; 못한다. start 를 제외한 gcl2.bat 를 만들어서 이놈을 불러주면 해결된다.
;; (setq gcl-program "C:/bin/GCL-2.6.5-ANSI/bin/gcl2.bat")
;; (setq inferior-lisp-program gcl-program)

;; (add-to-list 'auto-mode-alist '("\\.lisp\\'" . lisp-mode))
;; (add-to-list 'auto-mode-alist '("\\.lsp\\'" . lisp-mode))
;; (add-to-list 'auto-mode-alist '("\\.cl\\'" . lisp-mode))
;; (add-hook 'lisp-mode-hook '(lambda () (require 'ilisp)))

;; (setq common-lisp-hyperspec-root "file:/C:/bin/GCL-2.6.5-ANSI/doc/HyperSpec/")
;; (setq common-lisp-hyperspec-symbol-table "C:/bin/GCL-2.6.5-ANSI/doc/HyperSpec/Data/Map_Sym.txt")

;; ;; hyperspec-root
;; ;; (setq common-lisp-hyperspec-root
;; ;; "file:/home/joe/HyperSpec/")
;; ;; (setq common-lisp-hyperspec-symbol-table
;; ;; "/home/joe/HyperSpec/Data/Map_Sym.Txt")
;; )



;;;; paredit.el
;;; 이게 묘하게 기능이 많다. M-1 ( 등등 편한기능도 많고 이놈때문에
;;; 불편한점도 좀 있으니 잘 알아서 써먹자.
(autoload 'paredit-mode "paredit"
"Minor mode for pseudo-structurally editing Lisp code."
t)

;; http://www.emacswiki.org/cgi-bin/wiki/ParEdit 에서 주은 코드 이거 좋군
(mapc (lambda (mode)
(let ((hook (intern (concat (symbol-name mode)
"-mode-hook"))))
(add-hook hook (lambda () (paredit-mode +1)))))
'(emacs-lisp lisp inferior-lisp scheme clojure))



;;;; slime 설정
;; http://home.comcast.net/~bc19191/blog/040306.html 를 참고하자
;;
(when win32p ; 리눅스인경우는 clbuild 를 활용하기에 요로코롬
(with-extra-package
"slime"
(setq inferior-lisp-program "sbcl") ; SBCL 1.0 win32 용이 나와서 그놈을 써본다.
(setq slime-complete-symbol*-fancy t)
(require 'slime)
(add-hook 'lisp-mode-hook (lambda ()
(slime-mode t)
(setq indent-tabs-mode nil)))
(add-hook 'inferior-lisp-mode-hook (lambda () (inferior-slime-mode t)))
;; If you don't want eldoc-like behavior, comment out the following line
;; (slime-autodoc-mode)

(add-to-list 'auto-mode-alist '("\\.lsp\\'" . lisp-mode))
(add-to-list 'auto-mode-alist '("\\.cl\\'" . lisp-mode))

;; clisp 은 euc-kr 과 친하지 않으니 utf-8 을 쓰도록 하자
(add-to-list 'file-coding-system-alist '("\\.lisp\\'" . utf-8))
(add-to-list 'file-coding-system-alist '("\\.cl\\'" . utf-8))
(add-to-list 'file-coding-system-alist '("\\.lsp\\'" . utf-8))
;; slime 이 utf-8 을 쓰도록 한다.
(setq slime-net-coding-system 'utf-8-unix)

(define-key slime-mode-map (kbd "M-<return>") 'slime-fuzzy-complete-symbol)

(defun indent-or-slime-complete-symbol ()
"포인트(커서)가 단어 끝에 위치했다면 slime-complete-symbol 을
부르고 아니라면 인덴트"

(interactive)
(if (looking-at "\\>")
(slime-complete-symbol)
(indent-according-to-mode)))

;; bind return key to newline-and-indent
(add-hook 'slime-mode-hook (lambda ()
(local-set-key (kbd "RET") 'newline-and-indent)
(local-set-key (kbd "TAB") 'indent-or-slime-complete-symbol)))

;; slime-mode 에서 인덴트가 elisp 스타일로 되는것을 막기위해
;; http://www.cliki.net/SLIME%20Tips 에서 얻은 팁
(add-hook 'lisp-mode-hook (lambda ()
(set (make-local-variable 'lisp-indent-function)
'common-lisp-indent-function)))
(slime-setup '(slime-fancy
slime-fancy-inspector
slime-tramp
slime-asdf
slime-indentation
slime-fontifying-fu))))

;; (eval-after-load "slime"
;; '(progn
;; (slime-setup '(slime-fancy
;; slime-fancy-inspector
;; slime-asdf
;; slime-indentation
;; slime-fontifying-fu))
;; (slime-autodoc-mode)
;; (setq slime-complete-symbol*-fancy t)
;; (setq slime-complete-symbol-function 'slime-fuzzy-complete-symbol)))
;; (require 'slime)


;;;; webjump
;; 이전에 쓰던 yoonkn-help-* 함수들을 대신하기 위해서 webjump 를 이용한다.
;; 주로 코딩시 자주 쓰는 레퍼런스 사이트들을 등록할 생각.
(require 'webjump)
(global-set-key (kbd "ESC ESC bm") 'webjump) ; bm 은 bookmark 의미
(global-set-key (kbd "ESC ESC wj") 'webjump)
(setq webjump-sites
'(("emacs" . "http://www.gnu.org/software/emacs/manual/emacs.html")
("elisp-intro" . "http://www.gnu.org/software/emacs/emacs-lisp-intro/html_mono/emacs-lisp-intro.html")
("elisp-reference" . "http://www.gnu.org/software/emacs/elisp-manual/html_mono/elisp.html")
("msdn" . "http://msdn.microsoft.com/library/default.asp")
("msdn-forum" . "http://forums.microsoft.com/msdn/")
("iostream" . "http://www.cplusplus.com/ref/")
("stl" . "http://www.sgi.com/tech/stl/table_of_contents.html")
("sgi" . "http://www.sgi.com/tech/stl/")
("tr1" . "http://www.aristeia.com/EC3E/TR1_info.html")
("man" . "http://www.freebsd.org/cgi/man.cgi")
("wikipedia" . "http://en.wikipedia.org/wiki/Main_Page")
("koders" . "http://www.koders.com")
("c++faq" . "http://www.parashift.com/c++-faq-lite/index.html")
("python" . "http://www.python.org/doc/")
("erlang" . "http://www.erlang.org/doc.html")
("sbcl" . "http://www.sbcl.org/manual/")
("java" . "http://java.sun.com/javase/6/docs/api/")
("haskell" . "http://haskell.org/ghc/docs/latest/html/libraries/")))


;; ;;;; html-helper-mode
;; ;; http://www.nongnu.org/baol-hth/
;; ;; ASP,PHP 등을 편집하기 위한 모드
;; (autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
;; (setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist))
;; (setq auto-mode-alist (cons '("\\.asp$" . html-helper-mode) auto-mode-alist))
;; (setq auto-mode-alist (cons '("\\.phtml$" . html-helper-mode) auto-mode-alist))


;;;; visual-basic-mode
;; http://www.nongnu.org/baol-hth/
;; html-helper-mode 지원을 위해서
;; (autoload 'visual-basic-mode "visual-basic-mode" "Visual Basic mode." t)
;; (setq auto-mode-alist (append '(("\\.\\(frm\\|bas\\|cls\\)$" .
;; visual-basic-mode)) auto-mode-alist))


;;;; folding mode
;; http://www.emacswiki.org/cgi-bin/wiki/FoldingMode
;; http://www.chrislott.org/geek/emacs/n2n_folding_mode.php
;; (if (load "folding" 'nomessage 'noerror)
;; (folding-mode-add-find-file-hook))


;;;; use GNU GLOBAL
;;
;; xgtags.el 를 잠시 써봤는데, gtags.el 의 동작이 더 맘에 들어서 원복
;;
(load "~/emacs/gtags")
(add-hook 'c-mode-common-hook
(lambda () (gtags-mode 1)))
(global-set-key "\C-c\M-." 'gtags-find-rtag) ; gtags-find-rtag 는 매핑해서 써야지

;; gtags-mode 상태에서는 C-S-f 를 gtags 의 기능을 이용하도록 하자
(defun yoonkn%search-project-by-gtags ()
(interactive)
(if current-prefix-arg
(yoonkn-grep-project)
(gtags-find-pattern)))

(add-hook 'gtags-mode-hook
'(lambda ()
(local-set-key (kbd "C-S-f")
'yoonkn%search-project-by-gtags)))

;; 헐 힘들게 만들었다.
;; 리스트들을 join 해서 스트링으로 만드는것은 (mapconcat 'identity ffap-c-path "") 으로 하고
;; 거기에 loop collect 를 한번 써봤다.
;; (defun yoonkn%setenv-gtagslibpath (path-list)
;; (setenv "GTAGSLIBPATH"
;; (mapconcat 'identity
;; (loop for path in path-list
;; collect (concat (convert-standard-filename path) ";"))
;; ""
;; )))

;; 위의 함수를 이용해서 ffap-c-path 를 GTAGSLIBPATH 로 잡아주도록 하자.
;; dirvars.el 하고 같이 쓰려다 보니 find-file-hook 에 매달게 되었다.
;; 다른 hook 에 매달면 dirvars.el 통해서 ffap-c-path 가 바뀌기 전에 불려버리네..
;; (add-hook 'find-file-hook
;; '(lambda () (yoonkn%setenv-gtagslibpath ffap-c-path)))


;;;; use xcscope.el
;; 요거 존내 좋구나
;; gtags 의 깔끔함이 더 맘에 들지만 이것도 세팅해둔다
;; cscope-database-regexps 설정은 office.el 에 해둔다.
;; cscope 설치후엔 INCLUDEDIRS 환경변수를 잡는것을 잊지 말자
(require 'xcscope)

(defun yoonkn%select-other-window ()
"cscope-bury-buffer 가 오동작하길래 땜빵으로 만들었다"
(interactive)
(message "cscope-bury-buffer 가 정상작동하는지 확인해보고 이거 지워라!")
(select-window (previous-window))
(delete-other-windows))

(define-key cscope-list-entry-keymap [(return)] 'cscope-select-entry-one-window)
(define-key cscope-list-entry-keymap "q" 'yoonkn%select-other-window)


;;;; cdb-gud.el
;; MS 의 cdb.exe 를 쓰기 위해
;; http://www.emacswiki.org/elisp/cdb-gud.el
;; (load "cdb-gud")


;;;; quack.el
;; SICP 를 공부하기 위해서 scheme 모드를 설치했다.
;; http://www.neilvandyke.org/quack/
;; (setq quack-pltcollect-dirs '("C:/Program Files/PLT/collects/"))
;; (require 'quack)



;;;; howm
;; http://howm.sourceforge.jp/ 에서 받을수 있다.
;; planner 보다 좀더 나은듯
;;
;; NOTE 음. EmacsW32 의 문제인가.. emacs 를 새로 깔았더니 howm 을
;; .emacs 실행중에 읽으면 안되고 user init 이 다 끝난후에 불러야만
;; 로딩이 되는 문제가 있어서 window-setup-hook 에 매달아 뒀다.
(when nil
(add-to-list 'auto-mode-alist '("\\.howm$" . org-mode))
(add-hook 'window-setup-hook
(lambda ()
(with-extra-package
"howm-1.3.4"
(add-hook 'org-mode-hook 'howm-mode)
(let ((howm-installed-path (format "%s/howm-1.3.4" extra-packages)))
(defconst howm-en-dir (expand-file-name (concat howm-installed-path "/en")))
(add-to-list 'load-path howm-installed-path)
(setf howm-directory "~/emacs/howm/")
(require 'howm)
(setf howm-menu-todo-priority (- howm-huge-))))))) ; 지나간 TODO 들이 표시되는것을 막았다. 버전1.3.3 부터 이러더라.

;;;; RFC 가져오기
;; http://emacswiki.org/cgi-bin/wiki/JorgenSchaefersEmacsConfig
;; M-x rfc 후 0 또는 원하는 rfc 문서번호를 넣는다.
;; RFC 를 가져오는것 자체보다, 여러가지로 응용해볼만한 함수
(defun rfc (num)
"Show RFC NUM in a buffer."
(interactive "nRFC (0 for index): ")
(let ((url (if (zerop num)
"http://www.ietf.org/iesg/1rfc_index.txt"
(format "http://www.ietf.org/rfc/rfc%i.txt" num)))
(buf (get-buffer-create "*RFC*")))
(with-current-buffer buf
(let ((inhibit-read-only t))
(delete-region (point-min) (point-max))
(let ((proc (start-process "wget" buf "wget" "-q" "-O" "-" url)))
(set-process-sentinel proc 'rfc-sentinel))
(message "Getting RFC %i..." num)))))

(defun rfc-sentinel (proc event)
"Sentinel for `rfc'."
(with-current-buffer (process-buffer proc)
(goto-char (point-min))
(view-mode 1)
(when (fboundp 'rfcview-mode)
(rfcview-mode)))
(display-buffer (process-buffer proc)))



;;;; dired-do-kill-comment dired 모드중 선택된 파일의 주석 제거
;; 공부겸 짜봤다.
;; save-current-buffer, set-buffer, save-buffer 의 사용법과
;; dolist, dired-get-marked-files, find-file-noselect, 그외
;; count-lines, point-min, point-max 등의 용법을 봐두자.
(defun dired-do-kill-comment ()
"dired 모드중 선택된 파일들의 주석들을 지워준다. kill-comment 를
이용하기 때문에 주석이 지워지고 난후 공백이 남는다."

(interactive)
(dolist (file (dired-get-marked-files))
(save-current-buffer
(set-buffer (find-file-noselect file))
(message "%s 의 주석을 지우는 중입니다." file)
(kill-comment (count-lines (point-min) (point-max)))
(when (buffer-modified-p)
(message "%s 의 주석을 지웠습니다." file)
(save-buffer)))))


;;;; yoonkn-fortune
;; shell-command-to-string 의 함수를 몰랐을때는
;; (insert
;; (with-temp-buffer
;; (shell-command "fortune" t)
;; (buffer-string))))
;; 이렇게 만들어 썼었다.
;; (with-temp-buffer ... (buffer-string))
;; 은 기억해둘만한 표현이라 주석으로 남겨둔다.
(defun yoonkn-fortune ()
"시작시 fortune 을 보려고
http://www.pie.pe.kr/cgi-bin/moin.cgi/stupid_fortune_for_win32
를 짜고, 이런 함수를 만든다."

(interactive)
(insert (shell-command-to-string "fortune")))


;;;; yoonkn/create-file
;; emacs 초기화과정에 필요한 파일이 없는경우 그 파일을 생성해내기
;; 위해서 만든 함수인데 이걸 만든 현재는 아직 적용하지는 않았다. 대강
;; 만들어보고 테스트까지만 끝낸 상태.
(defun yoonkn/create-file (path content &optional overwrite)
"content 의 내용을 가지는 path 파일을 생성한다. 이미 파일이
존재하는 경우는 아무일도 하지 않지만, overwrite 가 t 로 주어지면
파일을 새로 덮어 쓰게 된다."

(interactive)
(when (or (not (file-exists-p path))
(eql overwrite t))
(set-buffer (find-file-noselect path))
(erase-buffer)
(insert content)
(save-buffer)
(kill-buffer nil)))

;;;; muse-mode
;;; 홈: http://www.mwolson.org/projects/MuseMode.html
;;; 문서: http://www.mwolson.org/static/doc/muse.html
(with-extra-package
"muse/lisp"
(require 'muse-mode)
(require 'muse-html)
(require 'muse-wiki)
;; (define-auto-insert "\\.muse\\'" "autoinsert.muse")
;; (add-to-list 'auto-mode-alist '("\\.muse\\'" . muse-mode))
(add-hook 'muse-mode-hook 'footnote-mode)
(setq muse-html-charset-default "euc-kr")
(setq muse-html-style-sheet
"<style type=\"text/css\">
html {
background-color: white;
color: black;
font-family: 맑은고딕, Verdana, Tahoma, Arial, sans-serif;
font-size: 0.9em;
}

body {
margin-left: 2%
}

p {
margin-top: 1%;
margin-left: 1%;
}


h1 { font-size: 210% }
h2 { font-size: 200% }
h3 { font-size: 190% }
h4 { font-size: 180% }

table
{
margin: 0.5em 0 0 0.5em;
border-collapse: collapse;
}

td
{
padding: 0.25em 0.5em 0.25em 0.5em;
border: 1pt solid #ADB9CC;
}

td p {
margin: 0;
padding: 0;
}

pre {
padding: 5px;
border: 1pt solid #AEBDCC;
background-color: #F3F5F7;
font-family: Consolas, Bitstream Bera Sans Mono, courier new, courier, monospace;
margin-left: 3%;
white-space: pre;
}
</style>
"
)
)

;;;; planner-mode (muse 지원 추가된 신버전)
;;; 원래의 planner 에서 planner-muse 를 쓰다가 planner 에 muse 지원이
;;; 추가되어서 다시 planner 에 맞는 세팅으로 수정
;;; 도움말은 http://www.mwolson.org/static/doc/planner.html
(with-extra-package
"planner"
(setq planner-project "WikiPlanner")
(load "planner")
(require 'planner)
(setq muse-project-alist
'(("WikiPlanner"
("~/emacs/plans"
:default "TaskPool"
:major-mode planner-mode
:visit-link planner-visit-link)
(:base "xhtml" :path "~/emacs/published_plans"))))
(setq mark-diary-entries-in-calendar t))


;;;; yoonkn-choose-random-line
(defun yoonkn-choose-random-line ()
"현재 버퍼 내에서 랜덤하게 10줄의 내용을 뽑아 보여준다.
CD 리스트중 랜덤하게 내용을 뽑고싶을때가 있어서 만들었다.

기억해둘만한 elisp 사용들은,

현재 버퍼의 줄수를 세고, 그중에 하나를 뽑아내는 random-line-number
지정된 줄의 내용을 가져오는 get-line-text
위의 함수들을 보기쉽도록 구분한 flet 용법
dotime 를 통한 반복문
princ 를 통해서 human-readable 한 출력 ( 시험삼아 print 로 바꿔서 출력해보자 )
new line 을 넣어주는 terpri ( common-lisp 의 fresh-line 함수는 지원되지 않았다 )
"

(interactive)
(flet ((random-line-number () (random (count-lines (point-min) (point-max))))
(get-line-text (num)
(save-excursion
(goto-line num)
(buffer-substring
(line-beginning-position)
(line-end-position))))
(get-random-line ()
(get-line-text (random-line-number))))
(dotimes (x 10)
(princ (get-random-line))
(terpri))))

;;;; darcs
;; (add-to-list 'vc-handled-backends 'DARCS)


;;;; yoonkn-execute-program
;;; http://www.pie.pe.kr/cgi-bin/moin.cgi/EmacsAsLauncher
;;; emacs 를 어플리케이션 런처로 이용
;;; launchy 를 쓰게되면서 더이상 쓰지 않게됐다.
(setq yoonkn-executable-program-list
'(("emacs" . "c:/bin/emacs/bin/emacs")
("notepad" . "notepad.exe")
("cmd" . "cmd.exe")))

(defun yoonkn-execute-program ()
"간단한 런처 함수. QuickCut 이란 런처로부터 동기를 얻고 webjump
와 iswitchb 패키지를 참고해서 작성했다. howm 을 참고해서
메이저모드로 짜고싶었는데 일단 간단한 함수로 하나 만들어 두고
뒤로 미룬다.
;; (setq yoonkn-executable-program-list
;; (append '((\"notepad\" . \"notepad.exe\")
;; (\"emacs\" . \"c:/bin/emacs/bin/emacs.exe\"))
;; yoonkn-executable-program-list))
이런식으로 원하는 프로그램을 등록해서 사용하자

TODO: 인자를 줘서 실행하는것도 있어야 할거 같은데
TODO: 실행전 cwd 를 옮겨주는 작업도 있어야 될듯"

(interactive)
(let* ((item (assoc
(ido-completing-read
"실행할 프로그램은? "
(mapcar 'car yoonkn-executable-program-list))
yoonkn-executable-program-list))
(name (car item))
(program (cdr item)))
(w32-shell-execute "OPEN" program)))

(global-set-key [(super return)] 'yoonkn-execute-program) ; 윈도키+엔터


;;;; gnuserv
;;; 브라우저에서 소스보기등, 윈도우와 emacs 를 좀더 친하게 지내기위한 툴
;;; http://www.gnu.org/software/emacs/windows/faq3.html#TOC36 를 읽어보자
;;; 그리고 에러처리를 하는 예제이기도 하다. 위쪽의 코드들도 이런식으로 수정해야 할텐데..
;;;
;;; EmacsW32 로 갈아타며 주석처리했다. EmacsW32 에선 기본으로 띄워주기때문에 쫑나더라
;;;
;; (condition-case nil
;; (progn
;; (load-library "gnuserv")
;; (gnuserv-start)
;; (setq gnuserv-frame (selected-frame)))
;; (file-error "no gnuserv.el")
;; (error "unknown error"))


;;;; w3
;;; 너무 느린감이 있는데, cygwin 을 쓰지 않다보니 w3m 은 안되고,
;;; nero.el 은 모양이 덜이뻐서 이걸 깔았다
;; (let*
;; ((w3-dir "~/.emacs_plugin/w3-4.0pre.47/lisp")
;; (w3-exists (file-exists-p w3-dir)))
;; (when w3-exists
;; (add-to-list 'load-path w3-dir)
;; (require 'w3-auto)))

;;;; nero.el
;;; w3 은 너무 느리고 최신버전의 윈도용 lynx 를 배포하는곳을 찾은김에
;;; nero.el 도 로딩해둔다 win32 용 lynx 는 아래사이트에서 받자
;;; http://csant.info/lynx
;;;
;;; nero.el 은 http://www.ma.utexas.edu/~jcorneli/a/elisp/nero.el 에서
;;; 받을수있다
;;;
;;; NOTE: path 내에 포함된 공백때문에 문제가 생겨서 c:/bin/lynx 에
;;; 설치를 하고 c:/bin/lynx/lynx.bat 를 약간 수정해서 lynx2.bat 를
;;; 만들었다 전에 쓰던 구버전의 lynx 보다 좀더 피곤한듯
;;;
;;; -------- lynx2.bat ---------
;;; @set temp=c:\bin\lynx\tmp
;;; @set lynx_cfg=c:\bin\lynx\lynx.cfg
;;; @set lynx_lss=c:\bin\lynx\opaque.lss
;;; @c:\bin\lynx\lynx.exe %1 %2 %3 %4 %5
;;; ----------------------------
;; (load-library "nero")
;; (setq nero-lynx-program "c:/bin/lynx/lynx2.bat")
;; (setq nero-links-display-default nil)
;; (setq nero-default-coding-system 'euc-kr)





;;;; tramp-mode
;; /plink:yoonkn@111.111.111.11:/home/yoonkn/src/ 형태로 열면 된다.
;; 아직 자주 쓰지 않으니 상세한 설정은 나중에
(require 'tramp)
(setq tramp-auto-save-directory "c:/tmp"
tramp-default-method "plink"
tramp-password-end-of-line "\r\n")



;;;; graphviz-dot-mode
;; http://users.skynet.be/ppareit/projects/graphviz-dot-mode/graphviz-dot-mode.el
(load "~/emacs/graphviz-dot-mode")




;;;; httpcall function
;; 자주쓰게 되길래 걍 만들어버렸다.
(defun httpcall ()
(interactive)
(save-excursion
(let ((url (read-from-minibuffer "url: " "http://")))
(set-buffer (get-buffer-create "*httpcall*"))
(erase-buffer)
(insert-buffer (url-retrieve-synchronously url))
(switch-to-buffer "*httpcall*"))))


;;; gud 설정
(setq gdb-many-windows t) ; mingw 의 gdb 버전을 올리면 그럭저럭 잘 돌아가길래 이걸 기본으로 했다.
(global-set-key [f9] 'gud-break)
(global-set-key [f10] 'gud-next)
(global-set-key [f11] 'gud-step)
(global-set-key [(shift f11)] 'gud-finish)
(global-set-key [(shift f10)] '(lambda ()
(interactive)
(call-interactively 'gud-tbreak)
(call-interactively 'gud-cont)))
(global-set-key (kbd "C-x C-a C-c") 'gud-cont)
(global-set-key (kbd "C-x C-a C-w") 'gud-watch)



;;;; org-mode
;; 아직 여기 적용하지는 않고 org-customize 를 통해서만 세팅하고 있는데
;; org-hide-leading-stars 를 t 로 잡고 org-hide face 를 gray90 정도로
;; 잡으면 흰색바탕에서 보기 좋은 모양이 나온다.
(require 'org)
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(add-to-list 'auto-mode-alist '("\\`TODO\\'" . org-mode))
(add-to-list 'auto-mode-alist '("\\`README\\'" . org-mode))
(global-set-key (kbd "ESC ESC <f12>") 'org-agenda) ; ESC ESC f12 로 org-agenda 띄우도록 했다.
(mapc #'(lambda (x) (add-to-list 'org-agenda-files x))
'("~/emacs/org/office.org"
"~/emacs/org/home.org"))
(setq org-log-done t
;; 시작할때 적절히 접은 상태로
org-startup-folded 'content
;; 태그로 검색했을때 너무 많이 걸리네. 태그상속은 끄자.
org-use-tag-inheritance nil
;; 헤더를 보여주는 * 들을 좀더 이쁘게 보자. org-face 페이스를
;; gray90 정도로 잡아주는것도 잊지말자. 여기서하는 하는 방법을
;; 모르겠네
org-hide-leading-stars t
)




;;; 매일매일 뭔가를 적을때도 org-mode 를 써먹자.
(defun yoonkn-today-org-note-name ()
"노트를 월단위로 작성하기 위해서 연도.월.org 의 이름을
리턴하도록 했다."

(let ((tm (decode-time (current-time))))
(format "~/emacs/org/%d.%02d.org" (nth 5 tm) (nth 4 tm))))

(defun yoonkn-today-node ()
(interactive)
(find-file (yoonkn-today-org-note-name)))

(global-set-key (kbd "ESC ESC M-<f12>") 'yoonkn-today-node)



;;;; F5 누르면 vsvars32.bat 먹은 cmd.exe 띄운다 윈도가 아니면 gnome-terminal 을 띄우자
(defun yoonkn-run-cmd ()
(interactive)
(if win32p
(w32-shell-execute "OPEN"
"cmd"
"/K \"c:\\Program Files\\Microsoft Visual Studio 8\\Common7\\Tools\\vsvars32.bat\"")
(start-process "gnome-terminal" nil "gnome-terminal")))
(global-set-key [(f5)] 'yoonkn-run-cmd)


;;;; meta-F5 누르면 탐색기
(global-set-key [(meta f5)]
'(lambda ()
(interactive)
(if win32p
(eshell/start ".")
(start-process "nautilus" nil "nautilus" "."))))
;;;; ocaml & F# 을 위한 tuareg-mode
(with-extra-package
"tuareg-mode-1.45.5"
(setq auto-mode-alist (cons '("\\.ml\\w?" . tuareg-mode) auto-mode-alist))
(autoload 'tuareg-mode "tuareg" "Major mode for editing Caml code" t)
(autoload 'camldebug "camldebug" "Run the Caml debugger" t)
(add-hook 'tuareg-mode-hook
(lambda ()
(local-set-key (kbd "RET") 'newline-and-indent)))

;; 요건 F# 을 위한것
;; http://cs.hubfs.net/forums/thread/299.aspx 에서 주워왔다.
(setq auto-mode-alist (cons '("\\.fs\\w?" . tuareg-mode) auto-mode-alist))
(add-hook 'tuareg-mode-hook
'(lambda ()
(set (make-local-variable 'compile-command)
(concat "fsc \""
(file-name-nondirectory buffer-file-name)
"\"")))))
(add-to-list 'file-coding-system-alist '("\\.fs\\w?" . utf-8))




;;;; findr 해서 indent 하기
;; findr.el 이 필요
(defun indent-all-files (dir)
"지정된 디렉토리 아래에서 C 소스파일들을 찾아 indent
한다. 사용하기 전에 상황에 맞게 조금씩 수정하면서 사용하자."

(interactive "D")
(save-excursion
(dolist (file (findr "\\.c$\\|\\.h$" dir))
(unless (string-match "_darcs" file)
(set-buffer (find-file-noselect file))
(message "indenting %s..." file)
(mark-whole-buffer)
(call-interactively 'indent-region)
(when (buffer-modified-p)
(message "done.")
(save-buffer))
(kill-buffer (current-buffer))))))

;;;; d-mode.el
;;
;; http://www.prowiki.org/wiki4d/wiki.cgi?EditorSupport/EmacsEditor
;;
(autoload 'd-mode "d-mode" "Major mode for editing D code." t)
(add-to-list 'auto-mode-alist '("\\.d[i]?\\'" . d-mode))
;; Many of DMD's compilation error messages lack a category prefix
;; (like "Error" or "Warning"). Without the category, the messages
;; don't match Emacs' built-in error matching regexps used for M-x
;; next-error after a M-x compile. That makes M-x compile unable to
;; take you to the the file and line where the error is.
(add-to-list
'compilation-error-regexp-alist
'("^\\([^ \n]+\\)(\\([0-9]+\\)): \\(?:error\\|.\\|warnin\\(g\\)\\|remar\\(k\\)\\)"
1 2 nil (3 . 4)))

;;;; erlang
(when win32p
(when (file-accessible-directory-p "C:/Program Files/erl5.6")
(add-to-list 'load-path "C:/Program Files/erl5.6/lib/tools-2.6/emacs")
(setq erlang-root-dir "C:/Program Files/erl5.6")
(add-to-list 'exec-path "C:/Program Files/erl5.6/bin")
(require 'erlang-start)))

(when (featurep 'erlang-start)
(add-hook 'erlang-mode-hook
(lambda ()
(local-set-key (kbd "RET") 'newline-and-indent)
(flymake-mode 1)))
(defun flymake-erlang ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "erlc" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.erl\\'" flymake-erlang)))



;;;; wedisk lister
;; 짜다 말았다.
;; (defun wedisk ()
;; (interactive)
;; (let ((url "http://wedisk.co.kr/wedisk/wedisk.jsp?qrytype=2&ds=107&dasort=107&sorttype=0&rc=100&cate_ds=0&wordtype2=1&category=08&wordtype=1")
;; (inbuf (get-buffer-create "*wedisk-raw*"))
;; (outbuf (get-buffer-create "*wedisk*"))
;; (maxpage 10))
;; (flet ((output (msg)
;; (with-current-buffer outbuf
;; (goto-char (point-max))
;; (insert msg)))
;; (extract (text begin end)
;; (let* ((pos1 (+ (string-match begin text) (length begin)))
;; (pos2 (string-match end text pos1)))
;; (substring text pos1 pos2)))
;; (geturl (page) (format "%s&vp=%d" url page)))
;; (with-current-buffer outbuf
;; (delete-region (point-min) (point-max)))
;; (with-current-buffer inbuf
;; (loop for i from 1 to maxpage
;; do (progn
;; (delete-region (point-min) (point-max))
;; (output (format "======== %d 페이지 ========\n" i))
;; (insert-buffer (url-retrieve-synchronously (geturl i)))
;; (while (re-search-forward "<td title=.*>.*\n*.*javascript:openDnWin(.*)" nil t)
;; (let* ((text (match-string 0))
;; (title (extract text "title=\"" "\>"))
;; (id (extract text "javascript:openDnWin(" ", ")))
;; (output (format "%s: %s\n" id title))))))
;; (switch-to-buffer outbuf)))))





;; ;;;; global-modes
;; ;; 아래의 light-symbol-mode 를 전체 버퍼에 적용하기 위해서 가져왔다.
;; ;; (add-hook 'find-file-hook 'light-symbol-mode) 이런것도 되지 않을까?
;; (load-library "global-modes")

;; ;;;; light-symbol-mode
;; ;; 이거 좋드라. 뉴스그룹에서 본것. 아직 초기버전이니 생각날때마다
;; ;; 새버전 찾아보자
;; (load-library "light-symbol")
;; (make-minor-mode-global 'light-symbol-mode)
;; (global-light-symbol-mode 1)


;;;; lispdoc
;; http://bc.tech.coop/blog/070515.html
(defun lispdoc ()
"Searches lispdoc.com for SYMBOL, which is by default the symbol
currently under the curser"

(interactive)
(let* ((word-at-point (word-at-point))
(symbol-at-point (symbol-at-point))
(default (symbol-name symbol-at-point))
(inp (read-from-minibuffer
(if (or word-at-point symbol-at-point)
(concat "Symbol (default " default "): ")
"Symbol (no default): "))))
(if (and (string= inp "") (not word-at-point) (not
symbol-at-point))
(message "you didn't enter a symbol!")
(let ((search-type (read-from-minibuffer
"full-text (f) or basic (b) search (default b)? ")))
(browse-url (concat "http://lispdoc.com?q="
(if (string= inp "")
default
inp)
"&search="
(if (string-equal search-type "f")
"full+text+search"
"basic+search")))))))


;;;; rect-mark.el
;; http://www.emacswiki.org/cgi-bin/emacs-en/RectangleMark
(global-set-key (kbd "C-x r C-SPC") 'rm-set-mark)
(global-set-key (kbd "C-x r C-x") 'rm-exchange-point-and-mark)
(global-set-key (kbd "C-x r C-w") 'rm-kill-region)
(global-set-key (kbd "C-x r M-w") 'rm-kill-ring-save)
(autoload 'rm-set-mark "rect-mark"
"Set mark for rectangle." t)
(autoload 'rm-exchange-point-and-mark "rect-mark"
"Exchange point and mark for rectangle." t)
(autoload 'rm-kill-region "rect-mark"
"Kill a rectangular region and save it in the kill ring." t)
(autoload 'rm-kill-ring-save "rect-mark"
"Copy a rectangular region to the kill ring." t)


;;;; snippet.el
;; 이정도만 알아두면 쓰는데 지장없다.
;; $${blahblah} blahblah 기본값가진 필드
;; blahblah$> blahblah 입력후 인덴트
;; $. 커서위치
;; \n newline
;; 보기 흉해서 뉴라인을 모두 \n 으로 적어뒀으니 수정할 일이 있으면 \n
;; 을 뉴라인으로 바꿔서 수정후 다시 \n 으로 바꿔주자.
(require 'snippet)
(defun install-c++-snippet ()
(abbrev-mode 1)
(snippet-with-abbrev-table
'c++-mode-abbrev-table
("classx" . "class $${class}$>\n{$>\npublic:$>\n$${class}();$>\n~$${class}();$>\nprivate:$>\n$${class}(const $${class}& _);$>\n$${class}& operator=(const $${class}& _);$>\n};\n")
("doxx" . "/**$>\n* \\brief $${brief}$>\n*$>\n* $.$>\n*/$>")
))
(add-hook 'c++-mode-hook 'install-c++-snippet)




;;;; ebrowse

;; ebrowse-build.bat
;; {{{
;; @echo off
;; set find=c:/bin/find.exe
;; set tr=c:/bin/tr.exe
;; set ebrowse=c:/"Program Files"/Emacs/emacs/bin/ebrowse.exe

;; set srcdir=%1
;; set list1=%srcdir%/.ebrowse.filelist.1
;; set list2=%srcdir%/.ebrowse.filelist.2
;; set brdat=%srcdir%/BROWSE

;; %find% %srcdir% -type f -regex ".*\.\(h\|\hh\|\H\|hpp\|hxx\)" > %list1%
;; %find% %srcdir% -type f -regex ".*\.\(c\|\cc\|\C\|cpp\|cxx\)" >> %list1%
;; %tr% \\ / < %list1% > %list2%
;; %ebrowse% -f %list2% -o %brdat%
;; rm -f %list1%
;; rm -f %list2%

;; @echo on
;; }}}
(defun my-ebrowse-build (srcdir)
(w32-shell-execute "OPEN"
"ebrowse-build.bat"
srcdir))

(defun my-ebrowse-switch ()
(interactive)
(let* ((srcdir (expand-file-name (or (and (boundp 'yoonkn-build-option)
(cdr (assq 'source-directory yoonkn-build-option)))
default-directory)))
(ebrowse-file (format "%s/BROWSE" srcdir))
(ebrowse-buffer (get-buffer "*Tree*")))
(if current-prefix-arg
(progn
(when ebrowse-buffer (kill-buffer ebrowse-buffer))
(my-ebrowse-build srcdir))
(cond (ebrowse-buffer
(switch-to-buffer ebrowse-buffer))
((file-exists-p ebrowse-file)
(find-file ebrowse-file))
(t
(my-ebrowse-build srcdir))))))

(global-set-key [(meta f12)] 'my-ebrowse-switch)





;;;; anything
;;; 이거 정말 다양하게 응용이 가능할듯.
(require 'anything-config)
(global-set-key (kbd "ESC ESC aa") 'anything)



;;;; Per-Directory Local Variables 하고 anything 을 이용해서 프로젝트 관리
;;; define-project-bindings, set-directory-project 로 적절히 프로젝트를
;;; 세팅해 두면 그걸 anything 이 읽어서 dired 를 띄울수 있도록 해줬다.
(defun yoonkn-projects-candidates ()
(reverse ; reverse 안해주면 set-directory-project 역순으로 나온다
(mapcar #'(lambda (x)
(symbol-name (cdr x)))
project-directory-alist)))

(defun yoonkn-projects-get-dir (name)
(let* ((name-symbol (intern name))
(dir (car (find name-symbol project-directory-alist :key 'cdr))))
dir))

(defun yoonkn-projects-dired (name)
(dired (yoonkn-projects-get-dir name)))

(defun yoonkn-projects-psvn (name)
(psvn-status (yoonkn-projects-get-dir name)))


(setq anything-sources-my-projects
'((name . "내 프로젝트들")
(candidates . yoonkn-projects-candidates)
(action . (("dired 실행하기" . yoonkn-projects-dired)
("psvn 실행하기" . yoonkn-projects-psvn)))))

(pushnew anything-sources-my-projects anything-sources)

;;;; c-eldoc-mode
;;; 요즘은 C++ 보다 C 가 더 좋아져서 이놈을 깔아버렸다.
;;; c-eldoc-includes 를 세팅하면 라이브러리 함수들에도 적용이
;;; 가능하겠지만 적용 안했다.
(when unixp
(load "c-eldoc")
(add-hook 'c-mode-hook 'c-turn-on-eldoc-mode))



;;;; doc-mode
;;; http://nschum.de/src/emacs/doc-mode/
;;; 자주 쓸만한 커맨드는
;;; C-c d d : 문서 작성
;;; C-c d n : 문서 작성중 다음 수정항목으로
;;; C-c d t : 폴딩 토글
;;; C-c d C-f : 버퍼 전체 폴드
;;; C-c d C-u : 버퍼 전체 언폴드
;; (when unixp
;; (require 'doc-mode)
;; (add-hook 'c++-mode-hook 'doc-mode)
;; (add-hook 'c-mode-hook 'doc-mode)
;; (add-hook 'java-mode-hook 'doc-mode))


;;;; csharp mode
(autoload 'csharp-mode "csharp-mode" "Major mode for editing C# code." t)
(setq auto-mode-alist
(append '(("\\.cs$" . csharp-mode)) auto-mode-alist))


;;;; erc
(setq erc-default-coding-system '(euc-kr . undecided))
;; (add-to-list 'erc-encoding-coding-alist '("#foo" . iso-8859-1))
(setq erc-autojoin-channels-alist
'(("freenode.net" "#emacs" "#lisp" "#nethack" "#clojure")
("irc.hanirc.org" "#kldp" "#ubuntu" "#gnome")))
;; (erc-select :server "irc.freenode.net" :port 6667 :nick "yoonkn")
;; (erc-select :server "irc.hanirc.org" :port 6667 :nick "yoonkn")



;;;; flymake
;; (add-hook 'find-file-hook 'flymake-mode)


;;;; scratch 에 저장기능을 넣다니.. 염병
(add-hook 'emacs-startup-hook
(lambda ()
(when (get-buffer "*scratch*")
(with-current-buffer "*scratch*"
(auto-save-mode -1)
(setq buffer-offer-save nil)))))




;;;; gambit
(let ((gambit-path "C:/Program Files/Gambit-C/v4.0.1/share/emacs/site-lisp"))
(when (file-accessible-directory-p gambit-path)
(add-to-list 'load-path gambit-path)
;; http://www.iro.umontreal.ca/~gambit/doc/gambit-c.html#SEC28
(autoload 'gambit-inferior-mode "gambit" "Hook Gambit mode into cmuscheme.")
(autoload 'gambit-mode "gambit" "Hook Gambit mode into scheme.")
(add-hook 'inferior-scheme-mode-hook (function gambit-inferior-mode))
(add-hook 'scheme-mode-hook (function gambit-mode))
(setq scheme-program-name "gsi -:d-")))



;;;; mercurial
;; C-c h h 로 도움말을 읽어보자.
;; mercurial 패키지를 세가지를 섞어쓰다보니 코드가 요꼴이됐다. 언젠가 하나로 통일되면 나머진 지우자.
(when win32p
(load "C:/Program Files/TortoiseHg/Contrib/mercurial" t)
(load "C:/Program Files/Mercurial/Contrib/mercurial" t))

;; 이거 좀 오버스런 코드인데 내 .emacs 에 condition-case 쓴적이 없길래 이걸로 적어둔다.
(when unixp
(condition-case nil
(load-library "mercurial")
(error nil)))
(setq hg-outgoing-repository "default")

;;;; C-x m 을 누르면 gmail compose 창이 뜨도록 했다.
(defun yoonkn-compose-mail ()
(interactive)
(browse-url "http://mail.google.com/mail/?account_id=yoonkn%40gmail.com&view=comp&extsrc=ig"))
(global-set-key (kbd "C-x m") 'yoonkn-compose-mail)


;;;; google code search
;; http://www.hoetzel.info/Hacking/emacs/codesearch.el
;; 이거 정말 편하구나 M-x codesearch 로 검색어를 넣으면 현재 모드에 맞는 언어로 검색을 해준다.
(load-library "codesearch")


;;;; dired-x
;; dired-omit-files 를 쓰기 위해서..
(require 'dired-x)
(defun add-to-dired-omit-files (pattern)
(setq dired-omit-files
(concat dired-omit-files
"\\|"
pattern)))
(mapc #'add-to-dired-omit-files
'(;; . 으로 시작하는놈들
"\\.hg\\'"
"\\.svn\\'"
"\\`\\." ; . 으로 시작하는놈은 걍 죄다 숨기자
;; emacs 가 만드는 파일들
"\\`semantic.cache\\'"
"\\.elc\\'"
;; 각종 태그 유틸리티들이 만드는 파일들
"\\`tags\\'"
"\\`TAGS\\'"
"\\`GPATH\\'"
"\\`GRTAGS\\'"
"\\`GSYMS\\'"
"\\`GTAGS\\'"
"\\`cscope.out\\'"
"\\`cscope.files\\'"
"\\`cscope.index\\'"
;; 몇몇 언어들이 만드는 중간파일들 (c/c++ 은 out of source build 를 하니 제외)
"\\.fas\\'"
"\\.fasl\\'"
"\\.pyc\\'"
"\\.pyo\\'"
"\\.beam\\'"
))
(add-hook 'dired-mode-hook '(lambda () (dired-omit-mode 1))) ; 단축키는 M-o


;;;; dired+.el
(require 'w32-browser)
(require 'dired-sort-menu)
;; sort 하려면 dired-mode 에서 C-d 눌러보자
(add-hook 'dired-load-hook
(lambda () (require 'dired-sort-menu)))

;;;; win32 일때 dired 모드에서 gid, uid 감추기
;; 이거 안해주면 보기싫게 나온다.
(when win32p
(setq ls-lisp-verbosity (delq 'uid ls-lisp-verbosity))
(setq ls-lisp-verbosity (delq 'gid ls-lisp-verbosity)))


;;;; ccrypt
;; http://ccrypt.sourceforge.net/
;; 개인정보를 담을때 써먹자. 확장자가 .cpt 인경우 적용된다.
;; 저장시에도 암호를 물어보는게 좀 귀찮은데 끄는 방법을 찾아봐야 할듯.
(let ((ccrypt-path "C:/bin/ccrypt"))
(when (file-accessible-directory-p ccrypt-path)
(add-to-list 'load-path ccrypt-path)
(add-to-list 'exec-path ccrypt-path)
(require 'jka-compr-ccrypt "jka-compr-ccrypt.el")))


;;;; nxml-mode
(let ((nxml-mode-path "~/.emacs.d/nxml-mode-20041004"))
(when (file-accessible-directory-p nxml-mode-path)
(load (format "%s/rng-auto" nxml-mode-path))
(add-to-list 'auto-mode-alist `(,(regexp-opt '("xml" "xsd" "sch" "rng" "xslt" "svg" "rss") t) . nxml-mode))))


;;;; rectangle
;;; * M-x delete-rectangle 직사각형 영역을 지운다.
;;; * M-x kill-rectangle 위의 명령과 비슷하다. 그러나, 지워지는 내용을 "last killed rectangle" 로 저장한다.
;;; * M-x yank-rectangle ``last killed rectangle''을 그것의 위 왼쪽 끝이 포인트 위치에 오도록 삽입한다.
;;; * M-x open-rectangle 직사각형영역을 빈 공간으로 채운다. 원래의 내용은 직사각형 영역 오른쪽으로 밀려난다.
;;; * M-x clear-rectangle 직사각형영역의 내용을 없에고 스페이스를 채운다.
;;; * M-x string-insert-rectangle 스트링 추가
;;; C-x r k 킬
;;; C-x r d 딜리트
;;; C-x r y yank
;;; C-x r o 빈공간 추가
(global-set-key (kbd "C-x r RET") 'string-insert-rectangle) ; 자주 쓸만한 놈이니 바인딩 해놓는다. C-x r i 를 하고 싶었는데 이미 쓰이길래 우선 엔터로.


;;;; haskell mode
;;; http://www.haskell.org/haskellwiki/Haskell_mode_for_Emacs#Obtaining_the_CVS_version
;;; haskell-font-lock-symbols 는 음.. 몇가지는 맘에 들고 몇가지는
;;; 아닌데 적절히 haskell-font-lock-symbols-alist 를 수정해서 쓰자.
(let ((haskell-mode-path "~/.emacs.d/haskell-mode-2.4"))
(when (file-accessible-directory-p haskell-mode-path)
(load (format "%s/haskell-site-file" haskell-mode-path))
(setq haskell-font-lock-symbols t)
(add-hook 'haskell-mode-hook (lambda () (local-set-key (kbd "RET") 'newline-and-indent)))
;(load "~/emacs/flymake-haskell")
;(add-hook 'haskell-mode-hook 'flymake-mode)
))



;;;; smart tab
;; http://www.emacswiki.org/cgi-bin/wiki/TabCompletion
;; tabkey2 라는놈으로 변경
;; (require 'smart-tab)
;; (global-set-key [(tab)] 'smart-tab)

;;;; tabkey2
;; http://www.emacswiki.org/cgi-bin/wiki/tabkey2.el
;; (require 'tabkey2)




;;;; smerge-mode
;; 이런것도 있구나. 현재 작업환경상 머지를 할일이 별로 없어서 당장
;; 이모드를 사용할 생각은 없는데 아래 코드는 여러가지로 응용이 가능할듯
;; 하다. find-file-hook 에 적당한 함수를 집어넣고 모드를
;; 제어하는것.. 언젠가 쓸날이 올것같다.
;; (defun sm-try-smerge ()
;; (save-excursion
;; (goto-char (point-min))
;; (when (re-search-forward "^<<<<<<< " nil t)
;; (smerge-mode 1))))
;; (add-hook 'find-file-hook 'sm-try-smerge t)



;;;; reddit.el
;; 내가 만든거.
(load "reddit")





;;;; yasnippet
;;; http://code.google.com/p/yasnippet/
(when (file-accessible-directory-p "~/.emacs.d/yasnippet")
(add-to-list 'load-path "~/.emacs.d/yasnippet")
(require 'yasnippet)
(yas/initialize)
(yas/load-directory "~/emacs/snippets/"))



;;;; htmlize
;; 웹에 긁어붙일때 유용하더라.
(setq htmlize-output-type 'inline-css)
(require 'htmlize-view)


;;;; etags-select
;; 이거 희한하네. 태그를 찾으면 그 태그위치로 가는게 아니고 해당
;; 파일에서 그 태그와 같은 단어가 나오는 첫번째 위치로 간다. 설마 이거
;; 의도한건가? 어쨌건 난 못쓰겠다.
;;
;; (require 'etags-select)
;; (global-set-key "\M-." 'etags-select-find-tag)

;;;; fullscreen 전체화면
;; http://www.emacswiki.org/cgi-bin/wiki/FullScreen
(when unixp
(defun fullscreen ()
(interactive)
(set-frame-parameter nil 'fullscreen
(if (frame-parameter nil 'fullscreen) nil 'fullboth))))

;;;; 자바스크립트 개발환경 ( moz 를 이용해서 REPL 까지 )
;;; http://wiki.github.com/bard/mozrepl/emacs-integration
(add-to-list 'auto-mode-alist '("\\.js\\'" . javascript-mode))
(autoload 'javascript-mode "javascript" nil t)
(autoload 'moz-minor-mode "moz" "Mozilla Minor and Inferior Mozilla Modes" t)
(add-hook 'javascript-mode-hook
(lambda ()
(moz-minor-mode 1)))



;;;; auto-complete-mode
;;; 자동완성을 별로 좋아하지 않지만... 있으면 편해지는건 사실이니 한번 써보자.
;;; http://www.emacswiki.org/emacs/AutoComplete
;;; http://www.emacswiki.org/emacs/AutoCompleteSources
;;; http://www.emacswiki.org/emacs/init-auto-complete.el
(require 'auto-complete)
(require 'auto-complete-extension)
(require 'ac-dabbrev)
(global-auto-complete-mode t)
(custom-set-variables
'(ac-sources
'(ac-source-words-in-buffer
ac-source-dabbrev)))


;;;; ysp, yoonkn-start-project
(require 'yoonkn-start-project)


;;;; 정규식
;; http://www.emacswiki.org/emacs/RegularExpression
;; 를 참고하자. 헷갈리는걸 적어둘까
;; \\`README\\' \` 와 \' 의 사용을 봐두자
;; \\.org\\' \. 을 봐두자
;;
;; http://www.emacswiki.org/emacs/ReplaceRegexp
;; 치환을 할때는 위링크 참고
;; (\.*\) 로.. \( 와 \) 로 묶어서 그룹을 만들고 이 그룹을 \1 또는 \2
;; 식으로 지칭할수 있다는정도만 머리에 넣어두자.

접어두기..


흠. 그나저나 예전에는 여러가지로 불편해서 남들 elisp 도 뒤져보고 내가 직접 만들어보는 삽질도 하고 했는데 요즘은 그야말로 불편한게 없어서 더이상 발전이 없네. 오랜만에 emacswiki 좀 구경가야겠다... 음 내일.. ㅎㅎ


http://yoonkn.textcube.com/163








:

Pretty Print source code

카테고리 없음 2010. 6. 22. 16:39

Pretty-print source code with enscript (See related posts)

man enscript
open http://trac.macports.org/wiki/InstallingMacPorts
sudo port install enscript

alias enscript='/opt/local/bin/enscript'
man enscript
enscript --help
enscript --list-media
enscript --help-highlight | less
enscript --help-pretty-print | less
# list available fonts for man enscript
cat -n /usr/share/enscript/font.map
man pstopdf # cf. http://codesnippets.joyent.com/posts/show/1601

FILE="/usr/include/sys/stat.h"
enscript -q -C -Ec --color -f Courier10 -p - "$FILE" | pstopdf -i -o ~/Desktop/test.pdf
enscript -q -B -C -Ec --color -f Courier10 -p - "$FILE" | pstopdf -i -o ~/Desktop/test.pdf
enscript -q -B -C -Ec -G --color -f Courier10 -p - "$FILE" | pstopdf -i -o ~/Desktop/test.pdf
enscript -q -B -C -Ec -G --color --word-wrap -f Courier10 -p - "$FILE" | pstopdf -i -o ~/Desktop/test.pdf
enscript -q -B -C -Ec -G --color --word-wrap -f Courier10 -MLetter -p - "$FILE" | pstopdf -i -o ~/Desktop/test.pdf
enscript -q -B -C -Ec -G --color --word-wrap -f Courier7 -MA4 -p - "$FILE" | pstopdf -i -o ~/Desktop/test.pdf
enscript -q -B -C -Ec -G --color --word-wrap -f Courier7 -MA4 -T4 -p - "$FILE" | pstopdf -i -o ~/Desktop/test.pdf
open -a Preview ~/Desktop/test.pdf

FILE="/usr/bin/isc-config.sh"
enscript -q -B -C -Esh -G --color --word-wrap -f Courier7 -MA4 -T4 -p - "$FILE" | pstopdf -i -o ~/Desktop/test.pdf
open -a Preview ~/Desktop/test.pdf
:

Summer Intern (See this after 2010.Dec)

카테고리 없음 2010. 6. 15. 13:18

Logo

Internship Application

The application deadline is January 31 of each year. Applications received after January 31 may not receive full consideration.

All of the following fields are required except Personal Web Page. Complete the required fields then click "Su

http://www.ttic.edu/intern.php

:

ACM ICPC 2003 Online Preliminary Contest

카테고리 없음 2010. 6. 11. 12:47
Online Preliminary Contest
Final Standing
Ranking School Team Solved Penalty
1 Yonsei U. Haeya 6 243
2 KAIST unKnown 6 300
3 Yonsei U. Attainment 6 387
4 Seoul National U. tazza 6 490
5 POSTECH The Lord Of Code 6 498
6 POSTECH Code Masters 6 532
7 Seoul National U. bugReloaded! 6 544
8 Seoul National U. chocopie 6 573
9 Yonsei U. ACCEPTED RELOADED 6 590
10 Soongsil U. MAWANG 5 282
11 KAIST Ghosts 5 309
12 Yonsei U. BT Boradolis 5 314
13 POSTECH The Artists of Programming 5 469
14 Korea U. WorldKorea 5 543
15 KAIST KIN~ 4 149
16 Soongsil U. El Dorado 4 191
17 ICU Misty 4 329
18 Changwon U. Bongrim 4 414
19 Sogang U. INVINCIBLE 4 418
20 KAIST Anything 4 477
21 Pusan National U. noname 4 522
22 Ajou U. Hantor 4 682
23 Hankuk U. of Foreign Studies Protocos 3 134
24 Ajou U. Spire 3 153
25 Kyungpook National U. COMENG2 3 160
26 Soongsil U. B-150 3 162
27 Yonsei U. The real uragirimonos 3 220
28 Kookmin U. Socoban 3 293
29 U. of Seoul Dark Templer 3 301
Honorable Mention (In Alphabetical Order)
School Team
Ajou U. accelerator
Ajou U. Junk
Andong National U. best
Changwon U. Sarim
Cheju National U. CNU Educom
Chosun U. JulRaDo Ggang
Chosun U. Muhan-Loop
Chosun U. Semicolon
Chosun U. Zest
Chungbuk National U. lazySwapper
Dong-A U. ChonNoms
Dongeui U. Dongeui-Unicorns
Dongguk U. DOSA2
Dongseo U. Miracle
DongYang U. FlipFlop
Ewha Womans U. HelloWorld
Ewha Womans U. Raeon
Halla U. N223
Hanbat U. WARNING
Hansung U. 3-XL
Hansung U. Night Birds
Hansung U. POCS
Hanyang U. Blue Lions
Hanyang U. HYTEA
Hanyang U. Roaring Lion
Hongik U. PCRC
Hoseo U. Avantasia
ICU ICU Pegasus
Inha U. ACCEPT
KAIST B.O.W
KAIST Infinite
Kangnung National U. BOOB
Kangnung National U. CanOfWorms
Kangnung National U. snakeho
Keimyung U. ICanDoIt
Kookmin U. ACE11
Korea U. KoreanTigers
Korea U. MATHKOREA
Korea U. OneAndZero
Korea U. of Technology and Education brain
KUMOH N.I.T. A.I.T.
Kwangwoon U. KITEL
Kyonggi U. HEUM
Kyonggi U. S.S.F
Kyung Hee U. KADA
Kyung Hee U. KimChiBokUm_BAB
Kyungpook National U. COMENG1
Kyungpook National U. Giant03
Kyungpook National U. Monsters
Pukyong Nat'l Univ. Guri-Guri
Pusan National U. NP-Solvers
Pusan National U. wind
Sangji U. Brave_Recruit
Sejong U. newbies
Seoul National U. of Technology alcoholic
Seoul National U. of Technology plum
Seoul Women's U. "June3"
Sogang U. Hulk Magmum
Sookmyung Women's U. carpediem
Sookmyung Women's U. D.C.C.
Sookmyung Women's U. SM Focus
Soongsil U. Ether
SungKongHoe U. SungKongHoe Penguins
The Catholic U. of Korea Hole
The Catholic U. of Korea Judi
The Catholic U. of Korea Mong
The Catholic U. of Korea Oracle
The Catholic U. of Korea The CIS
The Catholic U. of Korea The CPS
The Catholic U. of Korea The FAN
The Catholic U. of Korea Universal
U. of Seoul High Templer
Woosong U. Semtle 2
WooSong U. TripleM
:

.emacs

OSX 2010. 6. 10. 16:21

   윈도우용 Emacs 설정

이 문서는 윈도우용 Emacs의 설정에 관한 내용을 요약 한 것이다.


고친 과정
최초 작성 2007-04-30 작성자 kei

1. 설정 기본

emacs의 설정 파일은 .emacs 이고 계정 루트에 있다.

(XP - C:\Documents and Settings\사용자명\Application Data)

EmacsW32 설치시 위의 디렉터리에 .emacs.d 디렉터리 추가됨

설정파일 안에서 세미콜론(;)은 주석 표시이다.


2. 실행시 창 크기/위치 설정

; 창 사이즈
; emacs -g 80x40 or
(set-frame-width (selected-frame) 90)
(set-frame-height (selected-frame) 50)

; 창 생성 위치
(set-frame-position (selected-frame) 10 10)


3. 들여쓰기

;C 들여쓰기 기본 스타일 설정
(setq c-default-style "k&r")
; (setq c-default-style "cc-mode")
; (setq c-default-style "gnu")
; (setq c-default-style "bsd")
; (setq c-default-style "stroustrup")
; (setq c-default-style "whitesmith")

; 엔터 입력시 자동 들여쓰기 다른 방법
(load "cc-mode")
(define-key c++-mode-map "\r" 'reindent-then-newline-and-indent)
(define-key c-mode-map "\r" 'reindent-then-newline-and-indent)
(define-key java-mode-map "\r" 'reindent-then-newline-and-indent)

; 엔터 입력시 자동 들여쓰기 다른 방법
;(require 'cc-mode)
;(define-key c-mode-base-map (kbd "RET") 'newline-and-indent)

; { , ; 입력시 자동 줄 추가
;(add-hook 'c-mode-common-hook '(lambda () (c-toggle-auto-state 1)))


4. 탭 설정

;emacs tab 설정
(setq c-basic-offset 4
tab-width 4
indent-tabs-mode t)
;(add-hook 'c-mode-common-hook '(lambda () (c-toggle-auto-state 1)))

; 탭 대신 공백 넣기
(setq-default indent-tabs-mode nil)

; c-toggle-auto-state 기능에 backspace입력시 모든 공백(줄 바꿈 포함) 삭제
;(add-hook 'c-mode-common-hook '(lambda () (c-toggle-auto-hungry-state 1)))


5. 키 설정

GOTO LINE 키 설정

22버전은 M-g M-g 혹은 M-g g 로 설정되어 있음

; 라인 바로가기
(global-set-key "\M-g" 'goto-line)


6. 단어 자동완성

단어 자동 완성

M-x dynamic-completion-mode

;최근 사용된 word list를 가지고, 자동 완성구현, 3글자 이후에M-RET
(dynamic-completion-mode)


※ 참고
dynamic-completion-mode
http://kltp.kldp.org/stories.php?story=03/11/16/1067964&topic=26


7. vim o 키 흉내내기

; vim o 키 흉내내기 ; 함수 선언 후 키 맵핑
(defun my-insert-line ()
"Insert blank line below the cursor."
(interactive)
(end-of-line)
(newline-and-indent))
(global-set-key "\M-o" 'my-insert-line);M-o 는 원래 face바꾸기 임


8. HideShow모드 설정(Folding모드)

모드 활성화 시키기(.emacs에 추가)
;; hideshow for programming
(load-library "hideshow")
(add-hook 'c-mode-hook 'hs-minor-mode)
(add-hook 'c++-mode-hook 'hs-minor-mode)
(add-hook 'emacs-lisp-mode-hook 'hs-minor-mode)
;(add-hook 'java-mode-hook 'hs-minor-mode)
;(add-hook 'perl-mode-hook 'hs-minor-mode)

; hide상태에서 goto-line했을 때 자동으로 show로 변경
(defadvice goto-line (after expand-after-goto-line
activate compile)
"hideshow-expand affected block when using goto-line in a collapsed buffer"
(save-excursion
(hs-show-block)))
기본 키
For Emacs 20:
* C-c S show all
* C-c H hide all
* C-c s show block
* C-c h hide block

For Emacs 21(이후버전):
* C-c @ ESC C-s show all
* C-c @ ESC C-h hide all
* C-c @ C-s show block
* C-c @ C-h hide block
* C-c @ C-c toggle hide/show
키 복잡하니까
'hs-hide-all
'hs-hide-block
'hs-show-all
'hs-show-block
맵 핑해서 쓸 것.
ex.>
(global-set-key (kbd "ESC <f5>") 'hs-toggle-hiding)
(global-set-key (kbd "ESC <f6>") 'hs-show-all)
(global-set-key (kbd "ESC <f7>") 'hs-hide-all)

※ 참고
http://www.emacswiki.org/cgi-bin/wiki/HideShow


9. cscope 설정

Cscope on Win32
http://iamphet.nm.ru/cscope/
윈도우즈용으로 컴파일 된 cscope-16.0a-win32.7static.zip 다운
전역에서 쓸 수 있도록 PATH 처리된 디렉터리에 압축 해제(emacs설치 디렉터리/emacs/bin/)
혹은 아무 폴더에 압축해제후 시스템 환경변수의 PATH에 경로추가

http://cscope.sourceforge.net/
에서 최신버전 다운
(압축 폴더 안의 contrib\xcscope\xcscope.el 사용하기 위해)

emacs 설치 디렉터리/emacs/site-lisp/에 xcscope.el 복사

.emacs에 다음 줄 추가
(require 'xcscope)


윈도우용 find유틸 설치
GNU Win32
http://gnuwin32.sourceforge.net/
에서 find 다운
설치 후 시스템 환경변수 PATH에 경로 추가
Windows\system32 \find.exe와 겹치므로 GNU Win32 find.exe의 이름을 바꿔서 쓰거나
시스템 변수의 PATH 맨 앞에 추가 할 것
예> C:\Program Files\GnuWin32\bin;%SystemRoot%\system32;……

※ 참고
KLDP Wiki - Emacs Gdb Etags Cscope
http://wiki.kldp.org/wiki.php/EmacsGdbEtagsCscope


10. 라인넘버 표시하기

http://www.wonderworks.com/download/setnu.el.gz 다운.
emacs설치디렉터리/lisp/ 에 압축해제

.emacs(사용자 설정파일) 추가 아래 내용.

(load-library "setnu.el")
(add-hook 'c-mode-hook 'turn-on-setnu-mode)
(add-hook 'text-mode-hook 'turn-on-setnu-mode)
(add-hook 'c++-mode-hook 'turn-on-setnu-mode)

기타 필요한 모드 위의 방식(add-hook 'MODE.....)으로 추가

setnu-mode on/off 토글키
M-x setnu-mode RET

※ 참고
Emacs에서 vi 스타일(: set nu)의 줄 번호
http://kltp.kldp.org/stories.php?story=00/07/01/9629703&topic=26


11. Visual Studio에 emacs 등록하기

External Tools
Title : 이름
Command : C:\Program Files\Emacs\emacs\bin\runemacs.exe
(이맥스 실행파일 경로)

Arguments : +$(CurLine) $(ItemFileName)$(ItemExt)

Initial directory : $(ItemDir)


12. ECB / CEDET(미완성)

ECB
http://ecb.sourceforge.net/
CEDIT
http://cedet.sourceforge.net/



13. 상용구 설정

.abbrev_defs 파일 안에서 설정(.emacs 에서 해도 됨)

("준말" "본말" nil 0) 형태로 삽입. 준말에 특정 기호(@같은···) 및 한글은 안됨.

ex.)
(define-abbrev-table 'c++-mode-abbrev-table '(
("$l1"
"////////////////////////////////////////////////////////////////////////////////"
nil 0)
("$l2"
"//********************************************************************************"
nil 0)
("$h"
"// title :
// Author : "
nil 0)
))


14. ...

;emacs 외부에서 파일 변경시 현재 버퍼 자동으로 다시 읽게 하기
.emacs에 다음 내용 추가
(global-auto-revert-mode 1)

무 슨 말?
예를들어, test.txt 라는 파일을 emacs에서도 열고 메모장(notepad)에서도 열었다.
그런데 메모장에서 test.txt를 수정한 후 저장하면 emacs에서 자동으로 test.txt를 다시 읽는다.

그 외...
일회용으로 적용할려면
M-x auto-revert-mode RET

수동으로 버퍼 갱신할려면
M-x revert-buffer RET
참고 emacs 매뉴얼 항목 14.4 Reverting a Buffer
그외 참고해서 추가 할것...
14.5.1 Auto-Save Files
14.5.2 Controlling Auto-Saving
14.5.3 Recovering Data from Auto-Saves


※ 참고 사이트

emacs wiki
http://www.emacswiki.org/cgi-bin/wiki


EmacsKR
http://emacs.kldp.org/wiki/doku.php

kldp.org - 검색

http://kldp.org


kldp wiki - 검색

http://wiki.kldp.org/wiki.php

:

지능형 휠체어 동향

카테고리 없음 2010. 6. 7. 14:09

이탈리아에서 개발된 생각으로 움직이는 휠체어KISTI 『글로벌동향브리핑(GTB)』 2009-03-09

이 탈리아 연구팀이 컴퓨터로 보내진 정신적 신호에 복종하는 휠체어를 개발했다고 2009년 3월 6일 발표했다.

이탈리아 밀라노 공대(Milan`s Polytechnical Institute)의 인공지능 및 로봇연구실(artificial intelligence and robotics laboratory)은 이 시스템을 개발하는 데 3년이 걸렸다고 마테오 마테우치(Matteo Matteucci) 교수가 전했다.

사용자는 자신의 두피 상에 설치된 전극으로 컴퓨터와 연결되며, 스크린 상에 표시된 부엌, 침실, 화장실 등과 같은 원하는 목적지의 명칭을 수초 동안 집중함으로써 신호를 보낸다. 다음으로 컴퓨터는 미리 설정된 프로그램을 사용하는 선택된 목적지로 휠체어를 인도한다.

이러한 시스템은 마음을 읽는 것이 아니라, 보내지는 뇌 신호를 읽는 것이다. 휠체어는 장애물을 탐지할 수 있는 2개의 레이저 빔을 갖추었다.

연 구팀은 사지마비 환자를 목표로 하여 상업적 시제품을 생산할 수 있는 회사들과 이미 접촉했으며, 상업화에는 5~10년이 소요될 것이라고 마테오 마테우치 교수가 말했다. 연구팀에 따르면 이러한 휠체어는 전형적 동력 휠체어와 비교하여 비용이 단지 10%정도에 불과할 것이다.

소위 두뇌 컴퓨터 인터페이스(Brain Computer Interface)를 개발하기 위한 연구는 전세계에서 1980년대 초에 시작됐다. 스위스 로잔(Lausanne)에 위치한 공업기술학교(Federal Polytechnic School)를 포함하여 다른 여러 연구자들이 유사한 프로젝트에 종사하고 있다.

결국, 최선의 방법을 찾기 위한 기초로서 이러한 모든 프로젝트를 이용할 수 있는 연구 컨소시엄이 만들어져야 한다고 마테오 마테우치 교수는 주장했다.

마 테오 마테우치 교수 연구팀은 이제 막 GPS(위성위치확인시스템)를 사용하여 야외에서 동작하는 휠체어를 개발하는 연구를 시작했다.

2009-03-09_wheelchair.jpg











http://cafe.naver.com/gwcil.cafe?iframe_url=/ArticleRead.nhn%3Farticleid=2055

뇌병변 장애인들을 위한 발을 이용한 마우스 보조기구

사지마비 장애인들을 위한 전동휠체어에 로봇을 달아서 일상생활을 도울수 있게 한 전동휠체어도 있더군요...

http://cafe.naver.com/gwcil.cafe?iframe_url=/ArticleRead.nhn%3Farticleid=2055





장애인 돕는 재활로봇 나와 [중앙일보]

2003.04.23 15:49 입력 / 2003.04.23 16:34 수정

눈동자만 움직이면 알아서 척척…25일까지 KAIST서 전시
식사·세수 등 12가지 기능…日·佛 제품도 선보여

변증남 교수팀이 개발한 재활로봇. 컵 들어주기, 세수시키기, 문 여닫기 등 12가지 기능을 한다. 휠체어는 목 근육의 움직임으로 이동한다.
한 국과학기술원(KAIST) 변증남 교수팀은 눈동자의 움직임만으로 로봇 팔과 연결된 컴퓨터를 조작할 수 있는 장애인 재활로봇을 개발했다.

눈동자가 컴퓨터 화면의 특정 기능에 몇초간 멈춰 있으면 눈동자 감지기는 '주인이 그 기능을 이용하려고 하는 것'으로 판단한다.

이를테면 식판에 놓여 있는 음료수를 집어달라는 요구를 컴퓨터로 명령하면 로봇 팔이 그것을 들어 입에 대준다. 물론 캔에는 빨대가 꽂혀 있어야 한다. 이 로봇은 식사 보조, 얼굴 닦기, 면도, 문 여닫기 등 12가지 일을 도와준다.

이 로봇은 23~25일 KAIST 대강당에서 제8차 재활로봇학술회의와 함께 열리는 재활로봇 전시회에서 선보이고 있다. 여기에는 국내에서 개발된 것 외에 일본.프랑스에서도 첨단 제품을 출품해 관람객들이 그 기능을 직접 체험하고 있다. 4월은 장애인의 달이기도 하다.

변교수팀이 개발한 재활로봇은 휠체어에 부착돼 있다. 휠체어는 손을 사용하지 않고도 근전도로 앞.뒤.좌.우로 움직인다. 휠체어를 뒤로 움직이려면 목을 뒤로 젖히면 된다.

근육을 사용하면 미세한 전기가 발생하는데 그 전기와 근육의 방향을 목에 파스처럼 붙은 센서가 읽어내는 것이 그 원리다.

일본 세콤이 선보인 식사보조로봇(상품명:마이 스푼)도 관심을 끌고 있다. 게임기에 달린 것과 비슷한 조이스틱을 사용해 로봇을 조종한다. 딱딱한 음식은 물론이고 두부.국수.국 등 웬만한 음식은 모두 먹을 수 있다.

사지마비 장애인도 조이스틱을 움직일 수 있는 힘만 있으면 가족과 대화하면서 요리를 즐길 수 있는 것이 장점이다. 그 크기는 28(가로)×37(세로)×25㎝(높이)로, 식탁에 올려놓아도 크게 어색하지 않다.

척추 손상으로 사지가 마비된 후자와 다카시는 "다른 사람의 도움 없이 20분 정도 걸려 식사를 할 정도로 편하다"고 식사보조 로봇의 사용 소감을 말했다.

조이스틱으로 로봇 팔을 조종해 음식을 집어 입에 넣어주는 식이다. 한번에 집을 수 있는 음식의 양은 50g 정도며, 이 로봇용 식판을 사용해야 한다.

연세대 의공학과 김영호 교수가 개발한 소아마비 장애인의 하지 교정이나 보조용 제어기도 새롭게 선보이는 것이다. 기존 제품은 불편한 다리를 지탱해주기 위해 뻣뻣한 일자형을 주로 썼다.

이에 따라 장애인들은 무릎이 구부러지지 않아 다리를 질질 끌다시피 걸어야 하는 또 다른 불편을 겪어왔다.

그러나 이 제어기는 전기적으로 무릎 관절이 구부러지도록 해 장애인들의 이동이 쉽도록 했다.

KAIST 윤용산 교수가 개발한 의족 시뮬레이터는 장애인들이 의족을 맞출 때 인체 대신 기계로 잘 맞는지 안 맞는지를 실험할 수 있게 한다. 실제 보행 때 나타나는 특징을 시뮬레이터에 집어넣어 장애인의 발.보행 습관에 맞게 하는 것이 원리다.

프랑스 INT사가 내놓은 매너스 로봇은 장애인이 말이나 조이스틱으로 조종, 일상 생활의 보조원 역할을 하게 한다.

박방주 기자




작성하신 글은 아래의 서비스로 보내신 글입니다.
해당 서비스에서도 삭제 반영 됩니다.
(비디오반영은 추후 제공됩니다.)

* 글보내기 정보는 아래와 같습니다.

취소
:

Mac Keyboard Shortcuts

OSX 2010. 6. 6. 19:50

Mac Central: Your place for good, concise, Mac related hints.

Keyboard ShortcutsMulti-Touch GesturesTips & TricksRecommended Programs

Mac Keyboard Shortcuts

I like to figure out the fastest way to do things. I hope these shortcuts will help you become the power user that lies within. These keystrokes should work on Mac OS 10.6 Snow Leopard and 10.5 Leopard (many also work on 10.4 Tiger). I add new shortcuts as I find them, so check back!

Please note that Cmd is short for the Command key (otherwise called the Apple key).

Guide to the Mac’s Menu Symbols

Symbol
Key on Keyboard
Symbol
Key on Keyboard
Command/Apple key (like Control on a PC)
Delete
Option (like Alt on a PC)
Escape
Shift
Page Up
Control (Control-click = Right-click)
Page Down
Tab
Home
Return
End
Enter (on Number Pad)
Arrow Keys

Finder Shortcuts

Action Keystroke
Open Sidebar item in a new window Cmd-Click it
Switch Finder views (Icon, List, Column, Cover Flow) Cmd-1, Cmd-2, Cmd-3, Cmd-4
In List view, expand a folder Right Arrow
In List view, collapse a folder Left Arrow
Rename the selected file/folder Press Return (or Enter)
Go into selected folder or open the selected file Cmd-Down Arrow
Go to parent folder Cmd-Up Arrow
Go Back Cmd-[ (that’s left square bracket)
Go Forward Cmd-] (that’s right square bracket)
Select the next icon in Icon and List views Tab (Shift-Tab reverses direction)
Alternate columns in Column View Tab (Shift-Tab reverses direction)
Instantly show long file name (for names condensed with a “...”) Hold Option while mousing over long filenames
Resize current column to fit the longest file name Double-Click column resize widget
Resize all columns to fit their longest file names Option Double-Click resize widget
Copy and Paste files Cmd-C, then Cmd-V
Move a file instead of copying. (Copies the file to the destination and removes it from the original disk.) Cmd-Drag file to disk
Move selected files to the Trash Cmd-Delete
Empty the Trash (with warning) Cmd-Shift-Delete
Empty the Trash (without warning) Cmd-Opt-Shift-Delete
Cancel a drag-n-drop action while in the midst of dragging Esc
Show Inspector (a single, live refreshing Info window) Cmd-Opt-I
Undo the last action (such as rename file, copy file, etc.) Cmd-Z
Hide/Show Sidebar (on the left) Cmd-Opt-T
Move or Remove item in toolbar (at the top of the window).
This works in most programs.
Cmd-drag
Open Quick Look (Mac OS 10.5) With file selected, tap Spacebar (or Cmd-Y)
Zoom In/Out on a Quick Look Preview Cmd-Plus(+) or Cmd-Minus(-)
Find by File Name (Mac OS 10.5) Cmd-Shift-F

Application Switcher

Action Keystroke
Quickly switch between 2 programs
(such as: InDesign & Photoshop)
Press Cmd-Tab to switch to the last used program.
Press Cmd-Tab again to switch back.
NOTE: Press keys quickly and do NOT hold them down.
Switch between programs (but you choose which program to switch to) Press Cmd-Tab and continue holding Cmd.
While holding Cmd, to choose which program you want to switch to you can:
• press Tab (several times if needed) to scroll right
• press Shift-Tab or tilde(~) to scroll left
• use the left/right arrow keys
• aim with the mouse
• use end/home keys to just to first/last item
Quit a program using the application switcher When in the app switcher you’re already holding Cmd.
Once the program is selected hit Q to quit.
Hide a program using the application switcher When in the app switcher you’re already holding Cmd.
Once the program is selected hit H to hide.
Cancel out of the application switcher once it’s open When in the app switcher you're already holding Cmd.
Hit Esc or period(.)

Dock Shortcuts

Action Keystroke
Hide all other applications (except the one you're clicking on) Command-Option click an App’s icon in Dock
Reveal a Dock item’s location in the Finder Command Click on the icon in the Dock
Move and a Dock item to somewhere else on the hard drive Command Drag the icon from the Dock to new destination
Force a file to open in a specific program While dragging the file onto an app’s icon in the Dock, hold Command-Option
When in an app’s Dock menu, change the Quit to Force Quit Hold Option while in Dock menu
Force the Dock to only resize to non-interpolated icon sizes Hold Option while dragging Dock separator
Move Dock to left, bottom, right side of screen Hold Shift and drag Dock divider
Temporarily turn magnification on (or off) It’s a toggle. Hold Control-Shift (Mac OS 10.5 and later)

Working with Windows

Action Keystroke
Switch windows (works in most programs) Next window: Cmd-tilde(~)
Previous Window: Cmd-Shift-tilde(~)
See where the File/Folder is located (a menu will pop-up displaying the folder hierarchy). This works in “most” programs as well as the Finder. Cmd-Click on name of the window in its titlebar
Move a window in the background without switching to it.
(Example: You’re in a dialog and can’t move a window in the background, so Cmd-Drag its titlebar.)
Cmd-Drag on a window’s titlebar

Taking Screenshots

Action Keystroke
Take picture of the entire screen Cmd-Shift-3
Take picture of a selected area Cmd-Shift-4 and Drag over desired area
New in Mac OS 10.5: While dragging:
- Hold Spacebar to move selected area.
- Hold Shift to change size in one direction only (horizontal or vertical)
- Hold Option for center-based resizing.
Take picture of a specific window/object Cmd-Shift-4, then press Spacebar, then Click on the window/object
Copy the screenshot to the clipboard instead of making a file Hold Control with the above keystrokes
Screenshots are saved to the Desktop as PNG file in OS 10.4 and later (or a PDF file in OS 10.3 and prior).

Startup Commands

Action Keystroke
Eject CD on boot Hold Mouse button down immediately after powering on
OS X Safe boot Hold Shift during startup
Start up in FireWire Target Disk mode Hold T during startup
Startup from a CD Hold C during startup
Bypass primary startup volume and seek a different startup volume (CD, etc.) Hold Cmd-Opt-Shift-Delete during startup
Choose Startup disk before booting Hold Option during startup
Start up in Verbose mode Hold Cmd-V during startup
Start up in Single-User mode (command line) Hold Cmd-S during startup
Force OS X startup Hold X during startup

Shutdown/Sleep Commands

Action Keystroke
Shutdown immediately (no confirmation) Cmd-Opt-Ctrl-Eject
Sleep immediately (no confirmation) Cmd-Opt-Eject
Restart, Sleep, Shutdown dialog (like hitting the Power button on old Mac keyboards) Ctrl-Eject
Put display to sleep Ctrl-Shift-Eject

Dashboard

Action Keystroke
Open/Close Widget Dock Cmd-Plus(+)
Cycle to next/previous “page” of widgets in widget dock Cmd-Right/Left Arrow
Close a widget without having to open the widget dock Hold Option and hover over widget (close box will appear)
Reload/Refresh a widget Cmd-R

Spaces Mac OS 10.5 and 10.6

Action Keystroke
Activate Spaces (birds-eye view of all spaces) F8
Consolidate all windows into a Single Workspace After pressing F8, press C to consolidate (press C again to restore)
Move to a neighboring space Ctrl-arrow key (left, right, up or down)
Move to a specific space Ctrl-number of the space (1, 2, 3, etc.)
Move all windows of an app to another space Cmd-Drag in Space’s birds-eye view (Control and Shift also work)

Spotlight

Action Keystroke
Open Spotlight Menu Cmd-Space
Open Spotlight Window Cmd-Option-Space
In Spotlight menu: Launch Top Hit Return (In Mac OS 10.4 it’s Cmd-Return)
Reveal the selected item in the Finder

In Spotlight Menu: Cmd-click item or press Cmd-Return

In Spotlight Window: Press Cmd-R

Skip to first result in each category Cmd up/down arrow
Clear Spotlight’s search field Esc clears to do another search.
Esc a second time closes the spotlight menu.

Working with Text (some only work in Cocoa apps like Safari, Mail, TextEdit, etc.)

Action Keystroke
Go to end of line Cmd-right arrow
Go to beginning of line Cmd-left arrow
Go to end of all the text Cmd-down arrow
Go to beginning of all the text Cmd-up arrow
Go to end of current or next word Option-right arrow
Go to beginning of current or previous word Option-left arrow
NOTE: Add Shift to any of the above keystrokes to make a selection to that point.
On Laptops: Delete Text to the right of the cursor (like the Del key on a full keyboard) Function(fn)-Delete
Non-touching (Discontinuous) text selections Command-drag
Select non-linear areas Option-drag
Delete entire word to the left Opt-Delete
Look up word in dictionary Position mouse over a word and hold Cmd-Ctrl-D

Auto completion word

Start typing the word. Press Esc (or F5) to open suggested word list

Emacs Key Bindings (only work in Cocoa apps like Safari, Mail, TextEdit, iChat, etc.)

Action Keystroke Remember As
go to start of line (puts cursor at beginning of current line) Ctrl-A A = Start of alphabet
go to end of line (puts cursor at end of current line) Ctrl-E E = End
go up one line Ctrl-P P = Previous
go down one line Ctrl-N N = Next
go back one character (moves cursor left 1 place) Ctrl-B B = Back
go forward one character (moves cursor right 1 place) Ctrl-F F = Forward
delete the character to the right of the cursor Ctrl-D D = Delete
delete the character to the left of the cursor Ctrl-H
delete to end of the line (or delete the selection) Ctrl-K K = Kill rest of line
scroll down Ctrl-V
center the current line in the window Ctrl-L
insert line break after the cursor without moving the cursor Ctrl-O
transpose letters (swaps letter on the left and right of cursor) Ctrl-T T = Transpose

Miscellaneous

Action Keystroke
Force Quit (opens list so you can choose application) Cmd-Opt-Esc
Force Quit Frontmost Application (without confirmation) Hold Cmd-Opt-Shift-Escape for about 4 seconds
On Laptops: Scroll (like a mouse’s scroll wheel)
(Works on newer laptops if enabled in System Preferences)
Slide 2 fingers on the trackpad
On Laptops: Right-click (like on a 2 button mouse)
(Works on newer laptops if enabled in System Preferences)
Place 2 fingers on the trackpad and Click
Quickly find any menu item and launch it. (Mac OS 10.5) 1. Press Cmd-? FYI: That’s Cmd-Shift-/
2. In the Help menu Search that opens, start typing a few letters of your desired menu command.
3. Arrow key down to the item you want and press Return to choose it.
Change system volume without the confirmation beeps Hold Shift while changing volume
Completely smooth scrolling—one pixel at a time.
(Only works in Cocoa apps.)
Hold Option while dragging scrollbar
Open System Preferences:
NOTE: These launch directly into a preference pane.
Two examples are given.
To open “Sound” Preferences:
Hold Option and press any Sound key
(Mute, Volume Up or Down )

To open “Displays” Preferences:
Hold Option and press any Brightness key
Open Front Row Cmd-Esc
Quickly Exit Front Row Press any F key, like F5. In 10.5 and later, non F keys also work.
Customize the toolbar at the top of a window.
Works for toolbars like in Safari, Apple Mail, Preview, Finder, etc. But it doesn't work in all programs, like Firefox.

- Rearrange icons:
   Hold Cmd and drag the icons around.

- Remove icons:
   Hold Cmd and drag icon off toolbar.
- View toolbar options:
   Ctrl-click on the toolbar to get a menu.

Safari

Action Keystroke
Switch Tabs Next Tab: Ctrl-Tab (or Cmd-Shift-Right Arrow)
Previous Tab: Ctrl-Shift-Tab (or Cmd-Shift-Left Arrow)
Go to one of the first 9 bookmarks (not folders) in the Bookmarks Toolbar Cmd-1 through Cmd-9
Move between found items (in Safari 3 and later) Cmd-F, enter your search text and Press:
Return to Move Forward
Shift-Return to Move Backward
Cancel current Find Press Escape or Cmd-Period(.)
Scroll a webpage by a screenful Scroll Down: Spacebar or Option-Down Arrow
Scroll Up: Shift-Spacebar or Option-Up Arrow

Apple’s Mail.app

Action Keystroke
Reply to Message Cmd–R or
Option-Double Click Message
Go to the next/previous email in a thread even if you haven’t organized by threads Option-Up/Down Arrow
Scroll the listing of emails at the top (not the actual contents of an email) Ctrl-Page Up/Down

Apple’s Preview.app

Action Keystroke
Choose the Scroll/Move tool Cmd-1
Choose the Text tool Cmd-2
Choose the Select tool Cmd-3
Zoom in or out Cmd-Plus(+) or Cmd-Minus(-)
Scroll Large Images Hold Spacebar and drag on the image (like you do in Photoshop)


back to top

“Thanks Dan!” If you like this site, making a donation will:
Encourage Dan to keep adding useful information.
Make you (and Dan) feel warm and fuzzy inside.

Secure transactions by PayPal. No PayPal account required.

:

OpenCV on OSX

Image Processing 2010. 6. 3. 15:13

1. OpenCV Source 다운 받기


svn 을 통해서 다운 받을 수 있겠지만, 그냥 기본적으로 opencv-2.0.0으로 아래 사이트에서 다운 받습니다.
(여기서는 /Users/bkim/opencv에 소스파일을 다운받았습니다.)
2. pkgconfig, jpeg, libpng, tiff 설치
터미널에서
$ sudo port install pkgconfig $ sudo port install install jpeg libpng tiff

설 치를 마쳤다면, path 설정을 합니다.
$ export PKG_CONFIG_PATH = /usr/local/lib/pkgconfig

path 가 잘 나가는지, 확인하고 싶다면,
$ pkg-config --cflags opencv -> I/usr/local/include/opencv

$ pkg-config --libs opencv -> L/usr/local/lib -lcxcore -lcv -lhighgui -lcvaux -lml

3. cmake 설치
아 래 사이트에서 다운을 받습니다. 현재(09년 1월), cmake-2.8.0-Darwin-universal.dmg이 최신 버전이군요. http://www.cmake.org/cmake/resources/software.html
설 치 후, 실행을 하면,

Specify the generator for this project는 Xcode, 그리고 Use default native compilers 선택합니다.
Where is the source code에서 다운 받은 opencv 경로를 작성, Where to build the binaries에 원하는 경로를 작성합니다. (여 기선, source code 경로로 '/Users/bkim/opencv', binaries 경로로 '/Users/bkim/opencv/_make'로 설정하였습니다.) 경 로 설정 후, 'Configure' 버튼을 누르면, 아래와 같은 화면이 나타납니다.

붉 게 표시된 목록에서,
BUILD_NEW_PYTHON_SUPPORT = OFF ENABLE_OPENMP = ON

두 가지 옵션을 선택 후, 다시 한번 'Configure'버튼을 클릭합니다. 클릭 후 조금 기다리면 'Generate'을 누를 수있게 됩니다. 'Generate' 클릭 후 또한 조금 기다리면 성공을 알리는 메시지가 나타납니다.
최 종적으로 잘 마무리 되었는지는 설정한 binaries 경로에 OpenCV.xcodeproj이 존재하는지 확인합니다. (여 기서는, /Users/bkim/opencv/_make/)

4. Xcode 컴파일
생성된 OpenCV.xcodeproj 파일을 열면 XCode가 시작됩니다. 아래와 같이 설정 후, 컴파일(⌘B)을 합니다.
Active Configuration = Release Active Architecture = i386


5. OpenCV.framework 만들기
쉘스크립트를 통해서 framework를 만들 수 있습니다. opencv를 다운 받은 경로에서 (여기서는 /Users/bkim/opencv),
$ sh make_frameworks.sh

다소 시간이 흐른 뒤, opencv 경로에 'OpenCV.framework'가 생성되며, 그것을 '/Library/Framework'로 복사합니다.
framework이 잘 만들어졌는지 확인을 위해 'opecv/samples/MacOSX/FaceTracker.xcodeproj'를 실행 및 컴파일해봅니다.

향후, 본인만의 OpenCV 프로그래밍시에 Xcode 실행, 아래 그림처럼 'Add'->'Existing Frameworks' 선택, 그리고 'Opencv.Framework'이 존재하는지 확인합니다. 없다면, 'Add Other...'를 통해 '/Library/Framework'안에 존재하는 'opencv.framework'를 추가하시면 됩니다.


6. 예제 코드 컴파일하기
OpenCV에서 제공하는 예제 코드(opencv/samples/c)들을 가지고 놀기 위해서 컴파일을 해줍니다.
$ sh build_all.sh

혹시 컴파일에 문제가 있다면, build_all.sh 파일을 아래와 같이 수정해줍니다.
# 10번째 줄 # gcc -ggdb `pkg-config --cflags opencv` -o `basename $i .c` $i `pkg-config --libs opencv`; 를 다음처럼 수정 gcc-4.0 -ggdb `pkg-config --cflags opencv` -o `basename $i .c` $i `pkg-config --libs opencv`;
# 14번째 줄 # g++ -ggdb `pkg-config --cflags opencv` -o `basename $i .cpp` $i `pkg-config --libs opencv`; 를 다음처럼 수정 g++-4.0 -ggdb `pkg-config --cflags opencv` -o `basename $i .cpp` $i `pkg-config --libs opencv`;

컴파일이 마무리 되셨으면, 예제 코드를 가지고 놉니다. :)
$ ./edge



이상~ 끝. :)

http://wowjerry.tistory.com/archive/201001#recentTrackback






Build OpenCV on Snow Leopard

OpenCV (Open Source Computer Vision) is “a library of programming functions for real-time computer vision”.

It took me whole day yesterday to build OpenCV for my Snow Leopard. I still need to add the FFMPEG support but for now, it is turned off. I’ve followed the Mac OS X OpenCV Port doc.

svn co https://code.ros.org/svn/opencv/trunk opencv

cd opencv mkdir opencv/build cmake ..

ccmake .

Hit ‘t’ to toggle advanced mode. Set CMAKE_CXX_COMPILER=”/usr/bin/g++-4.0″ and CMAKE_C_COMPILER=”/usr/bin/gcc-4.0″. I also need to turn off FFMPEG and LIBDB1394, because I could not get them to install properly yet on Snow Leopard. Turn on the BUILD_EXAMPLE. Hit ‘c’ to configure and then ‘g’ to generate the config files and exit ccmake. make -j8 su make install To build the example, I need to change the opencv/sample/c/build_all.sh to the following: (change gcc to gcc-4.0 and g++ to g++-4.0, and also add “-arch i386″)

gcc-4.0 -arch i386 -ggdb `pkg-config opencv –cflags –libs` $base.c -o $base
g++-4.0 -arch i386 -ggdb `pkg-config –cflags opencv` -o `basename $i .cpp` $i `pkg-config –libs opencv`;

To build the c sample, just type:

./build_all.sh

Next step for me would be to build the universal library for OpenCV from Snow Leopard.

If you would like to use OpenCV with Java on Linux, check out this Walk into the Future article.

http://www.flex.shallwelearn.com/blog/archives/1902

: