Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add devil-exit-key for easy exit from repeating commands #32

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion devil.el
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ Devil can be activated using it. To support multiple activation
keys, this keymap may be modified to add multiple keys to
activate Devil.")

(defcustom devil-exit-key nil
"Key that stops the modal repeating of keys in sequence.
For example, you can set it to <return> like `isearch-exit'."
:type '(choice (const :tag "No special key to exit repeating sequence" nil)
(key :tag "Kbd keys that exit repeating sequence"))
:group 'devil)

(defcustom devil-logging nil
"Non-nil iff Devil should print log messages."
:type 'boolean)
Expand Down Expand Up @@ -608,7 +615,12 @@ last-command-event: %s; char-before: %s"
(devil--log "Setting transient repeatable key: %s => %s"
(key-description transient-key) binding)
(define-key map transient-key binding))))
(set-transient-map map t)))
(let ((exitfun (set-transient-map map t)))
(when devil-exit-key
(define-key map (if (key-valid-p devil-exit-key)
(kbd devil-exit-key)
devil-exit-key)
(lambda () (interactive) (funcall exitfun)))))))

(defun devil--find-repeatable-group (described-key)
"Find the repeatable keys group that DESCRIBED-KEY belongs to."
Expand Down