I have a program, say myprogram.exe, and I want to run it from within Emacs by using a key binding. I can run the program in the shell, but don't know how to write a function that calls this function and can be assigned a key binding.



1 Answer 1


I give here only the basic ingredients as a starter kit.

Define an interactive command that calls myprogram.exe:

(defun myprog ()
 (call-process "myprogram.exe"))

Now bind that command to the key of your liking:

(global-set-key (kbd "C-c p") #'myprog)
  • Thanks Tobias,works like a dream (I had written a script that sends a line from emacs to matlab and returns, so I can use matlab-mode and matlab on my windows machine) Jun 7, 2018 at 14:29
  • @arnyeinstein The standard way to indicate that the answer solves the problem is to accept it. (Click the green check mark.)
    – Tobias
    Jun 7, 2018 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.