all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* etags
@ 2003-06-17 12:09 Kevin Dziulko
  0 siblings, 0 replies; 6+ messages in thread
From: Kevin Dziulko @ 2003-06-17 12:09 UTC (permalink / raw


Hello

I am looking for a way to get a list of all user defined #define's in some 
C code that actaully get used.  I was reading up a little on etags, and I 
think it might help me with this.  Has anyone done or seen anything close 
to this?

Example:
#include <stdio.h>
#define MSG1 "Hello, world!"
#define CONST1 42

int main ()
{
    (void) printf("\n%s\n", MSG1);

    return 0;
}

/////////////////

Idealy, I would want something to say:

Line 7: MSG1


Perhaps this isn't the best place to post this. If you know a better 
place, please let me know.

Thanks a lot!
Kevin

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

* Re: etags
       [not found] <mailman.8073.1055852045.21513.help-gnu-emacs@gnu.org>
@ 2003-06-19  9:36 ` Alan Mackenzie
  2003-06-19 12:47   ` etags Kevin Dziulko
  0 siblings, 1 reply; 6+ messages in thread
From: Alan Mackenzie @ 2003-06-19  9:36 UTC (permalink / raw


Kevin Dziulko <dziulko@klaatu.canisius.edu> wrote on Tue, 17 Jun 2003
08:09:13 -0400 (EDT):
> Hello

> I am looking for a way to get a list of all user defined #define's in some 
> C code that actually gets used.  I was reading up a little on etags, and I 
> think it might help me with this.  Has anyone done or seen anything close 
> to this?

> Example:
> #include <stdio.h>
> #define MSG1 "Hello, world!"
> #define CONST1 42

> int main ()
> {
>     (void) printf("\n%s\n", MSG1);

>     return 0;
> }

> /////////////////

> Idealy, I would want something to say:

> Line 7: MSG1

grep is your friend.  "man grep" should tell you all you want to know
about it (and a lot more besides).  (I'm guessing you're on some sort of
Unix system, by the way.)  A command something like the following will
give you the information you want:

grep -n "^#define" *.c

You probably won't like the exact form the info takes, so you might want
to pipe it through a small script (written in something like sed or AWK
or Python) to massage it into something more readable.

The above command assumes that all your files.c are in the current
directory.  If they're not, you'll have to "find" them first, then do the
above.  Spend a few hours reading "man find"; it'll be time very well
spent.  Then you'll end up writing something like this:

find . -name "*.c" -exec grep -n "^define" \{} \; -print

> Perhaps this isn't the best place to post this. If you know a better 
> place, please let me know.

It isn't really the best place, no.  One of the groups on Unix shell
commands would have been better.   But what the heck, have a great day.

> Thanks a lot!
> Kevin

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").

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

* Re: etags
  2003-06-19  9:36 ` etags Alan Mackenzie
@ 2003-06-19 12:47   ` Kevin Dziulko
  0 siblings, 0 replies; 6+ messages in thread
From: Kevin Dziulko @ 2003-06-19 12:47 UTC (permalink / raw


On Thu, 19 Jun 2003, Alan Mackenzie wrote:

> Kevin Dziulko <dziulko@klaatu.canisius.edu> wrote on Tue, 17 Jun 2003
> 08:09:13 -0400 (EDT):
> > Hello
> 
> > I am looking for a way to get a list of all user defined #define's in some 
> > C code that actually gets used.  I was reading up a little on etags, and I 
> > think it might help me with this.  Has anyone done or seen anything close 
> > to this?
> 
> > Example:
> > #include <stdio.h>
> > #define MSG1 "Hello, world!"
> > #define CONST1 42
> 
> > int main ()
> > {
> >     (void) printf("\n%s\n", MSG1);
> 
> >     return 0;
> > }
> 
> > /////////////////
> 
> > Idealy, I would want something to say:
> 
> > Line 7: MSG1
> 
> grep is your friend.  "man grep" should tell you all you want to know
> about it (and a lot more besides).  (I'm guessing you're on some sort of
> Unix system, by the way.)  A command something like the following will
> give you the information you want:
> 
> grep -n "^#define" *.c
> 
> You probably won't like the exact form the info takes, so you might want
> to pipe it through a small script (written in something like sed or AWK
> or Python) to massage it into something more readable.
> 
> The above command assumes that all your files.c are in the current
> directory.  If they're not, you'll have to "find" them first, then do the
> above.  Spend a few hours reading "man find"; it'll be time very well
> spent.  Then you'll end up writing something like this:
> 
> find . -name "*.c" -exec grep -n "^define" \{} \; -print
> 
> > Perhaps this isn't the best place to post this. If you know a better 
> > place, please let me know.
> 
> It isn't really the best place, no.  One of the groups on Unix shell
> commands would have been better.   But what the heck, have a great day.
> 
> > Thanks a lot!
> > Kevin
> 
> 

Thanks for your reply, but "grep -n "^#define" *.c" isn't even close to 
what I'm looking for.  I don't want a list of #define'ed constants, but 
rather #define'ed constants *THAT ACTUALLY GET USED*. That's why in my 
example I just wanted "Line 7: MSG1" and nothing about CONST1 to 
ever get listed. [also, I only want defines from my local program listed, 
and not any of the system library defines]. The cxref command is the 
closest to this that I've found thus far.

Which one of the Unix shell groups should I use?  I can't seem to find the 
right mailing list.

Thanks again!!
Kevin

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

* Re: etags
       [not found] <mailman.8237.1056026853.21513.help-gnu-emacs@gnu.org>
@ 2003-06-19 17:42 ` Peter Lee
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Lee @ 2003-06-19 17:42 UTC (permalink / raw


>>>> Kevin Dziulko writes:
    Kevin> Thanks for your reply, but "grep -n "^#define" *.c" isn't
    Kevin> even close to what I'm looking for.  I don't want a list of
    Kevin> #define'ed constants, but rather #define'ed constants *THAT
    Kevin> ACTUALLY GET USED*. That's why in my example I just wanted
    Kevin> "Line 7: MSG1" and nothing about CONST1 to ever get
    Kevin> listed. [also, I only want defines from my local program
    Kevin> listed, and not any of the system library defines]. The
    Kevin> cxref command is the closest to this that I've found thus
    Kevin> far.

Seems like with a little lisp you could take the output of the above
grep and put it in a buffer.  Then using a regex pattern to match your
actual constant, on that buffer, perform a grep on each one appending
the output to a seperate buffer.

Or you could do the above and if grep returns nothing for a given
constant, put that constant in a buffer... when it's done then all you
have is a list of constants that are *not* used and can then infer
that all others must be used somewhere.

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

* etags
@ 2004-10-06  2:18 moheb missaghi
  0 siblings, 0 replies; 6+ messages in thread
From: moheb missaghi @ 2004-10-06  2:18 UTC (permalink / raw


Hi, I created a tags file using etags *.el */*.el in the lisp dir. find-tag
works when emacs is fired for just 1 time and then I get:

wrong type argument: stringp...

Any idea? thx.

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

* etags
@ 2009-11-09  6:53 Matzi Kratzi
  0 siblings, 0 replies; 6+ messages in thread
From: Matzi Kratzi @ 2009-11-09  6:53 UTC (permalink / raw
  To: emacs-devel

Hi,
I use etags a lot and find it invaluable for navigation in all code -
especially code that I am not familiar with.

I often find functions in several files that have the same name. I
think it would be good if etags could "prefer" find the function in
the buffer where I am calling find-tag from.

In the files below, go to file b and place the cursor at
"default_handler();". Wouldn't it make sense to end up in the the same
buffer?

Anyway, thanks a lot for all good work.

/Mats

file a.c
---------------8<----------------------
#include <stdio.h>

static void default_handler(void)
{
  printf("Default in a!\n");
}

void a(void)
{
  default_handler();
}
---------------8<----------------------


---------------8<----------------------
#include <stdio.h>

static void default_handler(void)
{
  printf("Default in b!\n");
}

int main(void)
{
  default_handler();
  a();

  return 0;
}
---------------8<----------------------




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

end of thread, other threads:[~2009-11-09  6:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-09  6:53 etags Matzi Kratzi
  -- strict thread matches above, loose matches on Subject: below --
2004-10-06  2:18 etags moheb missaghi
     [not found] <mailman.8237.1056026853.21513.help-gnu-emacs@gnu.org>
2003-06-19 17:42 ` etags Peter Lee
     [not found] <mailman.8073.1055852045.21513.help-gnu-emacs@gnu.org>
2003-06-19  9:36 ` etags Alan Mackenzie
2003-06-19 12:47   ` etags Kevin Dziulko
2003-06-17 12:09 etags Kevin Dziulko

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.