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

What about more generic bindings for the arrow keys in xah-fly-command-map #137

Open
dvdkhlng opened this issue Feb 18, 2022 · 1 comment

Comments

@dvdkhlng
Copy link

dvdkhlng commented Feb 18, 2022

Hi,

trying to get used to xah-fly-keys for one or two months now. Working on large projects, most of the load on hand/arms seems to come from navigating and looking up stuff, and not so much from typing, so this is what I'm currently focusing on.

My current keyboard: Truly Ergonomic Cleave does not have the arrow keys easily reachable, so having arrow key navigation in the xah-fly-command-map is quite helpful. However, in many special modes, especially minibuffer sutff like ido-find-file, isearch, ido-switch-buffer, various helm commands, the xah-fly-command-map's bindings for (dvorak) t,n,h,c directly invoke backward/forward char resp. line, which does not make sense in those contexts.

What I'm currently experimenting with, is to make those command-map "arrow keys" always trigger the current binding of the corresponding <up>, <left>, <down>, <right> keys. This seems to work, but the code does look ugly and I wonder whether there are cleaner ways to achieve this and what the downsides are (my elisp is a little rusty).

E.g. here is my (incomplete but working) example code for the up/down arrows, which is already enough to navigate e.g. in helm-occur:

(defun dk-arrow-up ()
  "Do what <Up> would do."
  (interactive)
  (call-interactively (key-binding [up])))

(defun dk-arrow-down ()
  "Do what <Down> would do."
  (interactive)
  (call-interactively (key-binding [down])))

(xah-fly--define-keys xah-fly-command-map
                      '(
                        ("t" . dk-arrow-down)
                        ("c" . dk-arrow-up))) 

An alternative would be to have a long cond block in the up/down etc. commands that invokes different functions depending on mode. In general, I think for efficiency's sake, some of the bindings in the command-map need to be used for different purpose depending on mode. Like when helm offers actions to run via the function keys F1..Fn, command map bindings for cut/copy/paste etc. are not needed and maybe should make room for easier reachable helm command invokation.

I think all this would be much easier to implement and talk about, if emacs key bindings were able to match on any mode/state information (command mode acting like a sticky modifier key). Then I could e.g. directly put bindings into the helm keymaps, that are specific to command mode.

@dvdkhlng
Copy link
Author

See also my thoughts commented on #133 on using key remapping instead of minor mode keymaps to turn command mode into a sticky "Hyper" modifier. The t,n,h,c arrow keys could just be directly remapped to arrow keys from inside key-translation-map when command-mode active.

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