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

switch between layouts #79

Open OrionRandD opened 4 years ago

OrionRandD commented 4 years ago

It is not really an issue. But, a PR. Since I am not very familiar with PRs, I had a chat with Xah in his discord channel and asked for him, if possible, to implement a function in xah-fly-keys to change the keyboard layouts on the fly to write documents in emacs in multiple languages. e.g. I need 5 keyboard layouts to write some documents:

  1. qwerty-abnt - which should really be qwerty-abnt2 (the default in Brazil) - the layout is right in xah-fly-keys, but the name is wrong.
  2. qwerty-es (Spain)
  3. qwerty-el (Greek)
  4. qwerry-hr (Hebrew)
  5. qwerty-us --variant intl

I have this setup in my init.el for two languages. I know that xah-fly-keys does not support all the above layouts... sigh! But, even setting emacs for xah-fly-keys to use 2 layouts, I have to comment/uncomment these lines in my init.el and eval one of them to use one or another

(xah-fly-keys-set-layout "qwerty-abnt") ; required ;; (xah-fly-keys-set-layout "qwerty") ; required

So, it is kind of painful...

xahlee commented 4 years ago

perhaps this will solve the problem?

(defun my-toggle-layout () "switch between qwerty-abnt and qwerty. Version 2019-11-20" (interactive) (if (string-equal xah-fly-key--current-layout "qwerty") (setq xah-fly-key--current-layout "qwerty-abnt") (setq xah-fly-key--current-layout "qwerty")))

OrionRandD commented 4 years ago

@xahlee Thx a lot for the function. I will test it here. Also. I found out that I can change to many keyboards layouts through Stumpwm, so that emacs respects them when I change them through a combo that I have set up here. Anyways, Thx a lot for your time and attention I will keep visiting your blog. Many thing there to learn... :)

OrionRandD commented 4 years ago

@xahlee I have written an anki file and a pdf for your keybinding. I think it is a way of giving back a little knowledge as well. Instructions are in the how-to. If you want to link it to your website, feel free... Thx again

https://github.com/OrionRandD/dotfiles/tree/master/xah_fly_keys