2010-11-25 6 views
4

저는 emacs lisp 프로그래밍을 처음 사용합니다. 저는 매일 개발자로서 c 프로그래밍을하고 있습니다. 이맥스 코드 브라우징을 위해 태그를 사용하고 싶습니다. 그러나, 프로젝트의 크기는 매우 크고, 매번 etags를 실행할 여유가 없습니다. 그런 식으로 이맥스에 lisp 함수 나 코드를 추가하고 싶습니다. 이맥스가 열리는 모든 파일은 하나의 파일 (~ project_files_opened.txt로 이름 지어야합니다)에 작성해야하며 열어 본 파일 만 열등화합니다. 누가이 일을하기 위해 참고 자료 나 기존 코드로 나를 도울 수 있습니까? 심지어 몇 가지 예제는 내가 데리러하는 데 도움이 될 것입니다 ... 감사합니다 ...emacs lisp 모니터링을위한 파일을 추가하는 코드

답변

1

어떻게 약간 다른 전술에 대해? 원하는 파일을 열면 해당 시점에 TAGS 파일에 추가합니다. 다음과 같은 코드로 아주 쉽게 그렇게 할 수 있습니다

(setq tags-file-name "/scratch2/TAGS") 
(setq tags-revert-without-query t) 
(add-hook 'find-file-hooks 'add-opened-file-to-tags) 
(defun add-opened-file-to-tags() 
    "every time a file is opened, add it to the TAGS file (if not already present) 
Note: only add it to the TAGS file when the major mode is one we care about" 
    (when (memq major-mode '(c-mode c++-mode)) 
(let ((opened-file (buffer-file-name))) 
    (save-excursion 
    (visit-tags-table-buffer) 
    (unless (member opened-file (tags-table-files)) 
     (shell-command 
      (format "etags -a --output %s %s" tags-file-name opened-file))))))) 
;; create an empty TAGS file if necessary 
(unless (file-exists-p tags-file-name) 
    (shell-command (format "touch %s" tags-file-name))) 

각을 한 번 당신이 내용을 새로 고치려면 태그 파일을 삭제할 수 있습니다 한 동안. 아니면 같은 것을 사용할 수있는 다음 M-X 새로 고침 - 태그 테이블 :

(defun refresh-tags-file() 
    "rebuild the tags file" 
    (interactive) 
    (let ((tags-files 
    (save-excursion 
     (visit-tags-table-buffer) 
     (tags-table-files)))) 
(delete-file tags-file-name) 
(dolist (file tags-files) 
    (shell-command (format "etags -a --output %s %s" tags-file-name file))))) 
0

CEDET 프레임 워크를 살펴볼 수 있습니다. semantic module을 참조하십시오.

+0

그 * 힘 * 갈 수있는 방법이 될 수 있지만 그것은 아주 무거운입니다. –

1

etags 대신에 GNU Global을 사용하는 것이 좋습니다. 내주의 사항은 내가 직접 사용하지 않았지만 기본 플랫 TAGS 파일과는 달리 적절한 데이터베이스를 구현한다고 생각하지만 점진적 업데이트는 매우 효율적이어야한다고 생각합니다.

자세한 내용은 tutorial을 참조하십시오. 특히 3.6 Extended Emacs using GLOBAL4.3 Incremental updating.

페이지가 이맥스 위키에서도 있습니다 :
http://www.emacswiki.org/emacs/GnuGlobal

관련 문제