-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwolfram-console.el
69 lines (55 loc) · 2.17 KB
/
wolfram-console.el
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
(require 'comint)
(defgroup wolfram-console nil
"REPL integration extention for `wolfram'"
:group 'applications
:group 'wolfram
:prefix "wolfram-console-")
(defcustom wolfram-console-cmd-args '()
"Arguments to be passed to the wolfram-console-cmd on start"
:type 'string
:group 'wolfram-console)
(defcustom wolfram-console-cmd-init-file nil
"Full path to the file who's contents are sent to the
wolfram-console-cmd on start
Should be NIL if there is no file not the empty string"
:type 'string
:group 'wolfram-console)
(defcustom wolfram-console-cmd "wolfram"
"Name of the executable used for the wolfram REPL session"
:type 'string
:group 'wolfram-console)
(defcustom wolfram-console-cmd-buffer-name "wolfram"
"Name of the buffer which contains the wolfram-console-cmd session"
:type 'string
:group 'wolfram-console)
(defun wolfram-console-create-session ()
"Starts a comint session wrapped around the wolfram-console-cmd"
(setq comint-process-echoes t)
(apply 'make-comint wolfram-console-cmd-buffer-name
wolfram-console-cmd wolfram-console-cmd-init-file wolfram-console-cmd-args))
;;TODO add hooks?
;; (mapc
;; (lambda ( comint-hook-sym )
;; (let ((local-comint-hook-fn-sym
;; (intern
;; (replace-regexp-in-string
;; "s$" "" (concat "j-console-" (symbol-name comint-hook-sym))))))
;; (when (symbol-value local-comint-hook-fn-sym)
;; (add-hook comint-hook-sym (symbol-value local-comint-hook-fn-sym)))))
;; '(comint-input-filter-functions
;; comint-output-filter-functions
;; comint-preoutput-filter-functions))
;; (with-current-buffer (process-buffer (get-process wolfram-console-cmd-buffer-name))
;; (goto-char (point-max))
;; (insert "cow\n" )
;; (comint-send-input)
;; (sit-for .1))
(defun wolfram-console-ensure-session ()
"Checks for a running wolfram-console-cmd comint session and either
returns it or starts a new session and returns that"
(or (get-process wolfram-console-cmd-buffer-name)
(progn
(wolfram-console-create-session)
(sleep-for .2)
(get-process wolfram-console-cmd-buffer-name))))
(provide 'wolfram-console)