-
Notifications
You must be signed in to change notification settings - Fork 0
/
dokey.el
56 lines (44 loc) · 1.71 KB
/
dokey.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
;;; dokey.el --- trigger kbd events -*- lexical-binding: t -*-
;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
;; Author: Ernst M. van der Linden <[email protected]>
;; URL: https://github.com/ernstvanderlinden/dokey
;; Version: 1.0.0
;; Package-Requires: ()
;; Keywords: convenience
;; This file is part of GNU Emacs.
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; For a full copy of the GNU General Public License
;; see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; The dokey package lets you fire kbd-macro events, in simple words,
;; automatically `press` keys. For example to trigger a key sequence
;; of `C-c C-m` you call (dokey-run "C-c C-m") .
;;
;; Two other examples:
;; (global-set-key (kbd "C-y") (dokey "M-x emacs-"))
;; (global-set-key (kbd "C-p") (dokey "C-x C-f dokey-tmp RET insert some text"))
;; To enable dokey on Emacs startup, add following to your init.el:
;;
;; (require 'dokey)
;;
;;; Code:
(defun dokey (kbd-macro)
"An interactive lambda which fires a KBD-MACRO."
(lambda ()
(interactive)
(dokey-run kbd-macro)))
(defun dokey-run (kbd-macro)
"Fires a KBD-MACRO provided as argument."
(setq unread-command-events
(listify-key-sequence
(read-kbd-macro kbd-macro))))
(provide 'dokey)
;;; dokey.el ends here