Skip to content

Commit 89b29d6

Browse files
committed
- [X] Reorganize var at the beginning of the buffer
1 parent ef515a9 commit 89b29d6

File tree

2 files changed

+32
-29
lines changed

2 files changed

+32
-29
lines changed

psci.el

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,31 @@
5858
(defvar psci/buffer-name "psci"
5959
"Buffer name of the psci buffer.")
6060

61-
(defun psci/process-name (buffer-name)
62-
"Compute the buffer's process name based on BUFFER-NAME."
63-
(format "*%s*" buffer-name))
64-
6561
(defvar psci/file-path "psci"
6662
"Path to the program used by `psci' function.")
6763

6864
(defvar psci/arguments '()
6965
"Commandline arguments to pass to `psci' function.")
7066

71-
(defvar psci-mode-map
72-
(let ((map (nconc (make-sparse-keymap) comint-mode-map)))
73-
(define-key map "\t" 'completion-at-point)
74-
map)
75-
"Basic mode map for `psci'.")
76-
7767
(defvar psci/prompt "> "
7868
"The psci prompt.")
7969

70+
(defvar psci/project-module-file ".psci"
71+
"The default file referencing the purescript modules to load at psci startup.")
72+
73+
(defvar psci/--modules-folder ".psci_modules"
74+
"The modules folder psci uses as cache.")
75+
76+
(defun psci/--project-root! ()
77+
"Determine the project's root folder."
78+
(->> psci/project-module-file
79+
(locate-dominating-file default-directory)
80+
expand-file-name))
81+
82+
(defun psci/--process-name (buffer-name)
83+
"Compute the buffer's process name based on BUFFER-NAME."
84+
(format "*%s*" buffer-name))
85+
8086
(defun psci ()
8187
"Run an inferior instance of `psci' inside Emacs."
8288
(interactive)
@@ -87,7 +93,7 @@
8793
(pop-to-buffer-same-window
8894
(if (or buffer (not (derived-mode-p 'psci-mode))
8995
(comint-check-proc (current-buffer)))
90-
(get-buffer-create (or buffer (psci/process-name psci/buffer-name)))
96+
(get-buffer-create (or buffer (psci/--process-name psci/buffer-name)))
9197
(current-buffer)))
9298
;; create the comint process if there is no buffer.
9399
(unless buffer
@@ -96,6 +102,12 @@
96102
psci-program psci/arguments)
97103
(psci-mode))))
98104

105+
(defvar psci-mode-map
106+
(let ((map (nconc (make-sparse-keymap) comint-mode-map)))
107+
(define-key map "\t" 'completion-at-point)
108+
map)
109+
"Basic mode map for `psci'.")
110+
99111
;;;###autoload
100112
(define-derived-mode psci-mode comint-mode "psci"
101113
"Major mode for `run-psci'.
@@ -117,14 +129,14 @@
117129

118130
(defun psci/--run-psci-command! (command)
119131
"Run psci COMMAND as string."
120-
(-when-let (process (get-buffer-process (psci/process-name psci/buffer-name)))
132+
(-when-let (process (get-buffer-process (psci/--process-name psci/buffer-name)))
121133
(comint-simple-send process command)
122134
(process-send-eof process)))
123135

124136
;; (defun psci/load-region! (region-start region-end)
125137
;; "Run purescript code between REGION-START and REGION-END."
126138
;; (interactive "r")
127-
;; (-when-let (process (get-buffer-process (psci/process-name psci/buffer-name)))
139+
;; (-when-let (process (get-buffer-process (psci/--process-name psci/buffer-name)))
128140
;; (comint-send-region process region-start region-end)
129141
;; (process-send-eof process)))
130142

@@ -160,9 +172,6 @@
160172
(-when-let (module-name (psci/--compute-module-name!))
161173
(psci/--run-psci-command! (format ":i %s" module-name))))
162174

163-
(defvar psci/project-module-file ".psci"
164-
"The default file referencing the purescript modules to load at psci startup.")
165-
166175
(defun psci/--file-content (filename)
167176
"Load the FILENAME's content as a string.
168177
When FILENAME is nil or not a real file, returns nil."
@@ -197,9 +206,6 @@ Assumes the location of the modules is the project root folder."
197206
(-filter 'file-exists-p)
198207
nreverse))))
199208

200-
(defvar psci/--modules-folder ".psci_modules"
201-
"The modules folder psci uses as cache.")
202-
203209
(defun psci/--compute-modules-folder (project-root-folder)
204210
"Compute the psci modules folder from PROJECT-ROOT-FOLDER."
205211
(concat project-root-folder psci/--modules-folder))
@@ -224,12 +230,6 @@ We chose to load the .psci file's content (the purescript doc proposes its use).
224230
(interactive)
225231
(psci/--run-psci-command! ":r"))
226232

227-
(defun psci/--project-root! ()
228-
"Determine the project's root folder."
229-
(->> psci/project-module-file
230-
(locate-dominating-file default-directory)
231-
expand-file-name))
232-
233233
(defvar inferior-psci-mode-map
234234
(let ((map (make-sparse-keymap)))
235235
(define-key map (kbd "C-c C-l") 'psci/load-current-file!)

todo.org

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
#+title: backlog
22
#+author: ardumont
33

4-
* IN-PROGRESS 0.0.5 [42%]
4+
* IN-PROGRESS 0.0.5 [50%]
55
- [X] Prepare backlog
66
- [X] Improve mode description header
77
- [X] Update version
8-
- [ ] Add quit session
9-
- [ ] Reorganize code for a better readability
10-
- [ ] Rename functions accoding to fully compliant emacs conventions?
8+
- [-] Reorganize code for a better readability
9+
- [X] Reorganize var at the beginning of the buffer
10+
- [ ] Add missing autoload property on psci function
11+
- [ ] Reorganize private functions at the beginning of the buffer
12+
- [ ] Rename functions according to fully compliant emacs conventions?
13+
- [ ] Add quit session command
1114
- [ ] Make psci's default completion work
1215
* DONE 0.0.4 [100%]
1316
CLOSED: [2014-10-29 Wed 20:08]

0 commit comments

Comments
 (0)