This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-13
Channels
- # announcements (18)
- # babashka (52)
- # beginners (47)
- # calva (45)
- # clj-kondo (31)
- # clojure (18)
- # clojure-brasil (2)
- # clojure-europe (3)
- # clojure-sweden (25)
- # clojurescript (19)
- # cursive (15)
- # datalevin (11)
- # defnpodcast (2)
- # duct (1)
- # editors (1)
- # emacs (6)
- # gratitude (1)
- # introduce-yourself (6)
- # jobs-discuss (11)
- # leiningen (3)
- # lsp (10)
- # luminus (2)
- # off-topic (4)
- # podcasts (2)
- # reitit (2)
- # shadow-cljs (10)
- # sql (9)
- # xtdb (4)
I would like some feedback on a hypothetical piece of emacs functionality i'm thinking about building. Imagine your threading some data through a functional pipeline, like any day working with clojure. (-> some-data ...) Now "some-data" is really a hash-map full of keys, it's like a big bag and at times you might need to pull some out. What if you could fire off a command and then select the keys you need? So "*" is the cursor (-> some-data *) will open a tiny window right there with the list of keys [<k_1> <k_2> ... <k_n>] each with a checkbox you can use to select. The selected keys are then available to paste. so you could just pick one (-> some-data :k_1) Of i you picked two you would get (-> some-data [:k_1 :k_2]) And obviously you would have to wrap it. maybe in something like "select keys" or maybe in "juxt". Currently solutions allow you to create a list easily enough, but not quickly select they keys beyond text manipulation. e.g i can print or create the full list but then i have to to remove keys. I'm not suggesting this is a huge win, just that I think this flow would be slightly more economical in a lot of common cases i run into.
It sounds good to me, with the nuance with the cost of building it might be somewhat excessive compared to the cost of (-> some-data (doto pprint))
or such, then copying the interesting keys by hand
I have this yasnippet https://raw.githubusercontent.com/zenmacs/.emacs.d/master/snippets/clojure-mode/ppr which I can use while inside a ->
, so I'm not interrupted by a require
step
A really generalized fix would be to make https://github.com/alexander-yakushev/compliment/ able to offer completions based on evaluating the sexp being completed
So in this UI, the options would be determined by evaluating (-> x)
, and observing that select-keys
needs a set of keys, so one then evaluates (-> x keys)
It's probably a lot of work, but also would show well what can be accomplished with the "CIDER approach" (favor eval
over static heuristics)
is there a cider eval option that keeps the surrounding s-expression and produces the result? What would be close to my suggestion is a fn similar to 'cider-eval-last-sexp-and-replace' only without the replace part. e.g (-> {:a 1 :c 2} keys *) 'cider-eval-sexp-and-keep' (this doesn't exist) (-> {:a 1 :c 2} keys *) [:a :b]
Don't know the answer directly but these seem self-contained, probably you can make your own https://github.com/clojure-emacs/cider/blob/83f18a9ad4b97614bf1ec9e65444ebc90dd8bddf/cider-eval.el#L935-L958