Let's say I bind the key to a certain function as follows:
(global-set-key (kbd "C-c =") 'function-foo)
Now, I want the key binding to work as:
After I press C-c =
for the first time, if I want to repeat the function-foo, I don't need to press C-c
again, but simply repeat pressing =
. Then, after I call the function-foo for enough times, I can just press keys other than =
(or explicitly press C-g
) to quit.
How to do this?
First, Emacs checks if there's a minor mode key binding; If there isn't, then Emacs checks if there are any local keys set. Typically this local map is shared by the major mode of the current buffer. So if you want to add a key binding to python-mode , you can use local-set-key to do this.
Probably one of our top feature requests. By Vim, I mean literally Vim, the command-line text editor. And by bindings, I mean keyboard commands that do specific things in the editor.
This may be the thing you are looking for:
(defun function-foo ()
(interactive)
(do-your-thing)
(set-temporary-overlay-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "=") 'function-foo)
map)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With