[Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


3. Various applications

3.1 Global facility for Bash

Special support for bash is available.

3.1.1 Features.

3.1.2 Preparation.

First, do the preparation of global. See section 2.1 Preparation.. And you can invoke bash(1) with --rcfile option.


    $ bash --rcfile /usr/local/share/gtags/globash.rc

You will see a prompt like this:


    [/usr/src/sys]/kern _

This prompt means that the current directory is '/usr/src/sys/kern' and the root of the source tree is '/usr/src/sys'. Tag and marker are valid only in a project.

When you get out of the project, globash warns like:


    [/usr/src/sys] cd ..
    You are going to get out of current project.
    Tag stack and marker will be removed. Sure? ([y]/n)_

If you answer 'y' and RET or just RET in above example then tag stack and marker will be removed.

If you need help then please type 'ghelp'.

3.1.3 Basic usage.

3.1.4 Applied usage.

3.2 Less using GLOBAL.

You can use GLOBAL as a tag system of less instead of ctags.

3.2.1 Features.

3.2.2 Preparation.

First, do the preparation of global. See section 2.1 Preparation..

Second, to use global from less, you need to set environment variable LESSGLOBALTAGS to "global".


    $ export LESSGLOBALTAGS=global

3.2.3 Basic usage.

3.2.4 Applied usage.

3.3 Extended nvi-1.79 using GLOBAL.

You can use GLOBAL as a tag system of Nvi editor instead of ctags.

3.3.1 Features.

3.3.2 Preparation.

First, do the preparation of global. See section 2.1 Preparation..

Second, to use global from nvi, you need to get into gtagsmode. There are several ways to do this:

  1. Start nvi with `-G' option
    
        $ nvi -G file.c
    
    
  2. Start nvi and execute set gtagsmode.
    
        $ nvi file.c
        ~
        ~
        ~
        :set gtagsmode
    
    
  3. Write the above set command to the `.exrc' or `.nexrc' and start nvi
    
        $HOME/.exrc
        +----------------------------
        |set gtagsmode
    
    
    You must start nvi under the source tree described in section 2.1 Preparation..

3.3.3 Basic usage.

3.3.4 Applied usage.

3.4 nvi-1.81.5 using GLOBAL.

You can use GLOBAL as a tag system of Nvi editor instead of ctags.

3.4.1 Features.

3.4.2 Preparation.

First, do the preparation of global. See section 2.1 Preparation..

Second, to use global from nvi, you need write to `.nexrc' like this: It assumed that gtags.pl is put on `$HOME/perl'.


    $HOME/.nexrc
    +----------------------------
    |perl use lib "$ENV{'HOME'}/perl"
    |perl require 'gtags.pl'
    |map ^P :tagprev^M
    |map ^N :tagnext^M
    |map ^] :perl tag^M
    |ab gtag perl tag qw(
    |ab gta perl tag qw(
    |ab gt perl tag qw(

You must start nvi under the source tree described in section 2.1 Preparation..

3.4.3 Basic usage.

3.5 Elvis using global

Elvis 2.1 has new tagprg and tagprgonce variables for running an external tag search program. You can use them with GLOBAL.

3.5.1 Features.

3.5.2 Preparation.

First, do the preparation of global. See section 2.1 Preparation..

Second, start elvis and execute set tagprg="global -t $1" like this.


    $ elvis
    ~
    ~
    ~
    ~
    ~
    ~
    :set tagprg="global -t $1"

3.5.3 Basic usage.

3.5.4 Applied usage.

3.6 Vim using global

In vim 6.2 or later, you can use gtags.vim script.

3.6.1 Features.

3.6.2 Preparation.

First, do the preparation of global. See section 2.1 Preparation..

Second, copy `gtags.vim' to your plugin directory or source it from your vimrc.


    $ cp /usr/local/share/gtags/gtags.vim $HOME/.vim/plugin

3.6.3 Basic usage.

3.6.4 Applied usage.

3.7 Extended emacs using global

You can use GLOBAL as a tag system of Emacs editor instead of etags.

3.7.1 Features.

3.7.2 Preparation.

First, do the preparation of global. See section 2.1 Preparation..

Second, to use global from emacs, you need to load the `gtags.el' and execute gtags-mode function in it.

  1. Write the autoload function to the `$HOME/.emacs', start emacs and execute the gtags-mode function. If you don't put `gtags.el' in standard macro directory, you need to add the directory to load-path.
    
        $HOME/.emacs
        +------------------------------------------------------
        |(setq load-path (cons "/home/owner/global" load-path))
        |(autoload 'gtags-mode "gtags" "" t)
        
        $ emacs
        
        |
        |J_:-----Mule: *scratch*       (Lisp Interaction)--L16--All----
        |M-x gtags-mode[RET]
        +------------------------------------------------------
    
    
    If you want to get into gtags-mode on c-mode then you can append followings into the `$HOME/.emacs'.
    
          (setq c-mode-hook
              '(lambda ()
                  (gtags-mode 1)
          ))
    
    
  2. Specify the root directory of the source tree using gtags-visit-rootdir. If you have tag files in /usr/src/sys then please do like this:
    
        Visit root directory: /usr/src/sys
    
    

3.7.3 Basic usage.

3.7.4 Applied usage.

3.8 Hypertext generator

You can use GLOBAL's facilities from WWW browser.

3.8.1 Features.

3.8.2 Preparation.

At first, you must ensure that you have a lot of disk space. Hypertext needs a great amount of disk space. For example, the source code of FreeBSD kernel needs:


    source code(/usr/src/sys)       14.0MB
    
    GTAGS                            1.5MB
    GRTAGS                           8.0MB
    GSYMS                           12.0MB
    HTML/                           55MB(!!!)
    -------------------------------------------------
    total                           77MB

Please invoke gtags(1)(see section 5.2 gtags - create tag files for global.) and htags(1)(see section 5.3 htags - generate hypertext from source code.) in order like this:


    (at your source directory)
    $ gtags                 # make the tag database(GTAGS,GRTAGS,GSYMS)
    $ htags                 # make the hypertext(HTML/)

Then you will find an `HTML' subdirectory in the current directory.

3.8.3 Usage.

Please start a web browser like this:


    $ lynx HTML/index.html

You will understand the usage by looking at the examples.

You can move the HTML directory to anywhere. It is independent of the source code.

Using mozilla, you can also utilize hypertext from your command line like this:


    $ mozilla				# load mozilla
    $ global -x main
    main        10 main.c main(int argc, char *argv[]) {
    $ gozilla +10 main.c		# usage is similar to vi editor.
    (show main.c at 10 on mozilla's screen.)
    

But in this case, you must not move HTML directory from the source directory.

3.9 Doxygen using global

You can use GLOBAL as a source browser of Doxygen.

Doxygen Release 1.4.3 or later includs config option USE_HTAGS. When enabled in combination with SOURCE_BROWSER=YES, htags(1) is used as the source browser instead of doxygen's own.

Here is an example.


(in source directory)
$ doxygen -g
$ vi Doxyfile
+---------------------------------
|...
|INPUT                  = .
|RECURSIVE              = YES
|SOURCE_BROWSER         = YES
|USE_HTAGS              = YES
|...

$ doxygen
$ lynx html/index.html


[Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]