0

I am fairly new to Emacs - transitioning from Neovim. I have the following line in my config file:

(use-package haskell-mode)

When I open any Haskell file, I see no effect, e.g., no syntax highlighting and in the lower right corner it says my major mode is Fundamental instead of Haskell.

Drew
  • 29,895
  • 7
  • 74
  • 104
Refael Sheinker
  • 713
  • 7
  • 20

1 Answers1

1

Likely a duplicate question - please search and delete if so.

"Using a package" doesn't apply any mode to any particular buffers visiting any particular kind of file.

If haskell-mode is a major mode then adjust the value of variable auto-mode-alist, so that it has one or more associations that turn it on when the relevant file types are visited.

If it's a minor mode then enable it in on the major-mode hook, haskell-mode-hook.


UPDATED after comments by OP that haskell-mode is in auto-mode-alist by default:

If it appears to be in auto-mode-alist by default, then check whether something in your init file is causing this. Test by starting with emacs -Q (no init file).

If you see haskell-mode in auto-mode-alist with your init file and you don't see it without your init file, then something in your init file is putting it there. ;-)

If that's the case, and you don't see any syntax highlighting even when haskell-mode is used, then your question isn't about getting haskell-mode turned on; it's about not getting some highlighting that you expect even when that mode is on. Then check font-lock for that mode.

Drew
  • 29,895
  • 7
  • 74
  • 104
  • "turn it on when the relevant file types are visited" - I am under the impression that Emacs does that automatically. No? It is says so here: https://www.gnu.org/software/emacs/manual/html_node/elisp/Auto-Major-Mode.html, in the very begining. – Refael Sheinker May 02 '23 at 20:09
  • "Likely a duplicate question - please search and delete if so." - I searched before posting and could not find anything. Probably did not use the correct keywords. – Refael Sheinker May 02 '23 at 20:12
  • 1
    @RefaelSheinker: No, it doesn't, except for the file types associated with the extensions in the default value of `auto-mode-alist`. (`haskell-mode` is not in that default value.) – Drew May 03 '23 at 01:12
  • I beg to differ. `haskell-mode` is in the default value. I just checked. C-h and then v and then type `auto-mode-alist`, It has a line there like this: `("\\.[gh]s\\'" . haskell-mode)` --> Haskell files should be recognized by defaul. – Refael Sheinker May 03 '23 at 04:14
  • 1
    If you see that immediately, when starting Emacs with `emacs -Q` (no init file) then they've added that since Emacs 28.2. If you didn't try `emacs -Q` then do so. If you see it with your init file and you don't see it without your init file, then something in your init file is putting it there. ;-) If that's the case, and you don't see any syntax highlighting, then please specify this in your question. In that case the question isn't about getting `haskell-mode` turned on; it's about not getting some highlighting that you expect even when that mode is on. Then check font-lock for that mode. – Drew May 03 '23 at 20:11
  • Thank you very much! Your `-Q` idea helped me pinpoint the problem in my config. Long story short: I forgot to specify `emacs-lisp` in of my `#+begin_src` blocks. Please convert your comment to an answer and I will accept it. – Refael Sheinker May 04 '23 at 16:04