Created
January 30, 2011 07:28
-
-
Save bowbow99/802650 to your computer and use it in GitHub Desktop.
`e' だけ(`C-x' なし)で kbd-macro を繰り返す #xyzzy
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
| ;;; repeat kbd-macro with just #\e (without #\C-x) | |
| (let ((repeating nil)) | |
| (labels ((check-repeating-kbd-macro () | |
| (unless (member *this-command* | |
| '(execute-last-kbd-macro | |
| repeat-kbd-macro-or-self-insert | |
| universal-argument | |
| digit-argument | |
| negative-argument)) | |
| (setf repeating nil) | |
| (delete-hook '*pre-command-hook* #'check-repeating-kbd-macro)))) | |
| (defun repeat-kbd-macro-or-self-insert (&optional (arg 1)) | |
| (interactive "*p") | |
| (if repeating | |
| (call-interactively 'execute-last-kbd-macro) | |
| (call-interactively 'self-insert-command))) | |
| (defun execute-last-kbd-macro (&optional (arg 1)) | |
| (interactive "*p") | |
| (call-interactively 'call-last-kbd-macro) | |
| (setf repeating t) | |
| (unless (and (boundp '*pre-command-hook*) | |
| (member #'check-repeating-kbd-macro *pre-command-hook*)) | |
| (add-hook '*pre-command-hook* #'check-repeating-kbd-macro))) | |
| )) ; let, labels | |
| (define-key *global-keymap* #\e 'repeat-kbd-macro-or-self-insert) | |
| (define-key ctl-x-map #\e 'execute-last-kbd-macro) |
Author
Author
*pre-command-hook* が(xyzzy 起動後最初に add-hook されるまで?)unbound なことがあるみたいなのでチェックするようにした。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
call-last-kbd-macroを実行すると*last-command*が kbd-macro で実行されたコマンドになってしまうので*pre-command-hook*など使うハメに。