genovese / win-switch

A utility for quickly navigating Emacs windows
27 stars 3 forks source link

Can't seem to get `win-switch-dispatch-once` to work #4

Closed jguenther closed 9 years ago

jguenther commented 9 years ago

Great package! I find it very useful.

I may be misreading the docs but as far as I can tell, win-switch-dispatch-once is a prefix command that uses the win-switch-once-map keymap. So I bound win-switch-dispatch-once to a key, but when I try to use it I get the error:

Symbol's function definition is void: win-switch-dispatch-once

I'm trying to fix it myself to submit a PR but haven't figured it out yet. I'm using the latest version of win-switch available on MELPA.

genovese commented 9 years ago

Thanks so much for the feedback.

You are right that there is a problem; something seems to have changed in the transition from Emacs 23 to Emacs 24 in the handling of this kind of prefix key that I didn't catch. I'm assuming you are using Emacs 24 as well. (Let me know if not.)

Here is a temporary fix that I just tested. I will upload a new version this weekend that will fix the problem there. In the meantime, executing this code should work for you:

(define-prefix-command 'win-switch-dispatch-once)
(map-keymap (lambda (event binding) 
                         (define-key win-switch-dispatch-once (vector event) binding))
            win-switch-once-map)

This redefines win-switch-dispatch-once to a prefix command and sets the keys as in win-switch-once-map. (In the current code, this was done with a one-step method that no longer seems to be working.)

Now, you can bind win-switch-dispatch-once to a key for that single switching action that does not engage win-switch mode. You can use any of the normal key binding commands using 'win-switch-dispatch-once as the command.

I just did this on GNU Emacs 24.4.1 with no problems. Please let me know if it gives you any trouble, and I'll try to help. I'll get the full fix up into the package as soon as possible.

Thanks again. -- Chris

jguenther commented 9 years ago

Yes, I'm using emacs 24.4.

That workaround works perfectly, thanks!

genovese commented 9 years ago

I've fixed this win-switch-dispatch-once more completely in the current version (v1.1) on github. The workaround above is no longer necessary as I've made win-switch-dispatch-once a genuine command. (Although if you do use the workaround after loading win-switch, it should not cause a problem.) If you try out the new version, let me know how it works for you.

I have a few more updates to make and then I will push the changes to MELPA and so forth.
Thanks again for your helpful feedback.

jguenther commented 9 years ago

I recently updated to the latest MELPA version and I can confirm that this is fixed for me. Thanks!