Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event handling #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions evil-escape.el
Original file line number Diff line number Diff line change
Expand Up @@ -189,18 +189,20 @@ with a key sequence."
(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)))
(evt (read-event nil t evil-escape-delay)))
(when inserted (evil-escape--delete))
;; NOTE Add syl20bnr/evil-escape#91: replace `set-buffer-modified-p'
;; with `restore-buffer-modified-p', which doesn't redisplay the
;; modeline after changing the buffer's modified state.
(restore-buffer-modified-p modified)
(cond
((and (characterp evt)
(or (and (equal (this-command-keys) (evil-escape--first-key))
(or (and (equal (this-command-keys-vector)
(evil-escape--first-key))
(char-equal evt skey))
(and evil-escape-unordered-key-sequence
(equal (this-command-keys) (evil-escape--second-key))
(equal (this-command-keys-vector)
(evil-escape--second-key))
(char-equal evt fkey))))
(evil-repeat-stop)
(let ((esc-fun (evil-escape-func)))
Expand Down Expand Up @@ -236,9 +238,9 @@ with a key sequence."
(not (memq evil-state evil-escape-excluded-states))
(or (not evil-escape-enable-only-for-major-modes)
(memq major-mode evil-escape-enable-only-for-major-modes))
(or (equal (this-command-keys) (evil-escape--first-key))
(or (equal (this-command-keys-vector) (evil-escape--first-key))
(and evil-escape-unordered-key-sequence
(equal (this-command-keys) (evil-escape--second-key))))
(equal (this-command-keys-vector) (evil-escape--second-key))))
(not (cl-reduce (lambda (x y) (or x y))
(mapcar 'funcall evil-escape-inhibit-functions)
:initial-value nil))))
Expand Down Expand Up @@ -283,16 +285,14 @@ with a key sequence."
(t 'evil-normal-state)))

(defun evil-escape--first-key ()
"Return the first key string in the key sequence."
(let* ((first-key (elt evil-escape-key-sequence 0))
(fkeystr (char-to-string first-key)))
fkeystr))
"Return a vector containing just the first key in the key sequence."
(let ((first-key (elt evil-escape-key-sequence 0)))
(vector first-key)))

(defun evil-escape--second-key ()
"Return the second key string in the key sequence."
(let* ((sec-key (elt evil-escape-key-sequence 1))
(fkeystr (char-to-string sec-key)))
fkeystr))
"Return a vector containing just the second key in the key sequence."
(let ((second-key (elt evil-escape-key-sequence 1)))
(vector second-key)))

(defun evil-escape--insert-func ()
"Default insert function."
Expand All @@ -315,7 +315,7 @@ with a key sequence."
('error nil)))

(defun evil-escape--insert-2 ()
"Insert character while taking into account mode specificites."
"Insert character while taking into account mode specificities."
(pcase major-mode
(`term-mode (call-interactively 'term-send-raw))
(_ (cond
Expand All @@ -333,7 +333,7 @@ with a key sequence."
(`iedit-insert (evil-escape--delete-func))))

(defun evil-escape--delete-2 ()
"Delete character while taking into account mode specifities."
"Delete character while taking into account mode specificities."
(pcase major-mode
(`term-mode (call-interactively 'term-send-backspace))
(_ (cond
Expand Down