페이지

레이블이 emacs인 게시물을 표시합니다. 모든 게시물 표시
레이블이 emacs인 게시물을 표시합니다. 모든 게시물 표시

2011년 8월 11일 목요일

emacs ido introduction

emacs의 저변 확대와 내 기억향상을 위해 이글을 작성함.
ido-mode는 emacs 22부터 emacs 패키지에 들어가게 되었고, ido는 Interactively Do Things의 약자라고 한다. 일종의 completion-engine 이라고 보면 된다.
예를 들어, “*Ediff Registry”로 버퍼를 변경(C-x b)한다고 가정하자. 그러면 먼저 첫번째 글자인 *를 입력하고 Tab을 치고 운좋게 자동완성이 되면 끝이고 안되면 그 다음글자를 입력하고 또 그 다음 글자를 입력하고 자동완성이 될때까지 반복하면 된다.
ido로는 Registry 혹은 Ediff만으로 선택할 수 있다. 입력한 글자와 말그대로 match만 되면 바로 해당 버퍼를 선택할 수 있다. 심지어는 *er 만으로 원하는 버퍼를 선택할 수 있다. 첫글자인 *, Ediff의 e, Registry의 r만으로.
ido-mode를 사용하려면 .emacs 파일에 아래부분을 추가해주면 된다.
(ido-mode 1);; for buffers and files
ido를 위와 같이 enable하면 Switch-buffer(C-x b) 와 find-file (C-x C-f) 이 각각 ido-switch-buffer와 ido-find-file로 바뀌게 된다.
ido의 동작을 변경하는 여러가지 옵션이 있는데 그 중 몇가지를 소개해 보면
  • ido-ignore-buffers : switch-buffer시 무시할 buffer를 regex형식으로 명시할 수 있다. 보통 *로 시작하는 버퍼들을 명시해주면 유용하다.
  • ido-ignore-files : 마찬가지로 무시할 파일을 regex형식으로 명시할 수 있다.
  • ido-ignore-directories : 무시할 directory를 regex로 명시.
  • ido-case-fold : t로 주면 case-insensitive하게 동작한다
  • ido-use-filename-at-point : 현재 커서가 위치하고 있는 곳의 스트링으로 필터링을 한다. 예를 들어 main.c 에서 #include “test.h”라는 소스 파일이 있다고 치고, 현재 커서가 test.h에 위치해 있다고 하고 이때 find-file(C-x C-f) 명령을 주면 test.h로 필터링 된다.
  • ido-confirm-unique-completion t : candidate가 하나만 남아 있더라도 리턴을 해야지만 선택되게 한다.
최종적으로 내가 사용하는 셋팅은 아래와 같다.
(setq
ido-save-directory-list-file "~/.emacs.d/ido.last"
ido-ignore-buffers ;; ignore these guys
'("\\` " "^\*Mess" "^\*Back" ".*Completion" "^\*Ido" "^\*trace"
"^\*compilation" "^\*GTAGS" "^session\.*" "^\*")
ido-case-fold  t                 ; be case-insensitive
ido-enable-last-directory-history t ; remember last used dirs
ido-max-work-directory-list 30   ; should be enough
ido-max-work-file-list      50   ; remember many
ido-use-filename-at-point 'guess
;; ido-use-url-at-point nil         ; don't use url at point (annoying)
ido-everywhere t       ; ??
ido-enable-flex-matching nil     ; don't try to be too smart
ido-max-prospects 8              ; don't spam my minibuffer
ido-confirm-unique-completion t) ; wait for RET, even with unique completion
;; Display ido results vertically, rather than horizontally
(setq ido-decorations (quote ("\n-> " "" "\n   " "\n   ..." "[" "]" " [No match]" " [Matched]" " [Not readable]" " [Too big]" " [Confirm]")))
(defun ido-disable-line-trucation () (set (make-local-variable 'truncate-lines) nil))
(add-hook 'ido-minibuffer-setup-hook 'ido-disable-line-trucation)
;; when using ido, the confirmation is rather annoying...
(setq confirm-nonexistent-file-or-buffer nil)
(ido-mode 1) ;; for buffers and files

2011년 1월 5일 수요일

emacs server mode in Windows

Emacs wiki에는 복잡하게 설명되어 있지만 실제로 최신버전의 이맥스-GNU Emacs 23.2.1-에서는 server mode는 별도의 해킹없이 동작한다. 그러니 괜히 시간 낭비 하지 마시라고..
server mode란 것은 하나의 emacs 프로그램이 오직 하나의 instance만 뜨게 제한 하는 방법이다. server mode가 아닐때는 모두 각각의 instance로 실행이 된다.
실제로 파일 하나 오픈했는데 새로운 emacs window가 떠버리면 더 불편할다. 초기화 하는데 시간이 걸리고 버퍼등이 공유가 되지 않기때문이다. 그래서 대부분  server mode를 default로 사용한다.
.emacs에
(server-start)
를 추가해 주고 최초 실행시는 runemacs.exe를 사용하고 이후에는 emacsclientw.exe FILE_NAME 이런식으로 실행하면 된다.
또 emacsclientw.exe로 오픈된 버퍼는 C-c #으로 종료하면 된다. 물론 C-x k 로 해도 되지만 client를 죽일 것인지 한번더 물어본다. 나의 경우는 이 컨펌 메세지를 없애기 위해서 (server-start) 의 아래 줄에,꼭 아래 줄이어야 함, 아래 lisp코드를 적어주면 그냥 깨끗하게 죽는다.
(remove-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function)

2010년 12월 27일 월요일

find.exe conflicts on Windows emacs

emacs를 사용할때 내부적으로 unix 툴인 find.exe를 사용하는데 이것은 Windows에 기본으로 내장되어 있는 find.exe프로그램과 이름이 같다. 따라서 emacs에서 unix의 find.exe를 call하고 싶어도 할 방법이 없다.

이것에 대한 해결책은 다음과 같다. 간단한 솔루션이지만 정말 많은 시간을 소비했다. --;;

Copy grep.exe and find.exe to Emacs’ own bin directory