2010-11-25 3 views
4

私はemacs lispプログラミングを初めて使いました。私は開発者であり、日常的にプログラミングしています。私はemacsでコードをブラウズするためにタグを使いたいと思っています。しかし、私のプロジェクトのサイズは非常に大きくて、エタグを毎時実行する余裕はありません。私はemacsを開いているすべてのファイルを1つのファイル(〜/ project_files_opened.txtという名前)に書き込む必要があり、オープンファイルのみをエタグするcronジョブを作成します。誰かがこれを行うためにいくつかの参考文献または既存のコードで私を助けてくださいできますか?いくつかの例でさえ私が拾うのを助けるでしょう...ありがとう..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))) 

時々、TAGSファイルを削除して内容を更新したい場合があります。それとも、のようなものを使用することができ、次の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 GLOBALおよび4.3 Incremental updatingである。

のEmacs Wikiのページもあります:わずかに異なるタクトについて
http://www.emacswiki.org/emacs/GnuGlobal

関連する問題