I wondering if there is a set of Emacs Lisp code that implements some of Clojure's functions. For example, -> and ->> and comp and partial, and others?
Thank you.
CIDER is the Clojure(Script) Interactive Development Environment that Rocks! CIDER extends Emacs with support for interactive programming in Clojure. The features are centered around cider-mode, an Emacs minor-mode that complements clojure-mode.
I've ported the ->
and ->>
macros to Emacs Lisp a while ago. I use them occasionally in my configuration code and they seem to work fine.
(defmacro -> (e &rest es)
(if (and (consp es) (not (consp (cdr es))))
(if (consp (car es))
`(,(caar es) ,e ,@(cdar es))
`(,(car es) ,e))
(if (consp es)
`(-> (-> ,e ,(car es)) ,@(cdr es))
e)))
(defmacro ->> (e &rest es)
(if (and (consp es) (not (consp (cdr es))))
(if (consp (car es))
`(,@(car es) ,e)
`(,(car es) ,e))
(if (consp es)
`(->> (->> ,e ,(car es)) ,@(cdr es))
e)))
You should definitely take a look at dash.el. It provides a lot of Clojure-inspired functions like:
(fn list)
(fn initial-value list)
(fn initial-value list)
(fn list)
(fn list)
(pred list)
(pred list)
(fn list)
(pred rep list)
(fn list)
(l)
(&rest lists)
(fn list)
(&rest args)
(pred list)
(pred list)
(pred list)
(pred list)
(pred list)
(list fn)
(list pred fn)
(num fn)
(n x)
(list from &optional to)
(n list)
(n list)
(pred list)
(pred list)
(n list)
(n x list)
(pred list)
(pred list)
(n list)
(n step list)
(n step list)
(n list)
(fn list)
(fn list)
(fn list)
(sep list)
(&rest lists)
(fn list1 list2)
(list1 list2)
(pred list)
(pred list)
(list list2)
(list list2)
(list list2)
(list)
(list element)
(predicate list)
(fn &rest args)
(fn &rest args)
(fn)
(x &optional form &rest more)
(x form &rest more)
(x form &rest more)
(var-val &rest body)
(vars-vals &rest body)
(var-val then &optional else)
(vars-vals then &optional else)
(car cdr)
(list)
I find this library extremely useful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With