You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hs-ctags 598B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env ruby
  2. #
  3. # pbrisbin 2013 - smartly update haskell ctags.
  4. #
  5. ###
  6. class Ctags
  7. def initialize(tags)
  8. @tags = tags || 'tags'
  9. @module = find_module or exit 1
  10. end
  11. def run
  12. system(%{ echo ":ctags #{@tags}" | cabal exec ghci -- -v0 '#{@module}' })
  13. end
  14. private
  15. def find_module
  16. Dir.glob(module_glob, File::FNM_CASEFOLD).first
  17. end
  18. def module_glob
  19. File.join('**', "{#{module_name},main}.hs")
  20. end
  21. def module_name
  22. File.join(*project_directory.split('-'))
  23. end
  24. def project_directory
  25. File.basename(ENV['PWD'])
  26. end
  27. end
  28. Ctags.new(ARGV.first).run