unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Finding files with tags
@ 2006-03-11  1:35 mlathe
  2006-03-11 11:15 ` Eli Zaretskii
  2006-03-13 18:56 ` Kevin Rodgers
  0 siblings, 2 replies; 9+ messages in thread
From: mlathe @ 2006-03-11  1:35 UTC (permalink / raw)



Is it possible get a listing of all the filenames that match a grep on TAGS?
Ideally you wouldn't need to cycle through the list but rather you would
simply get a listing in a buffer similar to dired or grep-find (no sure
about the exact term) that actually open the buffer.

Currently i use an index that i created using find, and some various tools i
wrote to do greps on that list. However i need to do this in the emacs
shell, then copy it into the find-file. Its not exactly ideal.

Thanks for any info
--matthias
--
View this message in context: http://www.nabble.com/Finding-files-with-tags-t1262543.html#a3350075
Sent from the Emacs - Help forum at Nabble.com.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Finding files with tags
  2006-03-11  1:35 Finding files with tags mlathe
@ 2006-03-11 11:15 ` Eli Zaretskii
  2006-03-13 18:02   ` mlathe
  2006-03-13 18:56 ` Kevin Rodgers
  1 sibling, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2006-03-11 11:15 UTC (permalink / raw)


> Date: Fri, 10 Mar 2006 17:35:53 -0800 (PST)
> From: mlathe <mlathe@gmail.com>
> Cc: 
> 
> Is it possible get a listing of all the filenames that match a grep on TAGS?

Would it be okay to go to the TAGS buffer and then do an "M-x occur"?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Finding files with tags
  2006-03-11 11:15 ` Eli Zaretskii
@ 2006-03-13 18:02   ` mlathe
  0 siblings, 0 replies; 9+ messages in thread
From: mlathe @ 2006-03-13 18:02 UTC (permalink / raw)



Yeah that's pretty close. I think that i can make a function to get only the
file names but not the instance variables. That shouldn't been hard.

Only problem that i see is that when you select the line (ie hit enter) it
doesn't do exactly what i want. It be nice if it would open the file rather
then going to the line in the TAGS file.

So i guess my real question is how do you attach logic to the action of
selecting a line in a mode? Is this difficult to do? I have a feeling that i
need to make my own mode, or perhaps fool the grep mode into doing what i
want? is that possible?

thanks
--Matthias
--
View this message in context: http://www.nabble.com/Finding-files-with-tags-t1262543.html#a3382350
Sent from the Emacs - Help forum at Nabble.com.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Finding files with tags
  2006-03-11  1:35 Finding files with tags mlathe
  2006-03-11 11:15 ` Eli Zaretskii
@ 2006-03-13 18:56 ` Kevin Rodgers
  2006-03-13 20:48   ` mlathe
  1 sibling, 1 reply; 9+ messages in thread
From: Kevin Rodgers @ 2006-03-13 18:56 UTC (permalink / raw)


mlathe wrote:
> Is it possible get a listing of all the filenames that match a grep on TAGS?
> Ideally you wouldn't need to cycle through the list but rather you would
> simply get a listing in a buffer similar to dired or grep-find (no sure
> about the exact term) that actually open the buffer.
> 
> Currently i use an index that i created using find, and some various tools i
> wrote to do greps on that list. However i need to do this in the emacs
> shell, then copy it into the find-file. Its not exactly ideal.

Here's what I came up with (note the literal DEL character immediately
after the first comma in the sed regex):

(defun dired-tags-table (tags)
   "Use Dired mode to edit the files listed in the TAGS table."
   ;; (interactive ...) copied from visit-tags-table:
   (interactive (list (read-file-name "Dired tags table: (default TAGS) "
				     default-directory
				     (expand-file-name "TAGS"
						       default-directory)
				     t)))
   (dired (cons (file-name-directory tags)
                (split-string
                 (shell-command-to-string
                  (format "sed -n 's/^\\([^,\x7f]*\\),[1-9][0-9]*$/\\1/p' %s"
                          tags))))))


-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Finding files with tags
  2006-03-13 18:56 ` Kevin Rodgers
@ 2006-03-13 20:48   ` mlathe
  2006-03-13 23:32     ` Kevin Rodgers
  0 siblings, 1 reply; 9+ messages in thread
From: mlathe @ 2006-03-13 20:48 UTC (permalink / raw)



Yeah this was basically the direction that i was heading. Leverage another
mode's logic for listing file names and opening the selected file. So i
guess i'm on the right track.

So which do you think is better? dired? or grep-find's (compilation?) mode?

thanks for the help
--Matthias
--
View this message in context: http://www.nabble.com/Finding-files-with-tags-t1262543.html#a3385374
Sent from the Emacs - Help forum at Nabble.com.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Finding files with tags
  2006-03-13 20:48   ` mlathe
@ 2006-03-13 23:32     ` Kevin Rodgers
  2006-03-14  2:47       ` mlathe
  0 siblings, 1 reply; 9+ messages in thread
From: Kevin Rodgers @ 2006-03-13 23:32 UTC (permalink / raw)


mlathe wrote:
> Yeah this was basically the direction that i was heading. Leverage another
> mode's logic for listing file names and opening the selected file. So i
> guess i'm on the right track.

Did you find my implementation lacking in some way?

> So which do you think is better? dired? or grep-find's (compilation?) mode?

If you're not interested in any particular line of the files, dired is
the appropriate function.

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Finding files with tags
  2006-03-13 23:32     ` Kevin Rodgers
@ 2006-03-14  2:47       ` mlathe
  2006-03-15 22:24         ` Kevin Rodgers
  0 siblings, 1 reply; 9+ messages in thread
From: mlathe @ 2006-03-14  2:47 UTC (permalink / raw)



Lacking? No i guess not. I didn't get it to work in its entirety, but i
didn't really try very hard. (also it was kind of slow, but i think that's
b/c its doing a sed on all of my 12MB TAGS file. I need to do a grep first
or something).

So thanks for the effort. I'll draw something up based on your example.

Another Question. This seems to be a very helpful feature. It seems to me
that my colleagues are aways trying to remember where a certain file lives
or doing a cd ../../../../foo/bar/path to move around. Can you think of a
more common way of doing a similar indexed search? (i guess jde-mode does
this for java files pretty good).

thanks for the help.
--Matthias
--
View this message in context: http://www.nabble.com/Finding-files-with-tags-t1262543.html#a3390232
Sent from the Emacs - Help forum at Nabble.com.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Finding files with tags
  2006-03-14  2:47       ` mlathe
@ 2006-03-15 22:24         ` Kevin Rodgers
  2006-03-16 16:57           ` Kevin Rodgers
  0 siblings, 1 reply; 9+ messages in thread
From: Kevin Rodgers @ 2006-03-15 22:24 UTC (permalink / raw)


mlathe wrote:
> Lacking? No i guess not. I didn't get it to work in its entirety, but i
> didn't really try very hard. (also it was kind of slow, but i think that's
> b/c its doing a sed on all of my 12MB TAGS file. I need to do a grep first
> or something).
 >
 > So thanks for the effort. I'll draw something up based on your example.

I wouldn't expect `grep | sed` or awk to be any faster than sed.
My guess is that the performance bottlenecks are (1) splitting the sed
output into a list of strings, (2) running ls on all those file names
(ls sorts its output), and (3) parsing the output in dired.

> Another Question. This seems to be a very helpful feature. It seems to me
> that my colleagues are aways trying to remember where a certain file lives
> or doing a cd ../../../../foo/bar/path to move around. Can you think of a
> more common way of doing a similar indexed search? (i guess jde-mode does
> this for java files pretty good).

See the recent thread re: globalff.el on gnu-emacs-sources:
http://lists.gnu.org/archive/html/gnu-emacs-sources/2006-03/msg00014.html

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Finding files with tags
  2006-03-15 22:24         ` Kevin Rodgers
@ 2006-03-16 16:57           ` Kevin Rodgers
  0 siblings, 0 replies; 9+ messages in thread
From: Kevin Rodgers @ 2006-03-16 16:57 UTC (permalink / raw)


Kevin Rodgers wrote:
> I wouldn't expect `grep | sed` or awk to be any faster than sed.
> My guess is that the performance bottlenecks are (1) splitting the sed
> output into a list of strings, (2) running ls on all those file names
> (ls sorts its output), and (3) parsing the output in dired.

I did a few timing experiments on just the sed command, using a 12MB
file like yourself and trying Sun's /usr/bin/sed and /usr/xpg4/bin/sed
and GNU's /usr/local/bin/gsed.  I was able to get more reliable results
by using ^A instead of DEL, and much better performance with this
command:

sed -n '/^A/!s/^\([^,]*\),[1-9][0-9]*$/\1/p' TAGS
          ^^
          just a single literal Control-A character

Another thing I thought of is that you could use the sed command to
generate a TAGS-FILES file once, whenever you update the TAGS file.
Then, the dired-tags-file command would just need to cat the TAGS-FILE
command (or better yet, visit it in a temporary buffer) to get the file
names to pass to dired.

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-03-16 16:57 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-11  1:35 Finding files with tags mlathe
2006-03-11 11:15 ` Eli Zaretskii
2006-03-13 18:02   ` mlathe
2006-03-13 18:56 ` Kevin Rodgers
2006-03-13 20:48   ` mlathe
2006-03-13 23:32     ` Kevin Rodgers
2006-03-14  2:47       ` mlathe
2006-03-15 22:24         ` Kevin Rodgers
2006-03-16 16:57           ` Kevin Rodgers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).