From a7b9654488693cdc9057a91410f74de42a397d1b Mon Sep 17 00:00:00 2001 From: Danny Freeman Date: Sun, 24 Sep 2023 09:46:50 -0400 Subject: [PATCH] Add preliminary support for jank This creates a new derived mode for the clojure dialect jank https://jank-lang.org/ See issue #23 for future work and https://github.com/jank-lang/jank/issues/24 for the expressed desire to support nested c++ --- clojure-ts-mode.el | 14 +++++++++++++- test/native.jank | 10 ++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 test/native.jank diff --git a/clojure-ts-mode.el b/clojure-ts-mode.el index d4111d5..8d40c75 100644 --- a/clojure-ts-mode.el +++ b/clojure-ts-mode.el @@ -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) @@ -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) diff --git a/test/native.jank b/test/native.jank new file mode 100644 index 0000000..bf07596 --- /dev/null +++ b/test/native.jank @@ -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 })));"))