modalka icon indicating copy to clipboard operation
modalka copied to clipboard

Easy way to remove unbound keys from modalka-mode?

Open Bhanukamax opened this issue 1 year ago • 4 comments

Is there a way to easily remove all the unbound keys from modalka minor mode. i.e. if it's not mapped it will not do anything.

Bhanukamax avatar Aug 15 '22 18:08 Bhanukamax

This is the state by default, isn't it?

mrkkrp avatar Aug 16 '22 08:08 mrkkrp

oh, sorry, I think, my question is not very clear. What I meant by unbind is like making them not do anything in modalka minor mode if they are not bound to anything.

so in the current implementation, let say for example I have not bound anything to key 'h', pressing 'h' would insert letter 'h'. What I would like to be able to do is if it's not bound to anything make it do nothing.

I guess what I can do to get this behaviour currently is to create function which does nothing and map that to modalka map for each key which I don't want to use in modalka mode. But, it would be great if there was like a flag to set, which if set modalka will not respond to any other key, other than the things specifically bound. Not sure if this is technically easy or hard to implement, I'm a fairly new emacs user.

If what I describe here is how it works by default, then there's clearly something going wrong in my setup, if so please let me know, I'll do a bit of digging in my config to see where it's going wrong.

Bhanukamax avatar Aug 17 '22 00:08 Bhanukamax

Thanks, this is indeed much clearer. The way it works has to do with the fact that modalka-mode is a minor mode. Therefore it takes precedence when Emacs decides what command to run. If a key is not present in modalka-mode other minor modes and the major mode bindings get a chance to run. For modalka-mode to inhibit self-inserting characters you would indeed need to bind them to a command that does nothing; it is probably the only way.

mrkkrp avatar Aug 18 '22 07:08 mrkkrp

n.b. ignore is the canonical command which does nothing. You could try this:

(define-key modalka-mode-map [t] #'ignore)

(untested)

phil-s avatar Sep 10 '22 03:09 phil-s