jerrypnz / major-mode-hydra.el

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

How to implement inheritance and mixing? #31

Closed Pfedj closed 5 years ago

Pfedj commented 5 years ago

I would like to have different hydra for different major-mode. Lets suppose this my config:

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

(major-mode-hydra-define (emacs-lisp-mode python-mode) nil
    ("Emacs"
   (("<escape>" nil "quit")
    ("q" nil "quit"))))

(major-mode-hydra-define+ emacs-lisp-mode nil
  ("Eval"
   (("b" eval-buffer "buffer")
    ("e" eval-defun "defun"))))

(major-mode-hydra-define+ python-mode nil
   ("Eval"
   (("i" elpy-importmagic-fixup "Importmagic fixup")
    ("d" elpy-goto-definition "Goto definition"))))

I expected to see in python-mode the following:

Eval 
"i": "Importmagic fixup"
"d": "Goto definition"

However union of columns seem to happen:

Eval 
"b" eval-buffer "buffer"
"e" eval-defun "defun"
"i": "Importmagic fixup"
"d": "Goto definition"

How can I get the expected results?

jerrypnz commented 5 years ago

Seems to be a bug. I'll take a look into it and hopefully fix it soon.

jerrypnz commented 5 years ago

Pushed a fix and should be available on Melpa soon. BTW if you don't mind not being to see the hint for quit keys, you can use the :quit-key body option instead of explicitly adding nil heads, e.g.

(major-mode-hydra-define python-mode (:quit-key ("<escape>" "q"))
  ("Eval"
   (("i" elpy-importmagic-fixup "Importmagic fixup")
    ("d" elpy-goto-definition "Goto definition"))))