From 95cd06f3c546983f18dd7758386ca6820c01ca45 Mon Sep 17 00:00:00 2001 From: sbenner Date: Tue, 20 Jan 2015 12:15:19 -0500 Subject: [PATCH] Fix regression with term buffers --- evil-escape.el | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/evil-escape.el b/evil-escape.el index 3bd585f..79c946f 100644 --- a/evil-escape.el +++ b/evil-escape.el @@ -5,7 +5,7 @@ ;; Author: Sylvain Benner ;; Keywords: convenience editing evil ;; Created: 22 Oct 2014 -;; Version: 2.03 +;; Version: 2.04 ;; Package-Requires: ((emacs "24") (evil "1.0.9")) ;; URL: https://github.com/syl20bnr/evil-escape @@ -80,7 +80,7 @@ :group 'evil-escape)) (defvar evil-escape-motion-state-shadowed-func nil - "Original function of `evil-motion-state' shadowed by `evil-escape'. + "Original function of `evil-motion-state' shadowed by `evil-espace'. This variable is used to restore the original function bound to the first key of the escape key sequence when `evil-escape' mode is disabled.") @@ -93,7 +93,7 @@ mode is disabled.") ;;;###autoload (define-minor-mode evil-escape-mode - "Buffer-local minor mode to escape insert state and everything else + "Buffer-local minor mode to escape insert state and everythin else with a key sequence." :lighter (:eval (concat " " evil-escape-key-sequence)) :group 'evil @@ -152,9 +152,13 @@ with a key sequence." (lookup-key evil-motion-state-map (evil-escape--first-key))) ;; evil states ;; insert state - (eval `(evil-escape-define-escape "insert-state" evil-insert-state-map evil-normal-state - :insert-func evil-escape--default-insert-func - :delete-func evil-escape--default-delete-func)) + (let ((insert-func (lambda (key) (interactive) + (cond ((eq 'term-mode major-mode) + (call-interactively 'term-send-raw)) + (t (evil-escape--default-insert-func key)))))) + (eval `(evil-escape-define-escape "insert-state" evil-insert-state-map evil-normal-state + :insert-func ,insert-func + :delete-func evil-escape--default-delete-func))) ;; emacs state (let ((exit-func (lambda () (interactive) (cond ((string-match "magit" (symbol-name major-mode)) @@ -244,6 +248,10 @@ with a key sequence." "Send `q' key press event to exit from a buffer." (setq unread-command-events (listify-key-sequence "q"))) +(defun evil-escape--term-insert-func (key) + "Insert KEY in current term buffer." + (term-send-raw)) + (defun evil-escape--execute-shadowed-func (func) "Execute the passed FUNC if the context allows it." (unless (or (null func)