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

Can't make xah-fly-keys work properly with exwm #132

Open
spiderbit opened this issue Nov 1, 2021 · 3 comments
Open

Can't make xah-fly-keys work properly with exwm #132

spiderbit opened this issue Nov 1, 2021 · 3 comments

Comments

@spiderbit
Copy link

spiderbit commented Nov 1, 2021

Basically what I want is to have in exwm buffers to have only a few commands in command mode and handle the rest like in insert-mode so that the X buffers can use this keys.

As example in a exwm buffer i/k or in dvorak c/t for forward-line / backward-line doesn't make sense.

(defvar xah-fly-exwm-command-map (cons 'keymap xah-fly-shared-map))
(xah-fly--define-keys
 xah-fly-exwm-command-map
("a" . xah-fly-M-x)
("u" . xah-fly-insert-mode-activate)
...)

(defun xah-fly--update-key-map ()
  (setq xah-fly-key-map (if xah-fly-insert-state-q
                            xah-fly-insert-map
			  (if (eq major-mode 'exwm-mode)
			      xah-fly-exwm-command-map
                              xah-fly-command-map))))

shouldn't that setup the exwm-command-map instead of the normal command-map in exwm buffers? the comparsion works, but despite I have not defined forward-line in exwm-command-map it's still defined.

Tried to overwrite it with "nil":
("t" . nil)

But it is still bound to forward line, till now I used that as hook:
(setq xah-fly-command-map (assq-delete-all ?t xah-fly-command-map))

That kind of worked... do I have to change something else to add such hybrid-keymap / alternative command-map into fly-keys?

@spiderbit
Copy link
Author

spiderbit commented Nov 3, 2021

If I change the xah-fly-command-mode-init to set the transient-map I want depending on mode, it works when I go first in insert mode and back to command mode afterwards, but always keeps that keymap when I switch windows, and not updates it back to the other command mode:

(defun xah-fly-command-mode-init ()
  "Set command mode keys.
Version 2020-04-28"
  (interactive)
  (setq xah-fly-insert-state-q nil)
  (xah-fly--update-key-map)
  (let ((map
	 (if (eq major-mode 'exwm-mode)
	     xah-fly-exwm-command-map
	   xah-fly-command-map)))
    (setq xah-fly--deactivate-command-mode-func
	  (set-transient-map map (lambda () t))))
  (modify-all-frames-parameters (list (cons 'cursor-type 'box)))
  (setq mode-line-front-space "C")
  (force-mode-line-update))

Do I have to make the keymaps local or something to not get overwritten by other buffers?

@spiderbit
Copy link
Author

spiderbit commented Nov 6, 2021

Adding that advises seem to fix it but it's a ugly hack:

(advice-add 'other-window :after (lambda (x)
				   (xah-fly-insert-mode-activate)
				   (xah-fly-command-mode-activate)))
(advice-add 'other-frame :after (lambda (x)
				  (xah-fly-insert-mode-activate)
				  (xah-fly-command-mode-activate)))
(advice-add 'switch-to-buffer :after (lambda (x)
				  (xah-fly-insert-mode-activate)
				  (xah-fly-command-mode-activate)))

@spiderbit
Copy link
Author

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

No branches or pull requests

1 participant