Skip to content

Commit

Permalink
Recognize non-ASCII escape sequences
Browse files Browse the repository at this point in the history
As suggested in section 21.7.15 of the elisp manual, handle keyboard
events internally as vectors across the board, rather than preferring
strings when possible. This commit, in combination with the one before
it, fixes syl20bnr#51: `this-command-keys' returns a vector
for most key sequences, so (for instance) the expression

  (equal (this-command-keys) "π")

is always nil.
  • Loading branch information
danielkoning committed Jun 13, 2020
1 parent df70ed6 commit b0a2f60
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions evil-escape.el
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,12 @@ with a key sequence."
(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 Down

0 comments on commit b0a2f60

Please sign in to comment.