abo-abo / ace-window

Quickly switch windows in Emacs
977 stars 87 forks source link

[feature-request] hope there is a customized key-binding option for cancel, like C-g, #137

Closed ethanyu336 closed 6 years ago

ethanyu336 commented 6 years ago

Thank you for such a good plugin, I hope there is a customized key-binding option for cancel windows jumping in ace-window,function like C-g , that would be perfect, maybe can be called "cancel-key"?

Generally, we have a local keymap ,but there is no way define that for ace-window, emmm..not that much practical..but ace-window must be more perfect with this :D

abo-abo commented 6 years ago

ace-window can be canceled with C-g.

ethanyu336 commented 6 years ago

@abo-abo thank your reply, I know C-g can do this, my expectation Is to able to specify another key to do the same, I have another key to keyboar-quit more frequently. :D。

abo-abo commented 6 years ago

You'll have to customize aw-dispatch-function to handle your custom key binding.

abo-abo commented 6 years ago

Also avy-key-to-char-alist.

ethanyu336 commented 6 years ago

@abo-abo Thanks for your patient explanation, now I can customized a char "x" for keyboard-quit, but what i actually want to use is a C-SPC, Below is some code i've tried. Is using C-SPC possible?Thanks again!

(setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))
(eval-after-load "ace-window" '(progn
(add-hook 'ace-window-display-mode-hook
          '(progn
             (defvar avy-key-to-char-alist
               '(
                 ;; ((kbd "C-SPC") "x")
                 ;; ((kbd "C-SPC") ?x)
                 ((kbd "C-SPC") x)       
                 ))
             ))
          ))
(defvar aw-dispatch-alist
  '(
    (?x keyboard-quit)
    ))
abo-abo commented 6 years ago

This should work:

(add-to-list 'avy-key-to-char-alist '(67108896 . ?x))
(setq aw-dispatch-function
      (lambda (char)
        (if (= char (aref (kbd "C-SPC") 0))
            (throw 'done 'exit)
          (aw-dispatch-default char))))
ethanyu336 commented 6 years ago

@abo-abo works! you're so cool! big thanks again for your patience. :D

abo-abo commented 6 years ago

You're welcome.