[Cook] Generating tags?

Jerry Pendergraft jerry at endocardial.com
Tue Jul 22 07:10:19 EST 2003


There

-- 
Jerry Pendergraft                        jerry.pendergraft at endocardial.com
Endocardial Solutions                    voice: 651-523-6935
1350 Energy Lane, Suite 110                fax: 651-644-7897
St Paul, MN 55108-5254                  mobile: 651-491-0163

On Tue, 22 Jul 2003, gaulanm wrote:

> I'd like to use cook to build a 'tags' file for our project.  Below is 
> what I've come up with--can anyone suggest a cleaner way?  I have three 
> separate targets:
>     'cook etags' builds a TAGS file, using the 'etags' program;
>     'cook ctags' builds a tags file, using the 'ctags' program;
>     'cook tags' builds TAGS or tags, based on the user's EDITOR 
> environment variable.
> Thanks for any suggestions,
> Mike
> 
> /*
>  * Build a 'tags' (vi) or 'TAGS') file.  The 'makeTags' function expects
>  * a single argument, either 'tags' or 'TAGS', then makes the appropriate
>  * file, using the 'ctags' or 'etags' program.
>  */
> function makeTags =
> {
>     if [matches "tags" [@1]] then {
>         TagsCommand = "ctags";
>     } else if [matches "TAGS" [@1]] then{
>         TagsCommand = "etags";
>     } else {
>         fail [catenate "Unknown tag file: " [@1]];
>     };
> 
>     /* Remove the old tags file: */
>     rm -f [@1];
> 
>     /*
>      * 'files' is the list of files to extract tags from.  Note that
>      * this may change when switching between the 'leon' and 'synth'
>      * platforms.
>      */
>     files = [src] [header_files];
> 
>     /*
>      * For each file of interest, invoke the tag-generating fuction,
>      * and append the tags to the list.
>      */
>     loop {
>         nextFile = [head [files]];
>     if [not [nextFile]] then loopstop;
>         files = [tail [files]];
>     
>         [shell [TagsCommand] --append [nextFile]];
>     }
> };
> 
> /*
>  * Use 'cook tags' to remake your tags file based on your EDITOR
>  * environment variable (make 'TAGS' using 'etags' if you're using Emacs;
>  * otherwise we assume vi and use 'ctags' to generate 'tags').
>  *
>  * 'set forced' forces the file to be rebuilt, even if the file 'tags' 
> exists.
>  */
> tags: [src] [header_files] set forced
> {
>    if [matches %macs [getenv EDITOR]] then {
>        [makeTags TAGS];
>    } else {
>        [makeTags tags];
>    }
> }
> 
> /*
>  * 'cook ctags' will make a 'tags' file, even if you're using Emacs.
>  */
> ctags:
> {
>     [makeTags tags];
> }
> 
> /*
>  * 'cook etags' will make a 'TAGS' file, even if you're no using Emacs.
>  */
> etags:
> {
>     [makeTags TAGS];
> }
> 
> _______________________________________________
> Cook-users mailing list
> Cook-users at auug.org.au
> http://www.auug.org.au/mailman/listinfo/cook-users
> 




More information about the Cook-users mailing list