Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.0.6 #5

Merged
merged 6 commits into from
Jan 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@

A major mode to try and improve the purescript repl experience within emacs.

* TOC :TOC:
- [[#description][Description]]
- [[#what][What]]
- [[#how][How]]
- [[#why][Why]]
- [[#when][When]]
- [[#who][Who]]
- [[#install][Install]]
- [[#git][Git]]
- [[#package-repositories][Package repositories]]
- [[#el-get][el-get]]
- [[#start-and-setup][Start and setup]]
- [[#start][Start]]
- [[#setup][Setup]]
- [[#use][Use]]
- [[#runtime-dependencies][Runtime dependencies]]
- [[#contributions][Contributions]]
- [[#pr][PR]]
- [[#issues][Issues]]
- [[#miscellaneous][Miscellaneous]]

* Description
** What

Expand Down
52 changes: 30 additions & 22 deletions psci.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

;; Author: Antoine R. Dumont <eniotna.t AT gmail.com>
;; Maintainer: Antoine R. Dumont <eniotna.t AT gmail.com>
;; Version: 0.0.5
;; Version: 0.0.6
;; Package-Requires: ((purescript-mode "13.10") (dash "2.9.0") (s "1.9.0") (f "0.17.1") (deferred "0.3.2"))
;; Keywords: purescript psci repl major mode
;; URL: https://github.com/ardumont/emacs-psci
Expand Down Expand Up @@ -77,11 +77,16 @@

;; private functions

(defun psci/log (msg)
"Log MSG for psci."
(message (format "psci - %s" msg)))

(defun psci/--project-root! ()
"Determine the project's root folder."
(->> psci/project-module-file
(locate-dominating-file default-directory)
expand-file-name))
"Determine the project's root folder.
Beware, can return nil if no .psci file is found."
(-when-let (project-root (->> psci/project-module-file
(locate-dominating-file default-directory)))
(expand-file-name project-root)))

(defun psci/--process-name (buffer-name)
"Compute the buffer's process name based on BUFFER-NAME."
Expand Down Expand Up @@ -133,31 +138,34 @@ Assumes the location of the modules is the project root folder."
"Compute the current file's module name."
(save-excursion
(goto-char (point-min))
(let ((regexp "^module \\\([a-zA-Z0-9\\\.]+\\\) "))
(let ((regexp "^module\\s-+\\\([a-zA-Z0-9\\\.]+\\\)\\b"))
(search-forward-regexp regexp)
(match-string 1))))

;; public functions

;;;###autoload
(defun psci ()
"Run an inferior instance of `psci' inside Emacs."
"Run an inferior instance of `psci' inside Emacs.
Relies on .psci file for determining the project's root folder."
(interactive)
(let* ((psci-program psci/file-path)
(buffer (comint-check-proc psci/buffer-name)))
;; pop to the "*psci*" buffer if the process is dead, the
;; buffer is missing or it's got the wrong mode.
(pop-to-buffer-same-window
(if (or buffer (not (derived-mode-p 'psci-mode))
(comint-check-proc (current-buffer)))
(get-buffer-create (or buffer (psci/--process-name psci/buffer-name)))
(current-buffer)))
;; create the comint process if there is no buffer.
(unless buffer
(setq default-directory (psci/--project-root!))
(apply 'make-comint-in-buffer psci/buffer-name buffer
psci-program psci/arguments)
(psci-mode))))
(-if-let (project-root-folder (psci/--project-root!))
(let* ((psci-program psci/file-path)
(buffer (comint-check-proc psci/buffer-name)))
;; pop to the "*psci*" buffer if the process is dead, the
;; buffer is missing or it's got the wrong mode.
(pop-to-buffer-same-window
(if (or buffer (not (derived-mode-p 'psci-mode))
(comint-check-proc (current-buffer)))
(get-buffer-create (or buffer (psci/--process-name psci/buffer-name)))
(current-buffer)))
;; create the comint process if there is no buffer.
(unless buffer
(setq default-directory (psci/--project-root!))
(apply 'make-comint-in-buffer psci/buffer-name buffer
psci-program psci/arguments)
(psci-mode)))
(psci/log "No .psci file so we cannot determine the root project folder. Please, add one.")))

(defvar psci-mode-map
(let ((map (nconc (make-sparse-keymap) comint-mode-map)))
Expand Down
13 changes: 11 additions & 2 deletions todo.org
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
#+title: backlog
#+author: ardumont

* TODO 0.0.6 [0%]
- [ ] Update version
* 0.0.7 [%]
- [ ] Add :b binding
- [ ] Add `:s import` binding
- [ ] Add `:s loaded` binding
- [ ] Make psci's default completion work
* DONE 0.0.6 [100%]
CLOSED: [2015-01-14 Wed 09:03]
- [X] Prepare backlog
- [X] Update version
- [X] Add TOC to the README.org (Cheers to org-toc!)
- [X] `M-x psci` errors if there is no .psci file. - CLOSE #3
- [X] Need better regex for `psci/--compute-module-name!` - CLOSE #4
* DONE 0.0.5 [100%]
CLOSED: [2014-10-30 Thu 18:17]
- [X] Prepare backlog
Expand Down