           `(define-key helm-map ,key
              (lambda () (interactive)
                (spacemacs/escape-state ',seq nil t 'helm-keyboard-quit)))))
+
       ;; manage the base state target when leaving the insert state
       (define-key evil-insert-state-map [escape]
         (lambda () (interactive)

        (setq spacemacs-last-base-state 'lisp))

      (defun spacemacs/escape-state-default-insert-func (key)
        "Insert KEY in current buffer if not read only."
        (let* ((insertp (not buffer-read-only)))
          (insert key)))

      (defun spacemacs/escape-state-isearch-insert-func (key)
        "Insert KEY in current buffer if not read only."
        (isearch-printing-char))

      (defun spacemacs/escape-state-default-delete-func ()
        "Delete char in current buffer if not read only."

          `(lambda () (interactive)
             (spacemacs/escape-state
              ',seq nil t 'isearch-abort 'spacemacs/escape-state-isearch-insert-func
              'isearch-delete-char)))
        (define-key evil-insert-state-map key
          `(lambda () (interactive)
             (let ((insertf (if (eq 'term-mode major-mode)
                                'spacemacs/escape-state-term-insert-func)))
               (spacemacs/escape-state
                ',seq nil t (intern (format "evil-%s-state" spacemacs-last-base-state)) insertf))))
        (define-key evil-visual-state-map key
          `(lambda () (interactive)
             (spacemacs/escape-state ',seq ',shadowed nil 'evil-exit-visual-state)))
