Skip to content

Commit

Permalink
Add preliminary support for jank
Browse files Browse the repository at this point in the history
This creates a new derived mode for the clojure dialect jank
https://jank-lang.org/

See issue #23 for future work and
jank-lang/jank#24 for the expressed desire to
support nested c++
  • Loading branch information
dannyfreeman committed Sep 24, 2023
1 parent 5e7506e commit a7b9654
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
14 changes: 13 additions & 1 deletion clojure-ts-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,11 @@ forms like deftype, defrecord, reify, proxy, etc."
(set-keymap-parent map clojure-ts-mode-map)
map))

(defvar clojure-jank-ts-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map clojure-ts-mode-map)
map))

(defun clojure-ts-mode-display-version ()
"Display the current `clojure-mode-version' in the minibuffer."
(interactive)
Expand Down Expand Up @@ -965,9 +970,16 @@ See `clojure-ts--font-lock-settings' for usage of MARKDOWN-AVAILABLE."
\\{clojure-dart-ts-mode-map}")

;;;###autoload
(define-derived-mode clojure-jank-ts-mode clojure-ts-mode "Jank[TS]"
"Major mode for editing Jank code.
\\{clojure-jank-ts-mode-map}")

(defun clojure-ts--register-novel-modes ()
"Set up Clojure modes not present in progenitor clojure-mode.el."
(add-to-list 'auto-mode-alist '("\\.cljd\\'" . clojure-dart-ts-mode)))
(add-to-list 'auto-mode-alist '("\\.cljd\\'" . clojure-dart-ts-mode))
(add-to-list 'auto-mode-alist '("\\.jank\\'" . clojure-jank-ts-mode)))

;; Redirect clojure-mode to clojure-ts-mode if clojure-mode is present
(if (require 'clojure-mode nil 'noerror)
Expand Down
10 changes: 10 additions & 0 deletions test/native.jank
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(defn create-vertex-shader! []
(native/raw "__value = make_box(glCreateShader(GL_VERTEX_SHADER));"))

(defn set-shader-source! [shader source]
(native/raw "auto const shader(detail::to_int(~{ shader }));
auto const &source(detail::to_string(~{ source }));
__value = make_box(glShaderSource(shader, 1, &source.data, nullptr));"))

(defn compile-shader! [shader]
(native/raw "__value = make_box(glCompileShader(detail::to_int(~{ shader })));"))

0 comments on commit a7b9654

Please sign in to comment.