ctagsexuberant-ctags

Adding new lang to ctags does not work


I am trying to add .volt extension to ctags language map, but it keep ignoring .volt file. This is content of my .ctags file:

--recurse=yes
--tag-relative=yes
--exclude=*.git*
--exclude=.DS_Store

--langmap=html:+.volt

When I do ctags --list-maps I will see .volt files being included in HTML:

HTML     *.htm *.html *.volt

But still when I run ctags, it completely ignores .volt files. What I am doing wrong here?


Solution

  • The reasons for the unexpected behavior are most likely:

    1. You are not using currently latest version 5.8 of Exuberant Ctags, but a version before 5.6.
    2. Your .ctags file has --langmap=html:+.volt at end of file with no line termination.

    Read the full story below on why I think those 2 reasons result in the unexpected behavior of Ctags on your computer.


    I looked on your problem on Windows first using older version 5.5.4 of Exuberant Ctags installed with text editor UltraEdit and later also with version 5.8 downloaded directly from Exuberant Ctags project page.

    I created a copy of one of my HTML projects with just 1 *.html file in parent directory of the test project, 3 *.html files in a subdirectory and two more *.html files also in the subdirectory with file extension changed from html to volt on both files which were just copies of 2 of the 3 *.html files in this subdirectory.

    Next I created in parent directory of the project a ctags.conf file and copied the few lines you posted into this file. Additionally I inserted at top a line with --verbose as this is useful on looking for problems like that.

    And last I copied ctags.exe (first v5.5.4, later v5.8) also into the test project directory just for making it easier to run it from command line.

    I opened a command prompt window in test project directory and executed

    ctags.exe -f test.tag --options=ctags.conf
    

    I could see on verbose output that both *.volt files were opened for processing and created test.tag contained also all the tags from the 2 *.volt files, the same tags as the 2 *.html files from which the *.volt files were copied before.

    So what could be the problem?

    I'm not only familiar with HTML. My main job is programming in C/C++. Therefore I know about an often made mistake in C source code files on reading in text files: a wrong handling of text files with no line termination on last line of the file.

    And I know that some text editors like gedit on Linux position the caret on Ctrl+End at beginning of the line below the last line in the file even when last line of the file does not have a line termination. The caret should be in this case positioned by the text editor at end of the string on last line instead of beginning on next line beyond real end of the file. This in my point of view wrong behavior lets a user of the text editor think that the text file has a line termination also on last line of the file even if this is not true.

    So I thought that you have appended --langmap=html:+.volt perhaps at end of the file without a line termination and ctags.exe does not evaluate the line in this case because of not well done text file parsing in source code. Therefore I removed the line termination in ctags.conf from last line containing now only --langmap=html:+.volt

    I executed same command line as before and AHA, both *.volt files are ignored because of unknown language.

    This was the time as I downloaded version 5.8 of Ctags for Windows and copied it into the test project directory replacing executable of version 5.5.4.

    I executed the command line again with not modified ctags.conf. Both *.volt files were processed by Ctags and test.tag contained again the tags from both *.volt files.

    Appending on last line of file ctags.conf again a line termination and executing the command line once more did not result in a different output. So this bug with ignoring last line of the options file if no line termination present at end of the file is fixed in version 5.8 of Ctags.

    I searched in Change Notes of Exuberant Ctags for last and found in changes notes block for ctags-5.6 (Mon May 29 2006)

    This is the confirmation for what I thought and could see. And of course the problem existed not only on reading the list file, but also on reading other text files like the options file, or C and Java files as the next line in the change notes informs