Forum OpenACS Q&A: Response to Tcl namespaces and Emacs etags

Collapse
Posted by Dan Wickstrom on
It depends on the style used for declaring namespaces. If you declare namespaces that don't have proc definitions and then later declare the procs separately as follows, then etags will work with tcl namespaces:

namespace eval blah {
	variable foo_var
}

proc blah::bar_proc {} {

}

proc blah::baz_proc {} {

}

I use an alias to generate the etags file:

alias tcltags='etags --regex="/proc[ 	]+([^ 	]+)//" --regex="/proc_doc[ 	]+([^ 	]+)//" --regex="/ad_proc[ 	]+((-([^ 	]+)[ 	]+)+)?([^ 	]+)//" `find . -name "*.tcl"`'
This should actually be rewritten to use xargs, but so far I haven't had problems with too many files yet.

If you use the namespace declaration style that encloses the proc defintions:

namespace eval blah {

	proc bar_proc {} {

	}

	proc bax_proc {} {

	}
}
Then I think it gets pretty hard to handle this format with a simple regexp. I've looked at the etags file format, and I think it would be fairly straight forward to create a perl script (or with a little more work a tcl script) that would generate the correct tag file for either package declaration format.