This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-21
Channels
- # announcements (26)
- # babashka (115)
- # babashka-sci-dev (5)
- # beginners (48)
- # calva (69)
- # cider (4)
- # clj-commons (11)
- # clj-kondo (1)
- # cljfx (29)
- # clojure (109)
- # clojure-art (1)
- # clojure-czech (1)
- # clojure-europe (33)
- # clojure-nl (1)
- # clojure-nlp (3)
- # clojure-norway (7)
- # clojure-uk (1)
- # clojurescript (63)
- # clr (1)
- # data-science (41)
- # datalevin (1)
- # datomic (11)
- # emacs (58)
- # etaoin (11)
- # figwheel-main (1)
- # fulcro (5)
- # google-cloud (12)
- # helix (2)
- # honeysql (21)
- # hyperfiddle (22)
- # joyride (53)
- # malli (52)
- # off-topic (27)
- # portal (4)
- # re-frame (19)
- # releases (3)
- # ring-swagger (5)
- # xtdb (30)
clj2el: a small clojure -> elisp transpiler 😂
https://borkdude.github.io/clj2el/


Coool, I can't wait for it to be able to take Clojure let
with destructuring and turn it into pcase-let
or something. That would be so awesome.
And turning clj maps into elisp alists or hashmaps. Converting (assoc m :foo x)
into proper setf
, etc. Clojure is awesome, and Elisp is not horrible either, but it can be annoyingly verbose, quirky and nonsensical.
I'd donate my pinky or thumb to have proper Clojure maps in Elisp. Maps alone make working with Clojure so much nicer.
now with a small babashka CLI ☝️
$ bbin install io.github.borkdude/clj2el --latest-sha
$ echo '(defn foo [x & xs] xs)' | clj2el
(defun foo (x &rest xs) xs)
now I'm just waiting for someone to write clj2el.el
which shells out to that CLI to convert a region
reminder that M-|
is shell-command-on-region
. If you highlight a region you can use it. If you give it a prefix, it will replace the region with the output of the shell command. I use this often with jet
to format edn and jq
to format json.
(I wish someone had posted that reminder years ago. forgot how powerful and useful it is in so many scenarios)
https://clojurians.slack.com/archives/C099W16KZ/p1679406764536459 Something like this?
(defun clj2el-transpile-region ()
(interactive)
(shell-command-on-region (point) (mark) "clj2el" (current-buffer) 't))
1. Select clojure region
2. M-x clj2el-transpile-region
3. you now have Emacs lisp!
https://github.com/borkdude/clj2el/pull/2I'm not quite sure about how to provide installation instructions for Emacs distributions other than Doom Emacs, suggestions welcome!
Do you know what is kaputt when my cider shadow session does not complete js/
(`js/console.log`)
In the browser console you should see
shadow-cljs: load JS cider/nrepl/inlined/deps/suitable/v0v4v1/suitable/js_introspection.cljs
nvm. I had it working for 30seconds. Now I am not sure if the version was the difference. Back to it not loading suitable
I swear, I feel like I used to know what's needed to make it work. But I've been trying for the past 40 minutes and can't figure it out. What do I need to tweak so evil-ex-search
- #
or *
in Evil-mode worked with Clojure symbols? So when I search for foo/bar
, while the cursor is on foo
part, it would search for foo
and not foo/bar
?
In your example, foo/bar
is one symbol, so setting evil-symbol-word-search
to nil
would give you the behaviour you want. I realise that's the opposite of how you've stated the problem, but afaik that's how it's always worked
yeah, but then it doesn't work for things like
foo-bar/zap-zop
- when the cursor at foo-bar
, pressing #
I'd expect it to find previous mention of foo-bar
, but it'd be looking for foo
Yes, no doubt. I'm not sure this has ever worked as you want, and if it has, it's not an evil setting. It will be what clojure-mode defines as a symbol, most likely
Evil, after all, defers to the syntax (defined by major mode usually) to decide what is a symbol
I need to figure out how to make emacs recognize (thing-at-point 'word)
for foo-bar
as foo-bar
and not foo
I think the simplest (dumb?) approach is
(modify-syntax-entry ?- "w" clojure-mode-syntax-table)
But someone has probably made a package that is smarter about this. Something like superword-mode is probably in that area (I haven't used it myself)Ya, so doing modify-syntax-entry makes it recognize the whole symbol as the word. so thing-at-point 'word
now returns the whole foo-bar/zap-zop
...
Now you probably understand why I spent almost an hour and still can't figure it out 🙂
Additionally, I realized that unlike in Vim, evil-ex-start-word-search doesn't respect the region, i.e., when I select a portion of the symbol/word I should expect it to search only for that part. IMO That's a legit bug.
https://github.com/bronson/vim-visual-star-search is a plugin, not default vim behaviour. Maybe I'm not understanding
see here: https://github.com/emacs-evil/evil/blob/master/evil-search.el#L1166 it should respect region if (use-region-p)
so, just to make sure I understand you, by "respects the region" do you mean "search within the region" or "search within the whole buffer for what is selected by the region"?
So I have foo-bar/zap-zop
. Cursor is at f
. I mark a region from f
to -
, selecting foo-
. When I press #
I expect it to search backwards for the previous occurrence of foo-
yeah, that's not default vim behaviour, hence vim-visual-star-search
plugin. it may have been added to neovim (it's the sort of thing I'd expect they would add) and it's not evil's official policy to mimic neovim (although sometimes we do if we fancy)
yeah, it's a "default mapping" according to their docs: https://neovim.io/doc/user/vim_diff.html#default-mappings
the line between "bug" and "feature" is fuzzy in Evil, even by optimistic developer standards, so file it either way on evil's github and one of us may take a look soon
Yeah, this should be trivial to make it work with an advise. Please don't waste your energy trying to fix something that's not broken 😉
nah, don't sweat it. It's not hugely important. I'm just having my emacs tantrum moment. I often want something badly. Would spend hours to make it work only two days later to realize I never needed that shit. Like some monkey that finds a stick, carries it like the most precious thing in the whole world and then drops it without any philosophical remorse. That's me. I'm an Emacs monkey.
Oy vey... took me forever to make it work. I did not expect it to be so non-trivial. This is what I had to do to make visual-star-search in evil:
(defun evil-ex-start-word-search-a (fn unbounded direction count &optional symbol)
(if (use-region-p)
(let* ((beg (region-beginning))
(end (1+ (region-end)))
(delta (- end beg 1))
(s (buffer-substring beg end))
(evil-ex-search-pattern s)
(evil-ex-search-offset 0))
(deactivate-mark)
(if (eq direction 'forward)
(goto-char end)
(goto-char beg))
(when (evil-ex-search-full-pattern s count direction)
(let ((p (progn (when (eq direction 'forward)
(backward-char))
(point))))
(set-mark p)
(goto-char (if (eq direction 'forward)
(- p delta)
(+ p delta))))))
(funcall fn unbounded direction count symbol)))
(advice-add #'evil-ex-start-word-search :around #'evil-ex-start-word-search-a)
I'm an idiot with no respect for the notion of Time. It already exists. https://github.com/bling/evil-visualstar