Chapter D8
Using Tags

Finding your way around in the Cactus structure can be pretty difficult to handle. To make life easier there is support for tags, which lets you browse the code easily from within Emacs/XEmacs or vi. A tags database can be generated with gmake:

D8.1 Tags with Emacs

The command gmake TAGS will create a database for a routine reference table to be used within Emacs. This database can be accessed within Emacs if you add either of the following lines to your .emacs file:
(setq tags-file-name "CACTUS_HOME/TAGS") XOR
(setq tag-table-alist ’(("CACTUS_HOME" . "CACTUS_HOME/TAGS")))
where CACTUS_HOME is your Cactus directory.

You can now easily navigate your Cactus flesh and Toolkits by searching for functions or “tags”:

  1. Alt. will find a tag
  2. Alt, will find the next matching tag
  3. Alt* will go back to the last matched tag

If you add the following lines to your .emacs file, the files found with tags will opened in read-only mode:

(defun find-tag-readonly (&rest a)  
  (call-interactively ‘find-tag a)  
  (if (eq nil buffer-read-only) (setq buffer-read-only t))  )  
(defun find-tag-readonly-next (&rest a)  
  (call-interactively ‘tags-loop-continue a)  
  (if (eq nil buffer-read-only) (setq buffer-read-only t))  )  
(global-set-key [(control meta \.)] ’find-tag-readonly)  
(global-set-key [(control meta \,)] ’find-tag-readonly-next)

The key strokes to use when you want to browse in read-only mode are:

  1. CTRL Alt. will find a tag and open the file in read-only mode
  2. CTRL Alt, will find the next matching tag in read-only mode

D8.2 Tags with vi

The commands available are highly dependent upon the version of vi, but the following is a selection of commands which may work.

  1. vi -t tag Start vi and position the cursor at the file and line where ‘tag’ is defined.
  2. Control-] Find the tag under the cursor.
  3. :ta tag Find a tag.
  4. :tnext Find the next matching tag.
  5. :pop Return to previous location before jump to tag.
  6. Control-T Return to previous location before jump to tag (not widely implemented).

Note: Currently some of the CCTK_FILEVERSION() macros at the top of every source file don’t have a trailing semicolon, which confuses the etags and ctags programs, so tags does not find the first subroutine in any file with this problem.