mrkkrp / modalka

Modal editing your way
280 stars 18 forks source link

Exit modalka-mode programatically #7

Closed rsuhada closed 8 years ago

rsuhada commented 8 years ago

When in modalka mode, I'd like to hit space and 1. exit into insert mode and 2. insert a space. This is my attempt, except I can't figure out how to exit modalka programatically:

(defun exit-on-space ()
   (interactive)
   (cond
    (modalka-mode
     (modalka-global-mode nil)
     (insert " ")
     )))

 (define-key modalka-mode-map (kbd "SPC") #'exit-on-space)
mrkkrp commented 8 years ago

This should do the trick (not tested):

(defun exit-on-space ()
  (interactive)
  (modalka-mode 0)
  (insert-char 32))
mrkkrp commented 8 years ago

BTW, if you type C-h f modalka-mode RET, then Emacs will tell you how to call the function and which arguments you can pass to it.

rsuhada commented 8 years ago

It works - thank you!