gcv / julia-snail

An Emacs development environment for Julia
GNU General Public License v3.0
231 stars 21 forks source link

difference in behavior with "equivalent" use-package configurations #145

Closed just-walk closed 4 months ago

just-walk commented 4 months ago

In trying to get julia-snail to conveniently format files on save, I've been messing with my configuration and found this issue. When adding julia-snail-mode to the julia-mode hook, different forms of the use-package syntax that should have "equivalent" behavior are in fact different. (https://www.gnu.org/software/emacs/manual/html_mono/use-package.html#Hooks)

The common config portion:

(use-package julia-mode
  :ensure t
  :mode "\\.jl\\'"
  )

This first does what I would expect it to do: it enables julia-snail-mode in a .jl buffer. If I I want a REPL, then I can use C-c C-z.:

(use-package julia-snail
  :ensure t
  :custom
  (julia-snail-terminal-type :eat)
  :hook (julia-mode . julia-snail-mode)
)

This second form shortens the hook declaration. In this case, when I open a buffer, it also automatically opens the REPL in a separate buffer, switching to it. The REPL buffer ignores the .dir-locals.el julia-mode configuration, and the original buffer has julia-mode enabled but not julia-snail-mode.

(use-package julia-snail
  :ensure t
  :custom
  (julia-snail-terminal-type :eat)
  :hook julia-mode
)

What's going on? Is this a bug in use-package?

gcv commented 4 months ago

I'm not sure it's a bug, but I've definitely found use-package semantics unintuitive before. Try checking the value of julia-mode-hook using M-: or eval-expression.

just-walk commented 4 months ago

Output from the first:

(toggle-input-method julia-snail-mode)

Output from the second:

(toggle-input-method julia-snail)

So, it seems to me that it is a bug with use-package because the documentation states that the second form assumes that the hook you're adding is the package name with -mode appended, julia-snail-mode in this case. But that clearly isn't happening.

gcv commented 4 months ago

Yes, it certainly looks like use-package strangeness.

gcv commented 4 months ago

Closing since there is nothing to do on the Snail side.