This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-06
Channels
- # announcements (3)
- # asami (41)
- # aws (2)
- # babashka (65)
- # beginners (85)
- # biff (7)
- # calva (10)
- # cider (5)
- # cljsrn (32)
- # clojure (6)
- # clojure-czech (3)
- # clojure-europe (10)
- # clojure-russia (4)
- # clojure-uk (3)
- # clojurescript (5)
- # core-typed (7)
- # data-science (13)
- # datomic (43)
- # etaoin (4)
- # fulcro (22)
- # graphql (3)
- # gratitude (1)
- # helix (1)
- # joyride (2)
- # liquid (10)
- # malli (16)
- # off-topic (10)
- # other-languages (1)
- # polylith (10)
- # reitit (3)
- # scittle (7)
- # shadow-cljs (103)
- # tools-deps (10)
- # vim (9)
- # xtdb (2)
Good timezone! Is there a single Calva command for "copy as kill" -- that is, instead of killing, copy what would have been killed? I know there are ways to achieve a comparable effect, but I'm looking for a single command.
How would that differ from regular kill? And if the answer is, the “killed text remains”, how is that different from regular copy???
I might be using the wrong terms (still new); my understanding of kill is "next/current form", so no selection necessary
So, you are looking for a way to select the current/next form and copy it with a single command/keyboard shortcut?
I’d try searching for that using appropriate keywords: “calva” “copy form” (or some such) to see if someone else has already implemented it.. Or you could create your own VS Code command that invokes select, followed by copy..
here's a joyride script that copies the content selected by the Calva Paredit: Select Current Top Level... command:
(ns copy-top-form
(:require ["vscode" :as vscode]
[promesa.core :as p]))
(let [editor ^js vscode/window.activeTextEditor
original-selection (.-selection editor)]
(p/do
(vscode/commands.executeCommand "paredit.rangeForDefun")
(vscode/env.clipboard.writeText (.getText
(.-document editor)
(.-selection editor)))
(set! (.-selection editor) original-selection)))
Indeed, Joyride is perfect for this. For your script there, @U015879P2F8, you could avoid saving and restoring the original selection by using the ranges.currentTopLevelDef
https://calva.io/api/#rangescurrenttopleveldef. There's no API for getting the range and text for the next form, though, @UEJUEMGHF, so for now you'll need to do that saving and restoring.