64
64
:group 'psci
65
65
:type 'string )
66
66
67
+ (defcustom psci/psc-package-path " psc-package"
68
+ " Path to the `psc-package' binary."
69
+ :group 'psci
70
+ :type 'string )
71
+
72
+ (defcustom psci/spago-path " spago"
73
+ " Path to the `spago' binary."
74
+ :group 'psci
75
+ :type 'string )
76
+
67
77
(defcustom psci/arguments '(" src/**/*.purs" " bower_components/purescript-*/src/**/*.purs" )
68
78
" Commandline arguments to pass to `psci' function."
69
79
:group 'psci
@@ -111,8 +121,19 @@ When FILENAME is nil or not a real file, returns nil."
111
121
(match-string 1 ))))
112
122
113
123
(defun psci/--get-psc-package-sources! ()
114
- (when (file-exists-p " psc-package.json" )
115
- (split-string (shell-command-to-string " psc-package sources" ))))
124
+ (cond
125
+ ((file-exists-p " psc-package.json" )
126
+ (process-lines (psci/--executable-find-relative psci/psc-package-path) " sources" ))
127
+ ((file-exists-p " spago.dhall" )
128
+ (process-lines (psci/--executable-find-relative psci/spago-path) " sources" ))))
129
+
130
+ (defun psci/--executable-find-relative (path )
131
+ " If PATH is a relative path to an executable, return its full path.
132
+ Otherwise, just return PATH."
133
+ (let ((relative (expand-file-name path)))
134
+ (if (file-executable-p relative)
135
+ relative
136
+ path)))
116
137
117
138
; ; public functions
118
139
@@ -122,7 +143,9 @@ When FILENAME is nil or not a real file, returns nil."
122
143
Relies on .psci file for determining the project's root folder."
123
144
(interactive (list (read-directory-name " Project root? "
124
145
(psci/--project-root!))))
125
- (let* ((psci-program psci/purs-path)
146
+ (let* ((default-directory project-root-folder)
147
+ (psci-program psci/purs-path)
148
+ (extra-sources (psci/--get-psc-package-sources!))
126
149
(buffer (comint-check-proc psci/buffer-name)))
127
150
; ; pop to the "*psci*" buffer if the process is dead, the
128
151
; ; buffer is missing or it's got the wrong mode.
@@ -133,10 +156,7 @@ Relies on .psci file for determining the project's root folder."
133
156
(current-buffer )))
134
157
; ; create the comint process if there is no buffer.
135
158
(unless buffer
136
- (setq default-directory project-root-folder)
137
- (let ((full-arg-list (-if-let (psc-package-sources (psci/--get-psc-package-sources!))
138
- (append psci/arguments psc-package-sources)
139
- psci/arguments)))
159
+ (let ((full-arg-list (append psci/arguments extra-sources)))
140
160
(apply 'make-comint-in-buffer psci/buffer-name buffer
141
161
psci-program nil " repl" full-arg-list))
142
162
(psci-mode))))
0 commit comments