ace-window icon indicating copy to clipboard operation
ace-window copied to clipboard

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

Open bob333 opened this issue 3 years ago • 6 comments

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

bob333 avatar Apr 29 '21 21:04 bob333

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.

onetom avatar Jul 18 '21 18:07 onetom

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

cleyon avatar Nov 05 '21 20:11 cleyon

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 avatar Jan 28 '22 10:01 ville-h

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

ville-h avatar Jan 28 '22 10:01 ville-h

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 avatar Apr 17 '22 04:04 onetom

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.

onetom avatar May 02 '22 10:05 onetom