Last active
December 10, 2016 03:00
-
-
Save syl20bnr/6437663 to your computer and use it in GitHub Desktop.
This function is for evil-mode Emacs users.
It executes the passed callback when 'fd' sequence is quickly pressed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; inspired from: | |
;; https://github.com/roman/emacs.d/blob/master/zoo/zoo-evil.el | |
(evil-define-command fd-trigger (callback) | |
"Allows to execute the passed function using 'fd'." | |
:repeat change | |
(let ((modified (buffer-modified-p))) | |
(insert "f") | |
(let ((evt (read-event | |
(format "Insert %c to exit insert state" ?d) | |
nil 0.2))) | |
(cond | |
((null evt) | |
(message "")) | |
((and (integerp evt) | |
(char-equal evt ?d)) | |
;; remove the f character | |
(delete-char -1) | |
(set-buffer-modified-p modified) | |
(funcall callback)) | |
(t ; otherwise | |
(setq unread-command-events (append unread-command-events | |
(list evt)))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment