Skip to content
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

julia-snail-mode not activating with use-package :hook #70

Closed
Nathan-Furnal opened this issue Dec 3, 2021 · 9 comments
Closed

julia-snail-mode not activating with use-package :hook #70

Nathan-Furnal opened this issue Dec 3, 2021 · 9 comments
Labels
bug Something isn't working

Comments

@Nathan-Furnal
Copy link

Hi!

I'm trying to use julia-snail with this simple config :

(use-package julia-mode
  :pin melpa
  :ensure t
  :diminish "Jl"
  :mode ("\\.jl\\'" . julia-mode)
  :config
  (setenv "JULIA_NUM_THREADS" "16"))

(use-package julia-snail
  :pin melpa
  :ensure t
  :requires vterm
  :custom
  (julia-snail-show-error-window nil)
  :diminish " 🐌"
  :hook (julia-mode-hook . julia-snail-mode))

When I open a julia file, snail is not started though the hook is there and I have vterm installed as well. I can M-x julia-snail-mode without an issue but the hook does not seem to work.

I'm using the master branch of emacs with native compilation.

How can I fix this?

Thanks for the help.

@gcv
Copy link
Owner

gcv commented Dec 3, 2021

I love the emoji lighter idea! I'll have to steal it.

Your hook is not quite right. Try :hook (julia-mode . julia-snail-mode) instead.

More troubleshooting tips:

  1. If the REPL crashes instantly, that usually means the Julia binary did not start (I'll have to improve the error messaging when that happens). Check the path and any command-line arguments.

  2. Be sure to run vterm before installing julia-snail (https://github.com/gcv/julia-snail#installation, steps 3 and 4). Try M-x vterm and make sure it can run a shell, then delete and reinstall julia-snail.

@Nathan-Furnal
Copy link
Author

I love the emoji lighter idea! I'll have to steal it.

Please do, I didn't think it would render but it does!
image

Your hook is not quite right. Try :hook (julia-mode . julia-snail-mode) instead.

No, it's correct because I have (setq use-package-hook-name-suffix nil) at the top of my init but I think I fixed it, I merely needed the hook in the julia-mode declaration rather than in julia-snail.

Something like this :

(use-package julia-mode
  :pin melpa
  :defer t
  :ensure t
  :diminish "Jl"
  :mode ("\\.jl\\'" . julia-mode)
  :config
  (setenv "JULIA_NUM_THREADS" "16")
  :hook (julia-mode-hook . julia-snail-mode))

(use-package julia-snail
  :pin melpa
  :defer t
  :ensure t
  :after (vterm julia-mode)
  :custom
  (julia-snail-show-error-window nil)
  :diminish " 🐌")

@gcv
Copy link
Owner

gcv commented Dec 4, 2021

Weird. It's almost like the Snail autoloads aren't working in your environment. I wonder if native compilation affects this.

I'd like to know a bit more, because I'm sure other people will run into this problem. If you don't mind running the original configuration with a fresh Emacs session, please try the following:

  1. As a quick sanity check, does your installation's julia-snail-autoloads.el file have a line like this?
(autoload 'julia-snail-mode "julia-snail" ; ... probably more stuff here
  1. Open a Julia source file, and look at the julia-mode-hook variable (using M-: or C-h v). What is its value?
  2. What if you manually enable julia-snail-mode the first time, and then reload the file (using find-alternate-file or C-x C-v)? Same problem? What is the value of julia-mode-hook after you manually enable julia-snail-mode?

PS: Also... 1411921 😎

@Nathan-Furnal
Copy link
Author

  1. Yep it's there!
    2/3. Seems correct, when using the hook with julia-snail, it's not loaded but when enabling manually, it does work.

PS: Also... 1411921 sunglasses

I've made the update and I see our friendly snail!

@gcv
Copy link
Owner

gcv commented Dec 5, 2021

Just to clarify, after you manually load julia-snail-mode once, and then open another Julia file, does julia-snail-mode get automatically enabled for the new Julia file? I'm wondering if the hook gets messed up somehow between buffers.

@Nathan-Furnal
Copy link
Author

Alright I tried again, I put the hook back in the julia-snail declaration. I can also confirm the autoload is present in julia-snail-autoloads in my elpa directory.

Opening a julia file does not load the mode, the value of the hook after opening a julia file is nil. Once julia-snail-mode is manually enabled, opening a different julia file does use the mode correctly and the hook has the correct value.

I'm not really sure what's going on. It might be that some other hook is messing up with snail but this is the only place I act on julia related mode. I usually delay a lot of loading and it might be that the hook is not used properly in julia-mode because of that, but it's strange since I don't have problems with other modes.

@gcv
Copy link
Owner

gcv commented Dec 6, 2021

Thank you for investigating that. I wonder if it's a deferred loading bug in use-package; perhaps some subtle interaction with native compilation. I'm reluctant to make your workaround an official recommendation, since it feels wrong to affect other modes' configurations. For now, I'll keep this ticket open, and we'll see if anyone else finds something.

@gcv gcv changed the title Julia snail does not start with hook julia-snail-mode not activating with use-package :hook Dec 6, 2021
@gcv
Copy link
Owner

gcv commented Feb 1, 2022

I've been looking into this problem in #75, and I think I finally understand what happens. You don't have an explicit (use-package vterm ...) form evaluating before your julia-mode and julia-snail use-package sections. It seems that messes things up. If you remove :after (vterm julia-mode) and :requires vterm from (use-package julia-snail ...), the hook should work.

gcv added a commit that referenced this issue Feb 1, 2022
@gcv gcv added the bug Something isn't working label Feb 1, 2022
@gcv
Copy link
Owner

gcv commented Mar 14, 2022

This should be resolved, please see #70 (comment)

Please reopen this ticket if there's anything else.

@gcv gcv closed this as completed Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants