Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5360b24

Browse filesBrowse files
authored
Merge pull request #21 from purescript-emacs/user-chooses-working-dir
allows the user to specify a working dir for startup
2 parents 47a0ba7 + 63790ec commit 5360b24
Copy full SHA for 5360b24

File tree

1 file changed

+21
-22
lines changed
Filter options

1 file changed

+21
-22
lines changed

‎psci.el

Copy file name to clipboardExpand all lines: psci.el
+21-22Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -117,30 +117,29 @@ When FILENAME is nil or not a real file, returns nil."
117117
;; public functions
118118

119119
;;;###autoload
120-
(defun psci ()
120+
(defun psci (project-root-folder)
121121
"Run an inferior instance of `psci' inside Emacs.
122122
Relies on .psci file for determining the project's root folder."
123-
(interactive)
124-
(-if-let (project-root-folder (psci/--project-root!))
125-
(let* ((psci-program psci/purs-path)
126-
(buffer (comint-check-proc psci/buffer-name)))
127-
;; pop to the "*psci*" buffer if the process is dead, the
128-
;; buffer is missing or it's got the wrong mode.
129-
(pop-to-buffer
130-
(if (or buffer (not (derived-mode-p 'psci-mode))
131-
(comint-check-proc (current-buffer)))
132-
(get-buffer-create (or buffer (psci/--process-name psci/buffer-name)))
133-
(current-buffer)))
134-
;; create the comint process if there is no buffer.
135-
(unless buffer
136-
(setq default-directory (psci/--project-root!))
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)))
140-
(apply 'make-comint-in-buffer psci/buffer-name buffer
141-
psci-program nil "repl" full-arg-list))
142-
(psci-mode)))
143-
(psci/log "No .psci file so we cannot determine the root project folder. Please, add one.")))
123+
(interactive (list (read-directory-name "Project root? "
124+
(psci/--project-root!))))
125+
(let* ((psci-program psci/purs-path)
126+
(buffer (comint-check-proc psci/buffer-name)))
127+
;; pop to the "*psci*" buffer if the process is dead, the
128+
;; buffer is missing or it's got the wrong mode.
129+
(pop-to-buffer
130+
(if (or buffer (not (derived-mode-p 'psci-mode))
131+
(comint-check-proc (current-buffer)))
132+
(get-buffer-create (or buffer (psci/--process-name psci/buffer-name)))
133+
(current-buffer)))
134+
;; create the comint process if there is no buffer.
135+
(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)))
140+
(apply 'make-comint-in-buffer psci/buffer-name buffer
141+
psci-program nil "repl" full-arg-list))
142+
(psci-mode))))
144143

145144
(defvar psci-mode-map
146145
(let ((map (nconc (make-sparse-keymap) comint-mode-map)))

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.