I have the following code to run python and get the result in the buffer from scratch.
(defun hello () "Test, just prints Hello, world to mini buffer" (interactive) (start-process "my-process" "*scratch*" "python" "/Users/smcho/Desktop/temp/hello.py") (message "Hello, world : I'm glad to see you")) (define-key global-map "\C-ck" 'hello)
The python code is as follows.
if __name__ == "__main__": print "hello, world from Python"
Using Cc k gives me the following code in the buffer from scratch.
hello, world from Python
Process my-process finished
I do not need the last part, since it is not from python. Is there a way to not get this line or delete it effectively?
Added
Trey helped me get the answer.
(defun hello () "Test, just prints Hello, world to mini buffer" (interactive) (insert (shell-command-to-string "python /Users/smcho/Desktop/temp/hello.py")) (message "Hello, world : I'm glad to see you")) (define-key global-map "\C-ck" 'hello)
source share