Coder Social home page Coder Social logo

emacs-psci's Introduction

psci-mode http://melpa.org/packages/psci-badge.svg http://stable.melpa.org/packages/psci-badge.svg

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

TOC

Description

What

Major mode for purescript’s repl psci.

How

Based on comint-mode (command interpreter). Following this tutorial.

Why

The purescript-mode (forked from haskell-mode) does not provide any repl integration (yet?). The experience inside the terminal is somewhat tedious at the moment. So I thought of giving it a shot.

When

How about now? (work in progress)

Who

me

Install

Many different installation possible:

Git

Clone the repository, and:

M-x package-install-file RET /path/to/emacs-psci/psci.el

Note Provided you already use melpa, the needed deps should be installed.

Package repositories

Melpa

Their documentation:

(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages") t)
(package-initialize)

Note Providing PR is merged.

Melpa-stable

Their documentation:

(require 'package)
(add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/") t
(package-initialize)

Marmalade

Their documentation:

(require 'package)
(add-to-list 'package-archives '("marmalade" . "https://marmalade-repo.org/packages/"))
(package-initialize)

Install

With melpa, melpa-stable, marmalade:

M-x package-install RET psci RET

el-get

Their documentation:

M-x el-get-install RET psci RET

Note Providing PR is merged.

Start and setup

Start

M-x psci

This will open a psci repl within emacs from your current project root folder (using projectile or project.el to determine that).

Setup

bindings

Add the inferior-psci-mode to the purescript-mode will permit access to some default bindings:

(add-hook 'purescript-mode-hook 'inferior-psci-mode)

repl toggle

I encounter (thanks to @purcell) a simple mode that I quite like which is called repl-toggle. This permits, using the same universal binding `C-c C-z`, to go back and forth between the repl and the buffer.

(require 'repl-toggle)
(require 'psci)
(add-to-list 'rtog/mode-repl-alist '(purescript-mode . psci))

Use

Default bindings available from a purescript buffer:

KeybindingsInteractive commandsDescription
C-c C-lM-x psci/load-current-file!Equivalent of `:m /path/to/current/module/file.purs` - Load <file> for importing
C-c M-nM-x psci/load-module!Equivalent of `:i your.current.module.name` - Import <module> for use in PSCI
C-c C-rM-x psci/load-project-modules!Load or reload files defined in the project file .psci
N/AM-x psci/reset!Equivalent of `:r` - Reset
N/AM-x psci/quit!Equivalent of `:q` - Quit
C-c C-zProvided you use the previous setup, this will switch back and forth between repl and buffer

Runtime dependencies

A purescript dev platform ready. I based this development on the online book https://leanpub.com/purescript/.

Contributions

PR

More than welcome. Send me a PR and I will gladly merge it.

Simply, use fork, branch, and rebase to the latest commit. Also, I prefer code that is understandable (ymmv) and doc-stringified.

Issues

Issues, there will be.

Open issues on the tracker, I’ll do my best to answer.

Just, be sure to be clear, complete and concise about what your trouble is.

I’m open to suggestions but I’m far from being omniscient. Please, add information links, this helps everyone.

Miscellaneous

I tend to rely on other people’s code. That’s why I use a lot of dependencies. I’ll remove the unnecessary dependencies (for the moment, none but surely, some code can be rewritten without the deps) later.

emacs-psci's People

Contributors

actionshrimp avatar ardumont avatar artenator avatar bsermons avatar epost avatar gavinok avatar jeslie0 avatar kritzcreek avatar purcell avatar rgrinberg avatar vlatkob avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

emacs-psci's Issues

strange keybinding

For some reason after pressing Enter in any purescript file, it makes me jump to another buffer saying

purescript-mode-hook is a variable defined in `purescript-mode.el'.
Its value is nil

  This variable may be risky if used as a file-local variable.

Documentation:
Hook run after entering PureScript mode.
No problems result if this variable is not bound.
`add-hook' automatically binds it.  (This is true for all hook variables.)

You can customize this variable.

[back]

I guess its not linked to emacs-psci though, but to my purescript mode conf..

psci/--project-root!: Wrong type argument: stringp, nil [3 times] on launch

Hi,

I am using the latest (d773b40)
snapshot of psci.el

Whenever I do M-x psci I get this error message

psci/--project-root!: Wrong type argument: stringp, nil [3 times]

It happens even if there is .psci file in the current directory. The function (psci/--project-root!)
does return the current directory if evaluated with purescript source buffer as a current buffer
but breaks down if it is dired for example. Still, it doesn't matter whether I call psci from a purescript
buffer or from any other buffer --- I still have this error message above.

support for 'pulp' projects

Dropping into a psci inside a pulp project should launch psci with pulp psci. It also needs yo run pulp for the 'project' folder.

M-x psci fails

Please forgive whatever I'm missing, it's my first day with Purescript. When I run M-x pscithe repl fails to load and I get an Emacs error:
psci/--project-root!: Wrong type argument: stringp, nil

If I run pulp repl from a command line everything works fine.

I also see a previous issue #3 but that doesn't seem relevant since my searches suggest .psci files are no longer used. The entirety of my psci-related configuration is, as suggested:

(add-hook 'purescript-mode-hook 'inferior-psci-mode)

Completion doesn't work

Latest build of purescript-mode from Github and psci-20150328.1201 installed from Melpa. TAB completion doesn't show loaded symbols, say trying to complete Chap doesn't offer Chapter2 even though:

> :s loaded
Chapter2
Control.Monad.Eff
Control.Monad.Eff.Unsafe
Control.Monad.ST
Data.Function
Debug.Trace
Math
Prelude
Prelude.Unsafe

Maybe it needs completion-at-point-functions properly setup? Like sending token + "\t" to psci process to get candidates? I think that's what nodejs-repl does.

I'm on:

"GNU Emacs 24.5.1 (x86_64-apple-darwin14.3.0, NS apple-appkit-1347.57)
 of 2015-06-09 on 95.108.174.109-red.dhcp.yndx.net"```

Sending commands to psci causes the process to quit

Using 0.7.5.3 of purescript/psci, anything that calls the psci/--run-psci-command! function causes the psci process to quit.

I think it is the call to process-send-eof that is causing it since manually sending EOF has the same behavior.

`M-x psci` errors if there is no .psci file.

In a PureScript buffer, I run M-x psci and an empty “psci” buffer opens. Then the entry “psci/--project-root!: Wrong type argument: stringp, nil” is added to “Messages”. debug-on-error is enabled, but I don’t end up in the debugger for some reason.

It looks like psci/--project-root! doesn’t try to do anything (even report a better error, like “need a .psci file”) if locate-dominating-file returns nil.

Module X has been defined multiple times

I see lots of these errors every time I do M-x psci. However, pulp psci from the project root works just fine.

I've managed to solve this problem by customizing Psci/Arguments (I removed bower_components/purescript-*/src/**/*.purs).

I don't know why it worked (and have no time to dig it).

So I'll just leave it here for those who encounter the same problem.

Project root is not necessarily the right working dir to run psci

This is more of an observation than an issue, I suppose.

I spent quite a lot of time trying to get psci-mode to work with the purescript book examples. I ran into two issues:

  • The examples are in a 'mono-repo', ie each chapter has its own purescript project in a repo subdir. projectile-project-root returns the root of the git project, but in this case it's the wrong directory to run psci in.
  • The error message from psci and psci-mode was the usual: PSCi requires the purescript-psci-support package to be installed., which is very frustrating when you know that the package is installed already.

I'd suggest that psci-mode would try to work out the project root with eg looking for a bower.json file or a bower_components directory, but I'm new to purescript, so I'm not 100% confident this is universally appropriate.

And it would be super helpful towards newcomers if it was possible to render an error message that included some more hints about how to fix the issue.

Thanks for a great mode!

load-current-file! doesn't load that file's imports to psci's scope

It would be nice if, when you loaded a file, all the imports in the file would be in scope in the repl, so you could access anything that code in that file could also access. So if it imported Prelude, then when you loaded that file, all the functions in prelude would be available to use. However, it seems to only load the functions and types that are declared within that actual module. Is there a way to do that?

Need better regex for `psci/--compute-module-name!`

The current regex requires a space after the module name, but I have Emacs clean up all trailing whitespace, so it can never find the module. I think "^module\\s-+\\\([a-zA-Z0-9\\\.]+\\\)\\b" (using word boundary rather than a space) will do the right thing. I also replace the space after “module” with \\s-+ to allow for arbitrary whitespace.

Move this repository into the purescript-emacs org

Hey, I just created a new organisation at https://github.com/purescript-emacs. I'm hoping to collect the repositories I'm currently maintaining (psc-ide-emacs, purescript-mode) and this one, and invite all the people that have an interest, so that we always have enough people to review and merge pull requests.

I'd be happy to invite you too, if you still have an interest in PureScript!

`:reset` should be `:clear`

psci/load-current-file! doesn't work because psci/reset! function sends :reset instead of :clear to repl, in psci.el.

(defun psci/reset! ()
  "Reset the current status of the repl session."
  (interactive)
  (psci--run-psci-command! ":reset")) ;; wrong command
(defun psci/reset! ()
  "Reset the current status of the repl session."
  (interactive)
  (psci--run-psci-command! ":clear"))  ;; should be this

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.