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

[Support]: How to correctly add a hook in a use-package declaration with Elpaca #183

Closed
3 of 4 tasks
Nekosis opened this issue Sep 14, 2023 · 7 comments
Closed
3 of 4 tasks

Comments

@Nekosis
Copy link

Nekosis commented Sep 14, 2023

Confirmation

  • I have read the documentation and need clarification.
  • I have searched previous issues to see if my question is a duplicate.
  • I am checking these without reading them.
  • I have checked the Elpaca github wiki to see if my issue is covered.

Elpaca Version

Elpaca 9a130c0 HEAD -> master, origin/master, origin/HEAD
installer: 0.5
emacs-version: GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.17.8)
git --version: git version 2.42.0

Operating System

Meowix Linux x86_64

Description

I'm trying to install evil-org with Elpaca and use-package. This block of code is in my configuration, slightly edited from the README:

(use-package
 evil-org
 :ensure t
 :after org
 :hook (org-mode . (lambda () evil-org-mode))
 :config
 (evil-org-set-key-theme '(textobjects insert navigation additional shift todo heading))
 (require 'evil-org-agenda)
 (evil-org-agenda-set-keys))

From my understanding, the line :hook (org-mode . (lambda () evil-org-mode)) is supposed to run evil-org-mode when an Org document is opened. However, this is unfortunately not working for me. The command did not seem to be ran and the EvilOrg minor mode launched by this command did not activate automatically either. When I manually run M-x evil-org-mode, the minor mode activates as expected.

What am I doing wrong? Is this unsupported in Elpaca?

@progfolio
Copy link
Owner

progfolio commented Sep 14, 2023

From my understanding, the line :hook (org-mode . (lambda () evil-org-mode))
is supposed to run evil-org-mode when an Org document is opened.

The syntax for the hook is incorrect.
You should open a bug report upstream with evil-org.
They probably meant:

(use-package evil-org-mode
  :hook (org-mode . evil-org-mode))

What am I doing wrong? Is this unsupported in Elpaca?

Not an Elpaca issue.
Please always rule out your configuration, the package you are using, then Elpaca in that order.
See: https://github.com/progfolio/elpaca/wiki/Troubleshooting

As a side note:
:ensure t should be removed from the use-package declaration when using Elpaca.

@Nekosis
Copy link
Author

Nekosis commented Sep 14, 2023

Sorry. Thank you.

@progfolio
Copy link
Owner

Not a problem. For what it's worth, I tested the suggested config I wrote in my previous comment and evil-org was properly enabled in Org files. I suggest opening a bug with evil-org to update that part of their docs.

@Nekosis
Copy link
Author

Nekosis commented Sep 14, 2023

Will do soon.

@Nekosis
Copy link
Author

Nekosis commented Sep 14, 2023

Oh, it turns out someone already made this PR: Somelauw/evil-org-mode#110
Although they did it in a slightly different way. Not sure if it is correct.

@Nekosis
Copy link
Author

Nekosis commented Sep 14, 2023

Can confirm that your method works, however.

@progfolio
Copy link
Owner

Oh, it turns out someone already made this PR: Somelauw/evil-org-mode#110 Although they did it in a slightly different way. Not sure if it is correct.

The wrapping lambda is unnecessary. It's also better to add a named function to a hook vs a lambda. See the rationale here:

https://www.gnu.org/software/emacs/manual/html_node/elisp/Setting-Hooks.html

So I'd stick with directly adding the mode's command.

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

No branches or pull requests

2 participants