Emacs lisp code for adding files for monitoring

I am new to emacs lisp programming. I am a developer and programmer in c on a daily basis. I would like to use tags to view code using emacs. However, the size of my project is very large and cannot afford to launch etiges from time to time. I would like to add a lisp function or code in emacs this way, each open emacs file I have to be written to one file (name it ~ / project_files_opened.txt) and I will do a cron job that will only call open files .. Can someone please help me with some links or existing code for this? Even some examples will help me find ... Thank you ..

+4
source share
3 answers

How about a slightly different beat? When you open the file (which is interesting for you), at this point add it to the TAGS file. You can do this quite easily with the following code:

(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))) 

From time to time, you want to delete the TAGS file to update the content. Or you can use something like Mx refresh-tags-table :

 (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))))) 
+1
source

You may prefer GNU Global as a replacement for etags. My caveat is that I did not use it myself, however I believe that it implements the correct database and not the base TAGS flat file, and therefore incremental updates should be very effective.

For more details see the textbook ; in particular 3.6 Extended Emacs using GLOBAL and 4.3 Incremental update .

There is also a page in the Emacs Wiki:
http://www.emacswiki.org/emacs/GnuGlobal

+1
source

You can take a look at the CEDET structure. See semantic module .

0
source

All Articles