Search code examples
phpctags

What is wrong with my .ctags file?


I am a ctags newbie, coding in PHP. I have found this ctags file online:

-R
--exclude=.svn
--tag-relative=yes
--PHP-kinds=+cfpd
--regex-PHP=/abstract\s+class\s+([^ ]+)/\1/c/
--regex-PHP=/interface\s+([^ ]+)/\1/c/
--regex-PHP=/(public\s+|static\s+|protected\s+|private\s+)\$([^     =]+)/\2/p/
--regex-PHP=/const\s+([^    =]+)/\1/d/
--regex-PHP=/final\s+(public\s+|static\s+|abstract\s+|protected\s+|private\s+)function\s+\&?\s*([^ (]+)/\2/f/

However, I am getting this error:

$ ctags
ctags: Warning: Unsupported parameter 'p' for --PHP-kinds option

From experimentation I see that the p needs to be defined, and in fact it is defined on the seventh line of the file. So why is the error being thrown?

EDIT: The ctags file came from here, which was linked from this terrific article.

Here is the output of my configuration:

$ ctags --version
ctags: Warning: Unsupported parameter 'p' for --PHP-kinds option
Exuberant Ctags 5.6, Copyright (C) 1996-2004 Darren Hiebert
Compiled: Jan  6 2007, 02:10:54
Addresses: <[email protected]>, http://ctags.sourceforge.net
Optional compiled features: +wildcards, +regex
$ cat ~/.ctags
-R
--exclude=.svn
--tag-relative=yes
--regex-PHP=/abstract\s+class\s+([^ ]+)/\1/c/
--regex-PHP=/interface\s+([^ ]+)/\1/c/
--regex-PHP=/(public\s+|static\s+|protected\s+|private\s+)\$([^ \t=]+)/\2/p/
--regex-PHP=/const\s+([^ \t=]+)/\1/d/
--regex-PHP=/final\s+(public\s+|static\s+|abstract\s+|protected\s+|private\s+)function\s+\&?\s*([^ (]+)/\2/f/
--PHP-kinds=+cpdf
$ ctags
ctags: Warning: Unsupported parameter 'p' for --PHP-kinds option
$

Solution

  • The 'p' kind is not defined for PHP by default.

    --regex-PHP=/(public\s+|static\s+|protected\s+|private\s+)\$([^     =]+)/\2/p/
    

    is defining a 'p' kind for PHP in your case. If you move

    --PHP-kinds=+cfpd 
    

    after this, it will not give you an error.

    Note: Here is my version info for ctags:

    $ ctags --version 
    Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
      Compiled: Apr 19 2012, 11:31:19
      Addresses: <[email protected]>, http://ctags.sourceforge.net
      Optional compiled features: +wildcards, +regex