Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add Modifier key sequence to aw-dispatch-list ? #210

Open
bob333 opened this issue Apr 29, 2021 · 6 comments
Open

How to add Modifier key sequence to aw-dispatch-list ? #210

bob333 opened this issue Apr 29, 2021 · 6 comments

Comments

@bob333
Copy link

bob333 commented Apr 29, 2021

Hi,
I have global keybinding "M-o" set to ace-window. I would like the keybinding "M-o M-o" bound to "other-window" command. Most of the time I switch back to the recently used window when more than two windows exist.

Thanks

@onetom
Copy link

onetom commented Jul 18, 2021

I just tried ace-window for ~10minutes and I wished for this to be possible too.
However, the default M-o n sequence is not too bad.
Alternatively, I would probably redefine the default C-x C-o binding, because its assigned delete-blank-lines command doesn't seem to be frequently desired.
But I agree that none of these are as effective or convenient as M-o M-o would be.

@cleyon
Copy link

cleyon commented Nov 5, 2021

;; `M-o M-o' switches to the window you were previously in.
(setq aw-translate-char-function
(lambda (c) (if (= c ?\M-o) ?n c)))

@ville-h
Copy link

ville-h commented Jan 28, 2022

cleyon's answer somewhat works, but it means aw-show-dispatch-help won't list the "correct" remapped entry. It would be nicer to be able to do keybinds the regular way: (kbd "<C-left>") and such.

@ville-h
Copy link

ville-h commented Jan 28, 2022

For benefit of others who may have wished to bind something to C-k or similar you can achieve it with: (?\C-k delete-other-windows).

@onetom
Copy link

onetom commented Apr 17, 2022

Since (?\M-o aw-flip-window) seems to solve the problem quite well, this issue could be closed.
Do you agree @bob333?
Can you close it please?

For a complete example, here is my use-ace-window.el, which I just (require use-ace-window) from my ~/.config/emacs/init.el:

(straight-use-package 'ace-window)
(setq aw-dispatch-always t)
(setq aw-keys '(?a ?s ?d ?f ?j ?k ?l))
(setq aw-dispatch-alist
  '((?x aw-delete-window "Delete Window")
    (?m aw-swap-window "Swap Windows")
    (?M aw-move-window "Move Window")
    (?c aw-copy-window "Copy Window")
    (?b aw-switch-buffer-in-window "Select Buffer")
    (?o switch-to-buffer)
    (?\M-o aw-flip-window)
    (?O aw-switch-buffer-other-window "Switch Buffer Other Window")
    (?F aw-split-window-fair "Split Fair Window")
    (?v aw-split-window-vert "Split Vert Window")
    (?h aw-split-window-horz "Split Horz Window")
    (?X delete-other-windows "Delete Other Windows")
    (?? aw-show-dispatch-help)))
(global-set-key (kbd "M-o") #'ace-window)

(provide 'use-ace-window)

@onetom
Copy link

onetom commented May 2, 2022

I was just trying out the lispy package and I had to unbind M-o (lispy-left-maybe) in it, to avoid conflicting with the ace-window setup mentioned above:

 (define-key lispy-mode-map (kbd "M-o") nil)

Just putting it here for the sake of copy-paste convenience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants