-
Notifications
You must be signed in to change notification settings - Fork 2
/
run-command-recipes-racket.el
146 lines (126 loc) · 5.54 KB
/
run-command-recipes-racket.el
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
;;; run-command-recipes-racket.el --- Recipe of `run-command' for `racket` -*- lexical-binding: t; -*-
;; Author: semenInRussia <[email protected]>
;; Version: 0.1.0
;; Keywords: extensions run-command
;; Homepage: https://github.com/semenInRussia/emacs-run-command-recipes
;; URL: https://github.com/semenInRussia/emacs-run-command-recipes/blob/main/docs/racket.md
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; For use this code put the following to your Emacs configuration:
;;
;; (run-command-recipes-use-one 'racket)
;;
;;; Code:
(require 'dash)
(require 'f)
(require 'run-command-recipes-lib)
(defcustom run-command-recipes-racket-modes
'(racket-mode)
"List of major modes in which recipe of `run-command' for racket should work."
:type '(repeat symbol)
:group 'run-command-recipes)
(defcustom run-command-recipes-racket-raco-to-bytecode-command
"raco make {file-name}"
"Command of raco, which translate racket source file to racket bytecode.
See `run-command-recipes-lib-build' for understand what's {file-name}."
:type 'string
:group 'run-command-recipes)
(defcustom run-command-recipes-racket-compile-and-run-command
"raco exe {file-name} && {file-name-no-ext}"
"Command of raco, which compile and execute racket source file.
See `run-command-recipes-lib-build' for understand what's {file-name}."
:type 'string
:group 'run-command-recipes)
(defcustom run-command-recipes-racket-compile-and-run-command
"raco exe {file-name} && {file-name-no-ext}"
"Command of raco, which compile and execute racket source file.
See `run-command-recipes-lib-build' for understand what's {file-name}."
:type 'string
:group 'run-command-recipes)
(defcustom run-command-recipes-racket-run-command
"racket {file-name}"
"Command of racket, which juts run a racket source file.
See `run-command-recipes-lib-build' for understand what's {file-name}."
:type 'string
:group 'run-command-recipes)
(defcustom run-command-recipes-racket-compile-command
"raco exe {file-name}"
"Command of raco, which compile racket source file.
See `run-command-recipes-lib-build' for understand what's {file-name}."
:type 'string
:group 'run-command-recipes)
(defcustom run-command-recipes-racket-run-test-file-command
"raco test {file-name}"
"Command of raco, which run tests of racket source file.
See `run-command-recipes-lib-build' for understand what's {file-name}."
:type 'string
:group 'run-command-recipes)
(defcustom run-command-recipes-racket-run-directory-tests-command
"raco test ."
"Command of raco, which run all tests of current racket project."
:type 'string
:group 'run-command-recipes)
(defcustom run-command-recipes-racket-pretty-read-command
"raco read {file-name}"
"Command of raco, which pretty print content of current racket source file.
See `run-command-recipes-lib-build' for understand what's {file-name}."
:type 'string
:group 'run-command-recipes)
(defun run-command-recipes-racket ()
"Recipe of `run-command' for racket."
(when (run-command-recipes-racket-p)
(run-command-recipes-lib-compose-recipes
#'run-command-recipes-racket-virgin
#'run-command-recipes-racket-raco)))
(defun run-command-recipes-racket-p ()
"Return t, when recipe of `run-command' for racket should work."
(-contains-p run-command-recipes-racket-modes major-mode))
(defun run-command-recipes-racket-virgin ()
"Recipe of `run-command' for virgin version of racket, subrecipe of racket."
(run-command-recipes-lib-build
(when (and (buffer-file-name) (executable-find "racket"))
(list
(list
:command-name "racket-run-file"
:display "Racket: run, execute file (without compiling!)"
:command-line run-command-recipes-racket-run-command)))))
(defun run-command-recipes-racket-raco ()
"Recipe of `run-command' for raco, subrecipe of racket."
(run-command-recipes-lib-build
(when (and (buffer-file-name) (executable-find "raco"))
(list
(list
:command-name "raco-check-file"
:display "Raco: byte-compile file"
:command-line run-command-recipes-racket-raco-to-bytecode-command)
(list
:command-name "raco-compile-file"
:display "Raco: compile file"
:command-line run-command-recipes-racket-compile-command)
(list
:command-name "raco-run-file"
:display "Raco: run, execute file"
:command-line run-command-recipes-racket-compile-and-run-command)
(list
:command-name "raco-run-tests-in-file"
:display "Raco: run file tests"
:command-line run-command-recipes-racket-run-test-file-command)
(list
:command-name "raco-run-directory-tests"
:display "Raco: run directory, project tests"
:command-line run-command-recipes-racket-run-directory-tests-command)
(list
:command-name "raco-pretty-read-file"
:display "Raco: pretty print file"
:command-line run-command-recipes-racket-pretty-read-command)))))
(provide 'run-command-recipes-racket)
;;; run-command-recipes-racket.el ends here