xahlee / xah-fly-keys

the most efficient keybinding for emacs
http://xahlee.info/emacs/misc/xah-fly-keys.html
470 stars 80 forks source link

Permanent recursive-load fix #90

Closed wi11dey closed 4 years ago

wi11dey commented 4 years ago

Hey Xah,

Saw your notes in your blog and think I figured out why the recursive-load was happening: because of the way the Customize interface works, it tries to use the setter (same as the custom-set property) to set the default value. However, the setter is xah-fly-keys-set-layout, which reloads the file to update the keybindings to the new layout. Loading the file again calls the setter again which reloads the file, etc which causes the recursive load.

I've fixed this by not making the Customize interface dependent on xah-fly-keys-set-layout and only have it reload the file if it was already loaded and the new value is different than the old one. Otherwise, the bindings will not be updated to use the new layout when people set the layout through Customize. (Also removed the extra quote I added for the Customize choices)

xah-fly-keys-set-layout just calls the same function that Customize would have, for people who don’t like the Customize interface or just want to do it lisp-only. The widget-prompt-value just asks the human-friendly names for the keyboard layouts during completion, but it will never be called for users who don’t call xah-fly-keys-set-layout interactively.

Note: doing (setq xah-fly-key-current-layout 'qwerty) before it is loaded is the same as calling xah-fly-keys-set-layout after it is loaded, and will speed up your init slightly since the file will only be loaded once.


As for the isearch: I think your solution with the isearch hooks is a good one, since isearch only tries to be careful if a transient map is started during isearch, but it replaces any maps that were there before it. This is bad behavior on the part of isearch (and I might try to make a change to upstream Emacs to convert it to set-transient-keymap too :smile:), but for now it is ok to use the hooks since isearch is an exception to how modes should interact.