Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

etags for Tcl?

171 views
Skip to first unread message

Steve Pothier

unread,
May 24, 1996, 3:00:00 AM5/24/96
to

Ok, I've tried my lame searches to no avail. Can anyone tell me where to
find a version of etags that will create tags for Tcl?? Surely there must be
one somehwere!

advTHANKSance,
-sp-

Emmanuel Kartmann

unread,
May 28, 1996, 3:00:00 AM5/28/96
to "pothier@a...@vbormc.vbo.dec.com

Here's one tcl script (tcltags) that build an emacs tags file from a
list of Tcl sources.

#!/usr/local/bin/tcl -f
#
# Make Emacs-style TAGS file for Tcl source.
# Tom Tromey <tro...@cns.caltech.edu> Mon Feb 15 1993
# Emmanuel KARTMANN <kart...@azur.enet.dec.com> Thu Nov 30 1995
#

# tcltags is not part of GNU Emacs, but is distributed under the same
# terms (IE the GNU Public License). tcltags is really only useful
# with GNU Emacs anyway.

# GNU Emacs is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY. No author or distributor
# accepts responsibility to anyone for the consequences of using it
# or for whether it serves any particular purpose or works at all,
# unless he says so in writing. Refer to the GNU Emacs General Public
# License for full details.

# Everyone is granted permission to copy, modify and redistribute
# GNU Emacs, but only under the conditions described in the
# GNU Emacs General Public License. A copy of this license is
# supposed to have been given to you along with GNU Emacs so you
# can know your rights and responsibilities. It should be in a
# file named COPYING. Among other things, the copyright notice
# and this notice must be preserved on all copies.


# KNOWN BUGS:
# * Should support updating existing tags files, ctags format, etc.
# * Should integrate with etags program somehow.

# Configuration stuff:
set verbose 1

#
# "rexp" is an array of regular expressions. Each must have exactly one
# parenthesized subexpression, which should match the tag exactly.
# The array indices are unimportant. The regexp as a whole should
# match the line containing the tag, up to the tag but not past it.
#
# Bogus quoting gyrations because Tcl regexps interpret \t as
# "t" and not TAB.
set rexp(proc) "^proc\[\ \t\]+(\[^\ \t\]+)"

# Next two are for local Tcl procs, for example purposes only.
# I can't give out defvar and defoption, sorry.
# set rexp(defvar) "^defvar\[\ \t\]+(\[^\ \t\]+)"
# set rexp(defoption) "^defoption\[\ \t\]+(\[^\ \t\]+)"

# itcl extensions
set rexp(itcl_class) "^itcl_class\[\ \t\]+(\[^\ \t\]+)"
set rexp(itcl_method) "^\[\ \t\]*method\[\ \t\]+(\[^\ \t\]+)"

#
# Figure out tags for one file.
#
proc tagify_file {file TAGS} {
global rexp verbose

if $verbose then {
puts stderr "Doing $file..." nonewline
}

set f [open $file r]
set where 0
set lineNo 0
while {[gets $f line] >= 0} {
foreach try [array names rexp] {
if [regexp $rexp($try) $line match tag] then {
if [info exists fileTags($tag)] then {
puts stderr "\n\tDuplicate tag $tag, ignoring"
} else {
set fileTags($tag) $match
append fileTags($tag) \177
append fileTags($tag) $lineNo,$where
append fileTags($tag) \n
}
break
}
}
incr where [string length $line]
incr lineNo
}
close $f

# Now sort list by tag, and create entry, but only if a tag was
# found.
set entry {}
if [string length [info locals fileTags]] then {
foreach tag [lsort [array names fileTags]] {
append entry $fileTags($tag)
}
}

# Write file part and then entry to TAGS file.
puts $TAGS \014
puts $TAGS $file,[string length $entry]
puts $TAGS $entry nonewline

if $verbose then {
puts stderr done
}
}

# Very simple arg parsing (-o for output file name)
if {[lindex $argv 0] == "-o"} {
set files [lrange $argv 2 end];
set tagfile [lindex $argv 1];
} else {
set files $argv;
set tagfile TAGS;
}

# Open output file
set TAGS [open $tagfile w];

# Munge every file listed on the command line.
foreach file $files {
tagify_file $file $TAGS
}

close $TAGS

# That's all folks
# --------------------------------------------------------------------

************************************************************************
* Emmanuel "W4" KARTMANN "W4 ? Weaving the World Wide Web !"
* mailto:kart...@azur.enet.dec.com
************************************************************************

Sidney Hellman

unread,
May 28, 1996, 3:00:00 AM5/28/96
to

In article <yyieno98wzy.fsf@mistral> pothier@mistral (Steve Pothier) writes:

>
> Ok, I've tried my lame searches to no avail. Can anyone tell me where to
> find a version of etags that will create tags for Tcl?? Surely there must be
> one somehwere!
>

I use a tcl script called tcltags, that I pulled off the net
someplace. According to the comments, it was written by Tom Tromey.

here it is in its entirety.. There may very well be a newversion out
there someplace.

Sid

#!/usr/local/bin/tcl -f
#
# Make Emacs-style TAGS file for Tcl source.
# Tom Tromey <tro...@cns.caltech.edu> Mon Feb 15 1993

# $Id: tcltags,v 1.1 1993/02/19 20:53:29 tromey Exp $
#


#

# Open output file
set TAGS [open TAGS w]

# Munge every file listed on the command line.

foreach file $argv {
tagify_file $file $TAGS
}

close $TAGS

--
Sid Hellman - Systems Analyst/Programmer - at the Passcal Instrument Center
Lamont-Doherty Earth Observatory of Columbia University
s...@ldeo.columbia.edu (603)878-1808 http://www.ldeo.columbia.edu/~sid
or to reach the Virtual Sid in New Hampshire.... s...@stowe.mv.com

Tom Tromey

unread,
May 29, 1996, 3:00:00 AM5/29/96
to

>>>>> "Sidney" == Sidney Hellman <s...@localhost.mv.com> writes:

Sidney> I use a tcl script called tcltags, that I pulled off the net
Sidney> someplace. According to the comments, it was written by Tom
Sidney> Tromey.

Sidney> here it is in its entirety.. There may very well be a
Sidney> newversion out there someplace.

There isn't a new version. The last few versions of Emacs have had
regexp-matching capability in etags. It is much faster and easier to
use this to generate tags files for Tcl code. It also means you can
mix tags from Tcl with tags from other languages.

The Emacs manual gives this example for generating tags from Tcl:

Tag TCL files (this last example shows the usage of a NAMEREGEXP):

--lang=none --regex='/proc[ \t]+\([^ \t]+\)/\1/'

Tom
--
tro...@cygnus.com Member, League for Programming Freedom
I have forgotten to mention that 'Art' is the only word
which carp are able to say.
-- Rene Daumal

0 new messages