Skip to content

Commit

Permalink
Added ryo-modal-set-key, and hydras can have keyword pairs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kungsgeten committed Jan 2, 2018
1 parent f6073b5 commit a3b0de1
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions ryo-modal.el
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ command Calls TARGET interactively.
list Each element of TARGET is sent to `ryo-modal-key' again, with
KEY as a prefix key.
:hydra If you have hydra installed, a new hydra will be created and
bound to KEY. ARGS should be a list containing the arguments
sent to `defhydra'.
bound to KEY. The first element of ARGS should be a list
containing the arguments sent to `defhydra'.
ARGS should be of the form [:keyword option]... if TARGET is a kbd-string
or a command. The following keywords exist:
Expand Down Expand Up @@ -99,8 +99,7 @@ or a command. The following keywords exist:
target))
((and (require 'hydra nil t)
(equal target :hydra))
(define-key ryo-modal-mode-map (kbd key) (eval `(defhydra ,@(car args))))
(add-to-list 'ryo-modal-bindings-list `(,key ,(symbol-name (caar args)) nil)))
(apply #'ryo-modal-key `(,key ,(eval `(defhydra ,@(car args))) ,@(cdr args))))
(t
(let* ((name (or (plist-get args :name)
(if (stringp target)
Expand Down Expand Up @@ -188,6 +187,28 @@ See `ryo-modal-keys' for more information."
:mode ,mode))
args)))

;;;###autoload
(defun ryo-modal-set-key (key command)
"Give KEY a binding as COMMAND in `ryo-modal-mode-map'.
This function is meant to be used interactively, if you want to
temporarily bind a key in ryo.
See `global-set-key' for more info."
(interactive "KSet ryo key: \nCSet ryo key %s to command: ")
(or (vectorp key) (stringp key)
(signal 'wrong-type-argument (list 'arrayp key)))
(define-key ryo-modal-mode-map key command))

;;;###autoload
(defun ryo-modal-unset-key (key)
"Remove `ryo-modal-mode-map' binding of KEY.
KEY is a string or vector representing a sequence of keystrokes.
This function is meant to unbind keys set with `ryo-modal-set-key'."
(interactive "kUnset ryo key: ")
(define-key ryo-modal-mode-map key nil))

;;;###autoload
(defun ryo-modal-bindings ()
"Display a buffer of all bindings in `ryo-modal-mode'."
Expand Down

1 comment on commit a3b0de1

@Kungsgeten
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#14

Please sign in to comment.