Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard layout tolerance #4

Open
Tyrn opened this issue Dec 21, 2022 · 2 comments
Open

Keyboard layout tolerance #4

Tyrn opened this issue Dec 21, 2022 · 2 comments

Comments

@Tyrn
Copy link

Tyrn commented Dec 21, 2022

Hi,

I've been trying to define some chords which should work across different keyboard layouts, something like that:

(key-chord-mode 1)
(key-chord-define-global "LL" "---~")

The above chord works on the English layout only.

(key-chord-mode 1)
(key-chord-define-global "LL" "---~")
(key-chord-define-global "ДД" "---~")

This additional chord uses the same key in Russian; doesn't appear to work, though.

I also use the "localization" package:

;; Shortcuts translation.
(use-package reverse-im
  :ensure t
  :custom
  (reverse-im-input-methods '("russian-computer"))
  :config
  (reverse-im-mode t))

I tried to comment it out experimentally, nothing apparently changed. Is there a way to make my chords "layout tolerant"?

@Tyrn
Copy link
Author

Tyrn commented Dec 21, 2022

Oh, I see.

;; ########   Limitations   ########################################
...
;; Emacs will not call input-method-function for keys that have non numeric
;; codes or whos code is outside the range 32..126. Thus you cannot define
;; key chords involving function keys, control keys, or even your non-english
;; letters (on national keyboards) that otherwise are well positioned for
;; chording on your keyboard.
...

No workaround whatsoever?

@tarsius tarsius closed this as completed May 22, 2023
@tarsius tarsius reopened this May 22, 2023
@bravosierrasierra
Copy link

i have found workaround to nonlatin layouts users

(with-eval-after-load "evil"

  (make-local-variable 'bss/move-from-insert-last-char)
  (setq-default bss/move-from-insert-last-char ??)

  (defun bss/move-from-insert (key &optional rest)
    (interactive)

    (let* (
           (line-move-visual t)
           (mycmd (format "(lambda nil (interactive) (bss/move-from-insert %s))" key))
           (prevcmd (format "%s" last-command))
           (multiplier 3)
           )
      (cond
       ((and
         (string-equal prevcmd mycmd)
         (eq bss/move-from-insert-last-char key)
         (looking-back (make-string (1- multiplier) key))
         )

        (setq this-command nil)
        (delete-backward-char (1- multiplier))
        (evil-normal-state)
        (cond
         ((member key '(?j ?о))
          (next-line multiplier))
         ((member key '(?k ?л))
          (previous-line multiplier))
         ((member key '(?l ?д))
          (forward-char multiplier))
         ((member key '(?h ?р))
          (backward-char multiplier))
         )
        )
       (t
        ;; (message "key: %s, last char: %s, last command: %s, my command: %s" key bss/move-from-insert-last-char prevcmd mycmd) 
        (insert key)
        (setq bss/move-from-insert-last-char key))
       )
      )
    )
  

  (define-key evil-insert-state-map (kbd "j") '(lambda () (interactive)(bss/move-from-insert ?j)))
  (define-key evil-insert-state-map (kbd "о") '(lambda () (interactive)(bss/move-from-insert ?о)))
  (define-key evil-insert-state-map (kbd "k") '(lambda () (interactive)(bss/move-from-insert ?k)))
  (define-key evil-insert-state-map (kbd "л") '(lambda () (interactive)(bss/move-from-insert ?л)))
  (define-key evil-insert-state-map (kbd "h") '(lambda () (interactive)(bss/move-from-insert ?h)))
  (define-key evil-insert-state-map (kbd "р") '(lambda () (interactive)(bss/move-from-insert ?р)))
  (define-key evil-insert-state-map (kbd "l") '(lambda () (interactive)(bss/move-from-insert ?l)))
  (define-key evil-insert-state-map (kbd "д") '(lambda () (interactive)(bss/move-from-insert ?д)))
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants