1

This blog post on migrating from vim to evil-mode in emacs gives code to make a single ESC quit/cancel helm instead of 3. It worked on Emacs.app (OS X) but doesn't work from Terminal.app (both emacs 24.x); that is, quitting helm requires ESC ESC ESC in Terminal emacs but not in Emacs.app. How can I get this functionality for emacs in Terminal.app?

From the blog:

;; esc quits
(defun minibuffer-keyboard-quit ()
  "Abort recursive edit.
In Delete Selection mode, if the mark is active, just deactivate it;
then it takes a second \\[keyboard-quit] to abort the minibuffer."
  (interactive)
  (if (and delete-selection-mode transient-mark-mode mark-active)
      (setq deactivate-mark  t)
    (when (get-buffer "*Completions*") (delete-windows-on "*Completions*"))
    (abort-recursive-edit)))
(define-key evil-normal-state-map [escape] 'keyboard-quit)
(define-key evil-visual-state-map [escape] 'keyboard-quit)
(define-key minibuffer-local-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-ns-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-completion-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-must-match-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-isearch-map [escape] 'minibuffer-keyboard-quit)
(global-set-key [escape] 'evil-exit-emacs-state)

I tried to figure out the answer here, but after looking at a number of tutorials on using defun I'm stuck. I have a number of arguments error as well as a free-variable error and I don't know what these things mean (that is, I don't understand the syntax of how the function is called nor do I understand what it is count

I blindly tried something like

(defun my-helm-quit-key ()                                 
  (define-key helm-map (kbd "ESC") helm-keyboard-quit-key))

and then (add-hook 'after-init-hook 'my-helm-quit-key) but that didn't work.

I later found another post about it here, but after installing bind-key I still get the error "reference to free variable helm-map". Where does helm-map come from? I believe I have the latest version of helm and helm-gtags and helm-core installed... The stuff I used from that site is as follows:

;; escape quits
(bind-key "<escape>" 'isearch-cancel isearch-mode-map)
(bind-key "<escape>" 'helm-keyboard-quit helm-map)
(bind-key "<escape>" 'helm-keyboard-quit helm-comp-read-map)
  • Could you clarify what you mean by "not working"? Possibly related: [Problems with keybindings when using terminal](http://emacs.stackexchange.com/questions/1020/problems-with-keybindings-when-using-terminal). – Dan Mar 12 '16 at 02:15
  • exiting helm still requires ESC ESC ESC when in terminal, even when I have loaded various combinations of the above lisp commands. In addition, evaluating the lisp commands seemed to produce errors. I will edit post. – Alejandro Erickson Mar 12 '16 at 10:07
  • What if you simply quit the minibuffer? (define-key minibuffer-local-map (kbd "ESC") 'keyboard-escape-quit) – Darryl Hebbes Mar 12 '16 at 10:25

0 Answers0