branch: externals/ergoemacs-mode commit 01197b35314f99f6a83edc7e3928262526e15080 Author: Fidler <matthew.fid...@gmail.com> Commit: Fidler <matthew.fid...@gmail.com>
Add undefined handling --- ergoemacs-advice.el | 32 +++++++++++++++++++------------- ergoemacs-command-loop.el | 3 +-- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/ergoemacs-advice.el b/ergoemacs-advice.el index de3453c..d935fef 100644 --- a/ergoemacs-advice.el +++ b/ergoemacs-advice.el @@ -320,24 +320,30 @@ command selected, instead of rerunning `smex' and :type :before (setq ergoemacs-command-loop--single-command-keys nil)) +(defun ergoemacs-mode--undefined-advice () + "Advice for undefined." + (let ((keys (this-single-command-keys))) + (if (member (substring keys -1) '([apps] [menu])) + (progn + (setq ergoemacs-command-loop--eat nil) + (ergoemacs-command-loop keys)) + (ding) + (ergoemacs-command-loop--temp-message "%s is undefined!" + (ergoemacs-key-description (this-single-command-keys))) + (setq defining-kbd-macro nil) + (force-mode-line-update) + ;; If this is a down-mouse event, don't reset prefix-arg; + ;; pass it to the command run by the up event. + (setq prefix-arg + (when (memq 'down (event-modifiers last-command-event)) + current-prefix-arg))))) + (ergoemacs-advice undefined () "Allow `ergoemacs-mode' to display keys, and intercept ending <apps> keys." :type :around (if (not ergoemacs-mode) ad-do-it - (let ((keys (this-single-command-keys))) - (if (member (substring keys -1) '([apps] [menu])) - (ergoemacs-command-loop keys) - (ding) - (ergoemacs-command-loop--temp-message "%s is undefined!" - (ergoemacs-key-description (this-single-command-keys))) - (setq defining-kbd-macro nil) - (force-mode-line-update) - ;; If this is a down-mouse event, don't reset prefix-arg; - ;; pass it to the command run by the up event. - (setq prefix-arg - (when (memq 'down (event-modifiers last-command-event)) - current-prefix-arg)))))) + (ergoemacs-mode--undefined-advice))) (provide 'ergoemacs-advice) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/ergoemacs-command-loop.el b/ergoemacs-command-loop.el index 68f797c..47ea3e6 100644 --- a/ergoemacs-command-loop.el +++ b/ergoemacs-command-loop.el @@ -1174,7 +1174,7 @@ is the :full command loop." (add-hook 'ergoemacs-mode-startup-hook #'ergoemacs-command-loop--prefix-timer) (add-hook 'ergoemacs-mode-shutdown-hook #'ergoemacs-command-loop--stop-prefix-timer) - +(add-hook 'post-command-hook #'ergoemacs-command-loop--eat) (defun ergoemacs-command-loop--start-with-pre-command-hook () "Start ergoemacs command loop. @@ -1828,7 +1828,6 @@ Emacs versions)." (when (and ergoemacs-command-loop--eat unread-command-events) (setq ergoemacs-command-loop--eat-unread unread-command-events unread-command-events nil)) - (ergoemacs-command-loop--eat) ;; If the command changed anything, fix it here. (unless (equal type ergoemacs-command-loop--current-type) (setq type ergoemacs-command-loop--current-type