Skip to content

haskell-mode-hook popup upon return #248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
developernotes opened this issue Mar 10, 2014 · 22 comments
Closed

haskell-mode-hook popup upon return #248

developernotes opened this issue Mar 10, 2014 · 22 comments

Comments

@developernotes
Copy link

Hello,
I recently installed haskell-mode, version 20140309.342 via melpa on Emacs 24.3.50.1 on OS X. I Created the a file, with the following content:

data MyMaybe t = Just t | Nothing

After typing Nothing, I pressed return which triggered my screen to split and showed the help for haskell-mode-hook. It states that the current value is nil. Note that I do not have any customizations to haskell-mode, nor do I have additional haskell emacs packages. Is it correct that this is not the desired behavior?

@ivan-m
Copy link
Contributor

ivan-m commented Mar 11, 2014

I think you need to choose an indentation mode at least.

@developernotes
Copy link
Author

Hi @ivan-m

You are correct, adding (add-hook 'haskell-mode-hook 'turn-on-haskell-simple-indent) resolved the issue. Thanks for the pointer!

@ivan-m
Copy link
Contributor

ivan-m commented Mar 12, 2014

Maybe we should set a default (probably simple indent) just for cases like this?

@hvr
Copy link
Member

hvr commented Mar 12, 2014

@ivan-m iirc there's an issue with circular dependencies between the .el-modules, the customize interface, and the way the indentation is currently integrated in haskell-mode that make it non-trivial to set a default in the current state (or at least would lead to other issues)

@developernotes
Copy link
Author

@ivan-m @hvr

Maybe as an alternative, a warning could be issued?

(when (eq nil haskell-mode-hook)
  (message "Please add an indentation hook to haskell-mode-hook"))

@chrisdone
Copy link
Member

I did write such a help buffer once that explained the various indentation types, when indentation has not been configured, but maybe it's gone.

@chrisdone
Copy link
Member

Oh, wait, the pop-up actually explains all this:

haskell-mode-hook is a variable defined in `haskell-mode.el'.
Its value is (haskell-auto-insert-module-template structured-haskell-mode)

Original value was nil

  This variable may be risky if used as a file-local variable.

Documentation:
Hook run after entering `haskell-mode'.

Some of the supported modules that can be activated via this hook:

   `haskell-decl-scan', Graeme E Moss
     Scans top-level declarations, and places them in a menu.

   `haskell-doc', Hans-Wolfgang Loidl
     Echoes types of functions or syntax of keywords when the cursor is idle.

   `haskell-indentation', Kristof Bastiaensen
     Intelligent semi-automatic indentation Mk2

   `haskell-indent', Guy Lapalme
     Intelligent semi-automatic indentation.

   `haskell-simple-indent', Graeme E Moss and Heribert Schuetz
     Simple indentation.

Module X is activated using the command `turn-on-X'.  For example,
`haskell-doc' is activated using `turn-on-haskell-doc'.
For more information on a specific module, see the help for its `X-mode'
function.  Some modules can be deactivated using `turn-off-X'.

See Info node `(haskell-mode)haskell-mode-hook' for more details.

Warning: do not enable more than one of the three indentation
modes. See Info node `(haskell-mode)indentation' for more
details.

You can customize this variable.

[back]

@chrisdone
Copy link
Member

Probably what's missing is a simple line that says how to add such a hook.

@developernotes
Copy link
Author

Hi @chrisdone

If it provided what you are showing above in the popup that would be great, unfortunately, this is what is displayed out of the box from the melpa installation:

haskell-mode-hook is a variable defined in `haskell-mode.el'.
Its value is nil

This variable may be risky if used as a file-local variable.

Documentation:
Hook run after entering Haskell mode.
No problems result if this variable is not bound.
`add-hook' automatically binds it.  (This is true for all hook variables.)

You can customize this variable.

Maybe something is out of sync between your version and what is available on melpa?

@hvr
Copy link
Member

hvr commented Mar 12, 2014

@developernotes what does M-x haskell-version tell?

(also, does your current haskell-mode version have any pointers into the info manual at all?)

@developernotes
Copy link
Author

Hi @hvr
M-x haskell-version prints this for me:

haskell-mode version @VERSION@ (@GIT_VERSION@ @ /Users/nparker/.emacs.d/elpa/haskell-mode-20140309.342/)

The info docs are installed, so section 6 on indentation is visible when viewed.

@ghost
Copy link

ghost commented May 1, 2014

This issue got me as well. Would have been really nice if after reading that lengthy intro I had any idea how to fix it. Instead I spent 15 minutes thinking I was crazy and almost disabled haskel-mode / renamed my file something other than .hs before stumbling on this page in my 3rd google search. This should really be modifed somehow.
My haskell-version is:
haskell-mode version @Version@ (@GIT_VERSION@ @ /home/russell/.emacs.d/elpa/haskell-mode-20140430.945/)
installed through list-packages and selecting haskell-mode.

@ghost
Copy link

ghost commented May 22, 2014

For me the issue persists after adding 'structured-haskell-mode to 'haskell-mode-hook. It should not happen because then 'haskell-mode-hook is not nil.

@developernotes
Copy link
Author

Hi @sumitsahrawat

Do you get the same behavior if you explicitly include a (require 'shm)?

@ghost
Copy link

ghost commented May 31, 2014

Yes, it did. But now i'm doing fine with (add-hook 'haskell-mode-hook 'turn-on-haskell-indentation) and have ditched shm.

@stehgold
Copy link

For mere mortals like me - where do I have to add this ? Getting only half the screen size is annoying. Here is my .emacs

(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ansi-color-names-vector ["#2e3436" "#a40000" "#4e9a06" "#c4a000" "#204a87" "#5c3566" "#729fcf" "#eeeeec"])
'(custom-enabled-themes (quote (tsdh-dark))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(custom-set-variables
'(haskell-mode-hook '(turn-on-haskell-indentation)))

@ghost
Copy link

ghost commented Dec 23, 2014

@stehgold You have to add "turn-on-haskell-indentation" to the haskell mode hook.
Instead of using custom set variables, write

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

@stehgold
Copy link

Ahh, it's silently auto-indenting now. What a relief... :)

Thank you,
Stephan

@gwern
Copy link

gwern commented Jan 14, 2015

Oh, so this is why haskell-mode has been so unbearable for the past year for me!

Oh, wait, the pop-up actually explains all this:

The Debian package seems to include only the less informative popup. I had no idea that it had anything to do with adding an indent-mode.

Actually, I don't think the version you quote is a clear explanation either. I thought I understood Emacs reasonably well, but I don't get anything like "I need to add (add-hook 'haskell-mode-hook 'turn-on-haskell-indentation) to my .emacs to make this popup go away" from that documentation...

@adnelson
Copy link

I've added this line to my init.el:

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

And even though I've run M-x eval-buffer, I still get this popup every time I press enter telling me about haskell-mode-hook. This is incredibly obnoxious. What am I not doing to get rid of this?

EDIT:
It seems that the the warning only keeps on popping up on haskell files that were opened before I made the change to my init.el. There's probably a better way to do it, but it seems that closing and reopening the source files I was working on gets the job done.

@gracjan
Copy link
Contributor

gracjan commented Jun 23, 2015 via email

@gracjan
Copy link
Contributor

gracjan commented Jun 23, 2015

@adnelson: Hooks are run when things happen, the hook says to enable haskell-indentation-mode just after haskell-mode is turned on. It does not work retroactively on already open buffer, as you have noticed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants