alchemist.el icon indicating copy to clipboard operation
alchemist.el copied to clipboard

Alchemist not auto-loading with elixir-mode

Open olieidel opened this issue 7 years ago • 1 comments

Having installed Alchemist via melpa, it doesn't activate alchemist-mode with elixir-mode in emacs-prelude.

Interestingly, manually evaluating

(add-hook 'elixir-mode-hook 'alchemist-mode-hook)

(as seen in alchemist.el) and then switching out and back into elixir-mode also doesn't activate alchemist-mode.

Instead, evaluating

(add-to-list 'elixir-mode-hook (alchemist-mode +1))

and then re-switching into elixir-mode does activate alchemist-mode (I therefore added this to my personal/init.el).

I have no idea why it makes a difference, but maybe someone else might be experiencing this problem.

I am using the latest emacs-prelude, emacs version 25.1.50.1. I'm by no means experienced with emacs, so if I'm missing something just close the issue :) Furthermore, this might be an isolated emacs-prelude problem..?

olieidel avatar Oct 24 '16 13:10 olieidel

I think you should write

(add-to-list 'elixir-mode-hook 'alchemist-mode)

Because a function alchemist-mode-hook is not an autoloaded function.

(add-to-list 'elixir-mode-hook (alchemist-mode +1))

This code works because

  1. Evaluate (alchemist-mode +1)
  2. alchemist-mode command is an autoloaded function so that alchemist.el is loaded at that time
  3. Evaluate this code and set alchemist-mode-hook to elixir-mode-hook.
  4. alchemist.el is already loaded so 3. code works.

However this is not lazy loading and this equals to (require 'alchemist)

syohex avatar Oct 25 '16 02:10 syohex