diff options
author | Kyle Meyer <kyle@kyleam.com> | 2015-12-26 11:41:43 -0500 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2015-12-26 11:41:43 -0500 |
commit | 3e26e28599c9586122539915518b803d873da4b5 (patch) | |
tree | 795531268d1616c4bcfccdbf0a5672d00c3fae12 | |
parent | 9c7cb9251998417d29575b7a07228de7916a16a5 (diff) | |
download | emacs.d-3e26e28599c9586122539915518b803d873da4b5.tar.gz |
Add setkey command
-rw-r--r-- | lisp/init-general.el | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lisp/init-general.el b/lisp/init-general.el index 926e787..36cbfaa 100644 --- a/lisp/init-general.el +++ b/lisp/init-general.el @@ -60,4 +60,32 @@ (global-auto-revert-mode) (key-chord-mode 1) + +;;; Set key + +(defvar km/setkey-command nil) +(defvar km/setkey-last-call-time nil) +(defvar km/setkey-seconds-timeout 600) + +(defun km/setkey-call () + "Call `km/setkey-command'. +When `km/setkey-command' is nil or the time since the last call +has exceeded `km/setkey-seconds-timeout', read the command to +call." + (interactive) + (when (or (not km/setkey-command) + (> (- (float-time) km/setkey-last-call-time) + km/setkey-seconds-timeout)) + (setq km/setkey-command (read-command "Command: " km/setkey-command))) + (setq km/setkey-last-call-time (float-time)) + (call-interactively km/setkey-command)) + +(defun km/setkey-reset () + "Reset `km/setkey-call' command." + (interactive) + (setq km/setkey-command nil + km/setkey-last-call-time nil)) + +(global-set-key (kbd "C-c v") 'km/setkey-call) + (provide 'init-general) |