[comp.emacs] Is there a fix for "File tags not a valid tag table"?

todd@hpfcdq.HP.COM (Todd Spencer) (06/13/89)

I'm running emacs version 18.51.1 on a HP 9000/360 and I'm trying to
get ESC-. (find-tag) working.  It appears that the "tags" file I
create via "ctags" is incompatible with my version of emacs.
The error message I receive is "File tags not a valid tag table."

The documentation instructs that the tags file is to be created with
the "etags" command (not "ctags").  Where do I get such a beast? or
is the "ctags" command ok to use - which means my emacs is broken?

Send comments to todd@hpfcra.hp.com

Thanx in advance.
Todd

ecb@utrccm (ecb) (06/13/89)

on 12 Jun 89 20:11:42 GMT,
Todd Spencer <hpfcdc!hpfcdq!todd@hplabs.hp.COM> said:

Todd> The documentation instructs that the tags file is to be created with
Todd> the "etags" command (not "ctags").  Where do I get such a beast? or
Todd> is the "ctags" command ok to use - which means my emacs is broken?

On my system etags.c is in $EMACS/etc/etags.c and etags is in both
$EMACS/etags and $EMACS/etc/etags. If you don't find them there on
yours let me know and I'll send you my copy of the source code.

This brings up a question I've wondered about for some time now. Can
anyone tell me what the difference is between ctags and etags? On the
face of it, it looks as if one is better for C code and the other is
better for elisp, but Todd's question and my own experience seem to
negate that idea. What's the difference?

Also, I don't like having to run etags as a shell command. Can anyone
tell me how I can bind it to a key, or at least run it as an argument
to M-x? 


			Bud Boman
			United Technologies Research Center
			(203) 727-7128
			ecb@utrccm.smc.utc.com

todd@hpfcdq.HP.COM (Todd Spencer) (06/14/89)

For those of you who are interested in using tags within emacs but haven't
been able to get it to work listen up:  (The find-tag command is a great
way of locating where functions, macros, and typedefs are defined - very
useful when working with several thousand lines of code.)

Use the "etags" command to create your TAGS file.  This file is
found under the emacs etc directory, e.g.,
/usr/local/gnu-emacs/dist-18.51/etc/etags
and by default creates a TAGS file in the current directory containing
the location information for all functions/macros/typedefs found in
the files specified, (etags *.c *.h ../mystuff/*).  Do a man on ctags/etags
for more information.

To use emacs tags you will need to modify your ~/.emacs file to include
the following lines:

  ;; Load tags file - otherwise might encounter ABS undefined error.
  (load-file "/usr/local/gnu-emacs/dist-18.51/lisp/tags.elc")
  ;; Suppress prompt asking for name of tags file by binding variable.
  (setq-default tags-file-name "TAGS")

Now, to use the find-tag command position the cursor over the
function you desire to locate and press ESC followed by period (ESC-.).
A new buffer will be created (if necessary) and the cursor positioned
at the start of the function's definition.  It works like a charm.

Todd

pablo@ppgbms (Pablo Gonzalez) (06/14/89)

I am developing an application written mostly in PostScript and using
a tool called ptags that generates a ctags formatted file. Emacs
version 18.52 comes up with the same error message when reading the
tags file. 

I would appreciate any info on any macros available to either convert
a ctags table to etags format, or to have emacs read a ctags formatted file.

	Thanks,

	Pablo Gonzalez
	One Campus Drive
	Pleasantville, N.Y.  10570

	(914) 741-4626

	path ppgbms!moe!pablo@philabs.phillips.com
	

kim@kim.misemi (Kim Letkeman) (06/14/89)

In article <380001@hpfcdq.HP.COM>, todd@hpfcdq.HP.COM (Todd Spencer) writes:
> I'm running emacs version 18.51.1 on a HP 9000/360 and I'm trying to
> get ESC-. (find-tag) working.  It appears that the "tags" file I
> create via "ctags" is incompatible with my version of emacs.
> The error message I receive is "File tags not a valid tag table."
> 
> The documentation instructs that the tags file is to be created with
> the "etags" command (not "ctags").  Where do I get such a beast? or
> is the "ctags" command ok to use - which means my emacs is broken?
> 
> Send comments to todd@hpfcra.hp.com
> 
> Thanx in advance.
> Todd

ctags was originally designed to work (I believe) with vi. It also
works well with jove. It does not work at all with gnu emacs. The 
file structures are completely different. 

I do not have any manuals, so I don't know all the ins and outs of
emacs's tag tables, but I have reverse engineered both vi and emacs
tag files to be used with a custom version of PASCAL that is used
here.

A vi tag file contains records of the format:

<search key>\t<filename>\t/pattern/

The search key is a function name (or variable if you are using that
feature.) The search key may be preceded by an "M" if it is the main
of a specific program. The search pattern can use ?pattern? if you
want it to search backwards. This allows you to see the function
definition if it occurs in the same file before your current position
(or some such reason.) The tag table must be sorted lexically.

In emacs, the tag file has a more global structure. There is an entry
for each file that consists of:

^L
<filename>,<total characters in tag entry for this file>
<search key>^?<character offset in file>,<line offset in file>
<search key>^?<...>,<...>

and so on ...

As you can see, this is a much more complex structure, but it allows
some very nice functionality. For example, searching is extremely fast
because emacs tries to find the search key at the specified offset
first. Since it is usually there, response is immediate. If the file
has been changed, emacs will search until it finds the key, it just
takes a bit longer.

I wrote an awk program to generate a tag table for our PASCAL source
files and the results were nothing short of spectacular. I can
instantaneously look at all files that contain a function or procedure
that has any arbitrary character sequence as part of the name. It
works to perfection (something my vi table never quite accomplished
under jove.)

Anyway ... etags is capable of building tag tables for C (with defines
if you want) and for lisp. It handles a number of other language as
well. Interestingly, it does not purport to handle PASCAL at all.

On the other hand, ctags does purport to handle PASCAL, but the man
page admits that the handling is not very clean, a fact that I can
verify through experience. I would recommend that you use etags and
forget that ctags exists.

You should be able to find etags in $EMACS/etc.

Kim

P.S. I'm pretty new to the net and don't have my signature figured out
yet. Sorry.

thf@otter.hpl.hp.com (Toby Ferguson) (06/14/89)

In article <8906131549.AA01104@utrccm.SMC.UTC.COM> ecb@utrccm (ecb) writes:

   This brings up a question I've wondered about for some time now. Can
   anyone tell me what the difference is between ctags and etags? On the
   face of it, it looks as if one is better for C code and the other is
   better for elisp, but Todd's question and my own experience seem to
   negate that idea. What's the difference?

As I understand it, ctags creates output for vi and etags creates output for
emacs.  The emacs tags are superior to those for vi in that the ability to
traverse the directory hierarchy is supported by emacs tagging but not for vi.
(This was one of the original reasons for me switching from vi to emacs!)

However it *might* be that ctags supports c code better than etags does, but I
haven't the experience to say one way or the other.  (I could RTFM and give you
my opinion but I'm sure you don't want that! ;-) )


Toby Ferguson
=============================================================================
e-mail: thf@otter (Bristol internal)
	thf@hplb.hpl.hp.com (USA + HP internal)
	thf@hpl.hp.co.uk (Europe)
HPDESK: thf /hpc600/ux
In real life : Toby Ferguson, MTS, HPLABS, Bristol
=============================================================================
--
Toby Ferguson
=============================================================================
e-mail: thf@otter (Bristol internal)
	thf@hplb.hpl.hp.com (USA + HP internal)
	thf@hpl.hp.co.uk (Europe)
HPDESK: thf /hpc600/ux
In real life : Toby Ferguson, MTS, HPLABS, Bristol
=============================================================================

weiner@novavax.UUCP (Bob Weiner) (06/15/89)

In article <8906131549.AA01104@utrccm.SMC.UTC.COM> ecb@utrccm (ecb) writes:

   This brings up a question I've wondered about for some time now. Can
   anyone tell me what the difference is between ctags and etags?

Ctags works only on C files.  Etags works on any combination of C,
Fortran, and Lisp files.  Thus, one etags file will suffice for a
program written in multiple languages such as GNU Emacs (C and Lisp).

   Also, I don't like having to run etags as a shell command. Can anyone
   tell me how I can bind it to a key, or at least run it as an argument
   to M-x? 

{M-!} runs 'shell-command'.  Hence, {M-! etags <files>} will work if
etags is in your search path.  This is probably your best bet since if
you write an Emacs command that calls etags, you will have to
interactively prompt for a series of files and you won't be able to use
filename wildcarding.  Just keep your program sources in separate
directories and then use something like 'etags *.[ch]'.

-- 
Bob Weiner, Motorola, Inc.,   USENET:  ...!gatech!uflorida!novavax!weiner
(407) 738-2087

thf@otter.hpl.hp.com (Toby Ferguson) (06/15/89)

In article <380002@hpfcdq.HP.COM> todd@hpfcdq.HP.COM (Todd Spencer) writes:

   To use emacs tags you will need to modify your ~/.emacs file to include
   the following lines:

     ;; Load tags file - otherwise might encounter ABS undefined error.
     (load-file "/usr/local/gnu-emacs/dist-18.51/lisp/tags.elc")
     ;; Suppress prompt asking for name of tags file by binding variable.
     (setq-default tags-file-name "TAGS")

This is just not true!  There is NO need to do all this stuff to get it to
work!  All that has to be done is to hit M-. and you're asked which TAGS file
to scan.  RTFM!

Toby Ferguson
=============================================================================
e-mail: thf@otter (Bristol internal)
	thf@hplb.hpl.hp.com (USA + HP internal)
	thf@hpl.hp.co.uk (Europe)
HPDESK: thf /hpc600/ux
In real life : Toby Ferguson, MTS, HPLABS, Bristol
=============================================================================
--
Toby Ferguson
=============================================================================
e-mail: thf@otter (Bristol internal)
	thf@hplb.hpl.hp.com (USA + HP internal)
	thf@hpl.hp.co.uk (Europe)
HPDESK: thf /hpc600/ux
In real life : Toby Ferguson, MTS, HPLABS, Bristol
=============================================================================

jcgs@wundt.harlqn.uucp (John Sturdy) (06/22/89)

In article <8906131549.AA01104@utrccm.SMC.UTC.COM> ecb@utrccm (ecb) writes:
   Also, I don't like having to run etags as a shell command. Can anyone
   tell me how I can bind it to a key, or at least run it as an argument
   to M-x? 
If you're using make to run your compilations, you can set up TAGS as
a target, with the appropriate files called for etc etc.
--
__John            The Lord bless you and watch over you, The Lord make his face
         shine upon you and be gracious to you, The Lord look kindly on you and
   give you peace; My brothers, my sisters, God bless you. Amen.  (St. Francis)