abo-abo / hydra

make Emacs bindings that stick around
1.84k stars 112 forks source link

Error unrecognized key after upgrading to latest melpa Hydra #117

Closed dahanbn closed 9 years ago

dahanbn commented 9 years ago

After upgrading to the latest hydra (20150423.653) from Melpa I am not able to initialise the following hydra:

(defhydra dh-hydra-markdown-mode (:hint nil)
  "
Formatting     C-c C-s    _s_: bold          _e_: italic     _b_: blockquote   _p_: pre-formatted    _c_: code

Headings       C-c C-t    _h_: automatic     _1_: h1         _2_: h2           _3_: h3               _4_: h4

Lists          C-c C-x    _m_: insert item   

Demote/Promote C-c C-x    _l_: promote       _r_: demote     _u_: move up      _d_: move down

"

  ("s" markdown-insert-bold)
  ("e" markdown-insert-italic)
  ("b" markdown-insert-blockquote :color blue)
  ("p" markdown-insert-pre :color blue)
  ("c" markdown-insert-code)

  ("h" markdown-insert-header-dwim) 
  ("1" markdown-insert-header-atx-1)
  ("2" markdown-insert-header-atx-2)
  ("3" markdown-insert-header-atx-3)
  ("4" markdown-insert-header-atx-4)

  ("m" markdown-insert-list-item)

  ("l" markdown-promote)
  ("r" markdown-demote)
  ("d" markdown-move-down)
  ("u" markdown-move-up)  
)

(global-set-key [f9] 'dh-hydra-markdown-mode/body)

After starting my Emacs I got the following debug backtrace:

 Debugger entered--Lisp error: (error "Unrecognized key: __: h1         _")
  signal(error ("Unrecognized key: __: h1         _"))
  error("Unrecognized key: _%s_" "_: h1         ")
  hydra--format(dh-hydra-markdown-mode (nil nil :hint nil)
  "\nFormatting     C-c C-s    _s_: bold          _e_: italic
  _b_: blockquote   _p_: pre-formatted    _c_: code\n\nHeadings
  C-c C-t    _h_: automatic     _1_: h1         _2_: h2
  _3_: h3               _4_: h4\n\nLists          C-c C-x    _m_:
  insert item   \n\nDemote/Promote C-c C-x    _l_: promote
  _r_: demote     _u_: move up      _d_: move down\n\n" (("s"
  markdown-insert-bold nil :exit nil :cmd-name
  dh-hydra-markdown-mode/markdown-insert-bold) ("e"
  markdown-insert-italic nil :exit nil :cmd-name
  dh-hydra-markdown-mode/markdown-insert-italic) ("b"
  markdown-insert-blockquote nil :exit t :cmd-name
  dh-hydra-markdown-mode/markdown-insert-blockquote-and-exit) ("p"
  markdown-insert-pre nil :exit t :cmd-name
  dh-hydra-markdown-mode/markdown-insert-pre-and-exit) ("c"
  markdown-insert-code nil :exit nil :cmd-name
  dh-hydra-markdown-mode/markdown-insert-code) ("h"
  markdown-insert-header-dwim nil :exit nil :cmd-name
  dh-hydra-markdown-mode/markdown-insert-header-dwim) ("1"
  markdown-insert-header-atx-1 nil :exit nil :cmd-name
  dh-hydra-markdown-mode/markdown-insert-header-atx-1) ("2"
  markdown-insert-header-atx-2 nil :exit nil :cmd-name
  dh-hydra-markdown-mode/markdown-insert-header-atx-2) ("3"
  markdown-insert-header-atx-3 nil :exit nil :cmd-name
  dh-hydra-markdown-mode/markdown-insert-header-atx-3) ("4"
  markdown-insert-header-atx-4 nil :exit nil :cmd-name
  dh-hydra-markdown-mode/markdown-insert-header-atx-4) ("m"
  markdown-insert-list-item nil :exit nil :cmd-name
  dh-hydra-markdown-mode/markdown-insert-list-item) ("l"
  markdown-promote nil :exit nil :cmd-name
  dh-hydra-markdown-mode/markdown-promote) ("r" markdown-demote
  nil :exit nil :cmd-name dh-hydra-markdown-mode/markdown-demote)
  ("d" markdown-move-down nil :exit nil :cmd-name
  dh-hydra-markdown-mode/markdown-move-down) ("u" markdown-move-up
  nil :exit nil :cmd-name
  dh-hydra-markdown-mode/markdown-move-up)))

The hydra worked before. Do you have any idea?

abo-abo commented 9 years ago

Thanks for reporting, should work now.

dahanbn commented 9 years ago

Yeah. It works now. Thanks a lot for the quick fix and your amazing lisp coding. :-)

jagrg commented 9 years ago

I'm getting a similar error with the 20150423.1401 update. Hydra is no longer recognizing "-" as a head. It gives me an error:

Debugger entered--Lisp error: (error "Unrecognized key: __: volume down     _")
  signal(error ("Unrecognized key: __: volume down     _"))
  error("Unrecognized key: _%s_" "_: volume down     ")
abo-abo commented 9 years ago

@jagrg, you mean the minus symbol? I've just checked that it works:

(defhydra hydra-toggle ()
  "
_-_ abbrev-mode
"
  ("-" abbrev-mode nil)
  ("q" nil "quit"))
jagrg commented 9 years ago

Try this

(defhydra hydra-buffer-menu (:color pink
                             :hint nil)
  "
^Mark^             ^Unmark^           ^Actions^          ^Search
^^^^^^^^-----------------------------------------------------------------
_-_: mark          _u_: unmark        _x_: execute       _R_: re-isearch
_s_: save          _U_: unmark up     _b_: bury          _I_: isearch
_d_: delete        ^ ^                _g_: refresh       _O_: multi-occur
_D_: delete up     ^ ^                _T_: files only: % -28`Buffer-menu-files-only
_~_: modified
"
  ("-" Buffer-menu-mark)
  ("u" Buffer-menu-unmark)
  ("U" Buffer-menu-backup-unmark)
  ("d" Buffer-menu-delete)
  ("D" Buffer-menu-delete-backwards)
  ("s" Buffer-menu-save)
  ("~" Buffer-menu-not-modified)
  ("x" Buffer-menu-execute)
  ("b" Buffer-menu-bury)
  ("g" revert-buffer)
  ("T" Buffer-menu-toggle-files-only)
  ("O" Buffer-menu-multi-occur :color blue)
  ("I" Buffer-menu-isearch-buffers :color blue)
  ("R" Buffer-menu-isearch-buffers-regexp :color blue)
  ("c" nil "cancel")
  ("v" Buffer-menu-select "select" :color blue)
  ("o" Buffer-menu-other-window "other-window" :color blue)
  ("q" quit-window "quit" :color blue))

(define-key Buffer-menu-mode-map "." 'hydra-buffer-menu/body)
abo-abo commented 9 years ago

@jagrg, thanks. Should work now.