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

A function to list all modalka state bindings #8

Open
sriramkswamy opened this issue May 10, 2016 · 5 comments
Open

A function to list all modalka state bindings #8

sriramkswamy opened this issue May 10, 2016 · 5 comments

Comments

@sriramkswamy
Copy link

Is it possible to add a function, say modalka-describe-bindings, which just lists all the bindings bound in modalka state (preferably with the function it is bound to)? This can be useful when I know I bound something but I forgot what I bound it too.

@mrkkrp
Copy link
Owner

mrkkrp commented May 11, 2016

Yes, that's possible. Not sure when I get to it, though, but I like the idea.

@mrkkrp mrkkrp added this to the 0.1.3 milestone May 11, 2016
@mrkkrp mrkkrp self-assigned this May 11, 2016
@mrkkrp mrkkrp removed this from the 0.1.3 milestone May 29, 2016
@phil-s
Copy link

phil-s commented May 31, 2016

Now that #10 is implemented and modalka-mode-map is using symbols, a convenient way to facilitate this might be to add a target-key symbol property at the point when each key is defined.

(At present it looks like this information is captured only in the lexical closure for each anonymous function, and the manual recommends against relying on the current closure implementation, so a new property seems like a better option than inspecting the closure environment.)

A way to list all modalka bindings would then be to iterate through the keymap and, for each key, get the target-key symbol property, look up the current binding for that target, and display them both (much as the docstring for a single binding now does).

(put SYM 'target-key target-key) ;; where SYM is the (make-symbol) value

(let ((sym (lookup-key modalka-mode-map KEY))) ;; obtain symbol
  (key-binding (get sym 'target-key))) ;; the target binding

@phil-s
Copy link

phil-s commented May 31, 2016

Even cooler would be a way to get the normal keymap descriptions (e.g. C-h b) to output the target bindings, but I can't see how to do that. We're well into C code territory (the describe_map and get_keyelt C functions are responsible, I believe). From a look at the latter function I'm guessing that using the fancy menu-item form of key binding might facilitate a solution via its :filter option, but I don't know very much about that.

@mrkkrp mrkkrp removed their assignment May 31, 2016
@mrkkrp
Copy link
Owner

mrkkrp commented May 31, 2016

@phil-s, Do you want to make a PR for this feature? I'm quite busy these days, unfortunatelly. You seem to be advanced ELisp user who can handle it.

@phil-s
Copy link

phil-s commented May 31, 2016

Definitely maybe? I'll try to take a look at this sometime soon.

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

No branches or pull requests

3 participants