I have been modifying my Emacs setup quite alot recently but I reached a problem which is starting to annoy me. I would like to be able to introduce additional modifier like keys. What I am trying to do, to make things clearer, is when I am in dired-mode (which doesn’t accept textual input so normal letters can be rebound) I would like it so that when I hold down the letter s and press j or l the cursor moves to the next and previous directory line respectively. Effectively making the s key act like a modifier.
I have looked into making the s apply a modifier such as super or hyper but those are all used for global things. Is this possible? if not then that’s a shame.
Edit:
There seems to be some confusion with what I’m after. If I define a normal key sequence such as
(define-key map (kbd "s j") 'dired-next-dirline)
Then I have to keep pressing the s key every time before I press j to move to the next directory line. This is not what I am looking for (not to sound angry :P) I want s to act like a modifier where I can keep the s key held down and keep tapping j to move down the lines.
I hope I have made this more clear. Thanks.
I dug around in the code and came up with this. It binds
s jtomy-dired-next-dirline, but right after you’ve done that, justjis enough to do it again. Any other key resets the temporary binding.Note that the function
set-temporary-overlay-mapwas added in Emacs 24.2, which at the time of this writing hasn’t been released yet, so you’ll need to build Emacs from git.