jerrypnz / major-mode-hydra.el

Spacemacs-esque major mode leader key powered by Hydra
297 stars 9 forks source link

major-mode-hydra: Unrecognized keyword mode-hydra in use-package #37

Closed hjpotter92 closed 5 years ago

hjpotter92 commented 5 years ago

I have the following use package config:

(use-package emacs-lisp-mode
  :ensure nil
  :after (major-mode-hydra)
  :mode-hydra
  ("Eval"
   (("b" eval-buffer "buffer")
    ("e" eval-defun "defun")
    ("r" eval-region "region"))
   "REPL"
   (("I" ielm "ielm"))
   "Test"
   (("t" ert "prompt")
    ("T" (ert t) "all")
    ("F" (ert :failed) "failed"))
   "Doc"
   (("d" describe-foo-at-point "thing-at-pt")
    ("f" counsel-describe-function "function")
    ("v" counsel-describe-variable "variable")
    ("i" info-lookup-symbol "info lookup"))
   "Quit"
   (("q" nil "quit hydra"))))

I have also tried :defer t. I keep getting the following warning:

Error (use-package): Failed to parse package emacs-lisp-mode: use-package: Unrecognized keyword: :mode-hydra

The way I setup major-mode-hydra is:

(use-package major-mode-hydra
  :bind
  ("M-SPC" . major-mode-hydra))

The order of appearance of them is also sequential. I load major-mode-hydra just after (require 'use-package) and emacs-lisp-mode is loaded quite later.

hjpotter92 commented 5 years ago

The debug error trace:

Debugger entered--Lisp error: (error "use-package: Unrecognized keyword: :mode-hydra")
  signal(error ("use-package: Unrecognized keyword: :mode-hydra"))
  error("use-package: %s" "Unrecognized keyword: :mode-hydra")
  use-package-normalize-plist(emacs-lisp-mode (:mode-hydra ("Eval" (("b" eval-buffer "buffer") ("e" eval-defun "defun") ("r" eval-region "region")) "REPL" (("I" ielm "ielm")) "Test" (("t" ert "prompt") ("T" (ert t) "all") ("F" (ert :failed) "failed")) "Doc" (("d" describe-foo-at-point "thing-at-pt") ("f" counsel-describe-function "function") ("v" counsel-describe-variable "variable") ("i" info-lookup-symbol "info lookup")) "Quit" (("q" nil "quit hydra")))) nil use-package-merge-keys)
  use-package-normalize-plist(emacs-lisp-mode (:after (major-mode-hydra) :mode-hydra ("Eval" (("b" eval-buffer "buffer") ("e" eval-defun "defun") ("r" eval-region "region")) "REPL" (("I" ielm "ielm")) "Test" (("t" ert "prompt") ("T" (ert t) "all") ("F" (ert :failed) "failed")) "Doc" (("d" describe-foo-at-point "thing-at-pt") ("f" counsel-describe-function "function") ("v" counsel-describe-variable "variable") ("i" info-lookup-symbol "info lookup")) "Quit" (("q" nil "quit hydra")))) nil use-package-merge-keys)
  use-package-normalize-plist(emacs-lisp-mode (:ensure nil :after (major-mode-hydra) :mode-hydra ("Eval" (("b" eval-buffer "buffer") ("e" eval-defun "defun") ("r" eval-region "region")) "REPL" (("I" ielm "ielm")) "Test" (("t" ert "prompt") ("T" (ert t) "all") ("F" (ert :failed) "failed")) "Doc" (("d" describe-foo-at-point "thing-at-pt") ("f" counsel-describe-function "function") ("v" counsel-describe-variable "variable") ("i" info-lookup-symbol "info lookup")) "Quit" (("q" nil "quit hydra")))) nil use-package-merge-keys)
  use-package-normalize-keywords(emacs-lisp-mode (:ensure nil :after (major-mode-hydra) :mode-hydra ("Eval" (("b" eval-buffer "buffer") ("e" eval-defun "defun") ("r" eval-region "region")) "REPL" (("I" ielm "ielm")) "Test" (("t" ert "prompt") ("T" (ert t) "all") ("F" (ert :failed) "failed")) "Doc" (("d" describe-foo-at-point "thing-at-pt") ("f" counsel-describe-function "function") ("v" counsel-describe-variable "variable") ("i" info-lookup-symbol "info lookup")) "Quit" (("q" nil "quit hydra")))))
  #f(compiled-function (name &rest args) "Declare an Emacs package by specifying a group of configuration options.\n\nFor full documentation, please see the README file that came with\nthis file.  Usage:\n\n  (use-package package-name\n     [:keyword [option]]...)\n\n:init            Code to run before PACKAGE-NAME has been loaded.\n:config          Code to run after PACKAGE-NAME has been loaded.  Note that\n                 if loading is deferred for any reason, this code does not\n                 execute until the lazy load has occurred.\n:preface         Code to be run before everything except `:disabled'; this\n                 can be used to define functions for use in `:if', or that\n                 should be seen by the byte-compiler.\n\n:mode            Form to be added to `auto-mode-alist'.\n:magic           Form to be added to `magic-mode-alist'.\n:magic-fallback  Form to be added to `magic-fallback-mode-alist'.\n:interpreter     Form to be added to `interpreter-mode-alist'.\n\n:commands        Define autoloads for commands that will be defined by the\n                 package.  This is useful if the package is being lazily\n                 loaded, and you wish to conditionally call functions in your\n                 `:init' block that are defined in the package.\n:hook            Specify hook(s) to attach this package to.\n\n:bind            Bind keys, and define autoloads for the bound commands.\n:bind*           Bind keys, and define autoloads for the bound commands,\n                 *overriding all minor mode bindings*.\n:bind-keymap     Bind a key prefix to an auto-loaded keymap defined in the\n                 package.  This is like `:bind', but for keymaps.\n:bind-keymap*    Like `:bind-keymap', but overrides all minor mode bindings\n\n:defer           Defer loading of a package -- this is implied when using\n                 `:commands', `:bind', `:bind*', `:mode', `:magic', `:hook',\n                 `:magic-fallback', or `:interpreter'.  This can be an integer,\n                 to force loading after N seconds of idle time, if the package\n                 has not already been loaded.\n:after           Defer loading of a package until after any of the named\n                 features are loaded.\n:demand          Prevent deferred loading in all cases.\n\n:if EXPR         Initialize and load only if EXPR evaluates to a non-nil value.\n:disabled        The package is ignored completely if this keyword is present.\n:defines         Declare certain variables to silence the byte-compiler.\n:functions       Declare certain functions to silence the byte-compiler.\n:load-path       Add to the `load-path' before attempting to load the package.\n:diminish        Support for diminish.el (if installed).\n:delight         Support for delight.el (if installed).\n:custom          Call `customize-set-variable' with each variable definition.\n:custom-face     Call `customize-set-faces' with each face definition.\n:ensure          Loads the package using package.el if necessary.\n:pin             Pin the package to an archive." #<bytecode 0x1560fa88a3d1>)(emacs-lisp-mode :ensure nil :after (major-mode-hydra) :mode-hydra ("Eval" (("b" eval-buffer "buffer") ("e" eval-defun "defun") ("r" eval-region "region")) "REPL" (("I" ielm "ielm")) "Test" (("t" ert "prompt") ("T" (ert t) "all") ("F" (ert :failed) "failed")) "Doc" (("d" describe-foo-at-point "thing-at-pt") ("f" counsel-describe-function "function") ("v" counsel-describe-variable "variable") ("i" info-lookup-symbol "info lookup")) "Quit" (("q" nil "quit hydra"))))
  macroexpand((use-package emacs-lisp-mode :ensure nil :after (major-mode-hydra) :mode-hydra ("Eval" (("b" eval-buffer "buffer") ("e" eval-defun "defun") ("r" eval-region "region")) "REPL" (("I" ielm "ielm")) "Test" (("t" ert "prompt") ("T" (ert t) "all") ("F" (ert :failed) "failed")) "Doc" (("d" describe-foo-at-point "thing-at-pt") ("f" counsel-describe-function "function") ("v" counsel-describe-variable "variable") ("i" info-lookup-symbol "info lookup")) "Quit" (("q" nil "quit hydra")))))
  elisp--eval-defun()
  eval-defun(nil)
  funcall-interactively(eval-defun nil)
  call-interactively(eval-defun nil nil)
  command-execute(eval-defun)
jerrypnz commented 5 years ago

Could you try adding :demand t and see if works for you?

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

major-mode-hydra needs to be requried before those keywords can be used. Without :demand t the package is not loaded immediately.

hjpotter92 commented 5 years ago

That works. I had not read the following in use-package docs:

NOTE: Pay attention if you set use-package-always-defer to t, and also use the :after keyword, as you will need to specify how the declared package is to be loaded: e.g., by some :bind. If you’re not using one of tho mechanisms that registers autoloads, such as :bind or :hook, and your package manager does not provide autoloads, it’s possible that without adding :demand t to those declarations, your package will never be loaded.