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

⛔ Error (use-package): use-package: Unrecognized keyword: :pretty-hydra #53

Open
nkpf42 opened this issue Oct 3, 2023 · 10 comments
Open

Comments

@nkpf42
Copy link

nkpf42 commented Oct 3, 2023

Hello,

I've got a problem loading the :pretty-hydra keyword for use-package even if I request it with :demand t. Do you have any tips for this? Thanks

(use-package hydra)
(use-package pretty-hydra
  :demand t
  :after (hydra))
@nkpf42 nkpf42 changed the title ⛔ Error (use-package): Failed to parse package org-roam: use-package: Unrecognized keyword: :pretty-hydra ⛔ Error (use-package): use-package: Unrecognized keyword: :pretty-hydra Oct 3, 2023
@jerrypnz
Copy link
Owner

jerrypnz commented Oct 3, 2023

What version of Emacs and use-package are you using?

@nkpf42
Copy link
Author

nkpf42 commented Oct 4, 2023

I'm using

GNU Emacs 29.1.50
Development version 45cc57ac2586 on emacs-29 branch; build date 2023-08-21.

And I just realized that I didn't took a tag while compiling it myself. Shall I switch to stable commit and retry my setup to see if it's fixed?

And use-package is at 2.4.5

@nkpf42
Copy link
Author

nkpf42 commented Oct 4, 2023

Just switched to a stable emacs 29.1 version

GNU Emacs 29.1
Development version a9b28224af0f on HEAD branch; build date 2023-10-04.

Same version of use-package and bug still here

@bestlem
Copy link

bestlem commented Oct 4, 2023

Don't you need to load hydra by demand as well?
(use-package hydra :demand)
Otherwise pretty-hydra will never load

@nkpf42
Copy link
Author

nkpf42 commented Oct 4, 2023

It doesn't work too :/ I'm a bit at a loss here with use-package beahviour.

@bestlem
Copy link

bestlem commented Oct 4, 2023

What is the full use-package expression that you use that gives this error?

@nkpf42
Copy link
Author

nkpf42 commented Oct 4, 2023

This one

(use-package org-roam
  :after (pretty-hydra)
  :bind (("C-c n" . roam-hydra/body))
  :pretty-hydra (roam-hydra (:color teal :quit-key "q")
                 ("Roam"
                  (
                   ("l" org-roam-buffer-toggle)
                   ("f" org-roam-node-find)
                   ("i" org-roam-node-insert)
                   ("c" org-roam-capture)
                   ("t" org-roam-tag-add)
                   )
                  "Dailies"
                  (
                   ("j" org-roam-dailies-capture-today)
                   ("k" org-roam-dailies-capture-tomorrow)
                   ("h" org-roam-dailies-goto-yesterday)
                   ("a" org-roam-dailies-goto-today)
                   ("d" org-roam-dailies-goto-tomorrow)
                   ))
                 ))

@jerrypnz
Copy link
Owner

jerrypnz commented Oct 4, 2023

Without actually testing it, I wonder if it's the :after that's causing the issue for you. I'm using the same version of emacs and use-package 2.4.4 and it works fine for me.

To use :pretty-hydra, you need it loaded before any use-package with :pretty-hydra is called. In my config I have this loaded very early. I don't have a separate use-package for hydra and pretty-hydra as major-mode-hydra loads them all.

(use-package major-mode-hydra
  :straight t
  :demand t
  :bind
  (("C-M-SPC" . major-mode-hydra))

  :config
  (progn
    (setq major-mode-hydra-invisible-quit-key "q")
    (defun jp-major-mode-hydra-title-generator (_)
      `(with-mode-icon major-mode
                       (propertize (s-concat (format-mode-line mode-name) " Commands")
                                   'face '(:weight bold :height 1.1))
                       1.1))

    (setq major-mode-hydra-title-generator #'jp-major-mode-hydra-title-generator)))

Try removing the :after (hydra) and make sure it's loaded before other use-package calls.

@nkpf42
Copy link
Author

nkpf42 commented Oct 5, 2023

So I tried to remove all after's and using only major-mode-hydra but it still doesn't work. To ensure I've got a clean state, I've uninstalled and reinstalled all of my packages but to no avail.
major-mode-hydra is the 2nd package in my init.el, the first being elpaca

I've found a solution with

;; hydra

(use-package major-mode-hydra)

(elpaca-wait)

By placing an elpaca wait after I think it prevents elpaca from loading the rest of the file. But I thought it was use-package who was in charge of parsing this init file. I will ask them what the hell is going on

@bestlem
Copy link

bestlem commented Oct 26, 2023

elpaca messes around with loading things by loading asyncronouslly.

As use-package and the :pretty-hydra are in a macro you need all of those bits loaded before using them.

So you need loading of use-package (well not since 29.1 as now in emacs) and loading pretty-hydra and hydra before an elpaca-wait. Then after the elpaca-wait you can use your code

I found elpaca requires too much changing and reordering of code to easily switch to - straight.el and package.el just required a few lines except for non standard packages.

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

No branches or pull requests

3 participants