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.

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

5
  • 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 3 '14 at 20:30
  • Edited the answer for the solution
    – Naseer
    Dec 3 '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 2:45
  • It quits but still shows up on the buffer section
    – alper
    May 4 '20 at 13:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.