Skip to content

Commit

Permalink
Pass el-func-name as symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
kostafey committed Feb 26, 2023
1 parent 063cb97 commit 125d1fb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/clj/clomacs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -154,21 +154,25 @@ Classes like `ArrayList`, `Vector`, `Stack` or `clojure.lang.PersistentVector`."
`result-handler` - function called with result of Elisp returned
value as parameter, it returns the result of whapped function.
`debug` - show string passed to evaluation on Elisp side in *Messages* buffer."
`(defn ~cl-func-name [& params#]
~doc
(~result-handler
(clomacs-eval
~cl-func-name
(format "(%s%s)"
(str '~el-func-name)
(loop [rest-params# params#
acc# (new StringBuffer "")]
(let [param# (first rest-params#)]
(if (empty? rest-params#)
(str acc#)
(recur (next rest-params#)
(param-handler (.append acc# " ") param#))))))
~debug))))
(let [el-func-name
(if (symbol? el-func-name)
(str el-func-name)
`(str ~el-func-name))]
`(defn ~cl-func-name [& params#]
~doc
(~result-handler
(clomacs-eval
~cl-func-name
(format "(%s%s)"
~el-func-name
(loop [rest-params# params#
acc# (new StringBuffer "")]
(let [param# (first rest-params#)]
(if (empty? rest-params#)
(str acc#)
(recur (next rest-params#)
(param-handler (.append acc# " ") param#))))))
~debug)))))

(defn format-result
"Can be used to apply the same format to obtain result of Elisp->Clojure
Expand Down
1 change: 1 addition & 0 deletions test/clj/clomacs/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
(aset ar 1 2)
(aset ar 2 3)
ar)) "[1 2 3]"))
(is (number? (read-string (emacs-major-version))))
(is (= (el-identity [:a "b" 'c])
(if (>= (read-string (emacs-major-version)) 27)
"[:a b 'c]"
Expand Down

0 comments on commit 125d1fb

Please sign in to comment.