I am writing a small window navigation and manipulation package. Windows are numbered very much like WindowNumberingMode.

To make this concrete I have a series of commands:

"C-, 1"   ; Move focus to (select) window #1
..        ; ..
"C-, 9"   ; Move focus to (select) window #9
"C-, m 1" ; Move current buffer and focus to window #1
..        ; ..
"C-, m 9" ; Move current buffer and focus to window #9
"C-, x 1" ; Exchange current buffer and focus with window #1
..        ; ..
"C-, x 9" ; Exchange current buffer and focus with window #9
..        ; ..

At the time that I type "C-," I would like to offer visual prompts (similar to switch-window):

Can I do this and continue collecting the remainder of my key-sequence? Do I need "C-," to switch to a new minor-mode?

  • 5
    I am not trying to demotivate your package development, but I believe the ace-window package gives this or similar functionality. You can study that package to see how it implements it. – Kaushal Modi Sep 17 '15 at 14:15
  • 1
    You can also look at hydra : C-, would be bound to the hydra body, and 1, 9... would be hydra heads. See :pre and :post to set up visual hints. – ffevotte Sep 17 '15 at 18:43
  • 2
    IIUC, this question is not a duplicate of Emacs bind key to prefix: in this question the OP wants the prefix to do something while still allowing the user to subsequently press keys to terminate the action. In the other question, the OP wants to "alias" a prefix sequence to a key binding, in such a way that for example pressing C-x C-x a is the same as pressing C-c a. – ffevotte Sep 18 '15 at 7:11
  • 1
    I think that you can do what you want using set-transient-map. You can find examples of its use. I don't think there should be a problem with multiple requests, whether from pre-command-hook or otherwise - they are handled sequentially, after all. But give it a try, to see. – Drew Sep 18 '15 at 21:30
  • 1
    Wrt my parenthetical remark: A key can be bound to a command that, when invoked, returns a keymap. See C-h f keymapp and the Elisp manual, node Format of Keymaps. IOW, this is one possibility for (keymapp f): (and (symbolp f) (fboundp f) (keymapp (symbol-function f))) – Drew Sep 18 '15 at 21:35

Browse other questions tagged or ask your own question.