MarcWeber / hasktags

Produces ctags "tags" and etags "TAGS" files for Haskell programs
Other
127 stars 32 forks source link

Incremental updates? #46

Open jhenahan opened 6 years ago

jhenahan commented 6 years ago

A comment on Reddit mentioned that fast-tags can do incremental updates on save. This'd be a cute feature for hasktags, and it could make it easier to scale the tool's use for larger codebases.

yihuang commented 5 years ago

Actually, hasktags has an append mode, but it just simply append, rather than merge with current tags, which makes it quite useless. I'm interested to change the behavior of append to merge (like what exuberant ctags does).

yihuang commented 5 years ago

Actually, hasktags -x -c -a test.hs && sort -u -o tags tags works very well.

MarcWeber commented 5 years ago

Thinking about it its worth adding to the README. Because whenever you write a file you'll be up to date. its solving a problem. Do you want to send PR or shall I just add it and give you credits?

if fast-tags competes we can add it, too.

But there is another thing to consider -> why run hasktags at all, why not --watch ? It would be fastest eventually.

If it works for you we can wait till more people ask for it.

yihuang commented 5 years ago
#!/bin/zsh
if [[ -r tags ]]; then
    hasktags -x -c -a $1 && sort -u -o tags tags
fi
au BufWritePost *.hs            silent !update-tags %
au BufWritePost *.hsc           silent !update-tags %

I end up with configs like above. You can just add it to README. What do you mean by --watch ?

MarcWeber commented 5 years ago

Why make it so complicated?

au BufWritePost .hs,.hsc if (file_exists('tags') | exec "! ( hasktags -x -c -a % && sort -u -o tags ) &" | endif

should do it. I have to use exec to append | endif.

By --watch I mean update tags file whenever a .hs file changes.

http://hackage.haskell.org/package/hinotify-0.4/docs/System-INotify.html

If you make hasktags read the lines and start sorting you have more IO to do than keeping it in RAM ..

yihuang commented 5 years ago

Yeah, your script is better ;D I think --watch would be a useful feature, but it means we need to manage a daemon process.

jberryman commented 5 years ago

I don't see how hasktags -x -c -a $1 && sort -u -o tags tags does anything sensible...

codygman commented 4 years ago

Why make it so complicated?

au BufWritePost .hs,.hsc if (file_exists('tags') | exec "! ( hasktags -x -c -a % && sort -u -o tags ) &" | endif

should do it. I have to use exec to append | endif.

Do you mean why complicate the implementation or why complicate it from a user perspective?

Because from a user perspective having:

hasktags --file-watch .

Is as simple as it gets.

As someone about to implement hasktags for a team, if I could just do the above I would save an hour or two minimum. Instead I need to go find all the places/ways people update code. You can say "everyone should update it the same way", but that's not really realistic to expect everywhere in my opinion.

It would complicate implementation quite a bit to add something like --file-watch though, no arguments there.