Skip to content

Commit

Permalink
Handle error in evil-escape-pre-command-hook
Browse files Browse the repository at this point in the history
Otherwise emacs automatically removes the function from the
pre-command-hook.
  • Loading branch information
justbur authored and syl20bnr committed Sep 22, 2015
1 parent 7966f4b commit c23a84d
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions evil-escape.el
Original file line number Diff line number Diff line change
Expand Up @@ -150,26 +150,27 @@ with a key sequence."

(defun evil-escape-pre-command-hook ()
"evil-escape pre-command hook."
(when (evil-escape-p)
(let ((modified (buffer-modified-p))
(inserted (evil-escape--insert))
(fkey (elt evil-escape-key-sequence 0))
(skey (elt evil-escape-key-sequence 1))
(evt (read-event nil nil evil-escape-delay)))
(when inserted (evil-escape--delete))
(set-buffer-modified-p modified)
(cond
((and (integerp evt)
(or (and (equal (this-command-keys) (evil-escape--first-key))
(char-equal evt skey))
(and evil-escape-unordered-key-sequence
(equal (this-command-keys) (evil-escape--second-key))
(char-equal evt fkey))))
(evil-escape)
(setq this-command 'ignore))
((null evt))
(t (setq unread-command-events
(append unread-command-events (list evt))))))))
(with-demoted-errors "evil-escape: Error %S"
(when (evil-escape-p)
(let ((modified (buffer-modified-p))
(inserted (evil-escape--insert))
(fkey (elt evil-escape-key-sequence 0))
(skey (elt evil-escape-key-sequence 1))
(evt (read-event nil nil evil-escape-delay)))
(when inserted (evil-escape--delete))
(set-buffer-modified-p modified)
(cond
((and (integerp evt)
(or (and (equal (this-command-keys) (evil-escape--first-key))
(char-equal evt skey))
(and evil-escape-unordered-key-sequence
(equal (this-command-keys) (evil-escape--second-key))
(char-equal evt fkey))))
(evil-escape)
(setq this-command 'ignore))
((null evt))
(t (setq unread-command-events
(append unread-command-events (list evt)))))))))

(defun evil-escape-p ()
"Return non-nil if evil-escape can run."
Expand Down

0 comments on commit c23a84d

Please sign in to comment.