serras / emacs-haskell-tutorial

Tutorial on setting up Emacs to do Haskell programming
690 stars 100 forks source link

Generation of tags #39

Open paldepind opened 8 years ago

paldepind commented 8 years ago

I'm following along the tutorial. I'm stuck in the section on settings up tags. No TAGS file is being generated when I save.

Related to haskell-mode I have this in my .emacs

(let ((my-cabal-path (expand-file-name "~/.cabal/bin")))
  (setenv "PATH" (concat my-cabal-path path-separator (getenv "PATH")))
  (add-to-list 'exec-path my-cabal-path))

(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)

(custom-set-variables
  '(haskell-tags-on-save t))

If I do M-: (getenv "PATH") then the correct path to .cabal/bin appears. Hasktags is installed and a binary file exists in the Cabal bin directory.

As I mentioned a tags file is not being generated on save. Thus M-. does not work. If however I do haskell-mode-tag-find then a GHCi session is being started and a TAGS file is generated. From then on the TAGS file is also being updated on save.

In the haskell-mode documentation tags appears as belonging to the interactive mode.

I'm unsure if I'm doing something wrong of if the tags part shouldn't have been included in the non interactive part of the tutorial.

gromakovsky commented 8 years ago

I have the same problem.

tmbull commented 8 years ago

Be careful that you only have one custom-set-variables in your .emacs file. I had the same issue initially, and this was the problem.

paldepind commented 8 years ago

@tmbull I don't understand. What do you mean?

tmbull commented 8 years ago

custom-set-variables can only be defined once. For example:

(custom-set-variables '(haskell-tags-on-save t) '(some-other-val t))

Rather than two separate instances of custom-set-variables.

serras commented 8 years ago

@paldepind Did the solution by @tmbull work for you? If so, I can add it to the tutorial.

paldepind commented 8 years ago

No. I only have one custom-set-variables. As I mentioned, starting a GHCi session makes tag generation on save work.

I am still under the impression that one needs to have an open session in order for the on save tag generation to work. That is what I am experiencing. And I guess that is why the haskell-mode wiki page on the topic is titled "Haskell Interactive Mode Tags". Thus I believe the coverage of tags should be moved to the interactive part of the tutorial.

I also think suggesting the following binding to the tutorial would be a great idea:

(define-key haskell-mode-map (kbd "M-.") 'haskell-mode-jump-to-def)

Then a GHCi session will automatically be started and a tags file generated if it is missing.

ghost commented 8 years ago

I am still under the impression that one needs to have an open session in order for the on save tag generation to work.

It seems so. Take a look here: https://github.com/haskell/haskell-mode/blob/master/haskell.el#L341-L350

apuchitnis commented 8 years ago

Is there an agreement that this part of the documentation is in the wrong section? If so, I can move it across to the correct part of the docs.