#137 Unable to insert/process filename in custom regexes

open
nobody
None
5
2006-07-29
2006-07-29
Igor Peshansky
No

If one wants to specify a custom regex via the
--regex-lang option, there doesn't seem to be a way to
add all or part of the filename as part of the tag.
For example, suppose I have a language "foo" in which I
want the tags to include the file name. I can call
ctags with
--langdef=foo
--regex-foo='/(sometag)/abc:\1/q,qualified,file qualifier/'
but I cannot replace "abc" with the actual filename,
whether transformed or not.
I realize this is more of a feature request, and there
are multiple possible ways of doing this. One
particular way is to allow marking part of the match
buffer as the filename, and letting the regex capture
expressions from it, e.g.,
--regex-foo='/\F{(.*)\.[^.]*}(sometag)/\1:\2/q,qualified,file
qualifier/'
would use \F{...} as the zero-length match that puts
the current file into the pattern. One could also use
\F as a separator at the end of the pattern. Both ways
would keep backward compatibility.
If the maintainers are not averse to the idea, I'll
look into submitting a patch at some point, unless
someone beats me to it.

Discussion