Skip to content

Commit

Permalink
Add undefined handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Nov 22, 2016
1 parent 59235bb commit 01197b3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
32 changes: 19 additions & 13 deletions ergoemacs-advice.el
Expand Up @@ -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)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down
3 changes: 1 addition & 2 deletions ergoemacs-command-loop.el
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 01197b3

Please sign in to comment.