ctags 5.7 improves Perl support

Exuberant ctags, the standard tags utility on most systems today, has released version 5.7 for download with the following improvements to its Perl support (among many other improvements):

  • Added support for 'package' keyword
  • Added support for multi-line subroutine, package, and constant definitions
  • Added support for optional subroutine declarations
  • Added support for formats
  • Ignore comments mixed into definitions and declarations
  • Fixed detecting labels with whitespace after label name
  • Fixed misidentification of fully qualified function calls as labels

If you've never used tags or ctags, start today. Your life will never be the same after.

For example, if you run ctags on a tree of source code, and then run vim -t some_function from the shell, vim will open the file where some_function lives and leave your cursor there. Alternatively, if you're editing a file with vim and you position your cursor over the word some_function and press Ctrl-], vim will jump to the function. Other editors have similar bindings.

Your editor doesn't know Perl, but it relies on ctags generating a tags file, which is in a standard file. Of course, ctags isn't perl itself, so isn't as exact. These improvements in v5.7 will make your tag files more accurate.

If you've got a Perl module, it's easy to add a makefile target for tags. See any of my major modules (WWW::Mechanize, ack, etc) and steal from the Makefile.PL, or just add the following to your Makefile.PL:

sub MY::postamble {
    my $postamble = <<'MAKE_FRAG';
.PHONY: tags

tags:
	ctags -f tags --recurse --totals \
		--exclude=blib \
		--exclude=.svn \
		--exclude='*~' \
		--languages=Perl --langmap=Perl:+.t \
MAKE_FRAG
}
(With ctags 5.7 it turns out, that --exclude=.svn is no longer necessary, as ctags automatically knows to ignore it now.)

0 TrackBacks

Listed below are links to blogs that reference this entry: ctags 5.7 improves Perl support.

TrackBack URL for this entry: http://perlbuzz.com/cgi-bin/mt/mt-tb.cgi/112

Leave a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About this Entry

This page contains a single entry by Andy Lester published on September 8, 2007 4:22 PM.

Copenhagen to host YAPC::EU 2008: Official announcement was the previous entry in this blog.

mod_perl 2 User's Guide published: An interview with co-author Jim Brandt is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Other Perl Sites

Other Swell Blogs

  • geek2geek: An ongoing analysis of how geeks communicate, how we fail and how to fix it.
Technorati Profile