haskell-mode icon indicating copy to clipboard operation
haskell-mode copied to clipboard

How to use `fast-tags` instead of `hasktags`?

Open chshersh opened this issue 5 years ago • 4 comments

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!

chshersh avatar Dec 05 '19 15:12 chshersh

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 avatar Dec 19 '19 01:12 purcell

@purcell Thanks! I will try to use this hook and report the status back 👍

chshersh avatar Dec 19 '19 09:12 chshersh

@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.

chshersh avatar Dec 20 '19 09:12 chshersh

or implementing a wrapper fast-tags-emacs that 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)))

purcell avatar Dec 24 '19 02:12 purcell