File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ (require 'package )
2+ (setq package-archives '((" gnu" . " http://elpa.gnu.org/packages/" )
3+ (" melpa" . " https://melpa.org/packages/" )))
4+ (package-initialize )
5+ (package-refresh-contents )
6+ (package-install 's )
7+ (package-install 'dash )
Original file line number Diff line number Diff line change 11(require 's )
2+ (require 'dash )
3+
4+ (defun sepl--remove-comments (code )
5+ " Removes comments and newlines from code given in CODE. After execution, all lines will be concatenated to a single line."
6+ (s-join " "
7+ (-map (lambda (line )
8+ (car (s-split " ;" line)))
9+ (s-lines code))))
210
311(defun sepl-eval-sexp ()
412 (interactive )
715 (backward-sexp )
816 (point )))
917 ; ; sepl requires single lines
10- (code (s-replace " \n " " " (buffer-substring start end)))
18+ (code (sepl--remove-comments (buffer-substring start end)))
1119 (tmp-buf (get-buffer-create " *sepl-tmp-buf*" )))
1220 (when (boundp 'sepl-repl-process )
1321 (comint-redirect-send-command-to-process code tmp-buf sepl-repl-process nil t )
1725 (message " => %s " (s-replace " \n " " \n " (s-trim (buffer-string ))))))
1826 (kill-buffer tmp-buf)))
1927
28+ ; ; TODO: how to handle lines with comments?
2029(defun sepl-eval-buffer ()
2130 (interactive )
2231 (when (boundp 'sepl-repl-process )
4857 (require 'scheme )
4958 (setq-local font-lock-keywords scheme-font-lock-keywords)
5059
51- )
60+ ; ; TODO: completion of built-ins?
61+ )
5262
5363(defcustom sepl-program-bin " /Users/marie/Programming/Rust/shade-eval-print-loop/target/debug/shade-eval-print-loop"
5464 " Path to the SEPL binary"
Original file line number Diff line number Diff line change 1+ ; ; Basic unit tests for Elisp code
2+ (require 'sepl-mode )
3+ (require 's )
4+
5+ (ert-deftest remove-comments-single-line-test ()
6+ (should (s-equals? " hi there"
7+ (sepl--remove-comments " hi there" )))
8+ (should (s-equals? " (+ 2 3)"
9+ (sepl--remove-comments " (+ 2 3)" )))
10+ (should (s-equals? " "
11+ (sepl--remove-comments " ; Hi there" ))))
12+
13+ (ert-deftest remove-comments-multiple-lines-test ()
14+ (should (s-equals? " (+ 1 2) 2 (define (square x) (* x x))"
15+ (sepl--remove-comments " (+ 1 2)\n 2\n (define (square x)\n (* x x))" ))))
You can’t perform that action at this time.
0 commit comments