Created
November 27, 2021 18:24
-
-
Save mjkramer/39307cbf4fb0b7a15ca2045d72039162 to your computer and use it in GitHub Desktop.
This file contains 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
;;; keypeat.el -*- lexical-binding: t; -*- | |
(defvar ++keypeat-last-keys nil) | |
(defun ++keypeat-save-h () | |
(setq ++keypeat-last-keys (this-command-keys))) | |
(add-hook 'post-command-hook #'++keypeat-save-h) | |
(defun ++keypeat-push-prefix (keyseq) | |
(setq unread-command-events | |
(mapcar (lambda (k) `(t . ,k)) | |
(listify-key-sequence (seq-subseq keyseq 0 -1))))) | |
(defun ++keypeat-repeat () | |
(unless (memq this-command '(++keypeat/next ++keypeat/last)) | |
(if (not this-command) | |
(remove-hook 'post-command-hook #'++keypeat-repeat) | |
(++keypeat-push-prefix (this-command-keys))))) | |
(defun ++keypeat/next () | |
(interactive) | |
(add-hook 'post-command-hook #'++keypeat-repeat)) | |
(defun ++keypeat/last () | |
(interactive) | |
(++keypeat/next) | |
(++keypeat-push-prefix ++keypeat-last-keys)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment