help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: finding tags files based on location


From: Kevin Rodgers
Subject: Re: finding tags files based on location
Date: Tue, 26 Feb 2008 21:31:28 -0700
User-agent: Thunderbird 2.0.0.9 (Macintosh/20071031)

gamename wrote:
On Feb 25, 8:08 pm, Kevin Rodgers <kevin.d.rodg...@gmail.com> wrote:
gamename wrote:
I often have to checkout multiple copies of the same source tree from
cvs.  For example, if I have a source tree 'foo' in cvs, I may have 2
copies like ~/foo0/bar and ~/foo1/bar in my home directory at the same
time.  Each copy of the foo tree will have a tags file in 'foo/tags'.
Does anyone have code that will enable emacs to determine which tags
file to use based on the tree i'm currently using?  For example, if
I'm in foo1/bar, I would be using the tags file in foo1/tags, not foo0/
tags.  Is there code to dynamically determine that?
>>
Is it enough to make tags-file-name a buffer local variable, set
appropriately for each file?  If so:

(defun set-local-tags-file-name ()
   (when (file-exists-p "tags")
     (set (make-local-variable 'tags-file-name)
         (expand-file-name "tags"))))

(add-hook 'find-file-hook 'set-local-tags-file-name)

Thanks Kevin, but I don't think that scales very well.  If I have
thousands of files, that wouldn't be workable.

Actually, it scales perfectly well: No matter how many files you have,
the hook is only run once for each file that you actually visit.

The question is: Does it actually work?  I see now that vist-tags-table
explicitly provides a way to do the same thing, so perhaps this is
better:

(defun set-local-tags-file-name ()
  (when (file-exists-p "tags")
    (visit-tags-table (expand-file-name "tags") t)))

--
Kevin Rodgers
Denver, Colorado, USA





reply via email to

[Prev in Thread] Current Thread [Next in Thread]