4

I followed this guide to make escape quit from various modes...

;; 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)

To make helm quit using escape, I tried:

(define-key helm-map [escape] 'helm-keyboard-quit)

This didn't work. Setting other keys instead of escape works fine though.

programking
  • 7,064
  • 9
  • 41
  • 62
Naseer
  • 145
  • 1
  • 6

1 Answers1

4

Define a function my-helm-init which runs (define-key helm-map (kbd "ESC") 'helm-keyboard-quit)

Call my-helm-init from the after-init-hook

Naseer
  • 145
  • 1
  • 6
mgalgs
  • 464
  • 4
  • 12
  • Thanks for the suggestion - looking at those links made me find the solution that worked for me. The solution was to set the keymapping in the after-init-hook – Naseer Dec 03 '14 at 20:30
  • Edited the answer for the solution – Naseer Dec 03 '14 at 20:33
  • This only works for emacs GUI i.e. emacs running in its own window. When running emacs -nw in Linux gnome-terminal / xterm, I need ESC thrice. – Jeeves Mar 17 '17 at 12:02
  • Could you provide a full example? I can't figure out what the after-init-hook part should look like – priomsrb Mar 11 '19 at 02:45
  • It quits but still shows up on the buffer section – alper May 04 '20 at 13:57