-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpharo.el
More file actions
94 lines (81 loc) · 3.08 KB
/
pharo.el
File metadata and controls
94 lines (81 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
;;; pharo.el --- Description -*- lexical-binding: t; -*-
;;
;; Copyright (C) 2021 Rafael Luque
;;
;; Author: Rafael Luque <https://github.com/luque>
;; Created: May 11, 2021
;; Modified: May 11, 2021
;; Version: 0.0.1
;; Keywords: Symbol’s value as variable is void: finder-known-keywords
;; Homepage: https://github.com/luque/life-elisp-smalltalk
;; Package-Requires: ((emacs "24.3"))
;;
;; This file is not part of GNU Emacs.
;;
;;; Commentary:
;;
;; Description
;;
;;; Code:
(require 'url)
(defconst default-repl-port 1701)
(defconst author-full-name-default "Emacs Lisp")
(defconst class-template "
%s subclass: #%s
instanceVariableNames: '%s'
classVariableNames: '%s'
package: '%s'")
(defconst compile-method-template "
%s
compile: ('%s', String cr, '%s')
classified: '%s'")
(defconst compile-class-method-template "
%s class
compile: ('%s', String cr, '%s')
classified: '%s'")
(defvar pharo-repl-port)
(defun setup-pharo-environment (&optional version arch)
(let* ((version (or version "stable"))
(arch (or arch "64"))
(pharoZeroConfUrl (format "https://get.pharo.org/%s/%s+vm" arch version)))
(message (format "Installing Pharo VM and Image from [%s]..." pharoZeroConfUrl))
(shell-command (format "curl %s | bash" pharoZeroConfUrl))
(message "Pharo VM/Image installed OK!")
)
)
(defun load-repl-server (&optional port)
;; ./pharo Pharo.image eval --save
;; "(ZnServer on: 1701) bindingAddress: NetNameResolver localHostAddress; delegate: ZnReadEvalPrintDelegate new; start"
(setq pharo-repl-port (or port default-repl-port))
(shell-command (format "./pharo Pharo.image eval --save '(ZnServer on: %d) bindingAddress: NetNameResolver localHostAddress; delegate: ZnReadEvalPrintDelegate new; register; start'" pharo-repl-port))
)
(defun launch-pharo-repl ()
(start-process "pharo-ui" "pharo-ui process" "./pharo-ui" "Pharo.image")
)
(defun url-pharo-post (body)
(url-http-post (format "http://localhost:%d/repl" pharo-repl-port) body)
)
(defun eval-pharo (expression)
(url-pharo-post expression)
)
(defun set-author (&optional author-full-name)
(let ((full-name (or author-full-name author-full-name-default)))
(eval-pharo (format "Author uniqueInstance fullName: '%s'" full-name))
)
)
(defun new-class (superclass name package instanceVariablesList classVariablesList)
(let ((instanceVariables (mapconcat 'identity instanceVariablesList " "))
(classVariables (mapconcat 'identity classVariablesList " ")))
(set-author)
(eval-pharo (format class-template superclass name instanceVariables classVariables package))
)
)
(defun new-morph (name package instanceVariablesList classVariablesList)
(new-class "Morph" name package instanceVariablesList classVariablesList)
)
(defun add-method (class name body classifier)
(eval-pharo (format compile-method-template class name body classifier)))
(defun add-class-method (class name body classifier)
(eval-pharo (format compile-class-method-template class name body classifier)))
(provide 'pharo)
;;; pharo.el ends here