New Tags Engine for JED

At work I have a lot of programs built from a large list of files distributed almost randomly in a couple of directories. So every time I'm browsing the sources (mainly because I'm looking for a weird bug) I use to spend a lot of time looking where some funny-named functions are defined. This seems like a work for ctags, but the standard was unable to handle the brain-damaged output from the SCO ctags program. For a while I used a slightly patched version, but after some time I got Exuberant ctags and decided to write my own version of JED tags support.

The main features of this version are:

It Has also some drawbacks:

You can download all the needed files here: ntags.tar.gz

How to use all this.

How it works.

The file implements a stack of positions. It allows going backward and forward on this stack, opening files, buffers and windows as needed (this is like navigation, as I discovered later). There are 2 configuration variables you can adjust:

Note that this file doesn't depend on ntags, so it may be used by other scripts as well. I use it also in (see the followgrep page) and in my very own version of, in Others.

The behaviour of file may be tuned by changing the following variables:

To set these variables, and maybe do other things depending where you are, you may use my, look at Project handling.

When looking for a tag, it scans the tags buffer, assigning a score to every matching line. The line with the greatest score is chosen. The score is calculated using the extended information (if available), and comparing the source an destination files. If you want to play with the score calculation, take a look at the psyco_heuristics() function.

Goodies. implements some whole-word searching routines. (some are used by and, so it's here). contains some fun functions. Try binding '(' to intellijed() , (or, if you like the special effects, to intellijed_insert()). These functions try to extract the function definition from the tag line, and shows it with message() (using intellijed()) or insert it in your buffer (intellijed_insert()). All this may work or may not, depending on how you write the code (and how the tags file is built). Works well if you write all the function definition in one line, as in:

   int one_good_function(int x, char *str)
        bla bla;
        return 0;

But not if is written as:

   int one_bad_function(int x,
                        char *str)
       more bla;
      return 1;

So, this should work for some jed source files, but not for gnu indentation style :))).

The intellipointer() function tries to guess the type of the variable under the cursor, and follow the type as a tag. suppose you have written:

   int func(AStructType *a)
       int x;

       x = a->

But you don't remember the field name you need here. No problem, invoke the intellipointer() function (bind this function to a key, I use Ctrl-N). If you are lucky, you'll be warped to the file and position where this type is defined. This works only if the tags files cover the type definition and the variable is either a parameter to the current function or a local variable (and even when these conditions are met, it may not work, but most times it will).

The whatis() function was not written by me, but by the first user of my slang scripts, Maurizio Zanello, a friend which works with me. It searches the definition of the variable under the cursor, and shows it as a message().


I was thinking about rewriting all this using associative arrays instead of a buffer to store the tags. A more or less working version (plenty of bugs here) is in the New Technology Tags Engine. Grab my entire configuration directory tree, and look at file.

Back to home page.

Last Updated : Thu Nov  8 20:54:04 CET 2001