on master help sign in
Merge pull request #34 from replit/rr-elisp-cask
388a85cRadon Rosborough
languages/elisp/main.go+21−11
@@ -2,23 +2,24 @@ package main
2
2
3import (
3import (
4 "fmt"
4 "fmt"
5− "github.com/replit/prybar/utils"
6 "os"
5 "os"
7 "os/exec"
6 "os/exec"
8 "path/filepath"
7 "path/filepath"
9 "syscall"
8 "syscall"
9+
10+ "github.com/replit/prybar/utils"
10)
11)
11
12
12func Execute(config *utils.Config) {
13func Execute(config *utils.Config) {
14+ args := []string{}
13
15
16+ if _, err := os.Stat("Cask"); err == nil {
14− emacs, err := exec.LookPath("emacs")
17+ if _, err := exec.LookPath("cask"); err == nil {
15−
18+ args = append(args, "cask", "exec")
16− if err != nil {
19+ }
17− panic(err)
18 }
20 }
19
21
20 execPath, err := os.Executable()
22 execPath, err := os.Executable()
21−
22 if err != nil {
23 if err != nil {
23 panic(err)
24 panic(err)
24 }
25 }
@@ -26,6 +27,11 @@ func Execute(config *utils.Config) {
26 runDir := filepath.Dir(execPath)
27 runDir := filepath.Dir(execPath)
27 replPath := filepath.Join(runDir, "prybar_assets", "elisp", "repl.el")
28 replPath := filepath.Join(runDir, "prybar_assets", "elisp", "repl.el")
28
29
30+ args = append(
31+ args, "emacs", "-nw", "-Q", "--load", replPath,
32+ "--eval", "(prybar-repl)",
33+ )
34+
29 os.Setenv("PRYBAR_EVAL", config.Exp)
35 os.Setenv("PRYBAR_EVAL", config.Exp)
30 os.Setenv("PRYBAR_EXEC", config.Code)
36 os.Setenv("PRYBAR_EXEC", config.Code)
31 os.Setenv("PRYBAR_PS1", config.Ps1)
37 os.Setenv("PRYBAR_PS1", config.Ps1)
@@ -45,18 +51,22 @@ func Execute(config *utils.Config) {
45 }
51 }
46
52
47 if !(config.Interactive || config.OurInteractive) {
53 if !(config.Interactive || config.OurInteractive) {
48− fmt.Fprintln(os.Stderr, "prybar-elisp: warn: non-interactive mode not implemented");
54+ fmt.Fprintln(os.Stderr, "prybar-elisp: warn: non-interactive mode not implemented")
49 }
55 }
50
56
51 if config.Ps2 != "... " {
57 if config.Ps2 != "... " {
52− fmt.Fprintln(os.Stderr, "prybar-elisp: warn: ps2 not implemented");
58+ fmt.Fprintln(os.Stderr, "prybar-elisp: warn: ps2 not implemented")
53 }
59 }
54
60
55− args := []string{"emacs", "-nw", "-Q", "--load", replPath, "--eval", "(prybar-repl)"}
61+ path, err := exec.LookPath(args[0])
56− err = syscall.Exec(emacs, args, os.Environ())
62+ if err != nil {
63+ fmt.Fprintf(os.Stderr, "%s: command not found\n", args[0])
64+ }
57
65
66+ err = syscall.Exec(path, args, os.Environ())
58 if err != nil {
67 if err != nil {
59− panic(err)
68+ fmt.Fprintf(os.Stderr, "failed to exec %s: %s\n", path, err)
69+ os.Exit(1)
60 }
70 }
61
71
62}
72}
scripts/docker-install.sh+8
@@ -32,6 +32,7 @@ libffi-dev
32libnspr4-dev
32libnspr4-dev
33
33
34# used during installation
34# used during installation
35+git
35wget
36wget
36
37
37"
38"
@@ -58,4 +59,11 @@ wget -nv https://launchpadlibrarian.net/309343864/libmozjs185-dev_1.8.5-1.0.0+df
58dpkg -i *.deb
59dpkg -i *.deb
59rm *.deb
60rm *.deb
60
61
62+# prybar-elisp has support for automatically running inside a Cask
63+# environment if there is a Cask file in the working directory. Might
64+# as well install Cask so it's easy to test.
65+git clone https://github.com/cask/cask.git /usr/local/cask
66+ln -s /usr/local/cask/bin/cask /usr/local/bin/cask
67+cask upgrade-cask
68+
61rm /tmp/docker-install.sh
69rm /tmp/docker-install.sh