Version 10 of Exuberant Ctags

Updated 2017-01-30 13:25:07 by JMN

What: Exuberant Ctags

 Where: http://ctags.sf.net/ 
 Description: Multi-language reimplementation of the Unix ctags program.
        Generates an index of source code object definitions which is used
        by many editors and tools to look up definitions.  Currently supports
        Assembler, AWK, BETA, Bourne Shell, C, C++, COBOL, Eiffel, FORTRAN,
        Java, LISP, Perl, Python, Scheme, Tcl, Vim, YACC.
        Currently at version 5.5 .
 Updated: 11/2000
 Contact: See SF.net page for details.

Exuberant Ctags appears to be unmaintained, but the Universal Ctags project (https://ctags.io/ ) aims to continue Ctags development. More generally, see Ctags


AM A very simple-minded solution for just Tcl files in one directory is this:

 # Doodle to determine "tags" file
 #
 proc writeAllTags {tagfile sourcefile} {
    set infile [open $sourcefile]

    while { [gets $infile line] >= 0 } {
       if { [regexp {proc\s(\S+)} $line fullpatt fullname] } {
          regexp {[^:]+$} $fullname name
          puts $tagfile "$name\t$sourcefile\t/$fullpatt/"
       }
    }

    close $infile
 }

 set tagfile [open "tagstmp" "w"]
 foreach f [glob -nocomplain "*.tcl"] {
    puts $f
    writeAllTags $tagfile $f
 }
 close $tagfile

 # The tags facility expects the tags to be sorted ...

 exec sort tagstmp >tags

(For reasons I have not sorted out yet, "exec sort tagstmp > tags" does not work - at least on my system!) (PBO: missing a "close $tagfile" before the "exec sort ..." ? AM Yes, a mistake I should never have made :( )


Sarnold adds: On Windows, sort might not be available. Here is a Windows pure-Tcl version of the same basic tags generator:

 # Doodle to determine "tags" file
 #
 proc getAllTags {tags sourcefile} {
    set infile [open $sourcefile]

    while { [gets $infile line] >= 0 } {
       if { [regexp {proc\s(\S+)} $line fullpatt fullname] } {
          regexp {[^:]+$} $fullname name
          lappend tags "$name\t$sourcefile\t/$fullpatt/"
       }
    }

    close $infile
    return $tags
 }

 set tags ""
 foreach f [glob -nocomplain "*.tcl"] {
    lappend tags $f
    set tags [getAllTags $tags $f]
 }

 # The tags facility expects the tags to be sorted ...

 set tags [lsort $tags]
 set ftags [open tags w]
 foreach line $tags {puts $ftags $line}
 close $ftags

See also: