Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions resources/clojure-elisp/clojure-elisp-runtime.el
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
(require 'cl-lib)
(require 'seq)

;; Elisp-2 compatibility: defvars bridge function-slot names to value-slot.
;; CLJEL-compiled defmacro bodies reference these at macro-expansion time.
(defvar clojure-core-vector #'vector
"Function-slot bridge for `vector' (Elisp-2 compatibility).")
(defvar clojure-core-list #'list
"Function-slot bridge for `list' (Elisp-2 compatibility).")

(defun clel-vector (&rest args)
(let ((items (nthcdr 0 args)))
"Create a vector from ITEMS."
Expand Down
19 changes: 14 additions & 5 deletions src/clojure_elisp/emitter.clj
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,14 @@
([name env private?]
(let [current-ns (:ns env)
separator (if private? "--" "-")
mangled (mangle-name name)]
mangled (mangle-name name)
;; Strip leading dash to avoid triple-dash: ns-- + -name = ns---name
;; Clojure's -private convention conflicts with Elisp's ns--name convention
clean-name (if (and private? (str/starts-with? mangled "-"))
(subs mangled 1)
mangled)]
(if (and current-ns (not= current-ns 'user))
(str (mangle-name current-ns) separator mangled)
(str (mangle-name current-ns) separator clean-name)
(mangle-name name)))))

;; ============================================================================
Expand Down Expand Up @@ -125,9 +130,13 @@
:else
(let [qualified-sym (symbol (str ns) (str name))
separator (if private? "--" "-")
mangled (mangle-name name)]
mangled (mangle-name name)
;; Strip leading dash to avoid triple-dash (same as ns-qualify-name)
clean-name (if (and private? (str/starts-with? mangled "-"))
(subs mangled 1)
mangled)]
(or (get core-fn-mapping qualified-sym)
(str (mangle-name ns) separator mangled)))))
(str (mangle-name ns) separator clean-name)))))

(defmethod emit-node :vector
[{:keys [items]}]
Expand Down Expand Up @@ -995,7 +1004,7 @@
_provides (format "(provide '%s)" elisp-name)]
(str ";;; " elisp-name ".el --- -*- lexical-binding: t; -*-\n"
";; Generated by ClojureElisp\n\n"
"(require 'clojure-elisp-runtime)\n"
"(eval-and-compile (require 'clojure-elisp-runtime))\n"
(when load-path-block
(str load-path-block))
(when (seq require-stmts)
Expand Down
Loading
Loading