haskell-mode
haskell-mode copied to clipboard
How to use `fast-tags` instead of `hasktags`?
Thanks for writing and maintaining this Emacs mode! It works really well so far :+1:
I have some difficulties figuring out how to use fast-tags instead of hasktags. I've installed fast-tags and I can generate proper TAGS file using the following command from the package root:
fast-tags -R -e .
However, I don't know how to call it automatically on file save. I tried the following (similar to #1576):
(setq
haskell-tags-on-save t
haskell-hasktags-path "~/.cabal/bin/fast-tags"
)
But this doesn't generate TAGS file on file save. Could you please help to find proper configuration to make fast-tags work properly with haskell-mode? Thanks in advance!
There is no such configuration possible currently because the code which constructs the hasktags command is pretty much hardcoded. You might consider writing your own function to call fast-tags, e.g.
(defun my/haskell-fast-tags ()
;; Use (buffer-file-name) and/or `default-directory` if necessary here
(shell-command "~/.cabal/bin/fast-tags ..."))
(add-hook 'haskell-mode-hook (lambda () (add-hook 'after-save-hook 'my/haskell-fast-tags t)))
@purcell Thanks! I will try to use this hook and report the status back 👍
@purcell That command, works, thanks! I specified the following command:
"~/.cabal/bin/fast-tags -R -e ."
Unfortunately, it doesn't completely work. When I'm trying to jump to definition, I see that haskell-mode is looking for the <project_root>/TAGS file while with my command the TAGS file is generated near the module I'm currently editing.
Anyway, looks like it's possible to implement a better integration with fast-tags either by patching fast-tags, or haskell-mode or implementing a wrapper fast-tags-emacs that will created a module in a proper place, or implementing more custom emacs hook.
or implementing a wrapper
fast-tags-emacsthat will created a module in a proper place
This is the way to go, I think. You can probably try something like this:
(defun my/haskell-fast-tags ()
;; Use (buffer-file-name) and/or `default-directory` if necessary here
(let ((default-directory (haskell-cabal--find-tags-dir)))
(shell-command "~/.cabal/bin/fast-tags ...")))
(add-hook 'haskell-mode-hook (lambda () (add-hook 'after-save-hook 'my/haskell-fast-tags t)))