Solution for using Exuberant Ctags

Solution for using Exuberant Ctags

19
Basic UserBasic User
19

    Sep 16, 2014#1

    I did not know how to setup CTAGS. I thought I would share the batch file I created to generate them.

    Code: Select all

    @echo off
    rem Create Ctags procedure
    rem file mkRSICTAG.bat
    rem run from comand prompt vbusb link with start in dir set to c:\vbusb
    rem A
    rem create lists of php files for input into EXUBERANT CTAGS
    rem source directory project 1
    rem dir /b /s R:\*.php > C:\vbusb\rsi\SearchResults1.txt
    rem source directory project 2
    rem dir /b /s P:\*.php > C:\vbusb\rsi\SearchResults2.txt
    
    rem B backup old CTAG file
    rem del back php CTAG file
    del  C:\CTAG\RSIBIGTAG.jic
    rem back existing php CTAG
    
    rem xcopy is not for just one file
    copy C:\CTAG\RSIBIGTAG.txt C:\CTAG\RSIBIGTAG.jic /y
    
    rem C
    rem use UE CTAGS to create and append CTAGS for 1 and 2 php files
    rem  1
    "C:\Program Files\IDM Computer Solutions\UltraEdit\GNU\ctags" -f C:\CTAG\RSIBIGTAG.txt -a -R --exclude=.svn --language-force=PHP -L C:\vbusb\rsi\SearchResults1.txt
    
    rem 2
    "C:\Program Files\IDM Computer Solutions\UltraEdit\GNU\ctags" -f C:\CTAG\RSIBIGTAG.txt -a -R --exclude=.svn --language-force=PHP -L C:\vbusb\rsi\SearchResults2.txt
    Whenever I have to decide between two evils, I always choose the one I haven't tried before. -Mae West

    6,600548
    Grand MasterGrand Master
    6,600548

      Sep 16, 2014#2

      Wow, you really wrote a batch file to run ctags.exe for creating the tag file. The usage of a batch file is really not needed.

      There are two possibilities to use Exuberant Ctags.


      For active file only.

      This is rarely used as it does not make much sense to create a symbol database for just a single file.

      However, opening Project - Ctag Options, specifying a default tag file and using the options -L %fi -f %fo with additional Ctags options if needed makes it possible to use Project - Create CTAG File. Then Search - Find Symbol can be used in this file.


      For all files of a project.

      The usage of Ctags for projects is what increases efficiency in writing code.

      Before Ctags can be used for a project, it is of course necessary to create a project using Project - New Project/Workspace. For large projects the method with adding folders using filters is the best method to add files to a project. This results in a dynamic list of project files always including all files in the specified folders (and subfolders) according to the used filters. For small projects where list of project files change only rarely the method of adding the files manually perhaps to groups (instead of folders) is often better. See Create project from an existing directory tree? for details about those two different project files management. It is of course possible to use both methods in same project. For example including header files of a used library using group method additionally to the dynamic list of self-coded project sources and headers using folder method.

      In UltraEdit in the project settings dialog opened with Project - Project Settings it is possible to specify the name and location of the Ctags tag file and if this tag file should be created/updated automatically on project load which makes most sense if often project files are modified/added/deleted outside UltraEdit/UEStudio while the project is not loaded.

      In UEStudio there are 2 symbol parsers available, the parser of UEStudio itself and of course also Ctags. The IntelliTips features (function tips, can be used only with using parser of UES.

      In UEStudio in Project Settings dialog there is on tab Settings the option Legacy Ctags Support which must be enabled to use Ctags instead of parser of UEStudio for this project. Then the name and location of the tag file and the option for creating the tag file on project load are available like in UltraEdit.

      Like for a single file the options defined under Project - Ctag Options define the parameters passed to Ctags.exe on execution for creating the tag file for all files of the project. UE/UES creates the list file with full names of all project files. The full name of the dynamically created list file is passed with -L %fi to Ctags.exe. Do not put double quotes around %fi and %fo as this is done by UE/UES automatically on replacing those 2 placeholders.

      Other parameters for Ctags can be specified in the Tag File Options dialog as well. UE/UES passes itself adds as first parameter only --fields=+n. All other parameters for Ctags must be specified in the options dialog.

      BTW: ctags.exe installed with UE/UES is not the latest version of Exuberant Ctags. But the installed version in subdirectory GNU of UE/UES can be either replaced by latest version for Windows, or latest version is installed (copied) to a different folder and this version of Ctags is specified in the options dialog.

      PS: What I miss is the possibility to specify a Ctags options file with "--options=%rp%rn_ctags.cfg" to use individual options depending on type of project. A C/C++ project needs different options than a web project. %rp and %rn can be used in project tools, but are not evaluated on calling Ctags. I think, I will send an enhancement request to IDM for supporting all placeholders as available for user and project tools also on running Ctags. But perhaps I'm the only UE/UES user using Ctags for different types of projects.
      Best regards from an UC/UE/UES for Windows user from Austria

      19
      Basic UserBasic User
      19

        Sep 16, 2014#3

        In the bat file I use the ctags read a list fo file from a file option

        -L xml_file_list_fpecf.txt

        and the -a apeedn to option for creating my output ctag file

        I have to create 2 different lists (from 2 different servers)
        Because the files are in multiple projects across 2 different servers and they change every day , creating a bat file that I can run on a daily basis seemed like a simple approach.

        There are other ways to do it, mine is one of the simpler way to use the advanced features of ctags
        Whenever I have to decide between two evils, I always choose the one I haven't tried before. -Mae West