-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharithmetic.el
More file actions
27 lines (24 loc) · 757 Bytes
/
arithmetic.el
File metadata and controls
27 lines (24 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(defun calculate ()
"calculate using arithmetic"
(interactive)
(set 'myfolder (file-name-directory (symbol-file 'calculate)))
(set 'module (concat myfolder "arithmetic.py"))
(set 'aprocess (start-process "arithmetic" "foo" "/usr/bin/python3" module))
(save-current-buffer
(set-buffer "foo")
(erase-buffer)
)
(set 'mytext (buffer-substring (point-min) (point-max)))
(process-send-string aprocess mytext)
(process-send-eof aprocess)
(accept-process-output aprocess 2)
(save-current-buffer
(set-buffer "foo")
(set 'result (buffer-substring (point-min) (point-max)))
)
(set 'mypoint (point))
(erase-buffer)
(insert result)
(goto-char mypoint)
)
(global-set-key (kbd "<f5>") 'calculate)