better generation of vi ctags in ghci

Peter Hercek phercek at
Wed Jun 17 05:14:39 EDT 2009

Hi GHC and VI users,

I got frustrated with vi tags not working after some unrelated code is 
edited in a source file. Moreover non-exported top level declarations 
were not available in vi tags file. Here is an attempt to fix it:

Why would you want the new implementation of :ctags ghci command?

* Tags are searched based on the line content. This is what Exuberant 
Ctags do for other languages and it is the other posix way to do it. 
This makes the positioning to work well even when the source code was 
edited (on places unrelated to the tag location). More complicated Ex 
statements can be used to improve it even more but then it does not work 
well with :tselect (it screws up tag kinds, at least with my version of 
vim 7.2.65).

* All top level symbols defined in a module are added to the tags file. 
Even the non-exported ones. These are marked as static (file:) so the 
default tag selection (Ctrl-]) works fine based on the file you started 
the search from.

* Tags get kinds added so you can select whether you want to get to a 
type constructor or a data constructor (that is if you share names 
between the two).

* In general it is a nice addition to vim haskellmode. If you search for 
help on symbols in libraries then opening haddock is cool. If you search 
for help on a symbol in your project then opening the tag in a preview 
window (Ctrl-W} or ptselect) is cool.


* It needs somebody to check that emacs tags were not broken. I'm not an 
emacs user but some tag generation code is shared for vim and emacs. I 
tried to keep emacs tags exactly the way they were (only the exported 
symbols, original file format).

* If your code happens to have definitions on lines which happen to 
exist more times in one source file then it may put you at an incorrect 
location. I doubt it will ever happen but if anybody thinks it is really 
bad we can keep the original format of vim tags too. Then e.g. :ctags 
would generate tags with line numbers and :ctags! would generate tags 
with search expressions.

If there is any support for this and ghc team decides to merge it I can 
provide darcs patch. I can do changes needed to get it merged.


More information about the Glasgow-haskell-users mailing list